結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-20 00:58:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,226 bytes |
| コンパイル時間 | 193 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 85,032 KB |
| 最終ジャッジ日時 | 2024-10-08 13:01:25 |
| 合計ジャッジ時間 | 3,320 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 RE * 11 |
ソースコード
import sys, random
input = lambda : sys.stdin.readline().rstrip()
write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda : list(map(int, input().split())); II=lambda : int(input())
def debug(_l_):
for s in _l_.split():
print(f"{s}={eval(s)}", end=" ")
print()
def dlist(*l, fill=0):
if len(l)==1:
return [fill]*l[0]
ll = l[1:]
return [dlist(*ll, fill=fill) for _ in range(l[0])]
n,k = list(map(int, input().split()))
ans = [0]*(n+3)
for i in range(k):
a,c = input().split()
a = int(a)
a -= 1
d,m = divmod(a,3)
for ind in range(3*d, 3*d+m):
if ans[ind]==c:
break
else:
ans[a] = c
for i in range((n+2)//3):
s = set("RGB")
for j in range(3*i, 3*i+3):
if ans[j]!=0:
s.remove(ans[j])
for j in range(3*i, 3*i+3):
if ans[j]==0:
ans[j] = s.pop()
count = {}
for c in "RGB":
count[c] = 0
for i in range(n):
assert ans[i] in "RGB"
count[ans[i]] += 1
assert count[ans[i]]==max(count.values())
write("".join(ans[:n]))