結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー titiatitia
提出日時 2023-05-19 22:34:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,123 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 46,820 KB
最終ジャッジ日時 2023-08-23 03:43:23
合計ジャッジ時間 43,649 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,520 KB
testcase_01 AC 20 ms
8,572 KB
testcase_02 AC 316 ms
8,852 KB
testcase_03 AC 292 ms
11,536 KB
testcase_04 AC 273 ms
11,320 KB
testcase_05 AC 272 ms
11,640 KB
testcase_06 AC 278 ms
11,880 KB
testcase_07 AC 235 ms
11,648 KB
testcase_08 AC 347 ms
22,460 KB
testcase_09 AC 330 ms
18,904 KB
testcase_10 AC 270 ms
30,132 KB
testcase_11 AC 419 ms
29,428 KB
testcase_12 AC 278 ms
23,460 KB
testcase_13 AC 477 ms
25,444 KB
testcase_14 AC 345 ms
28,020 KB
testcase_15 AC 243 ms
19,368 KB
testcase_16 AC 388 ms
23,152 KB
testcase_17 AC 334 ms
29,160 KB
testcase_18 AC 525 ms
43,076 KB
testcase_19 AC 642 ms
44,756 KB
testcase_20 AC 482 ms
46,076 KB
testcase_21 AC 511 ms
45,840 KB
testcase_22 AC 542 ms
43,464 KB
testcase_23 AC 498 ms
46,064 KB
testcase_24 AC 607 ms
42,648 KB
testcase_25 AC 556 ms
43,076 KB
testcase_26 AC 472 ms
41,036 KB
testcase_27 AC 571 ms
43,368 KB
testcase_28 AC 512 ms
40,816 KB
testcase_29 AC 500 ms
41,688 KB
testcase_30 AC 639 ms
42,608 KB
testcase_31 AC 485 ms
46,032 KB
testcase_32 AC 484 ms
45,964 KB
testcase_33 AC 573 ms
46,820 KB
testcase_34 AC 593 ms
42,092 KB
testcase_35 AC 642 ms
45,072 KB
testcase_36 AC 540 ms
40,820 KB
testcase_37 AC 559 ms
42,556 KB
testcase_38 AC 954 ms
8,720 KB
testcase_39 AC 1,123 ms
8,652 KB
testcase_40 AC 405 ms
9,144 KB
testcase_41 AC 533 ms
9,172 KB
testcase_42 AC 665 ms
45,644 KB
testcase_43 AC 669 ms
45,576 KB
testcase_44 AC 567 ms
45,232 KB
testcase_45 AC 483 ms
45,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import Counter

T=int(input())
for tests in range(T):
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))

    CA=Counter(A)
    CB=Counter(B)

    SAME=[]

    for c in CA:
        if CA[c]>0 and CB[c]>0:
            MIN=min(CA[c],CB[c])
            SAME+=[c]*MIN
            CA[c]-=MIN
            CB[c]-=MIN


    if len(SAME)==0 and A and B:
        print("No")
        continue
    
    print("Yes")

    ANS=[]
    for i in range(len(SAME)):
        if i%2==0:
            ANS.append(("Red",SAME[i]))
            ANS.append(("Blue",SAME[i]))
        else:
            ANS.append(("Blue",SAME[i]))
            ANS.append(("Red",SAME[i]))

    X=[]
    for c in CA:
        for i in range(CA[c]):
            X.append(("Red",c))

    Y=[]
    for c in CB:
        for i in range(CB[c]):
            Y.append(("Blue",c))

    ANS=X+ANS[0:2]+Y+ANS[2:]

    for x,y in ANS:
        print(x,y)


    
            
    

    
0