結果

問題 No.291 黒い文字列
ユーザー mamekinmamekin
提出日時 2016-10-14 20:54:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,715 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 111,944 KB
実行使用メモリ 39,552 KB
最終ジャッジ日時 2024-05-01 23:04:47
合計ジャッジ時間 9,532 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 185 ms
7,808 KB
testcase_17 AC 447 ms
12,288 KB
testcase_18 AC 226 ms
8,960 KB
testcase_19 AC 1,117 ms
20,864 KB
testcase_20 AC 1,430 ms
22,912 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 TLE -
testcase_23 AC 829 ms
12,032 KB
testcase_24 AC 748 ms
21,504 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    const string kuroi = "KUROI";

    string s;
    cin >> s;
    int n = s.size();

    set<vector<int> > x;
    vector<int> init(6, 0);
    init[0] = n;
    x.insert(init);

    for(int i=0; i<n; ++i){
        if(s[i] == '?'){
            set<vector<int> > y;
            for(const auto& v : x){
                for(int i=0; i<5; ++i){
                    if(v[i] > 0){
                        vector<int> w = v;
                        -- w[i];
                        ++ w[i+1];
                        y.insert(w);
                    }
                }
            }
            x.swap(y);
        }
        else{
            int k = kuroi.find(s[i]);
            if(k != string::npos){
                set<vector<int> > y;
                for(const auto& v : x){
                    if(v[k] > 0){
                        vector<int> w = v;
                        -- w[k];
                        ++ w[k+1];
                        y.insert(w);
                    }
                    else{
                        y.insert(v);
                    }
                }
                x.swap(y);
            }
        }
    }

    int ans = 0;
    for(const auto& v : x)
        ans = max(ans, v[5]);
    cout << ans << endl;

    return 0;
}
0