結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 23:15:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 134,220 KB
最終ジャッジ日時 2023-08-23 04:08:26
合計ジャッジ時間 32,272 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,212 KB
testcase_01 AC 67 ms
71,208 KB
testcase_02 AC 319 ms
80,196 KB
testcase_03 AC 216 ms
80,580 KB
testcase_04 AC 204 ms
80,244 KB
testcase_05 AC 215 ms
80,268 KB
testcase_06 AC 225 ms
82,100 KB
testcase_07 AC 188 ms
81,532 KB
testcase_08 AC 236 ms
96,132 KB
testcase_09 AC 223 ms
97,176 KB
testcase_10 AC 205 ms
105,524 KB
testcase_11 AC 245 ms
97,112 KB
testcase_12 AC 217 ms
108,728 KB
testcase_13 AC 272 ms
98,216 KB
testcase_14 AC 219 ms
102,964 KB
testcase_15 AC 203 ms
98,888 KB
testcase_16 AC 241 ms
93,540 KB
testcase_17 AC 252 ms
97,640 KB
testcase_18 AC 240 ms
110,444 KB
testcase_19 AC 279 ms
116,576 KB
testcase_20 AC 250 ms
134,200 KB
testcase_21 AC 264 ms
132,504 KB
testcase_22 AC 237 ms
109,928 KB
testcase_23 AC 268 ms
133,668 KB
testcase_24 AC 265 ms
109,956 KB
testcase_25 AC 257 ms
109,768 KB
testcase_26 AC 248 ms
132,360 KB
testcase_27 AC 253 ms
110,056 KB
testcase_28 AC 267 ms
126,248 KB
testcase_29 AC 257 ms
125,608 KB
testcase_30 AC 271 ms
109,084 KB
testcase_31 AC 248 ms
134,184 KB
testcase_32 AC 246 ms
134,220 KB
testcase_33 AC 240 ms
127,972 KB
testcase_34 AC 261 ms
126,956 KB
testcase_35 AC 277 ms
114,004 KB
testcase_36 AC 270 ms
126,340 KB
testcase_37 AC 273 ms
114,108 KB
testcase_38 AC 529 ms
78,520 KB
testcase_39 AC 675 ms
81,512 KB
testcase_40 AC 250 ms
78,988 KB
testcase_41 AC 284 ms
80,060 KB
testcase_42 AC 278 ms
114,552 KB
testcase_43 AC 265 ms
114,656 KB
testcase_44 AC 230 ms
131,764 KB
testcase_45 AC 228 ms
131,664 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 = []
    double = []
    for a in A:
        if a in B:
            double.append(a)
        else:
            A_solo.append(a)
    B_solo = []
    for b in B:
        if b not in A:
            B_solo.append(b)

    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(double) == 0:
            print('No')
        else:
            print('Yes')
            double = sorted(list(double))
            for a in A_solo:
                print('Red', a)
            print('Red', double[0])
            print('Blue', double[0])
            for b in B_solo:
                print('Blue', b)
            for i in range(1, len(double)):
                if i%2 == 1:
                    print('Blue', double[i])
                    print('Red', double[i])
                else:
                    print('Red', double[i])
                    print('Blue', double[i])
0