結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,664 KB
testcase_01 AC 3 ms
5,600 KB
testcase_02 AC 7 ms
10,040 KB
testcase_03 AC 5 ms
7,788 KB
testcase_04 AC 3 ms
5,568 KB
testcase_05 AC 5 ms
7,616 KB
testcase_06 AC 6 ms
9,892 KB
testcase_07 AC 5 ms
7,648 KB
testcase_08 AC 5 ms
7,952 KB
testcase_09 AC 3 ms
5,852 KB
testcase_10 WA -
testcase_11 AC 18 ms
21,452 KB
testcase_12 AC 16 ms
19,492 KB
testcase_13 WA -
testcase_14 AC 7 ms
10,260 KB
testcase_15 AC 5 ms
7,800 KB
testcase_16 AC 131 ms
109,144 KB
testcase_17 AC 150 ms
115,684 KB
testcase_18 WA -
testcase_19 AC 198 ms
133,748 KB
testcase_20 AC 208 ms
136,772 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 242 ms
142,124 KB
testcase_24 WA -
testcase_25 AC 153 ms
124,188 KB
testcase_26 AC 96 ms
85,464 KB
testcase_27 AC 39 ms
50,480 KB
testcase_28 AC 54 ms
63,396 KB
testcase_29 AC 109 ms
107,848 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() {
	if (s.size() > 100) {
		return 1;
	}
	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