結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 120 ms
5,376 KB
testcase_20 AC 295 ms
7,552 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 847 ms
12,032 KB
testcase_24 WA -
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 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
                    }
                }
                x.swap(y);
            }
        }
    }

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

    return 0;
}
0