結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー navel_tosnavel_tos
提出日時 2023-05-20 00:09:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 584 ms / 2,000 ms
コード長 1,699 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 127,364 KB
最終ジャッジ日時 2023-08-23 04:20:02
合計ジャッジ時間 31,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,220 KB
testcase_01 AC 75 ms
71,336 KB
testcase_02 AC 302 ms
79,072 KB
testcase_03 AC 200 ms
79,760 KB
testcase_04 AC 197 ms
79,108 KB
testcase_05 AC 214 ms
79,276 KB
testcase_06 AC 200 ms
80,092 KB
testcase_07 AC 185 ms
78,552 KB
testcase_08 AC 238 ms
96,596 KB
testcase_09 AC 201 ms
94,704 KB
testcase_10 AC 160 ms
93,784 KB
testcase_11 AC 219 ms
94,040 KB
testcase_12 AC 209 ms
106,844 KB
testcase_13 AC 243 ms
93,600 KB
testcase_14 AC 210 ms
102,956 KB
testcase_15 AC 182 ms
91,488 KB
testcase_16 AC 206 ms
85,928 KB
testcase_17 AC 224 ms
94,456 KB
testcase_18 AC 190 ms
107,592 KB
testcase_19 AC 233 ms
122,772 KB
testcase_20 AC 184 ms
108,064 KB
testcase_21 AC 207 ms
109,764 KB
testcase_22 AC 191 ms
105,860 KB
testcase_23 AC 204 ms
108,540 KB
testcase_24 AC 227 ms
110,952 KB
testcase_25 AC 222 ms
108,976 KB
testcase_26 AC 176 ms
108,956 KB
testcase_27 AC 215 ms
106,792 KB
testcase_28 AC 213 ms
110,056 KB
testcase_29 AC 200 ms
108,808 KB
testcase_30 AC 241 ms
119,176 KB
testcase_31 AC 183 ms
107,912 KB
testcase_32 AC 177 ms
108,372 KB
testcase_33 AC 206 ms
126,360 KB
testcase_34 AC 233 ms
127,364 KB
testcase_35 AC 244 ms
121,116 KB
testcase_36 AC 219 ms
111,128 KB
testcase_37 AC 225 ms
111,632 KB
testcase_38 AC 517 ms
78,680 KB
testcase_39 AC 584 ms
78,752 KB
testcase_40 AC 178 ms
78,092 KB
testcase_41 AC 231 ms
79,688 KB
testcase_42 AC 230 ms
124,232 KB
testcase_43 AC 228 ms
124,232 KB
testcase_44 AC 165 ms
100,468 KB
testcase_45 AC 162 ms
100,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 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