結果
| 問題 | No.2042 RGB Caps |
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2022-08-19 23:58:33 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 119 ms / 2,000 ms |
| + 547µs | |
| コード長 | 645 bytes |
| 記録 | |
| コンパイル時間 | 62 ms |
| コンパイル使用メモリ | 83,252 KB |
| 実行使用メモリ | 103,024 KB |
| 最終ジャッジ日時 | 2026-09-23 23:06:28 |
| 合計ジャッジ時間 | 3,839 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
n,k = map(int,input().split())
from collections import defaultdict
ac = defaultdict(str)
d = defaultdict(str)
for i in range(k):
a,c = input().split()
a = int(a)-1
d[a] = c
rgb = ["R","G","B"]
ans = []
for i in range(-(-n//3)*3):
ans.append(rgb[i%3])
for i in range(n):
if (i % 3 == 2):continue
if not d[i]:continue
c = d[i]
if i % 3 == 0:
if ans[i] != c:
idx = rgb.index(c)
for j in range(3):
ans[i+j] = rgb[(idx+j)%3]
if i % 3 == 1:
if ans[i] != c and ans[i-1] != c:
ans[i],ans[i+1] = ans[i+1],ans[i]
print("".join(ans[:n]))
SidewaysOwl