結果
問題 |
No.291 黒い文字列
|
ユーザー |
![]() |
提出日時 | 2015-10-16 23:47:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,411 bytes |
コンパイル時間 | 815 ms |
コンパイル使用メモリ | 62,836 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-21 20:47:23 |
合計ジャッジ時間 | 1,827 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 WA * 7 |
ソースコード
#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.size() > 0 && str.front() != 'K' && str.front() != '\?') str.erase(str.begin()); while (str.size() > 0 && 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]) { pos++; d.push_back(i); if (pos > 4) { for (int j = 0; j < 5; j++) { str[d[j]] = 'T'; } d.clear(); i = -1; ans++; pos = 0; } } if (i == str.length() - 1 && d.size() != 0) { i = d.front(); d.clear(); pos = 0; } } pos = 0; for (int i = 0; i < str.length(); i++) { if (str[i] == s[pos] || str[i] == '\?') { pos++; d.push_back(i); if (pos > 4) { for (int j = 0; j < 5; j++) { str[d[j]] = 'T'; } ans++; pos = 0; i = -1; d.clear(); } } if (i == str.length() - 1 && d.size() > 0) { while (d.size() > 0 && str[d.front()] == '\?')d.erase(d.begin()); str[d.front()] = 'T'; d.clear(); i = -1; pos = 0; } } std::cout << ans << std::endl; return 0; }