結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,736 KB
testcase_01 AC 4 ms
5,632 KB
testcase_02 AC 7 ms
9,984 KB
testcase_03 AC 5 ms
7,804 KB
testcase_04 AC 4 ms
5,564 KB
testcase_05 AC 5 ms
7,620 KB
testcase_06 AC 6 ms
9,712 KB
testcase_07 AC 5 ms
7,716 KB
testcase_08 AC 5 ms
7,948 KB
testcase_09 AC 3 ms
5,628 KB
testcase_10 WA -
testcase_11 AC 19 ms
21,492 KB
testcase_12 AC 16 ms
19,544 KB
testcase_13 WA -
testcase_14 AC 7 ms
10,204 KB
testcase_15 AC 5 ms
7,816 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

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;
	if (s.size() > 50) {
		return 1;
	}
	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