結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー 👑 Kazun
提出日時 2023-02-17 04:27:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 1,014 bytes
コンパイル時間 908 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 135,572 KB
最終ジャッジ日時 2024-12-20 03:27:31
合計ジャッジ時間 31,219 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

def Red(a):
    print("Red",a)

def Blue(b):
    print("Blue",b)

def solve():
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))

    if N==0:
        print("Yes")
        for b in B:
            Blue(b)
        return
    elif M==0:
        print("Yes")
        for a in A:
            Red(a)
        return

    A_set=set(A)
    B_set=set(B)
    C_set=A_set & B_set

    if not C_set:
        print("No")
        return

    A_set-=C_set
    B_set-=C_set

    print("Yes")
    for a in A_set:
        Red(a)

    c=C_set.pop()
    Red(c); Blue(c)

    for b in  B_set:
        Blue(b)

    mode=0
    for c in C_set:
        if mode==0:
            Blue(c); Red(c)
        else:
            Red(c); Blue(c)
        mode^=1

    return

#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

T=int(input())
for t in range(T):
    solve()
0