結果

問題 No.2148 ひとりUNO
ユーザー ThetaTheta
提出日時 2022-12-05 18:55:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 2,003 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 11,052 KB
実行使用メモリ 8,188 KB
最終ジャッジ日時 2023-08-02 18:44:58
合計ジャッジ時間 6,140 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,068 KB
testcase_01 AC 44 ms
8,004 KB
testcase_02 AC 44 ms
8,052 KB
testcase_03 AC 44 ms
8,188 KB
testcase_04 AC 44 ms
7,988 KB
testcase_05 AC 44 ms
8,176 KB
testcase_06 AC 44 ms
8,108 KB
testcase_07 AC 43 ms
8,024 KB
testcase_08 AC 47 ms
8,172 KB
testcase_09 AC 43 ms
8,120 KB
testcase_10 AC 45 ms
8,004 KB
testcase_11 AC 43 ms
8,004 KB
testcase_12 AC 44 ms
8,064 KB
testcase_13 AC 44 ms
8,128 KB
testcase_14 AC 43 ms
8,052 KB
testcase_15 AC 43 ms
8,080 KB
testcase_16 AC 229 ms
7,984 KB
testcase_17 AC 228 ms
7,988 KB
testcase_18 AC 228 ms
8,096 KB
testcase_19 AC 233 ms
8,044 KB
testcase_20 AC 222 ms
8,012 KB
testcase_21 AC 220 ms
8,056 KB
testcase_22 AC 219 ms
8,012 KB
testcase_23 AC 222 ms
8,052 KB
testcase_24 AC 223 ms
8,012 KB
testcase_25 AC 220 ms
8,152 KB
testcase_26 AC 102 ms
8,072 KB
testcase_27 AC 102 ms
8,012 KB
testcase_28 AC 101 ms
8,108 KB
testcase_29 AC 102 ms
8,004 KB
testcase_30 AC 101 ms
8,072 KB
testcase_31 AC 100 ms
8,176 KB
testcase_32 AC 101 ms
8,008 KB
testcase_33 AC 103 ms
8,056 KB
testcase_34 AC 100 ms
8,076 KB
testcase_35 AC 102 ms
7,988 KB
testcase_36 AC 100 ms
8,012 KB
testcase_37 AC 102 ms
7,988 KB
testcase_38 AC 100 ms
8,048 KB
testcase_39 AC 17 ms
8,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    for _ in range(int(input())):
        N = int(input())
        cards = [list(input().split()) for _ in range(N)]
        r_cards = filter(lambda card: card[0] == "R", cards)
        g_cards = filter(lambda card: card[0] == "G", cards)
        b_cards = filter(lambda card: card[0] == "B", cards)
        r_nums = set(map(lambda card: int(card[1]), r_cards))
        g_nums = set(map(lambda card: int(card[1]), g_cards))
        b_nums = set(map(lambda card: int(card[1]), b_cards))

        rg_common = r_nums & g_nums
        gb_common = g_nums & b_nums
        br_common = b_nums & r_nums

        if max(map(len, (r_nums, b_nums, g_nums))) == sum(map(len, (r_nums, b_nums, g_nums))):
            print("YES")
            continue

        if len(tuple(filter(lambda elm: len(elm) >= 2, (rg_common, gb_common, br_common)))) >= 2:
            print("YES")
            continue

        if max(map(len, (rg_common, gb_common, br_common))) >= 2:
            if sum(map(len, (rg_common, gb_common, br_common))) - max(map(len, (rg_common, gb_common, br_common))) > 0:
                print("YES")
            elif min(map(len, (r_nums, b_nums, g_nums))) == 0:
                print("YES")
            else:
                print("NO")
            continue

        if max(map(len, (rg_common, gb_common, br_common))) == 1:
            if sum(map(len, (rg_common, gb_common, br_common))) == 3:
                if rg_common & gb_common:
                    if all(len(nums) > 1 for nums in (r_nums, g_nums, b_nums)):
                        print("NO")
                    else:
                        print("YES")
                else:
                    print("YES")
            elif sum(map(len, (rg_common, gb_common, br_common))) == 2:
                print("YES")
            elif min(map(len, (r_nums, b_nums, g_nums))) == 0:
                print("YES")
            else:
                print("NO")
            continue

        print("NO")


if __name__ == "__main__":
    main()
0