結果
| 問題 |
No.2148 ひとりUNO
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2022-12-26 22:12:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,356 bytes |
| コンパイル時間 | 1,070 ms |
| コンパイル使用メモリ | 82,284 KB |
| 実行使用メモリ | 79,156 KB |
| 最終ジャッジ日時 | 2024-11-21 08:39:15 |
| 合計ジャッジ時間 | 9,472 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 35 |
ソースコード
from collections import Counter
T = int(input())
dic = {"R":0,"G":1,"B":2}
from collections import defaultdict
dic2 = defaultdict(lambda:[0,0,0])
def ok():
print("YES")
def ng():
print("NO")
def solve():
N = int(input())
dic2 = defaultdict(lambda: [0, 0, 0])
Y = 0
CN = [0] * 3
for _ in range(N):
c,d = input().split()
dic2[int(d)][dic[c]] += 1
CN[dic[c]] += 1
D = Counter(CN)
if D[0] == 2:
ok()
return
if D[0] == 1:
for i in range(3):
if CN[i] == 0:
a,b = (i+1)%3, (i+2)%3
for x in dic2.values():
if x[a] > 0 and x[b] > 0:
ok()
return
ng()
return
for X in dic2.values():
D = Counter(X)
if D[0] > 1:
continue
elif D[0] == 1:
for i in range(3):
if X[i] == 0:
if Y == 0 or Y == i+1:
Y = i+1
else:
ok()
return
elif D[1] == 3:
for i in range(3):
if CN[i] - X[i] == 0:
ok()
return
else:
Y = 4
else:
ok()
return
ng()
for _ in range(T):
solve()
ntuda