結果

問題 No.2042 RGB Caps
ユーザー buey_tbuey_t
提出日時 2023-03-27 12:16:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,863 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 101,972 KB
最終ジャッジ日時 2023-10-19 14:04:48
合計ジャッジ時間 7,451 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
84,156 KB
testcase_01 AC 126 ms
84,156 KB
testcase_02 AC 120 ms
84,156 KB
testcase_03 AC 121 ms
84,156 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 146 ms
94,956 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 #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    切り替わった場合はその間に切り替わったやつがある
    一個に特定するのではなく、あり得るやつを一つ出せばよい
    矛盾のないように
    後ろから見たほうがよさそう
    dpとかで各あり得る最大値とかを置いてみるとか
    
    矛盾もしてきしないとだめなのか
    区間を取っていって、被ってるところ
    それまでで、色が過半数ないといけない
    配置の順番は関係ない
    
    1つ目の区間について、過半数だけ置く。
    2つ目の区間について、1つ目の区間で過半数を超えないように置く。
    そのあと、2つ目の区間で残りを置く。
    
    ずっと三等分で置けばよいのでは
    場合分けえぐくね
    
    普通に3つサイクルで追加していく
    赤青緑
    それぞれの個数も記録しておく
    区間を超えたときに、少なかったらその分だけ足す
    '''
    
    N,K = map(int, input().split())
    
    C = [0]*(N+1)
    st = 0
    for i in range(K):
        a,c = input().split()
        C[int(a)] = c
        if i == 0:
            st = c
    
    r = 0
    g = 0
    b = 0
    ans = []
    
    if st == 'R':
        r += 1
    elif st == 'G':
        g += 1
    else:
        b += 1
    
    for i in range(1,N+1):
        if C[i] == 0:
            if r <= g and r <= b:
                s = 'R'
                r += 1
            elif g <= r and g <= b:
                s = 'G'
                g += 1
            else:
                s = 'B'
                r -= 1
                g -= 1
        else:
            s = C[i]
            if C[i] == 'R':
                r += 1
            elif C[i] == 'G':
                g += 1
            else:
                b += 1
        
        ans.append(s)
    
    print(''.join(ans))
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0