結果

問題 No.291 黒い文字列
ユーザー hanorverhanorver
提出日時 2015-10-16 23:12:47
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 948 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 63,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 01:41:03
合計ジャッジ時間 1,850 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 RE -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0