結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
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";
    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);
            }
        }
    }

    cout << x.size() << endl;

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

    return 0;
}
0