結果
| 問題 |
No.291 黒い文字列
|
| コンテスト | |
| ユーザー |
hanorver
|
| 提出日時 | 2015-10-16 23:12:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 948 bytes |
| コンパイル時間 | 486 ms |
| コンパイル使用メモリ | 62,492 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-21 20:20:27 |
| 合計ジャッジ時間 | 1,440 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 WA * 11 RE * 1 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
int main() {
std::string str;
std::cin >> str;
for (int i = 0; i < str.length(); i++) {
if (str[i] != 'K' && str[i] != 'U' && str[i] != 'R' && str[i] != 'O' && str[i] != 'I' && str[i] != '\?') {
str.erase(str.begin() + i);
i--;
}
}
while(str.front() != 'K' && str.front() != '\?') str.erase(str.begin());
while (str.back() != 'I' && str.back() != '\?') str.erase(str.begin() + str.size() - 1);
std::string s = "KUROI";
int pos = 0;
std::vector<int> d;
int ans = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] == s[pos] || str[i] == '\?') {
pos++;
d.push_back(i);
if (pos > 4) {
pos = 0;
for (int j = 0; j < 5; j++) {
str[d[j]] = 'T';
}
d.clear();
i = -1;
ans++;
}
}
if (i == str.length() - 1 && d.size() != 0) {
str[d.front()] = 'T';
d.clear();
i = -1;
}
}
std::cout << ans << std::endl;
return 0;
}
hanorver