結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー miya145592miya145592
提出日時 2023-05-19 23:42:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 744 ms / 2,000 ms
コード長 1,176 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 82,068 KB
実行使用メモリ 144,168 KB
最終ジャッジ日時 2024-12-21 04:05:16
合計ジャッジ時間 33,563 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    N, M = map(int, input().split())
    try:
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
    except:
        if N==0:
            A = []
        if M==0:
            B = []
    if N>0 and M>0:
        setA = set(A)
        setB = set(B)
        same = []
        diff = []
        for b in B:
            if b in setA:
                same.append(b)
            else:
                diff.append(b)
        if len(same)==0:
            print("No")
            continue

        print("Yes")
        for d in diff:
            print("Blue", d)
        for i, s in enumerate(same):
            if i%2==0:
                print("Blue", s)
                print("Red", s)
                if i==0:
                    for a in setA:
                        if a not in setB:
                            print("Red", a)
            else:
                print("Red", s)
                print("Blue", s)

    elif N>0:
        print("Yes")
        for a in A:
            print("Red", a)
    elif M>0:
        print("Yes")
        for b in B:
            print("Blue", b)
    else:
        print("Yes")
0