結果

問題 No.2276 I Want AC
ユーザー t98slidert98slider
提出日時 2023-04-21 21:39:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,108 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 166,012 KB
実行使用メモリ 8,480 KB
最終ジャッジ日時 2024-04-24 07:49:11
合計ジャッジ時間 9,548 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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 53 ms
5,376 KB
testcase_12 AC 172 ms
7,820 KB
testcase_13 AC 53 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 80 ms
6,064 KB
testcase_16 AC 70 ms
5,800 KB
testcase_17 AC 149 ms
7,544 KB
testcase_18 AC 119 ms
6,604 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 184 ms
8,340 KB
testcase_21 AC 60 ms
5,404 KB
testcase_22 AC 26 ms
5,376 KB
testcase_23 AC 209 ms
8,344 KB
testcase_24 AC 205 ms
8,348 KB
testcase_25 AC 205 ms
8,220 KB
testcase_26 AC 184 ms
8,352 KB
testcase_27 AC 179 ms
8,348 KB
testcase_28 AC 145 ms
8,476 KB
testcase_29 AC 128 ms
8,236 KB
testcase_30 AC 170 ms
8,352 KB
testcase_31 AC 110 ms
8,476 KB
testcase_32 AC 183 ms
8,480 KB
testcase_33 AC 171 ms
8,348 KB
testcase_34 AC 185 ms
8,348 KB
testcase_35 AC 83 ms
8,352 KB
testcase_36 AC 86 ms
8,344 KB
testcase_37 AC 131 ms
8,320 KB
testcase_38 AC 83 ms
8,348 KB
testcase_39 AC 84 ms
8,352 KB
testcase_40 AC 87 ms
8,348 KB
testcase_41 WA -
testcase_42 AC 131 ms
8,448 KB
testcase_43 AC 135 ms
8,348 KB
testcase_44 AC 158 ms
8,348 KB
testcase_45 AC 177 ms
8,220 KB
testcase_46 AC 168 ms
8,476 KB
testcase_47 AC 160 ms
8,348 KB
testcase_48 AC 161 ms
8,476 KB
testcase_49 WA -
testcase_50 AC 171 ms
8,348 KB
testcase_51 AC 175 ms
8,344 KB
testcase_52 AC 175 ms
8,344 KB
testcase_53 AC 175 ms
8,348 KB
testcase_54 AC 127 ms
8,348 KB
testcase_55 AC 106 ms
8,344 KB
testcase_56 AC 96 ms
8,348 KB
testcase_57 AC 87 ms
8,348 KB
testcase_58 AC 96 ms
8,352 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;
    cin >> n;
    string s, t = "AC{";
    cin >> s;
    auto f = [&](int mid){
        vector<array<ll,3>> dp(n + 1, {0, 0, 0});
        dp[0][0] = 1;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 3; j++){
                dp[i + 1][j] += dp[i][j];
                if(s[i] == '?'){
                    if(i < mid && j == 0) dp[i + 1][j + 1] += dp[i][j];
                    if(i >= mid && j == 1) dp[i + 1][j + 1] += dp[i][j];
                }else{
                    if(s[i] == t[j]) dp[i + 1][j + 1] += dp[i][j];
                }
            }
        }
        return dp[n][2];
    };
    ll ans = 0;
    int l = 0, r = n + 1, c1, c2;
    while(l + 3 < r){
        c1 = (2 * l + r) / 3;
        c2 = (l + 2 * r) / 3;
        ll v1 = f(c1), v2 = f(c2);
        ans = max(ans, max(v1, v2));
        if(v1 >= v2) r = c2;
        else l = c1;
    }
    for(int i = l; i <= r; i++){
        ans = max(ans, f(i));
    }
    cout << ans << '\n';
}
0