結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー rin204
提出日時 2024-05-04 16:07:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 568 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 119,936 KB
最終ジャッジ日時 2024-11-26 04:36:52
合計ジャッジ時間 31,286 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, m = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))

    if not A:
        print("Yes")
        for b in B:
            print("Blue", b)
        return
    if not B:
        print("Yes")
        for a in A:
            print("Red", a)
        return

    same = A & B
    if len(same) == 0:
        print("No")
        return
    print("Yes")
    A -= same
    B -= same
    p = same.pop()
    for a in A:
        print("Red", a)
    print("Red", p)
    print("Blue", p)
    for b in B:
        print("Blue", b)

    r = "Red"
    b = "Blue"
    for p in same:
        print(b, p)
        print(r, p)
        r, b = b, r


for _ in range(int(input())):
    solve()
0