結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,180 KB
testcase_01 AC 75 ms
71,468 KB
testcase_02 AC 360 ms
80,820 KB
testcase_03 AC 228 ms
80,948 KB
testcase_04 AC 216 ms
80,732 KB
testcase_05 AC 226 ms
80,964 KB
testcase_06 AC 231 ms
82,132 KB
testcase_07 AC 199 ms
81,064 KB
testcase_08 AC 254 ms
97,160 KB
testcase_09 AC 237 ms
97,076 KB
testcase_10 AC 217 ms
105,616 KB
testcase_11 AC 266 ms
98,828 KB
testcase_12 AC 230 ms
108,812 KB
testcase_13 AC 306 ms
98,440 KB
testcase_14 AC 233 ms
103,092 KB
testcase_15 AC 213 ms
99,220 KB
testcase_16 AC 256 ms
93,652 KB
testcase_17 AC 270 ms
94,544 KB
testcase_18 AC 267 ms
110,664 KB
testcase_19 AC 321 ms
123,208 KB
testcase_20 AC 279 ms
134,276 KB
testcase_21 AC 288 ms
132,964 KB
testcase_22 AC 245 ms
110,036 KB
testcase_23 AC 283 ms
133,844 KB
testcase_24 AC 302 ms
110,044 KB
testcase_25 AC 287 ms
109,964 KB
testcase_26 AC 268 ms
132,540 KB
testcase_27 AC 282 ms
109,908 KB
testcase_28 AC 287 ms
126,300 KB
testcase_29 AC 286 ms
125,364 KB
testcase_30 AC 321 ms
114,640 KB
testcase_31 AC 267 ms
133,932 KB
testcase_32 AC 268 ms
133,904 KB
testcase_33 AC 273 ms
127,828 KB
testcase_34 AC 285 ms
127,644 KB
testcase_35 AC 307 ms
119,520 KB
testcase_36 AC 290 ms
127,596 KB
testcase_37 AC 313 ms
113,948 KB
testcase_38 AC 548 ms
78,636 KB
testcase_39 AC 721 ms
81,376 KB
testcase_40 AC 269 ms
78,876 KB
testcase_41 AC 313 ms
79,924 KB
testcase_42 AC 334 ms
122,428 KB
testcase_43 AC 314 ms
123,080 KB
testcase_44 AC 244 ms
131,268 KB
testcase_45 AC 248 ms
131,344 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