結果

問題 No.291 黒い文字列
ユーザー koyoprokoyopro
提出日時 2015-10-17 15:30:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,226 bytes
コンパイル時間 2,489 ms
コンパイル使用メモリ 156,308 KB
実行使用メモリ 7,816 KB
最終ジャッジ日時 2023-09-29 16:05:06
合計ジャッジ時間 5,155 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()

int N,T;
string S, t;
map<char, int> KU;
int C[5];
int dfs(int n) {
    if (n == t.size()) {
        //printf("%d, [%d, %d, %d, %d, %d]\n", n, C[0], C[1], C[2], C[3], C[4]);
        return C[4];
    }
    int i = KU[t[n]];
    int ret = 0;
    if (i == -1) {
        REP(j,5) {
            if (j && C[j] >= C[j-1]) continue;
            C[j]++;
            ret = max(ret, dfs(n+1));
            C[j]--;
        }
    } else {
        C[i]++;
        if (i > 0) C[i] = min(C[i], C[i-1]);
        ret = dfs(n + 1);
        C[i]--;
    }
    return ret;
}
signed main()
{
    cin >> S;
    KU['K'] = 0;
    KU['U'] = 1;
    KU['R'] = 2;
    KU['O'] = 3;
    KU['I'] = 4;
    KU['?'] = -1;
    vector<char> KUROI;
    KUROI.push_back('K');
    KUROI.push_back('U');
    KUROI.push_back('R');
    KUROI.push_back('O');
    KUROI.push_back('I');
    for (auto&& s : S) {
        if (CONTAIN(KUROI, s) || s == '?') {
            t.push_back(s);
        }
    }
    cout << dfs(0) << endl;
    return 0;
}
0