結果

問題 No.2042 RGB Caps
ユーザー QCFiumQCFium
提出日時 2022-08-19 21:29:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 660 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 163,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 00:09:49
合計ジャッジ時間 3,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 9 ms
5,376 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 26 ms
5,376 KB
testcase_14 AC 26 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int k = ri();
	int limit[n];
	for (auto &i : limit) i = 0;
	for (int i = 0; i < k; i++) {
		int a = ri() - 1;
		std::string t;
		std::cin >> t;
		limit[a] = t[0] == 'R' ? 0 : t[0] == 'G' ? 1 : 2;
	}
	std::string res;
	int cnt[3] = {1, 1, 1};
	for (int i = 0; i < n; i++) {
		if (cnt[limit[i]]) res.push_back("RGB"[limit[i]]), cnt[limit[i]]--;
		else {
			for (int j = 0; j < 3; j++) if (cnt[j]) {
				cnt[j]--;
				res.push_back("RGB"[j]);
			}
		}
		if (i % 3 == 2) {
			cnt[0] = cnt[1] = cnt[2] = 1;
		}
	}
	std::cout << res << std::endl;
	return 0;
}
0