結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,668 KB
testcase_01 AC 24 ms
8,568 KB
testcase_02 AC 311 ms
8,772 KB
testcase_03 AC 239 ms
11,264 KB
testcase_04 AC 223 ms
11,028 KB
testcase_05 AC 220 ms
11,156 KB
testcase_06 AC 223 ms
10,972 KB
testcase_07 AC 181 ms
10,932 KB
testcase_08 AC 255 ms
25,552 KB
testcase_09 AC 256 ms
18,920 KB
testcase_10 AC 227 ms
24,684 KB
testcase_11 AC 332 ms
25,796 KB
testcase_12 AC 260 ms
24,976 KB
testcase_13 AC 387 ms
22,388 KB
testcase_14 AC 311 ms
23,360 KB
testcase_15 AC 208 ms
23,964 KB
testcase_16 AC 312 ms
21,856 KB
testcase_17 AC 273 ms
25,856 KB
testcase_18 AC 457 ms
37,804 KB
testcase_19 AC 481 ms
28,800 KB
testcase_20 AC 413 ms
38,928 KB
testcase_21 AC 436 ms
39,144 KB
testcase_22 AC 465 ms
38,496 KB
testcase_23 AC 414 ms
38,876 KB
testcase_24 AC 485 ms
31,048 KB
testcase_25 AC 517 ms
39,724 KB
testcase_26 AC 441 ms
38,248 KB
testcase_27 AC 486 ms
38,192 KB
testcase_28 AC 415 ms
38,460 KB
testcase_29 AC 413 ms
38,668 KB
testcase_30 AC 587 ms
30,636 KB
testcase_31 AC 461 ms
39,096 KB
testcase_32 AC 415 ms
39,012 KB
testcase_33 AC 511 ms
38,148 KB
testcase_34 AC 495 ms
37,360 KB
testcase_35 AC 444 ms
30,152 KB
testcase_36 AC 479 ms
31,212 KB
testcase_37 AC 510 ms
38,148 KB
testcase_38 AC 1,657 ms
8,556 KB
testcase_39 AC 1,853 ms
8,672 KB
testcase_40 AC 293 ms
8,960 KB
testcase_41 AC 354 ms
8,884 KB
testcase_42 AC 455 ms
30,696 KB
testcase_43 AC 472 ms
30,736 KB
testcase_44 AC 366 ms
38,076 KB
testcase_45 AC 340 ms
38,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

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

    AB = collections.Counter(A+B)
    AB_keys = list(AB.keys())
    AB_values = list(AB.values())
    #何もない
    if N==0 and M==0:
        print("Yes")
        continue

    #Noのパターン
    if max(AB_values)==1 and N>0 and M>0:
        print("No")
        continue

    #Yesのパターン
    print("Yes")
    #Redのみ
    if M==0:
        for i in range(N):
            print("Red", A[i])
    
    #Blueのみ
    if N==0:
        for i in range(M):
            print("Blue", B[i])

    #大本命
    if N>0 and M>0:
        #Redで1つしかないやつを表示する。
        for i in range(N):
            if AB[A[i]]==1:
                print("Red", A[i])
        #1回目の共通項を表示する
        cnt = 0
        for i in range(N):
            if AB[A[i]]==2:
                print("Red", A[i])
                print("Blue", A[i])
                cnt += 1
                save_point = i
                break
            
        #Blueで1つしかないやつを表示する。
        for i in range(M):
            if AB[B[i]]==1:
                print("Blue", B[i])

        #2回目の共通項
        for i in range(save_point+1, N):
            if AB[A[i]]==2 and cnt%2==0:
                print("Red", A[i])
                print("Blue", A[i])
                cnt += 1
            elif AB[A[i]]==2 and cnt%2==1:
                print("Blue", A[i])
                print("Red", A[i])
                cnt += 1
0