結果

問題 No.2148 ひとりUNO
ユーザー roaris
提出日時 2022-12-05 05:47:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2024-10-12 04:22:15
合計ジャッジ時間 6,232 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

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

def solve():
    N = int(input())
    S = [set() for _ in range(3)]
    
    for i in range(N):
        C, D = input().split()
        S[f(C)].add(D)
    
    v, e = 0, 0
    
    for i in range(3):
        if len(S[i])>0:
            v += 1
    
        for j in range(i+1, 3):
            if len(S[i]&S[j])>0:
                e += 1
    
    if e>=v-1:
        print('YES')
    else:
        print('NO')

for _ in range(int(input())):
    solve()
0