結果

問題 No.2278 Time Bomb Game 2
ユーザー t98slidert98slider
提出日時 2023-04-21 23:11:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,469 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 175,240 KB
実行使用メモリ 792,576 KB
最終ジャッジ日時 2024-04-24 09:12:22
合計ジャッジ時間 7,387 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 10 ms
13,952 KB
testcase_07 AC 53 ms
65,908 KB
testcase_08 AC 53 ms
69,568 KB
testcase_09 AC 95 ms
118,296 KB
testcase_10 AC 43 ms
59,560 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 102 ms
126,248 KB
testcase_14 AC 72 ms
91,300 KB
testcase_15 AC 81 ms
99,756 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 14 ms
18,432 KB
testcase_18 AC 47 ms
60,640 KB
testcase_19 AC 51 ms
66,600 KB
testcase_20 MLE -
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 83 ms
103,080 KB
testcase_24 AC 101 ms
120,872 KB
testcase_25 AC 74 ms
88,876 KB
testcase_26 AC 67 ms
81,576 KB
testcase_27 AC 87 ms
104,396 KB
testcase_28 AC 38 ms
43,904 KB
testcase_29 AC 71 ms
84,392 KB
testcase_30 AC 65 ms
76,584 KB
testcase_31 AC 7 ms
10,624 KB
testcase_32 AC 46 ms
59,556 KB
testcase_33 MLE -
testcase_34 AC 88 ms
113,704 KB
testcase_35 AC 97 ms
125,668 KB
testcase_36 AC 42 ms
51,880 KB
testcase_37 AC 48 ms
60,328 KB
testcase_38 AC 55 ms
68,520 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 73 ms
90,660 KB
testcase_42 AC 3 ms
5,376 KB
testcase_43 AC 57 ms
73,636 KB
testcase_44 AC 5 ms
6,528 KB
testcase_45 AC 21 ms
29,440 KB
testcase_46 AC 3 ms
5,376 KB
testcase_47 AC 3 ms
5,376 KB
testcase_48 AC 105 ms
130,996 KB
testcase_49 AC 70 ms
89,768 KB
testcase_50 AC 11 ms
15,744 KB
testcase_51 AC 81 ms
102,180 KB
testcase_52 AC 3 ms
5,376 KB
testcase_53 AC 65 ms
82,600 KB
testcase_54 AC 12 ms
16,512 KB
testcase_55 AC 16 ms
23,040 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 40 ms
52,904 KB
testcase_58 AC 7 ms
10,624 KB
testcase_59 AC 81 ms
102,824 KB
testcase_60 AC 88 ms
115,236 KB
testcase_61 AC 8 ms
10,240 KB
testcase_62 AC 96 ms
124,840 KB
testcase_63 AC 3 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 3 ms
5,376 KB
testcase_68 AC 2 ms
5,376 KB
testcase_69 AC 3 ms
5,376 KB
testcase_70 AC 2 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 <= 1000){
        vector<vector<int>> dp(n, vector<int>(1001, -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;
    t += 100;
    vector<vector<int>> dp(n, vector<int>(201, -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