結果

問題 No.2042 RGB Caps
ユーザー ntuda
提出日時 2022-08-23 22:09:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 101,672 KB
最終ジャッジ日時 2024-11-16 02:01:11
合計ジャッジ時間 3,328 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
AC = []
for _ in range(K):
    a, c = input().split()
    AC.append((int(a), c))
AC = dict(AC)
ans = []
dic = {"R": 0, "G": 1, "B": 2}
color = ["R", "G", "B"]
X = [0, 0, 0]
for i in range(-(-N // 3)):
    tmp = []
    k = 0
    for j in range(3):
        cnt = 3 * i + j + 1
        if cnt in AC and AC[cnt] not in tmp:
            c = AC[cnt]
            tmp.append(c)
            k = (dic[c] + 1) % 3
        else:
            while color[k] in tmp:
                k = (k + 1) % 3
            tmp.append(color[k])
    ans += tmp
ans = ans[:N]
print("".join(ans))
0