結果

問題 No.2042 RGB Caps
ユーザー neterukunneterukun
提出日時 2022-08-19 21:42:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 81,892 KB
実行使用メモリ 101,620 KB
最終ジャッジ日時 2024-04-27 20:31:49
合計ジャッジ時間 3,300 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,956 KB
testcase_01 AC 31 ms
52,144 KB
testcase_02 AC 31 ms
52,220 KB
testcase_03 AC 30 ms
52,880 KB
testcase_04 AC 33 ms
52,612 KB
testcase_05 AC 32 ms
53,216 KB
testcase_06 AC 37 ms
55,468 KB
testcase_07 AC 131 ms
82,200 KB
testcase_08 AC 217 ms
91,264 KB
testcase_09 AC 93 ms
78,032 KB
testcase_10 AC 292 ms
99,344 KB
testcase_11 AC 75 ms
77,856 KB
testcase_12 AC 349 ms
101,224 KB
testcase_13 AC 322 ms
101,076 KB
testcase_14 AC 321 ms
101,620 KB
testcase_15 AC 38 ms
53,272 KB
testcase_16 AC 125 ms
81,784 KB
testcase_17 AC 86 ms
77,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
info = [list(input().split()) for _ in range(k)]


for i in range(k):
    info[i] = (int(info[i][0]), info[i][1])

info.sort()


ans = ['R', 'G', 'B'] * n
for cnt, color in info:
    cnt -= 1
    if cnt % 3 == 0:
        if ans[cnt] == color:
            continue
        else:
            for i in range(1, 3):
                if ans[cnt + i] == color:
                    ans[cnt], ans[cnt + i] = ans[cnt + i], ans[cnt]

    if cnt % 3 == 1:
        if ans[cnt - 1] == color or ans[cnt] == color:
            continue
        else:
            ans[cnt], ans[cnt + 1] = ans[cnt + 1], ans[cnt]
    if cnt % 3 == 2:
        continue

print(''.join(ans[:n]))
0