結果

問題 No.2042 RGB Caps
ユーザー ikomaikoma
提出日時 2022-08-19 23:47:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 100,144 KB
最終ジャッジ日時 2024-04-27 20:36:00
合計ジャッジ時間 2,345 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,156 KB
testcase_01 AC 33 ms
53,500 KB
testcase_02 AC 33 ms
54,040 KB
testcase_03 AC 32 ms
52,796 KB
testcase_04 AC 32 ms
52,216 KB
testcase_05 AC 34 ms
52,612 KB
testcase_06 AC 56 ms
81,284 KB
testcase_07 AC 73 ms
83,396 KB
testcase_08 AC 96 ms
91,628 KB
testcase_09 AC 56 ms
73,780 KB
testcase_10 AC 121 ms
96,260 KB
testcase_11 AC 55 ms
73,004 KB
testcase_12 AC 116 ms
100,144 KB
testcase_13 AC 118 ms
100,012 KB
testcase_14 AC 119 ms
100,020 KB
testcase_15 AC 37 ms
54,060 KB
testcase_16 AC 71 ms
82,096 KB
testcase_17 AC 55 ms
70,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N,K=map(int,input().split())
AC=[input().strip().split()for _ in range(K)]

tmp = ["R" for _ in range(N)]
for a,c in AC:
    a = int(a)-1
    tmp[a] = c
ans = []
for i in range(N):
    if i%3==0:
        ans.append(tmp[i])
    elif i%3==1:
        if tmp[i] == ans[-1]:
            ans.append("G" if tmp[i]=="R" else "R")
        else:
            ans.append(tmp[i])
    else:
        s = set("RGB")
        s.discard(ans[-1])
        s.discard(ans[-2])
        ans.append(s.pop())
print("".join(ans))
0