結果

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

テストケース

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

ソースコード

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--;
    int cntA = count(s.begin(), s.end(), 'A');
    if (cntA == 0) {
        cout << "Alice" << '\n';
        return 0;
    } else {
        cout << "Bob" << '\n';
        return 0;
    }
    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) {
                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 - 2 && s[k + 2] == 'A')) {
                cout << "Alice" << '\n';
                return 0;
            }
            t--;
            bool win = false;
            if (k > 0) {
                int nk = k - 1;
                int l = -1, r = n;
                for (int i = 1; i <= t; i++) {
                    if (nk + i >= n) {
                        break;
                    }
                    if (s[nk + i] == 'A') {
                        r = i;
                        break;
                    }
                }
                for (int i = 1; i <= t; i++) {
                    if (nk - i < 0) {
                        break;
                    }
                    if (s[nk - i] == 'A') {
                        l = i;
                        break;
                    }
                }
                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;
                    }
                }
            }
            if (k < n - 1) {
                int nk = k + 1;
                int l = -1, r = n;
                for (int i = 1; i <= t; i++) {
                    if (nk + i >= n) {
                        break;
                    }
                    if (s[nk + i] == 'A') {
                        r = i;
                        break;
                    }
                }
                for (int i = 1; i <= t; i++) {
                    if (nk - i < 0) {
                        break;
                    }
                    if (s[nk - i] == 'A') {
                        l = i;
                        break;
                    }
                }
                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';
        }
    } else {
        for (int i = 0; i < n; i++) {
            s[i] = s[i] ^ 'A' ^ 'B';
        }
        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) {
                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';
        } else {
            if (t % 2 == 0) {
                cout << "Alice" << '\n';
                return 0;
            }
            if ((k > 1 && s[k - 2] == 'A') || (k < n - 2 && s[k + 2] == 'A')) {
                cout << "Bob" << '\n';
                return 0;
            }
            t--;
            bool win = false;
            if (k > 0) {
                int nk = k - 1;
                int l = -1, r = n;
                for (int i = 1; i <= t; i++) {
                    if (nk + i >= n) {
                        break;
                    }
                    if (s[nk + i] == 'A') {
                        r = i;
                        break;
                    }
                }
                for (int i = 1; i <= t; i++) {
                    if (nk - i < 0) {
                        break;
                    }
                    if (s[nk - i] == 'A') {
                        l = i;
                        break;
                    }
                }
                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;
                    }
                }
            }
            if (k < n - 1) {
                int nk = k + 1;
                int l = -1, r = n;
                for (int i = 1; i <= t; i++) {
                    if (nk + i >= n) {
                        break;
                    }
                    if (s[nk + i] == 'A') {
                        r = i;
                        break;
                    }
                }
                for (int i = 1; i <= t; i++) {
                    if (nk - i < 0) {
                        break;
                    }
                    if (s[nk - i] == 'A') {
                        l = i;
                        break;
                    }
                }
                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';
        }
    }
}
0