結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー |
![]() |
提出日時 | 2023-05-19 22:34:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,441 ms / 2,000 ms |
コード長 | 1,035 bytes |
コンパイル時間 | 477 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 49,064 KB |
最終ジャッジ日時 | 2024-12-21 03:15:45 |
合計ジャッジ時間 | 49,376 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
import sysinput = sys.stdin.readlinefrom collections import CounterT=int(input())for tests in range(T):N,M=map(int,input().split())A=list(map(int,input().split()))B=list(map(int,input().split()))CA=Counter(A)CB=Counter(B)SAME=[]for c in CA:if CA[c]>0 and CB[c]>0:MIN=min(CA[c],CB[c])SAME+=[c]*MINCA[c]-=MINCB[c]-=MINif len(SAME)==0 and A and B:print("No")continueprint("Yes")ANS=[]for i in range(len(SAME)):if i%2==0:ANS.append(("Red",SAME[i]))ANS.append(("Blue",SAME[i]))else:ANS.append(("Blue",SAME[i]))ANS.append(("Red",SAME[i]))X=[]for c in CA:for i in range(CA[c]):X.append(("Red",c))Y=[]for c in CB:for i in range(CB[c]):Y.append(("Blue",c))ANS=X+ANS[0:2]+Y+ANS[2:]for x,y in ANS:print(x,y)