結果
問題 | No.2276 I Want AC |
ユーザー |
|
提出日時 | 2023-04-21 21:39:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,108 bytes |
コンパイル時間 | 1,712 ms |
コンパイル使用メモリ | 171,048 KB |
実行使用メモリ | 8,456 KB |
最終ジャッジ日時 | 2024-11-06 15:09:05 |
合計ジャッジ時間 | 9,302 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 WA * 2 |
ソースコード
#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';}