結果

問題 No.2148 ひとりUNO
ユーザー ygd.ygd.
提出日時 2022-12-05 23:09:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,675 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 79,772 KB
最終ジャッジ日時 2024-04-20 21:13:02
合計ジャッジ時間 9,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
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 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
import math
import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
from collections import defaultdict
from collections import deque
#import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        dic = defaultdict(list)
        R = set([]); G = set([]); B = set([])
        for i in range(N):
            c,d = input().split()
            d = int(d)
            dic[d].append(c)
            if c == 'R': R.add(d)
            if c == 'G': G.add(d)
            if c == 'B': B.add(d)
        print(R,G,B)
        RGB = set([])
        RG = set([]); GB = set([]); BR = set([])
        for v,L in dic.items():
            if len(L) == 3:
                RGB.add(v)
            elif len(L) == 2:
                if 'R' in L and 'G' in L:
                    RG.add(v)
                if 'G' in L and 'B' in L:
                    GB.add(v)
                if 'B' in L and 'R' in L:
                    BR.add(v)
        # 1色のみの場合
        if len(G) == len(B) == 0:
            print('YES')
        elif len(B) == len(R) == 0:
            print('YES')
        elif len(R) == len(G) == 0:
            print('YES')
        # 2色のみの場合
        elif len(R) == 0:
            if len(GB) >= 1:
                print('YES')
            else:
                print('NO')
        elif len(G) == 0:
            if len(BR) >= 1:
                print('YES')
            else:
                print('NO')
        elif len(B) == 0:
            if len(RG) >= 1:
                print('YES')
            else:
                print('NO')
        # 3色ある場合
        elif len(RGB) >= 2:
            print('YES')
        elif len(RGB) == 1:
            if len(RG) >= 1 or len(GB) >= 1 or len(BR) >= 1:
                print('YES')
            else:
                # [R1,G1,B1,B2]ならいける
                if N == 4:
                    print('Yes')
                else:
                    print('NO')
        else:
            if len(RG) >= 1 and len(GB) >= 1:
                print('YES')
            elif len(GB) >= 1 and len(BR) >= 1:
                print('YES')
            elif len(BR) >= 1 and len(RG) >= 1:
                print('YES')
            else:
                print('NO')


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