結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー |
![]() |
提出日時 | 2023-05-20 00:09:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 834 ms / 2,000 ms |
コード長 | 1,750 bytes |
コンパイル時間 | 470 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 144,532 KB |
最終ジャッジ日時 | 2024-12-21 04:10:52 |
合計ジャッジ時間 | 37,178 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
import collectionsT = int(input())for _ in range(T):N, M = map(int, input().split())try:A = list(map(int, input().split()))B = list(map(int, input().split()))except:if N==0:A = []if M==0:B = []#辞書型の生成AB = collections.Counter(A+B)AB_keys = list(AB.keys())AB_values = list(AB.values())#何もないif N==0 and M==0:print("Yes")continue#Noのパターンif max(AB_values)==1 and N>0 and M>0:print("No")continue#Yesのパターンprint("Yes")#Redのみif M==0:for i in range(N):print("Red", A[i])#Blueのみif N==0:for i in range(M):print("Blue", B[i])#大本命if N>0 and M>0:#Redで1つしかないやつを表示する。for i in range(N):if AB[A[i]]==1:print("Red", A[i])#1回目の共通項を表示するcnt = 0for i in range(N):if AB[A[i]]>1:print("Red", A[i])print("Blue", A[i])cnt += 1save_point = ibreak#Blueで1つしかないやつを表示する。for i in range(M):if AB[B[i]]==1:print("Blue", B[i])#2回目の共通項for i in range(save_point+1, N):if AB[A[i]]>1 and cnt%2==0:print("Red", A[i])print("Blue", A[i])cnt += 1elif AB[A[i]]>1 and cnt%2==1:print("Blue", A[i])print("Red", A[i])cnt += 1