A
package newcoder.weekround36;
import java.util.Scanner;
/**
* @Title: A
* @Author 李浩天
* @Date 2024/3/14 下午8:22
* @description:
*/
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String n = sc.next();
System.out.println(n.substring(0, n.length() - 3));
}
}
B
package newcoder.weekround36;
import java.util.Scanner;
/**
* @Title: B
* @Author 李浩天
* @Date 2024/3/14 下午8:30
* @description:
*/
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
int[][] nums = new int[n][m];
long checkX = 0;
for (int i = 0; i < n; i ++ ) {
for (int j = 0; j < m; j ++ ) {
nums[i][j] = sc.nextInt();
checkX += nums[i][j];
}
}
int laOxT = 0;
boolean fr = true;
for (int i = 0; i < n; i ++ ) {
int oxT = 0;
for (int j = 0; j < m; j ++ ) {
oxT ^= nums[i][j];
}
if (i == 0) {
laOxT = oxT;
continue;
}
if (oxT != laOxT) {
fr = false;
}
laOxT = oxT;
}
boolean fc = true;
for (int i = 0; i < m; i ++ ) {
int oxT = 0;
for (int j = 0; j < n; j ++ ) {
oxT ^= nums[j][i];
}
if (oxT != laOxT) {
fc = false;
}
laOxT = oxT;
}
if (checkX == x && fr && fc) {
System.out.println("accepted");
} else {
System.out.println("wrong answer");
}
}
}
C
package newcoder.weekround36;
import java.util.Scanner;
/**
* @Title: C
* @Author 李浩天
* @Date 2024/3/14 下午9:08
* @description:
*/
public class C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
// tag : 取值为1 -> 2, 分别代表三种模式 如果tag取值为0说明该位置的上一个位置是擦除的
int tag = 0;
int now = 0;
int ans = 0;
while (now < s.length()) {
if (tag == 1 && Character.isLowerCase(s.charAt(now))) {
now ++ ;
continue;
}
if (tag == 1 && Character.isUpperCase(s.charAt(now))) {
now ++ ;
ans ++ ;
tag = 0;
continue;
}
if (tag == 2 && Character.isLowerCase(s.charAt(now))) {
now ++ ;
continue;
}
if (tag == 2 && Character.isUpperCase(s.charAt(now))) {
now ++ ;
tag = 0;
ans ++ ;
continue;
}
if (tag == 0 && Character.isLowerCase(s.charAt(now))) {
now ++ ;
tag = 1;
continue;
}
if (tag == 0 && Character.isUpperCase(s.charAt(now))) {
now ++ ;
tag = 2;
}
}
System.out.println(ans);
}
}
D
package newcoder.weekround36;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
/**
* @Title: D
* @Author 李浩天
* @Date 2024/3/14 下午9:37
* @description:
*/
public class D {
static class PII {
int x, y;
public PII(int x, int y) {
this.x = x;
this.y = y;
}
}
static int n, m;
static char[][] g;
static int[][] vis;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
g = new char[n][m];
vis = new int[n][m];
for (int i = 0; i < n; i ++ ) {
String s = sc.next();
for (int j = 0; j < s.length(); j ++ ) {
g[i][j] = s.charAt(j);
}
}
for (int i = 0; i < n; i ++ ) {
Arrays.fill(vis[i], Integer.MAX_VALUE);
}
System.out.println(bfs());
// System.out.println(Arrays.deepToString(vis));
}
static final int[] dx = new int[] {1, 0, -1, 0};
static final int[] dy = new int[] {0, -1, 0, 1};
public static int bfs() {
Queue<PII> que = new LinkedList<>();
que.add(new PII(0, 0));
vis[0][0] = 0;
while (!que.isEmpty()) {
PII t = que.poll();
int x = t.x, y = t.y;
for (int i = 0; i < 4; i ++ ) {
int a = x + dx[i], b = y + dy[i];
// System.out.println("vis[a][b] != Integer.MAX_VALUE : " + (vis[a][b] != Integer.MAX_VALUE));
if (a < 0 || a >= n || b < 0 || b >= m) {
// System.out.println("jj");
continue;
}
if (vis[a][b] != Integer.MAX_VALUE) {
// System.out.println("vv");
continue;
}
if (g[a][b] == g[x][y]) {
// System.out.println("gg");
// System.out.println("a = " + a);
// System.out.println("b = " + b);
// System.out.println("g[a][b] : " + g[a][b] + " g[x][y] : " + g[x][y]);
continue;
}
que.add(new PII(a, b));
vis[a][b] = vis[x][y] + 1;
}
}
if (vis[n - 1][m - 1] == Integer.MAX_VALUE) return -1;
return vis[n - 1][m - 1];
}
}