結果

問題 No.2148 ひとりUNO
ユーザー 👑 SPD_9X2
提出日時 2022-12-07 19:41:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-10-14 00:18:11
合計ジャッジ時間 6,026 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin

TT = int(stdin.readline())
ANS = []

for loop in range(TT):

    N = int(stdin.readline())
    DC = []

    for i in range(N):

        C,D = stdin.readline()[:-1].split()
        DC.append( (D,C) )

    DC.sort()

    cset = set()
    for i in range(N):
        cset.add(DC[i][1])

    same = [0] * 3

    for i in range(N-1):

        d1,c1 = DC[i]
        d2,c2 = DC[i+1]

        if d1 == d2:

            cs = (c1,c2)

            if "B" in cs and "G" in cs:
                same[0] = 1
            if "G" in cs and "R" in cs:
                same[1] = 1
            if "R" in cs and "B" in cs:
                same[2] = 1


    if len(cset) == 1:
        ANS.append("YES")
    elif len(cset) == 2:
        if sum(same):
            ANS.append("YES")
        else:
            ANS.append("NO")
    else:
        if sum(same) >= 2:
            ANS.append("YES")
        else:
            ANS.append("NO")

print ("\n".join(ANS))
0