結果

問題 No.2278 Time Bomb Game 2
ユーザー startcppstartcpp
提出日時 2023-04-22 03:41:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,315 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 67,060 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 11:56:00
合計ジャッジ時間 2,613 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 6 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 5 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 5 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 5 ms
5,376 KB
testcase_32 AC 6 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 5 ms
5,376 KB
testcase_37 AC 6 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 5 ms
5,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 6 ms
5,376 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 5 ms
5,376 KB
testcase_53 AC 5 ms
5,376 KB
testcase_54 AC 5 ms
5,376 KB
testcase_55 AC 5 ms
5,376 KB
testcase_56 WA -
testcase_57 AC 5 ms
5,376 KB
testcase_58 WA -
testcase_59 AC 5 ms
5,376 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 5 ms
5,376 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 5 ms
5,376 KB
testcase_68 WA -
testcase_69 AC 5 ms
5,376 KB
testcase_70 AC 5 ms
5,376 KB
testcase_71 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//実験を書くのが思ったより面倒くさいけど、S[k]='A', T:偶数のパターンだけ考えれば難しくない。
//最初に訪れるBまでの距離が偶数なら、遅延行為をすることでT=0の時点でBに押し付けられるのでA勝ち。
//最初に訪れるBまでの距離が奇数なら、どうやっても奇数ターンでBに到達して、Aに押し付けられるのでA負け。
#include <iostream>
using namespace std;

string flip(string s) {
	string ret;
	for (int i = 0; i < s.length(); i++) ret += ((s[i] == 'A') ? 'B' : 'A');
	return ret;
}

//Aliceが勝てるか?
bool check(string s, int K, int T) {
	int left;
	for (left = K; left >= 0; left--) if (s[left] == 'B') break;
	int dist = K - left;
	if (dist % 2 == 0 && dist <= T) return true;

	int right;
	for (right = K; right < s.length(); right++) if (s[right] == 'B') break;
	dist = right - K;
	if (dist % 2 == 0 && dist <= T) return true;

	return false;
}

int main() {
	int n, K, T;
	string s;
	cin >> n >> K >> T >> s;
	K--;
	if (s[K] == 'B') s = flip(s);

	bool ans = false;
	if (T % 2 == 1) {
		if (K > 0) ans |= check(s, K - 1, T - 1);
		if (K + 1 < n) ans |= check(s, K + 1, T - 1);
	}
	else {
		ans = check(s, K, T);
	}

	if (ans) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}
0