結果

問題 No.291 黒い文字列
ユーザー Kmcode1Kmcode1
提出日時 2015-10-16 23:07:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,367 bytes
コンパイル時間 2,791 ms
コンパイル使用メモリ 93,576 KB
実行使用メモリ 142,232 KB
最終ジャッジ日時 2023-09-29 01:38:14
合計ジャッジ時間 4,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,672 KB
testcase_01 AC 3 ms
5,532 KB
testcase_02 AC 7 ms
10,276 KB
testcase_03 AC 6 ms
7,788 KB
testcase_04 AC 3 ms
5,564 KB
testcase_05 AC 5 ms
7,600 KB
testcase_06 AC 6 ms
9,628 KB
testcase_07 AC 4 ms
7,684 KB
testcase_08 AC 5 ms
7,936 KB
testcase_09 AC 3 ms
5,696 KB
testcase_10 WA -
testcase_11 AC 19 ms
21,348 KB
testcase_12 AC 16 ms
19,480 KB
testcase_13 WA -
testcase_14 AC 7 ms
10,188 KB
testcase_15 AC 5 ms
7,804 KB
testcase_16 AC 134 ms
109,140 KB
testcase_17 AC 156 ms
115,676 KB
testcase_18 WA -
testcase_19 AC 212 ms
133,964 KB
testcase_20 AC 221 ms
136,808 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 262 ms
142,232 KB
testcase_24 WA -
testcase_25 AC 152 ms
124,128 KB
testcase_26 AC 95 ms
85,468 KB
testcase_27 AC 39 ms
50,656 KB
testcase_28 AC 54 ms
63,340 KB
testcase_29 AC 106 ms
107,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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][25][25][25][25];
bool use[102][25][25][25][25];
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 <= 25) {
									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 <= 25) {
									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 <= 25) {
									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 <= 25) {
									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;
}
0