結果
問題 |
No.2042 RGB Caps
|
ユーザー |
|
提出日時 | 2022-09-08 00:15:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 1,962 ms |
コンパイル使用メモリ | 201,856 KB |
最終ジャッジ日時 | 2025-02-07 03:26:18 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main () { int N, M; cin >> N >> M; string ans = ""; string key = "RGB"; for (int i = 0; i < N + 3 - N % 3; i ++) { ans += key[i % 3]; } vector<pair<int, char>> A(M); for (auto& [a, c] : A) { cin >> a >> c; } sort(A.begin(), A.end()); for (auto [a, c] : A) { a --; if (a % 3 == 0) { if (c == 'G') { swap(ans[a], ans[a+1]); } else if (c == 'B') { swap(ans[a], ans[a + 2]); } } else if (a % 3 == 1) { if (ans[a + 1] == c) { swap(ans[a], ans[a + 1]); } } } cout << ans.substr(0, N) << endl; }