結果

問題 No.2042 RGB Caps
ユーザー 👑 rin204rin204
提出日時 2022-08-19 21:31:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 89,120 KB
最終ジャッジ日時 2024-04-27 20:30:32
合計ジャッジ時間 2,506 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,404 KB
testcase_01 AC 32 ms
52,428 KB
testcase_02 AC 34 ms
52,268 KB
testcase_03 AC 33 ms
52,828 KB
testcase_04 AC 32 ms
52,328 KB
testcase_05 AC 31 ms
52,372 KB
testcase_06 AC 74 ms
84,392 KB
testcase_07 AC 113 ms
79,776 KB
testcase_08 AC 131 ms
85,020 KB
testcase_09 AC 87 ms
77,088 KB
testcase_10 AC 147 ms
88,124 KB
testcase_11 AC 84 ms
78,156 KB
testcase_12 AC 152 ms
89,120 KB
testcase_13 AC 144 ms
85,064 KB
testcase_14 AC 146 ms
85,252 KB
testcase_15 AC 34 ms
53,592 KB
testcase_16 AC 97 ms
79,124 KB
testcase_17 AC 85 ms
77,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
rgb = [""] * (n + 10)
for _ in range(k):
    a, c = input().split()
    rgb[int(a) - 1] = c

for i in range(0, n, 3):
    se = {"R", "G", "B"}
    se2 = set()
    for j in range(i, 3 + i):
        if rgb[j] in se:
            se.remove(rgb[j])
            se2.add(rgb[j])
    lst = sorted(se)
    for j in range(i, 3 + i):
        if rgb[j] == "":
            rgb[j] = lst.pop()
        elif rgb[j] in se2:
            se2.remove(rgb[j])
        else:
            rgb[j] = lst.pop()
print(*rgb[:n], sep="")
0