結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 21:58:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 707 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 134,164 KB
最終ジャッジ日時 2023-08-23 03:02:27
合計ジャッジ時間 33,901 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,068 KB
testcase_01 AC 78 ms
70,904 KB
testcase_02 AC 348 ms
80,176 KB
testcase_03 AC 224 ms
80,680 KB
testcase_04 AC 212 ms
80,988 KB
testcase_05 AC 223 ms
81,096 KB
testcase_06 AC 225 ms
82,320 KB
testcase_07 AC 194 ms
80,452 KB
testcase_08 AC 247 ms
97,084 KB
testcase_09 AC 233 ms
97,032 KB
testcase_10 AC 210 ms
105,484 KB
testcase_11 AC 258 ms
98,704 KB
testcase_12 AC 226 ms
108,736 KB
testcase_13 AC 286 ms
99,796 KB
testcase_14 AC 232 ms
102,656 KB
testcase_15 AC 209 ms
99,004 KB
testcase_16 AC 254 ms
93,336 KB
testcase_17 AC 267 ms
94,804 KB
testcase_18 AC 251 ms
110,412 KB
testcase_19 AC 319 ms
123,048 KB
testcase_20 AC 272 ms
134,164 KB
testcase_21 AC 287 ms
132,720 KB
testcase_22 AC 248 ms
109,748 KB
testcase_23 AC 298 ms
133,532 KB
testcase_24 AC 291 ms
109,944 KB
testcase_25 AC 281 ms
109,500 KB
testcase_26 AC 256 ms
132,716 KB
testcase_27 AC 269 ms
109,920 KB
testcase_28 AC 295 ms
126,608 KB
testcase_29 AC 282 ms
125,452 KB
testcase_30 AC 310 ms
114,320 KB
testcase_31 AC 267 ms
133,916 KB
testcase_32 AC 260 ms
134,044 KB
testcase_33 AC 258 ms
127,472 KB
testcase_34 AC 288 ms
127,420 KB
testcase_35 AC 307 ms
119,612 KB
testcase_36 AC 289 ms
127,772 KB
testcase_37 AC 287 ms
113,992 KB
testcase_38 AC 558 ms
78,532 KB
testcase_39 AC 707 ms
81,276 KB
testcase_40 AC 264 ms
78,840 KB
testcase_41 AC 300 ms
79,620 KB
testcase_42 AC 310 ms
122,904 KB
testcase_43 AC 321 ms
122,580 KB
testcase_44 AC 250 ms
131,508 KB
testcase_45 AC 237 ms
131,252 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.pop())
                    print('Red', A_double.pop())
                else:
                    print('Red', A_double.pop())
                    print('Blue', B_double.pop())
0