結果

問題 No.2148 ひとりUNO
ユーザー rlangevinrlangevin
提出日時 2023-06-20 12:31:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 78,480 KB
最終ジャッジ日時 2023-09-10 08:04:50
合計ジャッジ時間 7,535 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,384 KB
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 AC 130 ms
78,480 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 69 ms
71,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def f(c):
    if c == "R":
        return 0
    elif c == "G":
        return 1
    else:
        return 2

T = int(input())
for _ in range(T):
    N = int(input())
    S = [set() for i in range(3)]
    for i in range(N):
        C, n = input().split()
        n = int(n)
        S[f(C)].add(n)
    L = []
    for i in range(3):
        L.append((len(S[i]), S[i]))
    L.sort(reverse=True)
    S0, S1, S2 = L[0][1], L[1][1], L[2][1]
    if len(S2) == 0 and len(S1) == 0:
        print("YES")
        continue
    S01 = S1.intersection(S0)
    S02 = S2.intersection(S0)
    S12 = S1.intersection(S2)
    if len(S2) == 0 and S01:
        print("YES")
        continue
    if len(S01) >= 2 and (S02 or S12):
        print("YES")
        continue
    if len(S02) >= 2 and (S01 or S12):
        print("YES")
        continue
    if len(S12) >= 2 and (S02 or S01):
        print("YES")
        continue
    if S01 and S12 and (len(S1) == 1 or len(S0) * len(S2) == 1):
        print("YES")
        continue
    if S02 and S12 and (len(S2) == 1 or len(S0) * len(S1) == 1):
        print("YES")
        continue
    if S01 and S02 and (len(S0) == 1 or len(S1) * len(S2) == 1):
        print("YES")
        continue
    print("NO")
0