結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー とろちゃとろちゃ
提出日時 2023-05-19 22:46:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 455 ms / 2,000 ms
コード長 1,846 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 145,376 KB
最終ジャッジ日時 2023-08-23 03:52:47
合計ジャッジ時間 36,725 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
70,872 KB
testcase_01 AC 120 ms
71,016 KB
testcase_02 AC 455 ms
80,328 KB
testcase_03 AC 258 ms
80,956 KB
testcase_04 AC 275 ms
81,884 KB
testcase_05 AC 316 ms
81,172 KB
testcase_06 AC 332 ms
83,016 KB
testcase_07 AC 225 ms
80,496 KB
testcase_08 AC 267 ms
99,152 KB
testcase_09 AC 250 ms
97,972 KB
testcase_10 AC 226 ms
106,476 KB
testcase_11 AC 266 ms
95,896 KB
testcase_12 AC 247 ms
109,672 KB
testcase_13 AC 293 ms
99,960 KB
testcase_14 AC 264 ms
102,720 KB
testcase_15 AC 243 ms
98,956 KB
testcase_16 AC 286 ms
93,660 KB
testcase_17 AC 276 ms
97,656 KB
testcase_18 AC 275 ms
114,048 KB
testcase_19 AC 303 ms
117,140 KB
testcase_20 AC 298 ms
137,124 KB
testcase_21 AC 307 ms
136,820 KB
testcase_22 AC 271 ms
118,544 KB
testcase_23 AC 299 ms
137,220 KB
testcase_24 AC 301 ms
118,872 KB
testcase_25 AC 298 ms
118,436 KB
testcase_26 AC 283 ms
135,248 KB
testcase_27 AC 291 ms
118,744 KB
testcase_28 AC 298 ms
130,032 KB
testcase_29 AC 293 ms
126,176 KB
testcase_30 AC 303 ms
113,932 KB
testcase_31 AC 285 ms
136,800 KB
testcase_32 AC 274 ms
137,252 KB
testcase_33 AC 284 ms
128,904 KB
testcase_34 AC 293 ms
129,796 KB
testcase_35 AC 318 ms
113,908 KB
testcase_36 AC 296 ms
129,832 KB
testcase_37 AC 303 ms
113,656 KB
testcase_38 AC 270 ms
78,664 KB
testcase_39 AC 393 ms
80,540 KB
testcase_40 AC 175 ms
77,288 KB
testcase_41 AC 293 ms
79,800 KB
testcase_42 AC 304 ms
115,148 KB
testcase_43 AC 291 ms
115,124 KB
testcase_44 AC 236 ms
145,088 KB
testcase_45 AC 236 ms
145,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1")
# from bisect import *
# from collections import *
# from heapq import *
# from itertools import *
# from math import *
# from datetime import *
# from decimal import*
# from string import ascii_lowercase,ascii_uppercase
# import numpy as np
import sys
import os

# sys.setrecursionlimit(10**6)
INF = 10**18
MOD = 998244353
# MOD = 10**9 + 7
File = open("input.txt", "r") if os.path.exists("input.txt") else sys.stdin


def input():
    return File.readline()[:-1]


# ///////////////////////////////////////////////////////////////////////////


T = int(input())


def f(l, s):
    res = 0
    flag = [0] * (len(l))
    for i in range(len(l)):
        if l[i] in s:
            flag[i] = 1
            res += 1
    return flag, res


for _ in range(T):
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    As = set(A)
    B = list(map(int, input().split()))
    Bs = set(B)
    if len(A) == 0 or len(B) == 0:
        print("Yes")
        print(*["Red " + str(i) for i in A], sep="\n") if len(A) else print(
            *["Blue " + str(i) for i in B], sep="\n"
        )
        continue
    flagA, cnt1 = f(A, Bs)
    flagB, cnt2 = f(B, As)

    if cnt1 == 0 or cnt2 == 0:
        print("No")
        continue

    print("Yes")

    for i in range(N):
        if not flagA[i]:
            print("Red", A[i])

    parity = 1
    flag = 0
    for i in range(N):
        if flagA[i]:
            if parity:
                print("Red", A[i])
                print("Blue", A[i])
            else:
                print("Blue", A[i])
                print("Red", A[i])
            parity ^= 1
            if flag == 0:
                for j in range(M):
                    if not flagB[j]:
                        print("Blue", B[j])
                flag = 1
0