結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー navel_tosnavel_tos
提出日時 2023-05-20 00:09:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 585 ms / 2,000 ms
コード長 1,699 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 121,136 KB
最終ジャッジ日時 2024-12-21 04:12:57
合計ジャッジ時間 31,312 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

f=lambda:list(map(int,input().split()))
for _ in range(int(input())):
N,M=f()
if N==M==0: input(); input(); print('Yes'); continue
elif N==0:
input(); B=f(); print('Yes')
for i in B: print('Blue '+str(i))
continue
elif M==0:
A=f(); input(); print('Yes')
for i in A: print('Red '+str(i))
continue
A=f(); B=f(); P=set(A); matched=set()
for i in B:
if i in P: matched.add(i)
if not len(matched): print('No'); continue
if len(matched)==1:
print('Yes')
if N==1:
for i in B:
if i not in matched: print('Blue '+str(i))
for i in matched: print('Blue '+str(i)); print('Red '+str(i))
continue
else:
for i in A:
if i not in matched: print('Red '+str(i))
for i in matched: print('Red '+str(i)); print('Blue '+str(i))
for i in B:
if i not in matched: print('Blue '+str(i))
continue
else:
print('Yes')
start=matched.pop(); print('Blue '+str(start)); print('Red '+str(start))
for i in A:
if i==start: continue
if i not in matched: print('Red '+str(i))
next=matched.pop(); print('Red '+str(next)); print('Blue '+str(next))
for i in B:
if i==start or i==next: continue
if i not in matched: print('Blue '+str(i))
next_is_BL = True
while len(matched):
now=matched.pop()
if next_is_BL==True: print('Blue '+str(now)); print('Red '+str(now)); next_is_BL=False
else: print('Red '+str(now)); print('Blue '+str(now)); next_is_BL=True
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0