結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2022-08-19 23:58:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 186 ms / 2,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 95,684 KB |
| 最終ジャッジ日時 | 2024-11-16 02:00:02 |
| 合計ジャッジ時間 | 3,063 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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