結果
| 問題 | No.2042 RGB Caps |
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2022-08-09 20:50:00 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 848 bytes |
| 記録 | |
| コンパイル時間 | 1,024 ms |
| コンパイル使用メモリ | 90,252 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-20 01:17:13 |
| 合計ジャッジ時間 | 2,650 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 11 WA * 5 |
ソースコード
// WA
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
cin.tie(nullptr), ios::sync_with_stdio(false);
int N, K;
cin >> N >> K;
const string RGB = "RGB";
string target(N, '_');
while (K--) {
int i;
char c;
cin >> i >> c;
target[i - 1] = c;
}
string ret;
string rem;
for (int i = 0; i < N; ++i) {
if (i % 3 == 0) rem = RGB;
auto addchar = [&](char c) -> void {
ret += c;
auto itr = std::find(rem.begin(), rem.end(), c);
rem.erase(itr);
};
if (count(rem.begin(), rem.end(), target[i])) {
addchar(target[i]);
} else {
char c = rem.front();
addchar(c);
}
}
ret.back() = 'G';
cout << ret << endl;
}
hitonanode