結果

問題 No.2148 ひとりUNO
ユーザー ntudantuda
提出日時 2022-12-26 22:02:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,345 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 78,916 KB
最終ジャッジ日時 2024-05-01 06:24:00
合計ジャッジ時間 8,875 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
T = int(input())
dic = {"R":0,"G":1,"B":2}
from collections import defaultdict
dic2 = defaultdict(lambda:[0,0,0])

def ok():
    print("Yes")

def ng():
    print("No")

def solve():
    N = int(input())
    dic2 = defaultdict(lambda: [0, 0, 0])
    Y = 0
    CN = [0] * 3
    for _ in range(N):
        c,d = input().split()
        if dic2[int(d)][dic[c]] < 2:
            dic2[int(d)][dic[c]] += 1
        CN[dic[c]] += 1
    D = Counter(CN)
    if D[0] == 2:
        ok()
        return

    if D[0] == 1:
        for i in range(3):
            if CN[i] == 0:
                a,b = (i+1)%3, (i+2)%3
        for x in dic2.values():
            if not(x[a] == x[b] == 0):
                ok()
                return
        ng()
        return

    for X in dic2.values():
        D = Counter(X)
        if D[0] > 1:
            continue
        elif D[0] == 1:
            for i in range(3):
                if X[i] == 0:
                    if Y == 0 or Y == i+1:
                        Y = i+1
                    else:
                        ok()
                        return
        elif D[1] == 3:
            if 1 in CN:
                ok()
                return
            else:
                Y = 4
        else:
            ok()
            return
    ng()

for _ in range(T):
    solve()




0