結果

問題 No.2042 RGB Caps
ユーザー chineristACchineristAC
提出日時 2022-08-19 22:32:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,420 KB
実行使用メモリ 85,428 KB
最終ジャッジ日時 2024-04-27 20:35:13
合計ジャッジ時間 2,699 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
56,048 KB
testcase_01 AC 42 ms
55,844 KB
testcase_02 AC 43 ms
56,280 KB
testcase_03 AC 42 ms
57,312 KB
testcase_04 AC 43 ms
56,944 KB
testcase_05 AC 43 ms
56,568 KB
testcase_06 AC 77 ms
80,992 KB
testcase_07 AC 89 ms
79,732 KB
testcase_08 AC 108 ms
82,812 KB
testcase_09 AC 72 ms
77,984 KB
testcase_10 AC 123 ms
85,428 KB
testcase_11 AC 75 ms
78,492 KB
testcase_12 AC 127 ms
85,284 KB
testcase_13 AC 126 ms
85,052 KB
testcase_14 AC 124 ms
85,212 KB
testcase_15 AC 41 ms
57,304 KB
testcase_16 AC 81 ms
79,224 KB
testcase_17 AC 72 ms
77,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush
from itertools import cycle, permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())



N,K = mi()
res = [""] * (N+3)
for _ in range(K):
    a,c = input().split()
    a = int(a)-1
    res[a] = c

for i in range(0,N,3):
    for S in permutations("RGB"):
        S = "".join(S)
        flag = True
        for j in range(3):
            if res[i+j] and res[i+j] not in S[:j+1]:
                flag = False
        if flag:
            res[i],res[i+1],res[i+2] = S[0],S[1],S[2]
            break

print("".join(res[:N]))
    
0