結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 22:59:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 748 ms / 2,000 ms
コード長 1,448 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 134,148 KB
最終ジャッジ日時 2023-08-23 04:00:02
合計ジャッジ時間 36,373 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,084 KB
testcase_01 AC 78 ms
70,808 KB
testcase_02 AC 393 ms
81,008 KB
testcase_03 AC 245 ms
80,660 KB
testcase_04 AC 239 ms
80,660 KB
testcase_05 AC 243 ms
80,580 KB
testcase_06 AC 249 ms
82,328 KB
testcase_07 AC 218 ms
81,304 KB
testcase_08 AC 267 ms
97,128 KB
testcase_09 AC 246 ms
97,204 KB
testcase_10 AC 229 ms
105,612 KB
testcase_11 AC 290 ms
98,608 KB
testcase_12 AC 245 ms
108,820 KB
testcase_13 AC 304 ms
98,696 KB
testcase_14 AC 247 ms
102,816 KB
testcase_15 AC 224 ms
99,172 KB
testcase_16 AC 271 ms
93,548 KB
testcase_17 AC 270 ms
94,352 KB
testcase_18 AC 279 ms
110,364 KB
testcase_19 AC 331 ms
121,872 KB
testcase_20 AC 299 ms
134,112 KB
testcase_21 AC 286 ms
132,508 KB
testcase_22 AC 257 ms
109,968 KB
testcase_23 AC 298 ms
133,716 KB
testcase_24 AC 292 ms
109,980 KB
testcase_25 AC 294 ms
109,716 KB
testcase_26 AC 275 ms
133,008 KB
testcase_27 AC 295 ms
110,036 KB
testcase_28 AC 299 ms
126,532 KB
testcase_29 AC 284 ms
125,624 KB
testcase_30 AC 315 ms
113,404 KB
testcase_31 AC 279 ms
134,148 KB
testcase_32 AC 275 ms
134,072 KB
testcase_33 AC 277 ms
127,940 KB
testcase_34 AC 299 ms
127,320 KB
testcase_35 AC 320 ms
117,704 KB
testcase_36 AC 301 ms
127,332 KB
testcase_37 AC 299 ms
114,084 KB
testcase_38 AC 560 ms
78,268 KB
testcase_39 AC 748 ms
81,904 KB
testcase_40 AC 274 ms
78,948 KB
testcase_41 AC 313 ms
80,316 KB
testcase_42 AC 305 ms
121,452 KB
testcase_43 AC 294 ms
121,428 KB
testcase_44 AC 304 ms
131,140 KB
testcase_45 AC 256 ms
131,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 貪欲法

T = int(input())
for t in range(T):
    N, M = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    A_solo = []
    A_double = []
    for a in A:
        if a in B:
            A_double.append(a)
        else:
            A_solo.append(a)
    B_solo = []
    B_double = []
    for b in B:
        if b in A:
            B_double.append(b)
        else:
            B_solo.append(b)

    #print(A_solo, A_double)
    #print(B_solo, B_double)

    if N == 0 and M > 0:
        print('Yes')
        for b in B:
            print('Blue', b)
    elif M == 0 and N > 0:
        print('Yes')
        for a in A:
            print('Red', a)
    else:
        if len(A_double) == 0:
            print('No')
        else:
            print('Yes')
            
            A_double = sorted(list(A_double))
            #B_double = sorted(list(B_double))
            #print(A_solo, A_double, B_solo, B_double)
            for a in A_solo:
                print('Red', a)
            print('Red', A_double[0])
            print('Blue', A_double[0])
            for b in B_solo:
                print('Blue', b)
            for i in range(1, len(A_double)):
                if i%2 == 1:
                    print('Blue', A_double[i])
                    print('Red', A_double[i])
                else:
                    print('Red', A_double[i])
                    print('Blue', A_double[i])
0