結果
問題 | No.2278 Time Bomb Game 2 |
ユーザー | magsta |
提出日時 | 2023-04-16 17:34:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,550 bytes |
コンパイル時間 | 1,700 ms |
コンパイル使用メモリ | 169,136 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-06 17:00:31 |
合計ジャッジ時間 | 3,673 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 69 WA * 1 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:119:86: warning: 'left' may be used uninitialized [-Wmaybe-uninitialized] 119 | else if (((K - 1) - left) % 2 != T % 2 && (K - 1) - left < T && left != 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ main.cpp:68:21: note: 'left' was declared here 68 | int left, right = 0; | ^~~~ main.cpp:61:86: warning: 'left' may be used uninitialized [-Wmaybe-uninitialized] 61 | else if (((K - 1) - left) % 2 != T % 2 && (K - 1) - left < T && left != 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ main.cpp:10:21: note: 'left' was declared here 10 | int left, right = 0; | ^~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { long long N, K, T; cin >> N >> K >> T; string C; cin >> C; if (C[K - 1] == 'A') { int left, right = 0; for (int i = K - 1; i >= 0; i--) { if (C[i] == 'A') { left = i; } else { break; } } for (int i = K - 1; i < N; i++) { if (C[i] == 'A') { right = i; } else { break; } } if (right == left) { if (T % 2 == 0) cout << "Bob" << endl; else { int left_ = K - 1, right_ = K - 1; for (int i = K - 2; i >= 0; i--) { if (C[i] == 'B') { left_ = i; } else { break; } } for (int i = K; i < N; i++) { if (C[i] == 'B') { right_ = i; } else { break; } } if (!(right_ != K - 1 && right_ != N - 1 && (right_ - (K - 1)) % 2 == 0 && right - (K - 1) < T)) { cout << "Alice" << endl; } else if (!(left_ != K - 1 && left_ != N - 1 && ((K - 1) - left_) % 2 == 0 && (K - 1) - left_ < T)) { cout << "Alice" << endl; } else cout << "Bob" << endl; } } else { if ((right - (K - 1)) % 2 != T % 2 && right - (K - 1) < T && right != N - 1) { cout << "Alice" << endl; } else if (((K - 1) - left) % 2 != T % 2 && (K - 1) - left < T && left != 0) { cout << "Alice" << endl; } else cout << "Bob" << endl; } } else { int left, right = 0; for (int i = K - 1; i >= 0; i--) { if (C[i] == 'B') { left = i; } else { break; } } for (int i = K - 1; i < N; i++) { if (C[i] == 'B') { right = i; } else { break; } } if (right == left) { if (T % 2 == 0) cout << "Alice" << endl; else { int left_ = K - 1, right_ = K - 1; for (int i = K - 2; i >= 0; i--) { if (C[i] == 'A') { left_ = i; } else { break; } } for (int i = K; i < N; i++) { if (C[i] == 'A') { right_ = i; } else { break; } } if (!(right_ != K - 1 && right_ != N - 1 && (right_ - (K - 1)) % 2 == 0 && right - (K - 1) < T)) { cout << "Bob" << endl; } else if (!(left_ != K - 1 && left_ != N - 1 && ((K - 1) - left_) % 2 == 0 && (K - 1) - left_ < T)) { cout << "Bob" << endl; } else cout << "Alice" << endl; } } else { if ((right - (K - 1)) % 2 != T % 2 && right - (K - 1) < T && right != N - 1) { cout << "Bob" << endl; } else if (((K - 1) - left) % 2 != T % 2 && (K - 1) - left < T && left != 0) { cout << "Bob" << endl; } else cout << "Alice" << endl; } } }