結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー ああいいああいい
提出日時 2023-05-22 22:56:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 798 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 676 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 134,880 KB
最終ジャッジ日時 2024-12-22 16:43:50
合計ジャッジ時間 33,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    a = set(A)
    b = set(B)
    c = a & b

    if N == 0:
        print('Yes')
        for bb in B:
            print('Blue',bb)
        continue
    if M == 0:
        print('Yes')
        for aa in A:
            print('Red',aa)
        continue
    if len(c) == 0:
        print('No')
        continue
    print('Yes')
    for aa in A:
        if aa not in c:
            print('Red',aa)

    u = c.pop()
    print('Red',u)
    print('Blue',u)
    for bb in B:
        if bb not in c and bb != u:
            print('Blue',bb)
    now = True
    while c:
        u = c.pop()
        if now:
            print("Blue",u)
            print("Red",u)
        else:
            print('Red',u)
            print('Blue',u)
        now = not now
            
0