結果
問題 |
No.2148 ひとりUNO
|
ユーザー |
![]() |
提出日時 | 2023-06-20 12:39:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 1,513 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 77,032 KB |
最終ジャッジ日時 | 2024-06-27 23:44:03 |
合計ジャッジ時間 | 5,354 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 39 |
ソースコード
import sys input = sys.stdin.readline def f(c): if c == "R": return 0 elif c == "G": return 1 else: return 2 T = int(input()) for _ in range(T): N = int(input()) S = [set() for i in range(3)] for i in range(N): C, n = input().split() n = int(n) S[f(C)].add(n) L = [] for i in range(3): L.append((len(S[i]), S[i])) L.sort(reverse=True) S0, S1, S2 = L[0][1], L[1][1], L[2][1] if len(S2) == 0 and len(S1) == 0: print("YES") continue S01 = S1.intersection(S0) S02 = S2.intersection(S0) S12 = S1.intersection(S2) if len(S2) == 0 and S01: print("YES") continue if len(S01) >= 2 and (S02 or S12): print("YES") continue if len(S02) >= 2 and (S01 or S12): print("YES") continue if len(S12) >= 2 and (S02 or S01): print("YES") continue if S01 and S12: if S01 == S12: if len(S1) == 1: print("YES") continue else: print("YES") continue if S02 and S12: if S02 == S12: if len(S2) == 1: print("YES") continue else: print("YES") continue if S01 and S02: if S01 == S02: if len(S0) == 1: print("YES") continue else: print("YES") continue print("NO")