結果
問題 | No.2042 RGB Caps |
ユーザー |
![]() |
提出日時 | 2022-08-09 20:49:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 848 bytes |
コンパイル時間 | 963 ms |
コンパイル使用メモリ | 90,256 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-20 01:17:01 |
合計ジャッジ時間 | 3,248 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 8 WA * 8 |
ソースコード
// 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() = 'R';cout << ret << endl;}