結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,980 KB
testcase_01 AC 16 ms
8,060 KB
testcase_02 AC 235 ms
8,340 KB
testcase_03 AC 183 ms
10,948 KB
testcase_04 AC 182 ms
10,912 KB
testcase_05 AC 178 ms
10,876 KB
testcase_06 AC 185 ms
10,824 KB
testcase_07 AC 155 ms
11,052 KB
testcase_08 AC 213 ms
21,856 KB
testcase_09 AC 207 ms
18,476 KB
testcase_10 AC 184 ms
21,584 KB
testcase_11 AC 258 ms
22,176 KB
testcase_12 AC 189 ms
22,640 KB
testcase_13 AC 299 ms
22,012 KB
testcase_14 AC 213 ms
21,432 KB
testcase_15 AC 172 ms
20,804 KB
testcase_16 AC 250 ms
18,584 KB
testcase_17 AC 215 ms
21,720 KB
testcase_18 AC 324 ms
27,132 KB
testcase_19 AC 374 ms
30,968 KB
testcase_20 AC 335 ms
35,684 KB
testcase_21 AC 338 ms
35,868 KB
testcase_22 AC 337 ms
26,732 KB
testcase_23 AC 332 ms
35,804 KB
testcase_24 AC 344 ms
25,960 KB
testcase_25 AC 336 ms
26,480 KB
testcase_26 AC 325 ms
35,400 KB
testcase_27 AC 335 ms
25,764 KB
testcase_28 AC 320 ms
29,200 KB
testcase_29 AC 321 ms
29,360 KB
testcase_30 AC 352 ms
26,404 KB
testcase_31 AC 322 ms
35,792 KB
testcase_32 AC 335 ms
35,848 KB
testcase_33 AC 336 ms
32,532 KB
testcase_34 AC 361 ms
31,404 KB
testcase_35 AC 358 ms
30,244 KB
testcase_36 AC 338 ms
34,620 KB
testcase_37 AC 330 ms
30,200 KB
testcase_38 AC 1,215 ms
8,028 KB
testcase_39 AC 1,330 ms
8,084 KB
testcase_40 AC 259 ms
8,684 KB
testcase_41 AC 305 ms
8,616 KB
testcase_42 AC 348 ms
30,004 KB
testcase_43 AC 364 ms
30,044 KB
testcase_44 AC 325 ms
32,168 KB
testcase_45 AC 327 ms
32,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for _ in range(T):
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    s_A=set(A)
    s_B=set(B)
    if  not s_A:
        print('Yes')
        for t in s_B:
            print('Blue',t)
        continue
    if not s_B:
        print('Yes')
        for t in s_A:
            print('Red',t)
        continue
    for t in A:
        if t in s_B:
            break
    else:
        print('No')
        continue
    print('Yes')
    cnt=0
    ans=[]
    for t in A:
        if t in s_B:
            s_A.remove(t)
            s_B.remove(t)
            cnt+=1
            ans.append(t)
    if not s_A:
        for t in s_B:
            print('Blue',t)
        for i in range(cnt):
            if i%2==0:
                print('Blue',ans[i])
                print('Red',ans[i])
            else:
                print('Red',ans[i])
                print('Blue',ans[i])
    elif not s_B:
        for t in s_A:
            print('Red',t)
        for i in range(cnt):
            if i%2==0:
                print('Red',ans[i])
                print('Blue',ans[i])
            else:
                print('Blue',ans[i])
                print('Red',ans[i])
    else:
        for t in s_A:
            print('Red',t)
        print('Red',ans[0])
        print('Blue',ans[0])
        for t in s_B:
            print('Blue',t)
        for i in range(1,cnt):
            if i%2==1:
                print('Blue',ans[i])
                print('Red',ans[i])
            else:
                print('Red',ans[i])
                print('Blue',ans[i])
0