結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 22:30:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 681 ms / 2,000 ms
コード長 1,411 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 130,864 KB
最終ジャッジ日時 2024-06-01 01:26:07
合計ジャッジ時間 31,216 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 39 ms
52,204 KB
testcase_02 AC 340 ms
78,756 KB
testcase_03 AC 196 ms
80,568 KB
testcase_04 AC 183 ms
79,336 KB
testcase_05 AC 194 ms
79,852 KB
testcase_06 AC 197 ms
81,096 KB
testcase_07 AC 168 ms
79,320 KB
testcase_08 AC 220 ms
96,128 KB
testcase_09 AC 204 ms
97,324 KB
testcase_10 AC 184 ms
104,124 KB
testcase_11 AC 250 ms
97,224 KB
testcase_12 AC 194 ms
108,060 KB
testcase_13 AC 253 ms
99,576 KB
testcase_14 AC 201 ms
102,164 KB
testcase_15 AC 181 ms
97,832 KB
testcase_16 AC 223 ms
92,392 KB
testcase_17 AC 227 ms
96,100 KB
testcase_18 AC 216 ms
108,980 KB
testcase_19 AC 279 ms
119,840 KB
testcase_20 AC 228 ms
130,708 KB
testcase_21 AC 253 ms
129,080 KB
testcase_22 AC 222 ms
110,464 KB
testcase_23 AC 255 ms
130,848 KB
testcase_24 AC 266 ms
110,948 KB
testcase_25 AC 255 ms
110,532 KB
testcase_26 AC 227 ms
128,700 KB
testcase_27 AC 245 ms
110,464 KB
testcase_28 AC 252 ms
122,880 KB
testcase_29 AC 244 ms
122,120 KB
testcase_30 AC 278 ms
112,888 KB
testcase_31 AC 244 ms
130,864 KB
testcase_32 AC 234 ms
130,828 KB
testcase_33 AC 219 ms
120,372 KB
testcase_34 AC 249 ms
118,144 KB
testcase_35 AC 284 ms
116,696 KB
testcase_36 AC 259 ms
124,256 KB
testcase_37 AC 256 ms
111,928 KB
testcase_38 AC 527 ms
77,948 KB
testcase_39 AC 681 ms
80,268 KB
testcase_40 AC 226 ms
77,876 KB
testcase_41 AC 270 ms
78,668 KB
testcase_42 AC 277 ms
119,816 KB
testcase_43 AC 274 ms
119,764 KB
testcase_44 AC 216 ms
130,424 KB
testcase_45 AC 224 ms
130,720 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