結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
コンテスト
ユーザー detteiuu
提出日時 2026-07-30 23:21:56
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 1,035 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 96,108 KB
実行使用メモリ 141,696 KB
最終ジャッジ日時 2026-07-30 23:22:29
合計ジャッジ時間 28,029 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

for _ in range(int(input())):
    N, M = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))

    C = []
    D = []
    E = []
    for a in A:
        if a in B:
            if len(E) == 0 or E[-1][0] == "Red":
                E.append(("Red", a))
                E.append(("Blue", a))
            else:
                E.append(("Blue", a))
                E.append(("Red", a))
        else:
            C.append(("Red", a))
    for b in B:
        if b not in A:
            D.append(("Blue", b))

    ans = []
    if 1 <= len(E):
        ans += E[:-2]
        if ans[-1][0] == "Red":
            ans += C
            ans += E[-2:]
            ans += D
        else:
            ans += D
            ans += E[-2:]
            ans += C
    elif len(D) == 0:
        ans += C
    elif len(C) == 0:
        ans += D

    if 1 <= len(ans):
        print("Yes")
        for a, b in ans:
            print(a, b)
    else:
        print("No")
0