結果

問題 No.2148 ひとりUNO
ユーザー trineutrontrineutron
提出日時 2022-12-05 04:30:54
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 1,124 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 11,016 KB
実行使用メモリ 8,324 KB
最終ジャッジ日時 2023-08-02 08:38:21
合計ジャッジ時間 6,535 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,696 KB
testcase_01 AC 35 ms
8,292 KB
testcase_02 AC 35 ms
7,748 KB
testcase_03 AC 35 ms
8,176 KB
testcase_04 AC 34 ms
8,156 KB
testcase_05 AC 36 ms
8,172 KB
testcase_06 AC 39 ms
8,176 KB
testcase_07 AC 34 ms
8,240 KB
testcase_08 AC 34 ms
8,148 KB
testcase_09 AC 34 ms
8,216 KB
testcase_10 AC 34 ms
8,288 KB
testcase_11 AC 35 ms
8,200 KB
testcase_12 AC 34 ms
8,132 KB
testcase_13 AC 33 ms
8,180 KB
testcase_14 AC 36 ms
8,132 KB
testcase_15 AC 37 ms
8,196 KB
testcase_16 AC 218 ms
8,276 KB
testcase_17 AC 219 ms
8,324 KB
testcase_18 AC 232 ms
8,200 KB
testcase_19 AC 243 ms
8,276 KB
testcase_20 AC 234 ms
8,200 KB
testcase_21 AC 229 ms
8,204 KB
testcase_22 AC 217 ms
8,220 KB
testcase_23 AC 224 ms
8,272 KB
testcase_24 AC 223 ms
8,188 KB
testcase_25 AC 215 ms
8,216 KB
testcase_26 AC 93 ms
8,248 KB
testcase_27 AC 93 ms
8,188 KB
testcase_28 AC 94 ms
8,180 KB
testcase_29 AC 96 ms
8,188 KB
testcase_30 AC 98 ms
8,248 KB
testcase_31 AC 97 ms
8,176 KB
testcase_32 AC 94 ms
8,192 KB
testcase_33 AC 93 ms
8,236 KB
testcase_34 AC 101 ms
8,300 KB
testcase_35 AC 97 ms
8,192 KB
testcase_36 AC 98 ms
8,196 KB
testcase_37 AC 96 ms
8,164 KB
testcase_38 AC 97 ms
8,176 KB
testcase_39 AC 15 ms
8,112 KB
権限があれば一括ダウンロードができます

ソースコード

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_b == 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