結果
問題 | No.291 黒い文字列 |
ユーザー | Kmcode1 |
提出日時 | 2015-10-16 23:01:46 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,367 bytes |
コンパイル時間 | 676 ms |
コンパイル使用メモリ | 94,528 KB |
実行使用メモリ | 83,436 KB |
最終ジャッジ日時 | 2023-09-29 01:33:11 |
合計ジャッジ時間 | 3,675 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
4,380 KB |
testcase_01 | AC | 3 ms
4,376 KB |
testcase_02 | AC | 6 ms
5,848 KB |
testcase_03 | AC | 4 ms
4,376 KB |
testcase_04 | AC | 3 ms
4,376 KB |
testcase_05 | AC | 4 ms
4,376 KB |
testcase_06 | AC | 6 ms
5,700 KB |
testcase_07 | AC | 4 ms
4,384 KB |
testcase_08 | AC | 4 ms
4,380 KB |
testcase_09 | AC | 3 ms
4,376 KB |
testcase_10 | WA | - |
testcase_11 | AC | 15 ms
13,424 KB |
testcase_12 | AC | 14 ms
12,368 KB |
testcase_13 | WA | - |
testcase_14 | AC | 6 ms
6,232 KB |
testcase_15 | AC | 4 ms
4,380 KB |
testcase_16 | AC | 112 ms
66,100 KB |
testcase_17 | AC | 132 ms
70,068 KB |
testcase_18 | WA | - |
testcase_19 | AC | 176 ms
80,076 KB |
testcase_20 | AC | 185 ms
81,436 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 219 ms
83,436 KB |
testcase_24 | WA | - |
testcase_25 | AC | 119 ms
76,484 KB |
testcase_26 | AC | 83 ms
52,224 KB |
testcase_27 | AC | 34 ms
28,132 KB |
testcase_28 | AC | 44 ms
37,204 KB |
testcase_29 | AC | 80 ms
66,340 KB |
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> using namespace std; string s; int dp[102][21][21][21][21]; bool use[102][21][21][21][21]; int main() { cin >> s; int ans = 0; use[0][0][0][0][0] = true; for (int i = 0;i < s.size();i++) { for (int j = 0;j <= 20;j++) { for (int k = 0;k <= 20;k++) { for (int kk = 0;kk <= 20;kk++) { for (int kkk = 0;kkk <= 20;kkk++) { if (use[i][j][k][kk][kkk]) { // cout << j << " " << k << " " << kk << " " << kkk << endl; dp[i + 1][j][k][kk][kkk] = max(dp[i + 1][j][k][kk][kkk], dp[i][j][k][kk][kkk]); use[i + 1][j][k][kk][kkk] = true; if (s[i] == 'K'||s[i]=='?') { if (j+ 1 <= 20) { dp[i + 1][j + 1][k][kk][kkk] = max(dp[i + 1][j + 1][k][kk][kkk], dp[i][j][k][kk][kkk]); use[i + 1][j + 1][k][kk][kkk] = true; //continue; } } if (s[i] == 'U' || s[i] == '?') { if (k + 1 <= 20) { dp[i + 1][j][k+1][kk][kkk] = max(dp[i + 1][j][k+1][kk][kkk], dp[i][j][k][kk][kkk]); use[i + 1][j][k + 1][kk][kkk] = true; //continue; } } if (s[i] == 'R' || s[i] == '?') { if (kk + 1 <= 20) { dp[i + 1][j][k][kk+1][kkk] = max(dp[i + 1][j][k][kk+1][kkk], dp[i][j][k][kk][kkk]); use[i + 1][j][k][kk + 1][kkk] = true; // continue; } } if (s[i] == 'O' || s[i] == '?') { if (kkk + 1 <= 20) { dp[i + 1][j][k][kk][kkk+1] = max(dp[i + 1][j][k][kk][kkk+1], dp[i][j][k][kk][kkk]); use[i + 1][j][k][kk][kkk + 1] = true; // continue; } } if (s[i] == 'I' || s[i] == '?') { if (j&&k&&kk&&kkk) { dp[i + 1][j-1][k-1][kk-1][kkk-1] = max(dp[i + 1][j-1][k-1][kk-1][kkk-1], dp[i][j][k][kk][kkk] + 1); ans = max(ans, dp[i + 1][j-1][k-1][kk-1][kkk-1]); use[i + 1][j-1][k-1][kk-1][kkk-1] = true; } } } } } } } } cout << ans << endl; return 0; }