結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー rlangevin
提出日時 2023-05-19 21:35:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 130,404 KB
最終ジャッジ日時 2024-12-20 03:43:17
合計ジャッジ時間 29,636 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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()))
    BS = set(B)
    if N == 0 or M == 0:
        print("Yes")
        for a in A:
            print("Red", a)
        for b in B:
            print("Blue", b)
        continue
    S = set()
    for a in A:
        if a in BS:
            S.add(a)
    if len(S) == 0:
        print("No")
        continue
    
    print("Yes")
    for a in A:
        if a not in S:
            print("Red", a)
    s = S.pop()
    print("Red", s)
    print("Blue", s)
    S.add(s)
    for b in B:
        if b not in S:
            print("Blue", b)
    S.discard(s)
    flag = 1
    while S:
        s = S.pop()
        if flag:
            print("Blue", s)
            print("Red", s)
        else:
            print("Red", s)
            print("Blue", s)
        flag = 1 - flag
0