結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー ks2mks2m
提出日時 2023-05-19 23:09:33
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,072 bytes
コンパイル時間 2,613 ms
コンパイル使用メモリ 80,552 KB
実行使用メモリ 39,528 KB
最終ジャッジ日時 2023-08-23 04:03:13
合計ジャッジ時間 8,155 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		PrintWriter pw = new PrintWriter(System.out);
		for (int z = 0; z < t; z++) {
			String[] sa = br.readLine().split(" ");
			int n = Integer.parseInt(sa[0]);
			int m = Integer.parseInt(sa[1]);
			long[] a = new long[n];
			Set<Long> seta = new HashSet<>();
			long[] b = new long[m];
			Set<Long> setb = new HashSet<>();
			try {
				sa = br.readLine().split(" ");
				for (int i = 0; i < sa.length; i++) {
					a[i] = Long.parseLong(sa[i]);
					seta.add(a[i]);
				}
				sa = br.readLine().split(" ");
				for (int i = 0; i < sa.length; i++) {
					b[i] = Long.parseLong(sa[i]);
					setb.add(b[i]);
				}
			} catch (Exception e) {
			}

			for (int i = 0; i < n; i++) {
				if (!setb.contains(a[i])) {
					seta.remove(a[i]);
				}
			}
			if (seta.isEmpty()) {
				if (n == 0 || m == 0) {
					pw.println("Yes");
					if (n == 0) {
						for (int i = 0; i < m; i++) {
							pw.println("Blue " + b[i]);
						}
					} else {
						for (int i = 0; i < n; i++) {
							pw.println("Red " + a[i]);
						}
					}
				} else {
					pw.println("No");
				}
			} else {
				pw.println("Yes");
				for (int i = 0; i < n; i++) {
					if (!seta.contains(a[i])) {
						pw.println("Red " + a[i]);
					}
				}
				Long[] arr = seta.toArray(new Long[0]);
				pw.println("Red " + arr[0]);
				pw.println("Blue " + arr[0]);
				for (int i = 0; i < m; i++) {
					if (!seta.contains(b[i])) {
						pw.println("Blue " + b[i]);
					}
				}
				for (int i = 1; i < arr.length; i++) {
					if (i % 2 == 0) {
						pw.println("Red " + arr[i]);
						pw.println("Blue " + arr[i]);
					} else {
						pw.println("Blue " + arr[i]);
						pw.println("Red " + arr[i]);
					}
				}
			}
		}
		Thread.sleep(3000);
		pw.flush();
		br.close();

	}
}
0