結果
問題 |
No.2148 ひとりUNO
|
ユーザー |
![]() |
提出日時 | 2023-06-20 12:31:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,260 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 77,440 KB |
最終ジャッジ日時 | 2024-06-27 23:34:28 |
合計ジャッジ時間 | 6,096 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 37 |
ソースコード
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 and (len(S1) == 1 or len(S0) * len(S2) == 1): print("YES") continue if S02 and S12 and (len(S2) == 1 or len(S0) * len(S1) == 1): print("YES") continue if S01 and S02 and (len(S0) == 1 or len(S1) * len(S2) == 1): print("YES") continue print("NO")