結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 22:07:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 726 ms / 2,000 ms
コード長 1,411 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 86,560 KB
実行使用メモリ 134,312 KB
最終ジャッジ日時 2023-08-23 03:20:50
合計ジャッジ時間 35,893 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,300 KB
testcase_01 AC 76 ms
71,096 KB
testcase_02 AC 365 ms
81,596 KB
testcase_03 AC 243 ms
80,600 KB
testcase_04 AC 229 ms
80,760 KB
testcase_05 AC 239 ms
80,824 KB
testcase_06 AC 250 ms
82,500 KB
testcase_07 AC 218 ms
80,632 KB
testcase_08 AC 272 ms
97,100 KB
testcase_09 AC 251 ms
97,016 KB
testcase_10 AC 235 ms
105,520 KB
testcase_11 AC 287 ms
98,720 KB
testcase_12 AC 245 ms
109,100 KB
testcase_13 AC 306 ms
98,624 KB
testcase_14 AC 247 ms
102,748 KB
testcase_15 AC 227 ms
99,240 KB
testcase_16 AC 270 ms
93,584 KB
testcase_17 AC 274 ms
94,452 KB
testcase_18 AC 267 ms
110,572 KB
testcase_19 AC 341 ms
123,428 KB
testcase_20 AC 287 ms
134,056 KB
testcase_21 AC 308 ms
132,420 KB
testcase_22 AC 263 ms
109,928 KB
testcase_23 AC 301 ms
133,740 KB
testcase_24 AC 303 ms
110,028 KB
testcase_25 AC 297 ms
109,804 KB
testcase_26 AC 270 ms
132,648 KB
testcase_27 AC 285 ms
110,008 KB
testcase_28 AC 312 ms
126,424 KB
testcase_29 AC 300 ms
125,668 KB
testcase_30 AC 334 ms
114,684 KB
testcase_31 AC 286 ms
134,244 KB
testcase_32 AC 278 ms
134,312 KB
testcase_33 AC 275 ms
127,904 KB
testcase_34 AC 310 ms
127,664 KB
testcase_35 AC 327 ms
119,664 KB
testcase_36 AC 304 ms
127,704 KB
testcase_37 AC 296 ms
114,028 KB
testcase_38 AC 558 ms
78,516 KB
testcase_39 AC 726 ms
81,792 KB
testcase_40 AC 268 ms
78,984 KB
testcase_41 AC 320 ms
80,308 KB
testcase_42 AC 330 ms
123,352 KB
testcase_43 AC 314 ms
123,336 KB
testcase_44 AC 250 ms
131,444 KB
testcase_45 AC 251 ms
131,504 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')
    elif N == 0:
        print('Yes')
        for b in B:
            print('Blue', b)
    elif M == 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))
            for a in A_solo:
                print('Red', a)
            print('Red', A_double.pop())
            print('Blue', B_double.pop())
            for b in B_solo:
                print('Blue', b)
            for i in range(len(A_double)):
                if i%2 == 0:
                    print('Blue', B_double[i])
                    print('Red', A_double[i])
                else:
                    print('Red', A_double[i])
                    print('Blue', B_double[i])
0