結果

問題 No.291 黒い文字列
ユーザー mamekinmamekin
提出日時 2016-10-14 20:59:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,759 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 112,020 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 23:05:04
合計ジャッジ時間 3,230 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 126 ms
5,504 KB
testcase_17 AC 198 ms
5,760 KB
testcase_18 AC 128 ms
5,376 KB
testcase_19 AC 167 ms
5,376 KB
testcase_20 AC 156 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 323 ms
6,528 KB
testcase_23 AC 37 ms
5,376 KB
testcase_24 AC 232 ms
5,888 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 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";
    int len = kuroi.size();

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

    set<vector<int> > x;
    vector<int> init(len + 1, 0);
    init[0] = n / len;
    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<len; ++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[len]);
    cout << ans << endl;

    return 0;
}
0