結果

問題 No.2042 RGB Caps
ユーザー shotoyooshotoyoo
提出日時 2022-08-20 01:02:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,348 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 96,704 KB
最終ジャッジ日時 2024-04-17 03:22:50
合計ジャッジ時間 4,654 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,432 KB
testcase_01 AC 41 ms
55,024 KB
testcase_02 AC 42 ms
54,676 KB
testcase_03 AC 40 ms
54,856 KB
testcase_04 AC 40 ms
55,864 KB
testcase_05 AC 42 ms
54,332 KB
testcase_06 AC 108 ms
88,856 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
tmp = [[] for _ in range(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+3):
        if c in tmp[ind]:
            break
    else:
        ans[a] = c
        for ind in range(3*d, 3*d+3):
            tmp[ind].append(c)
#     print(tmp, 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]))
0