結果

問題 No.2042 RGB Caps
ユーザー ShirotsumeShirotsume
提出日時 2022-08-19 22:04:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 85,596 KB
最終ジャッジ日時 2024-04-27 20:33:53
合計ジャッジ時間 2,203 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,096 KB
testcase_01 AC 34 ms
52,352 KB
testcase_02 AC 35 ms
52,096 KB
testcase_03 AC 31 ms
52,352 KB
testcase_04 AC 32 ms
51,712 KB
testcase_05 AC 32 ms
51,968 KB
testcase_06 AC 79 ms
82,176 KB
testcase_07 AC 73 ms
79,104 KB
testcase_08 AC 95 ms
82,192 KB
testcase_09 AC 65 ms
77,480 KB
testcase_10 AC 104 ms
84,736 KB
testcase_11 AC 56 ms
74,380 KB
testcase_12 AC 109 ms
85,120 KB
testcase_13 AC 107 ms
85,596 KB
testcase_14 AC 108 ms
85,296 KB
testcase_15 AC 33 ms
52,352 KB
testcase_16 AC 69 ms
79,104 KB
testcase_17 AC 56 ms
72,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
rec = False #再帰を使うときはこれをTrueにする
if rec:
    sys.setrecursionlimit(5 * 10 ** 5)
    from pypyjit import set_param
    set_param('max_unroll_recursion=-1')
inf = 2 ** 63 - 1
mod = 998244353

n, k = mi()

a = [None] * (n + (3 - n) % 3)
color = ['R', 'G', 'B']
for _ in range(k):
    i, c = input().split()
    i = int(i)
    a[i - 1] = c

ans = [None] * (n + (3 - n) % 3)

for i in range((n + (3 - n) % 3) // 3):
    now = set(color)

    for j in range(3):

        if a[3 * i + j] is not None and a[3 * i + j] in now:
            now.discard(a[3 * i + j])
            ans[3 * i + j] = a[3 * i + j]
            

    for j in range(3):
        if ans[3 * i + j] is None:
            ans[3 * i + j] = now.pop()
print(''.join(ans[:n]))
0