結果
| 問題 |
No.291 黒い文字列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-14 20:54:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,715 bytes |
| コンパイル時間 | 1,247 ms |
| コンパイル使用メモリ | 113,720 KB |
| 実行使用メモリ | 39,552 KB |
| 最終ジャッジ日時 | 2024-11-22 06:51:57 |
| 合計ジャッジ時間 | 10,399 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 TLE * 1 |
ソースコード
#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;
}