結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー
提出日時 2023-05-19 22:02:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 167,800 KB
最終ジャッジ日時 2024-12-21 02:40:48
合計ジャッジ時間 34,802 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import partial
# import pypyjit
# pypyjit.set_param('max_unroll_recursion = -1')

sys.setrecursionlimit(500005)
stdin = sys.stdin

ns = lambda: stdin.readline().strip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nz = lambda: list(map(lambda x: int(x)-1, stdin.readline().split())) # 遅い
printa = partial(print, sep="\n") # printa(*A) で各要素を改行して出力
mod = 1000000007 # 998244353
inf = 10 ** 18

T = ni()

def solve():
    N, M = na()
    A = set(na())
    B = set(na())
    C = A & B
    Red = A - C
    Blue = B - C
    if N and M and not C:
        print("No")
        return
    print("Yes")
    if Red:
        for r in Red:
            print("Red", r)
    if C:
        x = C.pop()
        print("Red", x)
        print("Blue", x)
    if Blue:
        for b in Blue:
            print("Blue", b)
    f = 0
    for c in C:
        if not f:
            print("Blue", c)
            print("Red", c)
        else:
            print("Red", c)
            print("Blue", c)
        f = f ^ 1


for i in range(T):
    solve()
0