結果

問題 No.2042 RGB Caps
ユーザー ntudantuda
提出日時 2022-08-23 22:03:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 102,052 KB
最終ジャッジ日時 2024-04-19 12:30:05
合計ジャッジ時間 4,569 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,996 KB
testcase_01 AC 33 ms
52,524 KB
testcase_02 AC 33 ms
52,476 KB
testcase_03 AC 34 ms
52,816 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 58 ms
74,828 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
AC = []
for _ in range(K):
    a, c = input().split()
    AC.append((int(a), c))
AC = dict(AC)
ans = []
dic = {"R": 0, "G": 1, "B": 2}
color = ["R", "G", "B"]
X = [0, 0, 0]
for i in range(-(-N // 3)):
    tmp = []
    k = 0
    for j in range(3):
        cnt = 3 * i + j + 1

        if cnt in AC:
            c = AC[cnt]
            if c in tmp:
                tmp.append(color[j])
            else:
                tmp.append(c)
                k = (dic[c] + 1) % 3
        else:
            while color[k] in tmp:
                k = (k + 1) % 3
            tmp.append(color[k])
    ans += tmp
ans = ans[:N]
print("".join(ans))
0