結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー navel_tosnavel_tos
提出日時 2023-05-19 22:02:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,528 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 127,312 KB
最終ジャッジ日時 2023-08-23 03:09:25
合計ジャッジ時間 32,662 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
70,708 KB
testcase_01 AC 75 ms
71,156 KB
testcase_02 WA -
testcase_03 AC 201 ms
79,708 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 200 ms
79,932 KB
testcase_07 WA -
testcase_08 AC 234 ms
96,688 KB
testcase_09 AC 201 ms
94,552 KB
testcase_10 WA -
testcase_11 AC 219 ms
93,988 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 223 ms
102,912 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 195 ms
107,484 KB
testcase_19 AC 260 ms
122,520 KB
testcase_20 AC 192 ms
107,692 KB
testcase_21 AC 216 ms
109,932 KB
testcase_22 AC 193 ms
106,088 KB
testcase_23 AC 201 ms
108,484 KB
testcase_24 AC 230 ms
110,732 KB
testcase_25 AC 227 ms
108,668 KB
testcase_26 AC 175 ms
108,800 KB
testcase_27 AC 229 ms
106,852 KB
testcase_28 AC 215 ms
110,212 KB
testcase_29 AC 204 ms
109,132 KB
testcase_30 AC 237 ms
119,508 KB
testcase_31 AC 187 ms
108,092 KB
testcase_32 AC 178 ms
108,308 KB
testcase_33 WA -
testcase_34 AC 232 ms
127,312 KB
testcase_35 AC 237 ms
120,996 KB
testcase_36 AC 222 ms
111,172 KB
testcase_37 AC 224 ms
111,468 KB
testcase_38 AC 517 ms
78,280 KB
testcase_39 AC 595 ms
78,720 KB
testcase_40 AC 185 ms
77,964 KB
testcase_41 AC 237 ms
79,508 KB
testcase_42 AC 230 ms
123,824 KB
testcase_43 AC 230 ms
124,100 KB
testcase_44 AC 166 ms
100,528 KB
testcase_45 AC 163 ms
100,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder389C

'''
■考察欄
またカード食べてるよ・・・。

Aiは赤のカード、Bjは青のカード。これら(N+M)枚のカードを全部食べたい。
UNOの要領で食べてゆく。
食べるたびに色が異なっていた回数が多いほどcool。
全部食べろ。

とりあえず同じ数字がなければ、全部食べることは不可能。
一方、同じ数字が1個以上あれば全部食べられる。
1 _ 2 3 _ _ 6 : 6から降順に食べて 
1 1 _ _ 4 5 _ : 1をまたいだら昇順に食べる。かっこよさは1。

どうでもいいカードがなければ、かっこよさは2にできるのに。
1 _ _ _ : 縮小版
1 1 4 5 : 5,4,1,上1,1 と食べればかっこよさは2。

ちょっと難しい。紙で実験しよう。

Corner Case多すぎるだろ。これがyukicoder?
'''
f=lambda:list(map(int,input().split()))

for _ in range(int(input())):
    N,M=f()
    if   N==M==0: input(); input(); print('Yes'); continue
    elif N==0:
        input(); B=f(); print('Yes')
        for i in B: print('Blue '+str(i))
        continue
    elif M==0:
        A=f(); input(); print('Yes')
        for i in A: print('Red '+str(i))
        continue
    A=f(); B=f(); P=set(A); matched=set()
    for i in B:
        if i in P: matched.add(i)
    if not len(matched): print('No'); continue
    if len(matched)==1:
        print('Yes')
        if N==1:
            for i in B:
                if i not in P: print('Blue '+str(i))
            for i in matched: print('Blue '+str(i)); print('Red '+str(i))
            continue
        else:
            for i in A:
                if i not in P: print('Red '+str(i))
            for i in matched: print('Red '+str(i)); print('Blue '+str(i))
            for i in B:
                if i not in P: print('Blue '+str(i))
            continue
    else:
        print('Yes')
        start=matched.pop(); print('Blue '+str(start)); print('Red '+str(start))
        for i in A:
            if i==start: continue
            if i not in matched: print('Red '+str(i))
        next=matched.pop(); print('Red '+str(next)); print('Blue '+str(next))
        for i in B:
            if i==start or i==next: continue
            if i not in matched: print('Blue '+str(i))
        next_is_BL = True
        while matched:
            now=matched.pop()
            if next_is_BL==True: print('Blue '+str(now)); print('Red '+str(now)); next_is_BL=False
            else: print('Red '+str(now)); print('Blue '+str(now)); next_is_BL=True
0