結果

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

テストケース

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

ソースコード

diff #

//実験を書くのが思ったより面倒くさいけど、S[k]='A', T:偶数のパターンだけ考えれば難しくない。
//最初に訪れるBまでの距離が偶数なら、遅延行為をすることでT=0の時点でBに押し付けられるのでA勝ち。
//最初に訪れるBまでの距離が奇数なら、どうやっても奇数ターンでBに到達して、Aに押し付けられるのでA負け。
//注意点1: S[k] = 'B'でSをFlipするケースでは、勝者もFlipする必要がある。-> Aが勝てるか?ではなく手番プレイヤが勝てるかならFlip不要。
//注意点2: T:奇数で初手移動する場合、先にSをFlipしてしまうと移動先がBになりうるので、移動してからSをFlipする必要がある。
//注意点3: T:奇数で初手移動する場合、初手移動するプレイヤが勝てるムーブが存在するか?を判定する必要がある。
//注意点4: 右や左にBが無いケースは弾かなければならない。
#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;
}

//手番プレイヤが勝てるか?
bool check(string s, int K, int T) {
	if (s[K] == 'B') {
		s = flip(s);
	}

	int left;
	for (left = K; left >= 0; left--) if (s[left] == 'B') break;
	int dist = K - left;
	if (left >= 0 && 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 (right < s.length() && dist % 2 == 0 && dist <= T) {
		return true;
	}
	
	return false;
}

int main() {
	int n, K, T;
	string s;
	cin >> n >> K >> T >> s;
	K--;

	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 (s[K] == 'B') ans = !ans;	//手番プレイヤが勝てるか? -> Aliceが勝てるか?に変換。

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