結果
| 問題 | 
                            No.2148 ひとりUNO
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ntuda
                         | 
                    
| 提出日時 | 2022-12-26 22:04:05 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,345 bytes | 
| コンパイル時間 | 157 ms | 
| コンパイル使用メモリ | 82,256 KB | 
| 実行使用メモリ | 78,708 KB | 
| 最終ジャッジ日時 | 2024-11-21 08:25:08 | 
| 合計ジャッジ時間 | 9,235 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 2 WA * 37 | 
ソースコード
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()
            
            
            
        
            
ntuda