結果
問題 | No.2148 ひとりUNO |
ユーザー | ygd. |
提出日時 | 2022-12-05 23:34:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 216 ms / 2,000 ms |
コード長 | 2,761 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 78,624 KB |
最終ジャッジ日時 | 2024-04-20 21:30:55 |
合計ジャッジ時間 | 7,796 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
54,996 KB |
testcase_01 | AC | 165 ms
78,144 KB |
testcase_02 | AC | 142 ms
78,104 KB |
testcase_03 | AC | 148 ms
77,864 KB |
testcase_04 | AC | 154 ms
78,124 KB |
testcase_05 | AC | 143 ms
78,076 KB |
testcase_06 | AC | 149 ms
77,872 KB |
testcase_07 | AC | 144 ms
78,016 KB |
testcase_08 | AC | 150 ms
77,856 KB |
testcase_09 | AC | 159 ms
77,916 KB |
testcase_10 | AC | 141 ms
78,088 KB |
testcase_11 | AC | 149 ms
77,972 KB |
testcase_12 | AC | 158 ms
78,624 KB |
testcase_13 | AC | 160 ms
77,928 KB |
testcase_14 | AC | 149 ms
78,232 KB |
testcase_15 | AC | 160 ms
77,720 KB |
testcase_16 | AC | 190 ms
77,580 KB |
testcase_17 | AC | 192 ms
77,476 KB |
testcase_18 | AC | 189 ms
77,852 KB |
testcase_19 | AC | 189 ms
77,724 KB |
testcase_20 | AC | 216 ms
77,932 KB |
testcase_21 | AC | 209 ms
77,916 KB |
testcase_22 | AC | 199 ms
78,208 KB |
testcase_23 | AC | 194 ms
77,488 KB |
testcase_24 | AC | 192 ms
77,448 KB |
testcase_25 | AC | 197 ms
78,092 KB |
testcase_26 | AC | 158 ms
77,804 KB |
testcase_27 | AC | 169 ms
77,472 KB |
testcase_28 | AC | 161 ms
77,540 KB |
testcase_29 | AC | 184 ms
77,724 KB |
testcase_30 | AC | 161 ms
77,616 KB |
testcase_31 | AC | 160 ms
77,944 KB |
testcase_32 | AC | 159 ms
77,836 KB |
testcase_33 | AC | 161 ms
77,368 KB |
testcase_34 | AC | 161 ms
77,908 KB |
testcase_35 | AC | 167 ms
78,088 KB |
testcase_36 | AC | 149 ms
77,556 KB |
testcase_37 | AC | 155 ms
77,708 KB |
testcase_38 | AC | 166 ms
77,740 KB |
testcase_39 | AC | 39 ms
56,684 KB |
ソースコード
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) # print(RGB,RG,GB,BR) # 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()