結果

問題 No.2278 Time Bomb Game 2
ユーザー t98slidert98slider
提出日時 2023-04-21 23:10:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,453 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 175,236 KB
実行使用メモリ 89,344 KB
最終ジャッジ日時 2024-04-24 09:10:17
合計ジャッジ時間 5,549 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 7 ms
8,960 KB
testcase_07 AC 33 ms
36,336 KB
testcase_08 AC 35 ms
38,212 KB
testcase_09 AC 62 ms
64,020 KB
testcase_10 AC 31 ms
33,064 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 66 ms
68,140 KB
testcase_14 AC 47 ms
49,832 KB
testcase_15 AC 51 ms
54,188 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 10 ms
11,264 KB
testcase_18 AC 31 ms
33,576 KB
testcase_19 AC 34 ms
36,776 KB
testcase_20 AC 81 ms
89,344 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 53 ms
56,104 KB
testcase_24 AC 64 ms
65,188 KB
testcase_25 AC 45 ms
48,424 KB
testcase_26 AC 41 ms
44,708 KB
testcase_27 AC 53 ms
56,620 KB
testcase_28 AC 23 ms
24,704 KB
testcase_29 AC 42 ms
46,120 KB
testcase_30 AC 39 ms
42,020 KB
testcase_31 AC 6 ms
7,296 KB
testcase_32 AC 31 ms
33,192 KB
testcase_33 AC 38 ms
40,872 KB
testcase_34 AC 58 ms
61,608 KB
testcase_35 AC 66 ms
67,880 KB
testcase_36 AC 27 ms
28,964 KB
testcase_37 AC 31 ms
33,444 KB
testcase_38 AC 35 ms
37,800 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 46 ms
49,444 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 37 ms
40,360 KB
testcase_44 AC 4 ms
5,376 KB
testcase_45 AC 15 ms
17,152 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 3 ms
5,376 KB
testcase_48 AC 68 ms
70,700 KB
testcase_49 AC 45 ms
48,936 KB
testcase_50 AC 9 ms
9,984 KB
testcase_51 AC 51 ms
55,592 KB
testcase_52 AC 3 ms
5,376 KB
testcase_53 AC 42 ms
45,092 KB
testcase_54 AC 9 ms
10,368 KB
testcase_55 AC 12 ms
13,696 KB
testcase_56 AC 3 ms
5,376 KB
testcase_57 AC 28 ms
29,480 KB
testcase_58 AC 6 ms
7,168 KB
testcase_59 AC 52 ms
55,844 KB
testcase_60 AC 60 ms
62,248 KB
testcase_61 AC 5 ms
7,168 KB
testcase_62 AC 64 ms
67,500 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
testcase_65 AC 2 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 3 ms
5,376 KB
testcase_70 AC 3 ms
5,376 KB
testcase_71 AC 2 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--;
    if(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';
        return 0;
    }
    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