結果

問題 No.2042 RGB Caps
ユーザー KudeKude
提出日時 2022-08-19 21:33:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 78,132 KB
最終ジャッジ日時 2024-04-27 20:30:53
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,956 KB
testcase_01 AC 36 ms
53,000 KB
testcase_02 AC 34 ms
53,356 KB
testcase_03 AC 37 ms
53,276 KB
testcase_04 AC 33 ms
51,956 KB
testcase_05 AC 32 ms
53,720 KB
testcase_06 AC 52 ms
68,872 KB
testcase_07 AC 95 ms
77,152 KB
testcase_08 AC 100 ms
77,464 KB
testcase_09 AC 73 ms
76,480 KB
testcase_10 AC 113 ms
78,132 KB
testcase_11 AC 76 ms
76,576 KB
testcase_12 AC 119 ms
77,960 KB
testcase_13 AC 115 ms
78,048 KB
testcase_14 AC 121 ms
77,784 KB
testcase_15 AC 36 ms
52,864 KB
testcase_16 AC 86 ms
77,192 KB
testcase_17 AC 83 ms
76,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
d = [-1] * n
for _ in range(k):
    a, c = input().split()
    d[int(a) - 1] = 'RGB'.find(c)
ans = [0] * n
now = 0
for i in range(n):
    if i % 3 == 0:
        now = 7
    if d[i] == -1 or not now >> d[i] & 1:
        k = 0
        while not now >> k & 1:
            k += 1
    else:
        k = d[i]
    ans[i] = k
    now &= ~(1 << k)
print(''.join('RGB'[c] for c in ans))
0