結果

問題 No.2148 ひとりUNO
コンテスト
ユーザー H3PO4
提出日時 2022-12-20 21:06:47
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 952 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 294 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 81,920 KB
最終ジャッジ日時 2026-05-12 17:49:43
合計ジャッジ時間 4,346 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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