結果
問題 | No.2148 ひとりUNO |
ユーザー |
![]() |
提出日時 | 2022-12-05 23:14:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,731 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 81,972 KB |
実行使用メモリ | 78,876 KB |
最終ジャッジ日時 | 2024-10-12 19:29:36 |
合計ジャッジ時間 | 8,269 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 WA * 26 |
ソースコード
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: # [RN...R3,R2,R1,G1,B1,B2,B3...BN]ならいける if len(R) == 1 or len(G) == 1 or len(B) == 1: 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()