結果

問題 No.2278 Time Bomb Game 2
ユーザー ks2mks2m
提出日時 2023-04-21 23:46:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,716 bytes
コンパイル時間 3,345 ms
コンパイル使用メモリ 75,856 KB
実行使用メモリ 55,040 KB
最終ジャッジ日時 2024-04-24 09:40:41
合計ジャッジ時間 10,957 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
37,076 KB
testcase_01 AC 43 ms
37,116 KB
testcase_02 AC 43 ms
37,008 KB
testcase_03 AC 43 ms
37,076 KB
testcase_04 AC 44 ms
36,664 KB
testcase_05 AC 43 ms
36,724 KB
testcase_06 AC 52 ms
37,300 KB
testcase_07 AC 78 ms
39,056 KB
testcase_08 AC 73 ms
38,180 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 83 ms
39,348 KB
testcase_12 AC 89 ms
42,204 KB
testcase_13 WA -
testcase_14 AC 83 ms
39,828 KB
testcase_15 WA -
testcase_16 AC 81 ms
39,524 KB
testcase_17 WA -
testcase_18 AC 86 ms
39,600 KB
testcase_19 AC 84 ms
43,008 KB
testcase_20 AC 81 ms
39,356 KB
testcase_21 AC 81 ms
39,584 KB
testcase_22 AC 81 ms
39,292 KB
testcase_23 AC 85 ms
39,292 KB
testcase_24 AC 73 ms
39,636 KB
testcase_25 AC 78 ms
39,380 KB
testcase_26 AC 80 ms
39,380 KB
testcase_27 AC 83 ms
39,268 KB
testcase_28 AC 82 ms
39,536 KB
testcase_29 AC 80 ms
39,504 KB
testcase_30 AC 82 ms
39,488 KB
testcase_31 AC 74 ms
39,800 KB
testcase_32 AC 80 ms
39,380 KB
testcase_33 AC 82 ms
39,408 KB
testcase_34 AC 83 ms
39,104 KB
testcase_35 AC 81 ms
39,304 KB
testcase_36 AC 81 ms
39,348 KB
testcase_37 AC 91 ms
41,856 KB
testcase_38 AC 97 ms
46,656 KB
testcase_39 AC 86 ms
40,320 KB
testcase_40 AC 110 ms
55,040 KB
testcase_41 AC 92 ms
43,520 KB
testcase_42 AC 87 ms
50,356 KB
testcase_43 AC 86 ms
45,824 KB
testcase_44 AC 106 ms
52,960 KB
testcase_45 AC 104 ms
51,724 KB
testcase_46 AC 98 ms
52,864 KB
testcase_47 AC 92 ms
44,160 KB
testcase_48 AC 85 ms
40,428 KB
testcase_49 AC 94 ms
44,500 KB
testcase_50 AC 82 ms
39,268 KB
testcase_51 AC 83 ms
39,444 KB
testcase_52 AC 83 ms
39,680 KB
testcase_53 AC 82 ms
39,348 KB
testcase_54 AC 81 ms
39,516 KB
testcase_55 AC 81 ms
39,292 KB
testcase_56 AC 83 ms
39,692 KB
testcase_57 AC 74 ms
39,272 KB
testcase_58 AC 87 ms
39,320 KB
testcase_59 AC 70 ms
39,808 KB
testcase_60 AC 82 ms
39,532 KB
testcase_61 AC 86 ms
39,564 KB
testcase_62 AC 85 ms
39,432 KB
testcase_63 AC 81 ms
39,616 KB
testcase_64 AC 103 ms
47,928 KB
testcase_65 AC 108 ms
54,436 KB
testcase_66 AC 103 ms
49,492 KB
testcase_67 AC 86 ms
41,268 KB
testcase_68 AC 87 ms
39,972 KB
testcase_69 AC 107 ms
54,964 KB
testcase_70 AC 96 ms
54,836 KB
testcase_71 AC 46 ms
37,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int n;
	static char[] s;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]) - 1;
		int t = Integer.parseInt(sa[2]);
		s = br.readLine().toCharArray();
		br.close();

		char res = dfs(k, t, -2);
		if (res == 'A') {
			System.out.println("Alice");
		} else {
			System.out.println("Bob");
		}
	}

	static char dfs(int k, int t, int p) {
		if (t == 0) {
			if (s[k] == 'A') {
				return 'B';
			} else {
				return 'A';
			}
		}
		char c = s[k];
		if (t % 2 == 1) {
			if (p != k - 1 && k > 0) {
				char l = s[k - 1];
				if (l != c) {
					if (k == 1 || s[k - 2] == c) {
						return c;
					}
					if (k < n - 1 && s[k + 1] == c) {
						return c;
					}
				}
				char res = dfs(k - 1, t - 1, k);
				if (res == c) {
					return c;
				}
			}
			if (p != k + 1 && k < n - 1) {
				char r = s[k + 1];
				if (r != c) {
					if (k == n - 2 || s[k + 2] == c) {
						return c;
					}
					if (k > 0 && s[k - 1] == c) {
						return c;
					}
				}
				char res = dfs(k + 1, t - 1, k);
				if (res == c) {
					return c;
				}
			}
		} else {
			if (k > 0 && s[k - 1] == c ||
					k < n - 1 && s[k + 1] == c) {
				if (p != k - 1 && k > 1) {
					char res = dfs(k - 1, t - 1, k);
					if (res == c) {
						return c;
					}
				}
				if (p != k + 1 && k < n - 2) {
					char res = dfs(k + 1, t - 1, k);
					if (res == c) {
						return c;
					}
				}
			}
		}
		if (s[k] == 'A') {
			return 'B';
		} else {
			return 'A';
		}
	}
}
0