結果

問題 No.2148 ひとりUNO
ユーザー titiatitia
提出日時 2022-12-05 01:02:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 2,983 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-20 05:55:18
合計ジャッジ時間 4,477 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
11,008 KB
testcase_01 AC 44 ms
11,136 KB
testcase_02 AC 46 ms
11,008 KB
testcase_03 AC 43 ms
11,008 KB
testcase_04 AC 43 ms
11,008 KB
testcase_05 AC 43 ms
11,008 KB
testcase_06 AC 44 ms
11,008 KB
testcase_07 AC 44 ms
11,008 KB
testcase_08 AC 43 ms
11,008 KB
testcase_09 AC 42 ms
11,136 KB
testcase_10 AC 43 ms
11,008 KB
testcase_11 AC 43 ms
11,136 KB
testcase_12 AC 43 ms
11,008 KB
testcase_13 AC 43 ms
11,136 KB
testcase_14 AC 43 ms
11,008 KB
testcase_15 AC 42 ms
11,136 KB
testcase_16 AC 116 ms
11,136 KB
testcase_17 AC 117 ms
11,136 KB
testcase_18 AC 118 ms
11,008 KB
testcase_19 AC 118 ms
11,008 KB
testcase_20 AC 116 ms
11,008 KB
testcase_21 AC 118 ms
11,008 KB
testcase_22 AC 117 ms
11,008 KB
testcase_23 AC 123 ms
11,008 KB
testcase_24 AC 121 ms
11,136 KB
testcase_25 AC 117 ms
11,008 KB
testcase_26 AC 66 ms
11,008 KB
testcase_27 AC 66 ms
11,008 KB
testcase_28 AC 65 ms
11,136 KB
testcase_29 AC 66 ms
11,136 KB
testcase_30 AC 64 ms
11,008 KB
testcase_31 AC 65 ms
11,136 KB
testcase_32 AC 66 ms
11,008 KB
testcase_33 AC 66 ms
11,008 KB
testcase_34 AC 68 ms
11,008 KB
testcase_35 AC 66 ms
11,008 KB
testcase_36 AC 65 ms
11,136 KB
testcase_37 AC 65 ms
11,136 KB
testcase_38 AC 67 ms
11,136 KB
testcase_39 AC 32 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for tests in range(T):
    N=int(input())

    R=[]
    G=[]
    B=[]

    for i in range(N):
        x,y=input().split()
        y=int(y)
        if x=="R":
            R.append(y)
        elif x=="G":
            G.append(y)
        else:
            B.append(y)

    if R==[] and G==[]:
        print("YES")
        continue

    if R==[] and B==[]:
        print("YES")
        continue

    if G==[] and B==[]:
        print("YES")
        continue

    if R==[]:
        if set(G) & set(B)!=set():
            print("YES")
            continue
        else:
            print("NO")
            continue

    if G==[]:
        if set(R) & set(B)!=set():
            print("YES")
            continue
        else:
            print("NO")
            continue

    if B==[]:
        if set(R) & set(G)!=set():
            print("YES")
            continue
        else:
            print("NO")
            continue

    RG=set(R) & set(G)
    GB=set(G) & set(B)
    BR=set(R) & set(B)

    if len(RG)>0:
        if len(GB)>1:
            print("YES")
            continue
        elif len(GB)==1:
            x=list(GB)[0]

            if x in RG:
                if len(G)==1:
                    print("YES")
                    continue
            else:
                print("YES")
                continue

        if len(BR)>1:
            print("YES")
            continue
        elif len(BR)==1:
            x=list(BR)[0]

            if x in RG:
                if len(R)==1:
                    print("YES")
                    continue
            else:
                print("YES")
                continue

    if len(GB)>0:
        if len(RG)>1:
            print("YES")
            continue
        elif len(RG)==1:
            x=list(RG)[0]

            if x in GB:
                if len(G)==1:
                    print("YES")
                    continue
            else:
                print("YES")
                continue

        if len(BR)>1:
            print("YES")
            continue
        elif len(BR)==1:
            x=list(BR)[0]

            if x in GB:
                if len(B)==1:
                    print("YES")
                    continue
            else:
                print("YES")
                continue

    if len(BR)>0:
        if len(RG)>1:
            print("YES")
            continue
        elif len(RG)==1:
            x=list(RG)[0]

            if x in BR:
                if len(R)==1:
                    print("YES")
                    continue
            else:
                print("YES")
                continue

        if len(GB)>1:
            print("YES")
            continue
        elif len(GB)==1:
            x=list(GB)[0]

            if x in GB:
                if len(B)==1:
                    print("YES")
                    continue
            else:
                print("YES")
                continue

    print("NO")
        

    
0