結果

問題 No.291 黒い文字列
ユーザー sugim48sugim48
提出日時 2015-10-16 22:48:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,928 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 77,464 KB
実行使用メモリ 28,220 KB
最終ジャッジ日時 2023-09-29 01:21:24
合計ジャッジ時間 13,524 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
28,220 KB
testcase_01 AC 222 ms
21,172 KB
testcase_02 AC 641 ms
21,104 KB
testcase_03 AC 436 ms
21,204 KB
testcase_04 AC 215 ms
21,132 KB
testcase_05 AC 422 ms
21,148 KB
testcase_06 AC 568 ms
21,132 KB
testcase_07 AC 330 ms
21,188 KB
testcase_08 AC 418 ms
21,420 KB
testcase_09 AC 208 ms
21,148 KB
testcase_10 AC 1,533 ms
21,356 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 213 ms
21,148 KB
testcase_14 AC 635 ms
21,204 KB
testcase_15 AC 430 ms
21,208 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, c; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dp[101][51][34][26];

int main() {
	for (int k = 0; k <= 100; k++)
		for (int u = 0; u <= 50; u++)
			for (int r = 0; r <= 33; r++)
				for (int o = 0; o <= 25; o++)
					dp[k][u][r][o] = -1;
	dp[0][0][0][0] = 0;
	string S; cin >> S;
	for (int i = 0; i < S.length(); i++) {
		char c = S[i];
		for (int o = 25; o >= 0; o--)
			for (int r = 33; r >= 0; r--)
				for (int u = 50; u >= 0; u--)
					for (int k = 100; k >= 0; k--) {
						if (dp[k][u][r][o] == -1) continue;
						if (c == 'K' || c == '?')
							dp[k + 1][u][r][o] = max(dp[k + 1][u][r][o], dp[k][u][r][o]);
						if ((c == 'U' || c == '?') && k >= 1)
							dp[k - 1][u + 1][r][o] = max(dp[k - 1][u + 1][r][o], dp[k][u][r][o]);
						if ((c == 'R' || c == '?') && u >= 1)
							dp[k][u - 1][r + 1][o] = max(dp[k][u - 1][r + 1][o], dp[k][u][r][o]);
						if ((c == 'O' || c == '?') && r >= 1)
							dp[k][u][r - 1][o + 1] = max(dp[k][u][r - 1][o + 1], dp[k][u][r][o]);
						if ((c == 'I' || c == '?') && o >= 1)
							dp[k][u][r][o - 1] = max(dp[k][u][r][o - 1], dp[k][u][r][o] + 1);
					}
	}
	int maxi = 0;
	for (int k = 0; k <= 100; k++)
		for (int u = 0; u <= 50; u++)
			for (int r = 0; r <= 33; r++)
				for (int o = 0; o <= 25; o++)
					maxi = max(maxi, dp[k][u][r][o]);
	cout << maxi << endl;
}
0