結果
問題 |
No.2042 RGB Caps
|
ユーザー |
![]() |
提出日時 | 2022-08-09 20:49:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 832 bytes |
コンパイル時間 | 861 ms |
コンパイル使用メモリ | 91,028 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-20 01:16:15 |
合計ジャッジ時間 | 4,357 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 16 |
ソースコード
// 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); } } cout << ret + "R" << endl; }