結果

問題 No.2148 ひとりUNO
ユーザー trineutrontrineutron
提出日時 2022-12-05 04:27:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,124 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-20 08:11:40
合計ジャッジ時間 7,144 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 135 ms
10,880 KB
testcase_27 AC 136 ms
11,008 KB
testcase_28 AC 132 ms
10,880 KB
testcase_29 AC 137 ms
11,008 KB
testcase_30 AC 134 ms
10,880 KB
testcase_31 AC 130 ms
11,008 KB
testcase_32 AC 135 ms
11,008 KB
testcase_33 AC 133 ms
10,880 KB
testcase_34 AC 134 ms
10,880 KB
testcase_35 WA -
testcase_36 AC 133 ms
11,008 KB
testcase_37 AC 129 ms
10,880 KB
testcase_38 AC 131 ms
11,008 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    colors = [set() for _ in range(n)]
    for _ in range(n):
        c, d = input().split()
        d = int(d)
        d -= 1
        colors[d].add(c)
    count_r = 0
    count_g = 0
    count_b = 0
    rg = 0
    gb = 0
    br = 0
    rgb = 0
    for cs in colors:
        if 'R' in cs:
            count_r += 1
        if 'G' in cs:
            count_g += 1
        if 'B' in cs:
            count_b += 1
        if cs == {'R', 'G'}:
            rg = 1
        if cs == {'G', 'B'}:
            gb = 1
        if cs == {'B', 'R'}:
            br = 1
        if cs == {'R', 'G', 'B'}:
            rgb += 1
    # 1 color
    if count_r + count_g == 0 or count_g + count_b == 0 or count_b + count_r == 0:
        return True
    # 2 colors
    if count_r == 0 or count_g == 0 or count_r == 0:
        return rg + gb + br > 0
    # 3 colors
    if rg + gb + br + rgb >= 2:
        return True
    if rgb == 0:
        return False
    return count_r == 1 or count_g == 1 or count_b == 1


t = int(input())
for _ in range(t):
    if solve():
        print('YES')
    else:
        print('NO')
0