結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,060 KB
testcase_01 AC 79 ms
70,824 KB
testcase_02 AC 370 ms
80,988 KB
testcase_03 AC 236 ms
80,096 KB
testcase_04 AC 227 ms
80,196 KB
testcase_05 AC 237 ms
80,128 KB
testcase_06 AC 237 ms
81,652 KB
testcase_07 AC 210 ms
80,452 KB
testcase_08 AC 266 ms
96,744 KB
testcase_09 AC 248 ms
96,684 KB
testcase_10 AC 222 ms
104,984 KB
testcase_11 AC 280 ms
98,480 KB
testcase_12 AC 254 ms
108,336 KB
testcase_13 AC 315 ms
97,992 KB
testcase_14 AC 248 ms
102,248 KB
testcase_15 AC 230 ms
98,620 KB
testcase_16 AC 284 ms
93,000 KB
testcase_17 AC 272 ms
93,960 KB
testcase_18 AC 268 ms
109,764 KB
testcase_19 AC 331 ms
122,744 KB
testcase_20 AC 274 ms
133,548 KB
testcase_21 AC 296 ms
132,144 KB
testcase_22 AC 259 ms
109,484 KB
testcase_23 AC 306 ms
133,268 KB
testcase_24 AC 299 ms
109,548 KB
testcase_25 AC 291 ms
109,268 KB
testcase_26 AC 277 ms
132,300 KB
testcase_27 AC 278 ms
109,596 KB
testcase_28 AC 296 ms
125,928 KB
testcase_29 AC 282 ms
124,900 KB
testcase_30 AC 322 ms
114,100 KB
testcase_31 AC 262 ms
133,336 KB
testcase_32 AC 270 ms
133,488 KB
testcase_33 AC 262 ms
127,120 KB
testcase_34 AC 291 ms
127,168 KB
testcase_35 AC 309 ms
118,748 KB
testcase_36 AC 292 ms
127,156 KB
testcase_37 AC 292 ms
113,588 KB
testcase_38 AC 559 ms
78,120 KB
testcase_39 AC 711 ms
80,916 KB
testcase_40 AC 268 ms
78,232 KB
testcase_41 AC 317 ms
79,304 KB
testcase_42 AC 315 ms
122,640 KB
testcase_43 AC 316 ms
122,460 KB
testcase_44 AC 242 ms
130,836 KB
testcase_45 AC 245 ms
131,260 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', B_double[0])
            for b in B_solo:
                print('Blue', b)
            for i in range(1, len(A_double)):
                if i%2 == 1:
                    print('Blue', B_double[i])
                    print('Red', A_double[i])
                else:
                    print('Red', A_double[i])
                    print('Blue', B_double[i])
0