結果

問題 No.2278 Time Bomb Game 2
ユーザー tsugutsugutsugutsugu
提出日時 2023-04-21 22:51:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,927 bytes
コンパイル時間 3,539 ms
コンパイル使用メモリ 274,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 08:54:11
合計ジャッジ時間 4,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, t;
    cin >> n >> k >> t;
    string s;
    cin >> s;
    k--;
    if (s[k] == 'A') {
        bool adj = false;
        if (k > 0 && s[k - 1] == 'A') {
            adj = true;
        }
        if (k < n - 1 && s[k + 1] == 'A') {
            adj = true;
        }
        if (adj) {
            int l = -1, r = n;
            for (int i = 1; i <= t; i++) {
                if (k + i >= n) {
                    break;
                }
                if (s[k + i] == 'B') {
                    r = i;
                    break;
                }
            }
            for (int i = 1; i <= t; i++) {
                if (k - i < 0) {
                    break;
                }
                if (s[k - i] == 'B') {
                    l = i;
                    break;
                }
            }
            if ((l == -1 && r == n) || (l > t && r > t)) {
                cout << "Bob" << '\n';
                return 0;
            }
            bool win = false;
            if (l >= 0 && r < n && l % 2 != r % 2) {
                win = true;
            }
            if (l >= 0) {
                if (l % 2 == t % 2) {
                    win = true;
                }
            }
            if (r < n) {
                if (r % 2 == t % 2) {
                    win = true;
                }
            }
            cout << (win ? "Alice" : "Bob") << '\n';
        } else {
            if (t % 2 == 0) {
                cout << "Bob" << '\n';
                return 0;
            }
            if ((k > 1 && s[k - 2] == 'A') || (k < n - 1 && s[k + 2] == 'A')) {
                cout << "Alice" << '\n';
                return 0;
            }
            t--;
            int l = -1, r = n;
            for (int i = 1; i <= t; i++) {
                if (k + i >= n) {
                    break;
                }
                if (s[k + i] == 'A') {
                    r = i;
                    break;
                }
            }
            for (int i = 1; i <= t; i++) {
                if (k - i < 0) {
                    break;
                }
                if (s[k - i] == 'A') {
                    l = i;
                    break;
                }
            }
            if ((l == -1 && r == n) || (l > t && r > t)) {
                cout << "Alice" << '\n';
                return 0;
            }
            bool win = false;
            if (l >= 0 && r < n && l % 2 != r % 2) {
                win = true;
            }
            if (l >= 0) {
                if (l % 2 == t % 2) {
                    win = true;
                }
            }
            if (r < n) {
                if (r % 2 == t % 2) {
                    win = true;
                }
            }
            cout << (win ? "Bob" : "Alice") << '\n';
        }
    }
}
0