結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー i_takui_taku
提出日時 2023-05-19 22:17:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 126,768 KB
最終ジャッジ日時 2023-08-23 03:32:13
合計ジャッジ時間 31,883 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,320 KB
testcase_01 AC 71 ms
71,320 KB
testcase_02 AC 232 ms
78,320 KB
testcase_03 AC 166 ms
80,584 KB
testcase_04 AC 164 ms
80,696 KB
testcase_05 AC 160 ms
81,012 KB
testcase_06 AC 170 ms
80,572 KB
testcase_07 AC 156 ms
79,720 KB
testcase_08 AC 196 ms
98,920 KB
testcase_09 AC 196 ms
98,384 KB
testcase_10 AC 183 ms
104,132 KB
testcase_11 AC 204 ms
107,368 KB
testcase_12 AC 187 ms
105,648 KB
testcase_13 AC 224 ms
107,908 KB
testcase_14 AC 194 ms
96,708 KB
testcase_15 AC 176 ms
98,760 KB
testcase_16 AC 195 ms
98,520 KB
testcase_17 AC 182 ms
97,604 KB
testcase_18 AC 243 ms
112,764 KB
testcase_19 AC 241 ms
117,316 KB
testcase_20 AC 243 ms
126,768 KB
testcase_21 AC 252 ms
126,516 KB
testcase_22 AC 245 ms
109,680 KB
testcase_23 AC 245 ms
126,668 KB
testcase_24 AC 248 ms
111,012 KB
testcase_25 AC 243 ms
109,432 KB
testcase_26 AC 226 ms
125,100 KB
testcase_27 AC 254 ms
110,252 KB
testcase_28 AC 233 ms
120,304 KB
testcase_29 AC 242 ms
117,848 KB
testcase_30 AC 244 ms
113,708 KB
testcase_31 AC 234 ms
126,628 KB
testcase_32 AC 234 ms
126,684 KB
testcase_33 AC 240 ms
121,736 KB
testcase_34 AC 250 ms
120,916 KB
testcase_35 AC 241 ms
115,516 KB
testcase_36 AC 237 ms
121,576 KB
testcase_37 AC 244 ms
113,488 KB
testcase_38 AC 209 ms
78,704 KB
testcase_39 AC 331 ms
80,100 KB
testcase_40 AC 191 ms
78,412 KB
testcase_41 AC 190 ms
78,076 KB
testcase_42 AC 227 ms
116,512 KB
testcase_43 AC 225 ms
116,556 KB
testcase_44 AC 233 ms
125,028 KB
testcase_45 AC 202 ms
118,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


def main():
    T = int(input())
    for _ in range(T):
        N, M = map(int, input().split())
        A = set(map(int, input().split()))
        B = set(map(int, input().split()))
        pair = []
        ans = []
        while A:
            n = A.pop()
            if n in B:
                pair.append(n)
                B.discard(n)
            else:
                ans.append(f'Red {n}')
        if not pair:
            if M == 0:
                print('Yes')
                print(*ans, sep='\n')
            elif N == 0:
                print('Yes')
                while B:
                    print(f'Blue {B.pop()}')
            else:
                print('No')
            continue

        n = pair.pop()
        ans.append(f'Red {n}')
        ans.append(f'Blue {n}')
        while B:
            ans.append(f'Blue {B.pop()}')
        cur = 'Blue'
        while pair:
            n = pair.pop()
            if cur == 'Blue':
                ans.append(f'Blue {n}')
                ans.append(f'Red {n}')
                cur = 'Red'
            else:
                ans.append(f'Red {n}')
                ans.append(f'Blue {n}')
                cur = 'Blue'
        print('Yes')
        print(*ans, sep='\n')



main()
0