結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 22:54:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 700 ms / 2,000 ms
コード長 1,447 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 131,280 KB
最終ジャッジ日時 2024-06-01 01:39:29
合計ジャッジ時間 32,144 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,224 KB
testcase_01 AC 44 ms
52,608 KB
testcase_02 AC 363 ms
78,920 KB
testcase_03 AC 205 ms
80,696 KB
testcase_04 AC 194 ms
79,408 KB
testcase_05 AC 202 ms
80,224 KB
testcase_06 AC 207 ms
81,624 KB
testcase_07 AC 176 ms
79,212 KB
testcase_08 AC 228 ms
96,512 KB
testcase_09 AC 214 ms
97,536 KB
testcase_10 AC 193 ms
104,724 KB
testcase_11 AC 243 ms
97,404 KB
testcase_12 AC 209 ms
108,176 KB
testcase_13 AC 274 ms
99,204 KB
testcase_14 AC 210 ms
102,144 KB
testcase_15 AC 193 ms
98,104 KB
testcase_16 AC 238 ms
92,800 KB
testcase_17 AC 242 ms
96,424 KB
testcase_18 AC 226 ms
109,120 KB
testcase_19 AC 291 ms
119,796 KB
testcase_20 AC 259 ms
130,604 KB
testcase_21 AC 312 ms
129,492 KB
testcase_22 AC 235 ms
110,464 KB
testcase_23 AC 263 ms
130,856 KB
testcase_24 AC 274 ms
110,336 KB
testcase_25 AC 264 ms
110,336 KB
testcase_26 AC 240 ms
128,764 KB
testcase_27 AC 258 ms
111,104 KB
testcase_28 AC 267 ms
122,836 KB
testcase_29 AC 258 ms
121,872 KB
testcase_30 AC 287 ms
113,084 KB
testcase_31 AC 240 ms
131,280 KB
testcase_32 AC 239 ms
130,920 KB
testcase_33 AC 225 ms
120,448 KB
testcase_34 AC 263 ms
117,980 KB
testcase_35 AC 297 ms
116,572 KB
testcase_36 AC 271 ms
124,324 KB
testcase_37 AC 273 ms
111,864 KB
testcase_38 AC 530 ms
77,696 KB
testcase_39 AC 700 ms
80,180 KB
testcase_40 AC 233 ms
78,008 KB
testcase_41 AC 275 ms
78,788 KB
testcase_42 AC 281 ms
120,028 KB
testcase_43 AC 288 ms
120,152 KB
testcase_44 AC 217 ms
130,568 KB
testcase_45 AC 218 ms
130,544 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')
        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(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