結果

問題 No.2042 RGB Caps
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-08-19 23:58:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 95,812 KB
最終ジャッジ日時 2024-04-27 20:36:35
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,600 KB
testcase_01 AC 43 ms
54,504 KB
testcase_02 AC 43 ms
54,148 KB
testcase_03 AC 41 ms
53,704 KB
testcase_04 AC 42 ms
54,612 KB
testcase_05 AC 42 ms
53,516 KB
testcase_06 AC 68 ms
81,744 KB
testcase_07 AC 108 ms
82,988 KB
testcase_08 AC 141 ms
90,944 KB
testcase_09 AC 93 ms
77,848 KB
testcase_10 AC 169 ms
94,776 KB
testcase_11 AC 91 ms
79,712 KB
testcase_12 AC 178 ms
95,676 KB
testcase_13 AC 179 ms
95,812 KB
testcase_14 AC 184 ms
95,788 KB
testcase_15 AC 44 ms
54,308 KB
testcase_16 AC 108 ms
82,312 KB
testcase_17 AC 92 ms
77,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
from collections import defaultdict
ac = defaultdict(str)
d = defaultdict(str)
for i in range(k):
    a,c = input().split()
    a = int(a)-1
    d[a] = c
rgb = ["R","G","B"]
ans = []
for i in range(-(-n//3)*3):
    ans.append(rgb[i%3])
for i in range(n):
    if (i % 3 == 2):continue
    if not d[i]:continue
    c = d[i]
    if i % 3 == 0:
        if ans[i] != c:
            idx = rgb.index(c)
            for j in range(3):
                ans[i+j] = rgb[(idx+j)%3] 
    if i % 3 == 1:
        if ans[i] != c and ans[i-1] != c: 
            ans[i],ans[i+1] = ans[i+1],ans[i]
print("".join(ans[:n]))
            
0