結果

問題 No.2148 ひとりUNO
ユーザー H3PO4
提出日時 2022-12-20 21:06:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 76,768 KB
最終ジャッジ日時 2024-11-18 02:08:15
合計ジャッジ時間 4,775 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def color2int(c: str):
    if c == "R":
        return 1
    elif c == "G":
        return 2
    elif c == "B":
        return 4
    raise ValueError


def solve(N, cards):
    lst = [0] * N
    used_color = 0
    for c, d in cards:
        i = color2int(c)
        lst[d] += i
        used_color |= i
    ct = [0] * 8
    for x in lst:
        ct[x] += 1
    ct[1 | 2 | 4] += 3 - bin(used_color).count("1")
    return ((ct[1 | 2] and ct[1 | 4])
            or (ct[1 | 2] and ct[2 | 4])
            or (ct[1 | 4] and ct[2 | 4])
            or (ct[1 | 2] and ct[1 | 2 | 4])
            or (ct[1 | 4] and ct[1 | 2 | 4])
            or (ct[2 | 4] and ct[1 | 2 | 4])
            or ct[1 | 2 | 4] >= 2)


T = int(input())
for _ in range(T):
    N = int(input())
    cards = []
    for __ in range(N):
        c, d = input().split()
        cards.append((c, int(d) - 1))
    print("YES" if solve(N, cards) else "NO")
0