結果

問題 No.2042 RGB Caps
ユーザー rabimea
提出日時 2025-09-29 14:37:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 8,145 ms
コンパイル使用メモリ 285,720 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-29 14:37:45
合計ジャッジ時間 5,596 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>

using std::cin, std::cout, std::cerr;
using ll = long long;

int main() {
    std::ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    std::vector<char> c(n + 1);
    while(k --) {
        int a; char t;
        cin >> a >> t;
        c[a] = t;
    }

    std::string ans = "";
    std::map<char, int> cnt;
    std::set<char> turn = {'R', 'G', 'B'};
    for(int i = 1; i <= n; i ++) {
        char cur;
        if(c[i] != '0' && turn.count(c[i])) {
            cur = c[i];
        } else {
            cur = *turn.begin();
        }
        turn.erase(cur);
        ans += cur;
        if(turn.empty()) {
            turn = {'R', 'G', 'B'};
        }
    }
    cout << ans << '\n';
}
0