結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
71,264 KB
testcase_01 AC 87 ms
71,092 KB
testcase_02 AC 376 ms
81,560 KB
testcase_03 AC 244 ms
80,696 KB
testcase_04 AC 228 ms
80,820 KB
testcase_05 AC 236 ms
80,868 KB
testcase_06 AC 236 ms
82,140 KB
testcase_07 AC 204 ms
81,096 KB
testcase_08 AC 262 ms
97,544 KB
testcase_09 AC 244 ms
96,924 KB
testcase_10 AC 229 ms
105,524 KB
testcase_11 AC 284 ms
98,980 KB
testcase_12 AC 235 ms
108,952 KB
testcase_13 AC 299 ms
98,352 KB
testcase_14 AC 244 ms
102,860 KB
testcase_15 AC 223 ms
99,048 KB
testcase_16 AC 265 ms
93,504 KB
testcase_17 AC 266 ms
94,400 KB
testcase_18 AC 266 ms
110,376 KB
testcase_19 AC 329 ms
123,332 KB
testcase_20 AC 279 ms
134,196 KB
testcase_21 AC 303 ms
132,680 KB
testcase_22 AC 258 ms
109,916 KB
testcase_23 AC 289 ms
133,760 KB
testcase_24 AC 298 ms
110,064 KB
testcase_25 AC 291 ms
109,804 KB
testcase_26 AC 268 ms
132,388 KB
testcase_27 AC 285 ms
109,924 KB
testcase_28 AC 294 ms
126,656 KB
testcase_29 AC 287 ms
125,588 KB
testcase_30 AC 319 ms
114,400 KB
testcase_31 AC 276 ms
134,004 KB
testcase_32 AC 269 ms
134,136 KB
testcase_33 AC 267 ms
127,708 KB
testcase_34 AC 297 ms
127,648 KB
testcase_35 AC 320 ms
119,464 KB
testcase_36 AC 297 ms
127,676 KB
testcase_37 AC 298 ms
114,112 KB
testcase_38 AC 556 ms
78,280 KB
testcase_39 AC 716 ms
81,408 KB
testcase_40 AC 271 ms
78,932 KB
testcase_41 AC 315 ms
80,004 KB
testcase_42 AC 323 ms
123,092 KB
testcase_43 AC 316 ms
123,096 KB
testcase_44 AC 252 ms
131,520 KB
testcase_45 AC 251 ms
131,440 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:
        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))
            #print(A_solo, A_double, B_solo, B_double)
            for a in A_solo:
                print('Red', a)
            print('Red', A_double[0])
            print('Blue', B_double[0])
            for b in B_solo:
                print('Blue', b)
            for i in range(1, len(A_double)):
                if i%2 == 1:
                    print('Blue', B_double[i])
                    print('Red', A_double[i])
                else:
                    print('Red', A_double[i])
                    print('Blue', B_double[i])
0