結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,048 KB
testcase_01 AC 17 ms
8,172 KB
testcase_02 AC 218 ms
8,512 KB
testcase_03 AC 172 ms
10,336 KB
testcase_04 AC 168 ms
10,252 KB
testcase_05 AC 165 ms
10,160 KB
testcase_06 AC 163 ms
10,464 KB
testcase_07 AC 142 ms
10,868 KB
testcase_08 AC 200 ms
21,052 KB
testcase_09 AC 185 ms
16,648 KB
testcase_10 AC 164 ms
20,012 KB
testcase_11 AC 243 ms
21,708 KB
testcase_12 AC 162 ms
22,064 KB
testcase_13 AC 269 ms
20,124 KB
testcase_14 AC 188 ms
21,504 KB
testcase_15 AC 149 ms
17,900 KB
testcase_16 AC 227 ms
17,912 KB
testcase_17 AC 194 ms
20,252 KB
testcase_18 AC 291 ms
26,588 KB
testcase_19 AC 379 ms
30,976 KB
testcase_20 AC 290 ms
28,844 KB
testcase_21 AC 318 ms
28,808 KB
testcase_22 AC 298 ms
25,780 KB
testcase_23 AC 301 ms
28,752 KB
testcase_24 AC 338 ms
25,968 KB
testcase_25 AC 306 ms
26,384 KB
testcase_26 AC 289 ms
28,220 KB
testcase_27 AC 329 ms
25,952 KB
testcase_28 AC 301 ms
27,284 KB
testcase_29 AC 294 ms
26,352 KB
testcase_30 AC 366 ms
26,556 KB
testcase_31 AC 291 ms
28,784 KB
testcase_32 AC 293 ms
28,900 KB
testcase_33 AC 296 ms
32,704 KB
testcase_34 AC 338 ms
31,412 KB
testcase_35 AC 370 ms
26,232 KB
testcase_36 AC 332 ms
27,664 KB
testcase_37 AC 309 ms
26,440 KB
testcase_38 AC 1,061 ms
8,376 KB
testcase_39 AC 1,205 ms
8,464 KB
testcase_40 AC 209 ms
8,720 KB
testcase_41 AC 292 ms
8,748 KB
testcase_42 AC 390 ms
30,236 KB
testcase_43 AC 382 ms
30,228 KB
testcase_44 AC 227 ms
30,184 KB
testcase_45 AC 230 ms
30,084 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?
1ケース落ちるんだが。どうせコーナーケースだろ。
'''
f=lambda:list(map(int,input().split()))
nyu=int(input())

for _ in range(nyu):
    N,M=f()
    if   N==0 and 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 len(matched)==0: print('No'); continue
    elif len(matched)==1:
        print('Yes')
        if N==1:
            for i in B:
                if i not in matched: 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 matched: print('Red '+str(i))
            for i in matched: print('Red '+str(i)); print('Blue '+str(i))
            for i in B:
                if i not in matched: 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 len(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