結果

問題 No.291 黒い文字列
ユーザー 唐澤貴洋唐澤貴洋
提出日時 2015-10-17 00:00:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,569 bytes
コンパイル時間 903 ms
コンパイル使用メモリ 77,132 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 12:23:53
合計ジャッジ時間 2,074 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<bitset>
#include<array>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<numeric>
#define D int
#define U unsigned
using namespace std;
D n, m,a, b, d, e;
D i, j, k;
char c,f;
bool g, h;
string s;
D ans;
char ta[] = { 'K','U','R','O','I' };
struct Ku {
	int n;
	int m;
	bool operator<(const Ku &obj)const {
		return m < obj.m;
	}
};
int main() {
	Ku t;
	vector<Ku> kuroi;
	auto it = kuroi.begin();
	cin >> s;
	for (i = 0; i < s.size();i++) {
		auto &x = s[i];
		if (x == ta[0]) {
			t.n = i+1;
			t.m = 1;
			kuroi.push_back(t);
			x = ' ';
		}
		for (it = kuroi.begin(); it != kuroi.end(); it++) {
			if (ta[it->m]==x) {
				x = ' ';
				it->n = i+1;
				it->m++;
				if (it->m == 5) {
					ans++;
					kuroi.erase(it);
				}
				break;
			}
		}
	}
	for (i = 0; i < s.size(); i++) {
		sort(kuroi.begin(), kuroi.end());
		reverse(kuroi.begin(), kuroi.end());
		auto x = s[i];
		if (x == '?') {
			g = false;
			for (it = kuroi.begin(); it != kuroi.end(); it++) {
				if (i>=it->n) {
					it->m++;
					if (it->m == 5) {
						ans++;
						kuroi.erase(it);
					}
					g = true;
					break;
				}
			}
			if (g == false) {
				t.n = 0;
				t.m = 1;
				kuroi.push_back(t);
			}
		}
		for (it = kuroi.begin(); it != kuroi.end(); it++) {
			if (i >= it->n) {
				if (ta[it->m] == x) {
					it->m++;
					if (it->m == 5) {
						ans++;
						kuroi.erase(it);
					}
					break;
				}
			}
		}
	}
	
	cout << ans << endl;
}
0