結果

問題 No.291 黒い文字列
ユーザー 唐澤貴洋唐澤貴洋
提出日時 2015-10-17 01:49:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,253 bytes
コンパイル時間 1,341 ms
コンパイル使用メモリ 75,924 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 13:24:09
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 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 1 ms
4,376 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' };
int main() {
	cin >> s;
	vector<int> p[6];
	for (i = 0; i < 20; i++) {
		p[0].push_back(0);
	}
	i = 0;
	for (auto &x : s) {
		for (j = 4; j >= 0; j--) {
			if (!p[j].empty()&&x==ta[j]) {
				x = ' ';
				p[j].pop_back();
				p[j + 1].push_back(i);
				break;
			}
		}
		i++;
	}
	i = 0;
	for (auto x : s) {
		if (x == '?') {
			for (j = 4; j >= 0; j--) {
				auto it = p[j].begin();
				for (auto y : p[j]) {
					if (i < y)
						break;
					it++;
				}
				if (it!=p[j].begin()) {
					it--;
					p[j].erase(it);
					auto it2 = p[j + 1].begin();
					for (auto y : p[j+1]) {
						if (i < y)
							break;
						it2++;
					}
					p[j + 1].insert(it2,i);
					break;
				}
			}
		}
		for (j = 4; j >= 0; j--) {
			if (!p[j].empty() && x == ta[j]) {
				p[j].pop_back();
				p[j + 1].push_back(i);
				break;
			}
		}
		i++;
	}
	cout << p[5].size() << endl;
}
0