結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-19 22:32:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 136 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 228 ms |
| コンパイル使用メモリ | 82,196 KB |
| 実行使用メモリ | 85,144 KB |
| 最終ジャッジ日時 | 2024-11-16 01:58:05 |
| 合計ジャッジ時間 | 2,876 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
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]))