結果

問題 No.2278 Time Bomb Game 2
ユーザー Yaowei LyuYaowei Lyu
提出日時 2023-04-21 22:02:38
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,618 bytes
コンパイル時間 3,202 ms
コンパイル使用メモリ 284,752 KB
実行使用メモリ 815,872 KB
最終ジャッジ日時 2024-04-24 08:10:58
合計ジャッジ時間 6,928 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr LL mod = 998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, t;
    string s;
    cin >> n >> k >> t >> s;
    k -= 1;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i += 1) {
        if (i and s[i - 1] == s[i]) {
            l[i] = l[i - 1];
        } else {
            l[i] = i;
        }
    }
    for (int i = n - 1; i >= 0; i -= 1) {
        if (i + 1 < n and s[i + 1] == s[i]) {
            r[i] = r[i + 1];
        } else {
            r[i] = i;
        }
    }
    map<char, string> ans = {{'A', "Alice"}, {'B', "Bob"}};
    function<char(int, int)> f = [&](int k, int t) -> char {
        if ((k + t <= r[k] or r[k] == n - 1) and (k - t >= l[k] or l[k] == 0)) {
            return 131 - s[k];
        }
        if (l[k] == r[k]) {
            if (t % 2 == 0) {
                return 131 - s[k];
            }
            int l = k ? f(k - 1, t - 1) : 131 - s[k];
            int r = k + 1 < n ? f(k + 1, t - 1) : 131 - s[k];
            return l == s[k] or r == s[k] ? s[k] : 131 - s[k];
        }
        if (l[k] > 0 and k - l[k] < t and (k - l[k] + 1) % 2 == t % 2) {
            return s[k];
        }
        if (r[k] + 1 < n and r[k] - k < t and (r[k] - k + 1) % 2 == t % 2) {
            return s[k];
        }
        if ((r[k] - l[k]) % 2 == 0) {
            return s[k] ^ 1;
        }
        if (l[k] > 0 and k - l[k] < t) {
            return f(l[k] - 1, t - (k - l[k] + 1));
        }
        return f(r[k] + 1, t - (r[k] - k + 1));
    };
    cout << ans[f(k, t)];
}
0