結果

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

ソースコード

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:
            c = AC[cnt]
            if c in tmp:
                tmp.append(color[j])
            else:
                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