結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2022-12-20 00:32:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 908 bytes |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 118,868 KB |
| 最終ジャッジ日時 | 2024-11-18 01:37:53 |
| 合計ジャッジ時間 | 5,447 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 RE * 13 |
ソースコード
N, K = map(int, input().split())
c = {j:i for i,j in enumerate('RGB')}
rc = {i:j for i,j in enumerate('RGB')}
p = []
for i in range(K):
a, b = map(str, input().split())
p.append([int(a),b])
p.sort()
res = []
num = [0,0,0]
for i in range(K):
a, b = p[i]
n1, n2 = a//3,a%3
res.append('R'*(n1-num[0])+'G'*(n1-num[1])+'B'*(n1-num[2]))
num[0] += n1-num[0]
num[1] += n1-num[1]
num[2] += n1-num[2]
if n2==1:
num[c[b]] += 1
res.append(b)
if n2==2:
num[c[b]] += 1
num[(c[b]+1)%3] += 1
res.append(b)
res.append(rc[(c[b]+1)%3])
ans = ''.join(res)
if len(ans)!=N:
ans += 'R'*(N-len(ans))
debug = [[0]*3 for _ in range(N)]
for i in range(N):
debug[i][c[ans[i]]] += 1
if i>0:
for j in range(3):
debug[i][j] += debug[i-1][j]
for a, b in p:
assert debug[a-1][c[b]] == max(debug[a-1])
print(ans)
AEn