結果

問題 No.2042 RGB Caps
ユーザー FromBooskaFromBooska
提出日時 2023-03-21 21:49:08
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 751 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 81,784 KB
実行使用メモリ 841,532 KB
最終ジャッジ日時 2023-10-18 18:35:58
合計ジャッジ時間 5,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,456 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 38 ms
53,456 KB
testcase_03 AC 468 ms
75,568 KB
testcase_04 AC 38 ms
53,456 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 MLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 前からやるか後ろからやるか
# グラフ化するか、DFSか
# グラフ化するには、頂点の組合せが多すぎるか

N, K = map(int, input().split())
dic = {}
for i in range(K):
    a, c = map(str, input().split())
    if c == 'R':
        dic[int(a)] = 0
    elif c == 'G':
        dic[int(a)] = 1
    elif c == 'B':
        dic[int(a)] = 2

import sys
sys.setrecursionlimit(10**7)

def dfs(r, g, b, STRING):
    mx = max(r, g, b)
    if r+g+b in dic and [r, g, b][dic[r+g+b]] != mx:
        return
    else: 
        if r+g+b == N:
            print(STRING)
            exit()
            #return
        dfs(r+1, g, b, STRING+'R')
        dfs(r, g+1, b, STRING+'G')
        dfs(r, g, b+1, STRING+'B')

dfs(0, 0, 0, '')




0