結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2022-08-19 21:30:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 671 bytes |
| コンパイル時間 | 1,634 ms |
| コンパイル使用メモリ | 167,480 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-16 01:52:39 |
| 合計ジャッジ時間 | 2,754 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#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]);
break;
}
}
if (i % 3 == 2) {
cnt[0] = cnt[1] = cnt[2] = 1;
}
}
std::cout << res << std::endl;
return 0;
}
QCFium