結果

問題 No.2042 RGB Caps
ユーザー lloyzlloyz
提出日時 2022-08-20 01:09:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 25,728 KB
最終ジャッジ日時 2024-04-27 20:36:47
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 24 ms
10,752 KB
testcase_04 AC 24 ms
10,752 KB
testcase_05 AC 25 ms
10,624 KB
testcase_06 AC 99 ms
12,544 KB
testcase_07 AC 131 ms
14,976 KB
testcase_08 AC 229 ms
19,712 KB
testcase_09 AC 64 ms
12,416 KB
testcase_10 AC 341 ms
24,192 KB
testcase_11 AC 60 ms
11,776 KB
testcase_12 AC 367 ms
25,728 KB
testcase_13 AC 378 ms
25,728 KB
testcase_14 AC 366 ms
25,728 KB
testcase_15 AC 25 ms
10,624 KB
testcase_16 AC 111 ms
14,592 KB
testcase_17 AC 50 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
AC = [list(input().split()) for _ in range(k)]
C = ['R' for _ in range(n)]
for i in range(k):
    idx, c = AC[i]
    idx = int(idx) - 1
    C[idx] = c

j = 0
ANS = ['R' for _ in range(n)]
for i in range(n):
    c = C[i]
    if i % 3 == 1:
        if ANS[i - 1] == c:
            if c == 'R':
                c = 'G'
            else:
                c = 'R'
    elif i % 3 == 2:
        L = set(['R', 'G', 'B'])
        L.remove(ANS[i - 2])
        L.remove(ANS[i - 1])
        c = list(L)[0]
    ANS[i] = c
print(''.join(ANS))
0