結果

問題 No.2278 Time Bomb Game 2
ユーザー t98slidert98slider
提出日時 2023-04-21 23:08:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,726 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 173,956 KB
実行使用メモリ 70,824 KB
最終ジャッジ日時 2024-04-24 09:09:19
合計ジャッジ時間 4,639 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 7 ms
8,960 KB
testcase_07 AC 30 ms
36,336 KB
testcase_08 AC 31 ms
38,212 KB
testcase_09 AC 54 ms
64,020 KB
testcase_10 AC 26 ms
33,060 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 59 ms
68,136 KB
testcase_14 AC 41 ms
49,748 KB
testcase_15 AC 44 ms
54,312 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 7 ms
11,264 KB
testcase_18 AC 26 ms
33,448 KB
testcase_19 AC 28 ms
36,776 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 46 ms
56,100 KB
testcase_24 AC 56 ms
65,444 KB
testcase_25 AC 39 ms
48,552 KB
testcase_26 AC 35 ms
44,712 KB
testcase_27 AC 47 ms
56,616 KB
testcase_28 AC 19 ms
24,832 KB
testcase_29 AC 37 ms
46,124 KB
testcase_30 AC 33 ms
42,024 KB
testcase_31 AC 5 ms
7,424 KB
testcase_32 AC 26 ms
33,192 KB
testcase_33 AC 33 ms
40,744 KB
testcase_34 AC 50 ms
61,608 KB
testcase_35 AC 57 ms
67,880 KB
testcase_36 AC 23 ms
28,968 KB
testcase_37 AC 26 ms
33,580 KB
testcase_38 AC 31 ms
37,800 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 41 ms
49,448 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 32 ms
40,492 KB
testcase_44 AC 4 ms
5,376 KB
testcase_45 AC 13 ms
17,280 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 60 ms
70,824 KB
testcase_49 AC 40 ms
48,936 KB
testcase_50 AC 7 ms
9,984 KB
testcase_51 AC 43 ms
55,464 KB
testcase_52 AC 3 ms
5,376 KB
testcase_53 AC 37 ms
45,096 KB
testcase_54 AC 7 ms
10,496 KB
testcase_55 AC 10 ms
13,824 KB
testcase_56 AC 3 ms
5,376 KB
testcase_57 AC 23 ms
29,608 KB
testcase_58 AC 5 ms
7,168 KB
testcase_59 AC 46 ms
55,976 KB
testcase_60 AC 52 ms
62,376 KB
testcase_61 AC 5 ms
7,168 KB
testcase_62 AC 55 ms
67,624 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
testcase_65 AC 3 ms
5,376 KB
testcase_66 AC 2 ms
5,376 KB
testcase_67 AC 2 ms
5,376 KB
testcase_68 AC 3 ms
5,376 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 3 ms
5,376 KB
testcase_71 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, t, mn = 1 << 30;
    string s, s2;
    cin >> n >> k >> t >> s;
    k--;
    for(int i = k; i + 1 < n; i++){
        if(s[i] != s[i + 1]){
            mn = min(mn, i + 1 - k);
            break;
        }
    }
    for(int i = k; i >= 1; i--){
        if(s[i] != s[i - 1]){
            mn = min(mn, k - (i - 1));
            break;
        }
    }
    if(mn > t){
        cout << (s[k] == 'A' ? "Bob" : "Alice") << '\n';
        return 0;
    }
    char tmp = s[k];
    s[k] = 'C';
    vector<pair<char,int>> b;
    for(int i = 0; i < n; ){
        int p = i;
        while(i < n && s[i] == s[p]) i++;
        b.emplace_back(s[p], i - p);
    }
    
    for(int i = 0; i < b.size(); i++){
        char c;
        int v;
        tie(c, v) = b[i];
        if(c == 'C'){
            k = s2.size();
            s2 += tmp;
            continue;
        }
        s2 += string(v % 2 + (v >= 2) * 2, c);
    }
    swap(s, s2);
    n = s.size();
    t %= 100;
    vector<vector<int>> dp(n, vector<int>(101, -1));
    function<int(int,int)> rec = [&](int i, int t){
        if(t == 0) return s[i] == 'A' ? 0 : 1;
        if(dp[i][t] != -1) return dp[i][t];
        if(s[i] == 'A'){
            if(i >= 1 && rec(i - 1, t - 1) == 1) return dp[i][t] = 1;
            if(i + 1 < n && rec(i + 1, t - 1) == 1) return dp[i][t] = 1;
            return dp[i][t] = 0;
        }
        if(i >= 1 && rec(i - 1, t - 1) == 0) return dp[i][t] = 0;
        if(i + 1 < n && rec(i + 1, t - 1) == 0) return dp[i][t] = 0;
        return dp[i][t] = 1;
    };
    cout << (rec(k, t) ? "Alice" : "Bob") << '\n';
}
0