結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー ks2mks2m
提出日時 2023-05-19 22:07:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,059 ms / 2,000 ms
コード長 1,995 bytes
コンパイル時間 5,321 ms
コンパイル使用メモリ 77,228 KB
実行使用メモリ 97,612 KB
最終ジャッジ日時 2023-08-23 03:20:14
合計ジャッジ時間 59,934 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
50,976 KB
testcase_01 AC 54 ms
50,344 KB
testcase_02 AC 513 ms
61,288 KB
testcase_03 AC 507 ms
60,692 KB
testcase_04 AC 518 ms
61,480 KB
testcase_05 AC 496 ms
61,044 KB
testcase_06 AC 505 ms
60,676 KB
testcase_07 AC 513 ms
60,928 KB
testcase_08 AC 695 ms
69,520 KB
testcase_09 AC 691 ms
73,376 KB
testcase_10 AC 658 ms
73,900 KB
testcase_11 AC 707 ms
71,668 KB
testcase_12 AC 693 ms
78,420 KB
testcase_13 AC 750 ms
72,332 KB
testcase_14 AC 673 ms
76,888 KB
testcase_15 AC 621 ms
69,932 KB
testcase_16 AC 623 ms
68,760 KB
testcase_17 AC 672 ms
67,100 KB
testcase_18 AC 983 ms
79,632 KB
testcase_19 AC 868 ms
86,560 KB
testcase_20 AC 905 ms
93,988 KB
testcase_21 AC 933 ms
93,020 KB
testcase_22 AC 896 ms
78,880 KB
testcase_23 AC 834 ms
97,612 KB
testcase_24 AC 1,059 ms
81,052 KB
testcase_25 AC 940 ms
77,092 KB
testcase_26 AC 881 ms
94,080 KB
testcase_27 AC 944 ms
77,668 KB
testcase_28 AC 907 ms
90,704 KB
testcase_29 AC 905 ms
93,536 KB
testcase_30 AC 933 ms
80,076 KB
testcase_31 AC 791 ms
92,024 KB
testcase_32 AC 808 ms
88,596 KB
testcase_33 AC 836 ms
86,492 KB
testcase_34 AC 909 ms
89,340 KB
testcase_35 AC 971 ms
88,204 KB
testcase_36 AC 863 ms
89,348 KB
testcase_37 AC 959 ms
83,744 KB
testcase_38 AC 577 ms
59,912 KB
testcase_39 AC 716 ms
60,724 KB
testcase_40 AC 567 ms
61,496 KB
testcase_41 AC 603 ms
66,452 KB
testcase_42 AC 820 ms
86,264 KB
testcase_43 AC 980 ms
85,704 KB
testcase_44 AC 789 ms
87,956 KB
testcase_45 AC 773 ms
90,084 KB
権限があれば一括ダウンロードができます

ソースコード

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]);
			sa = br.readLine().split(" ");
			int[] a = new int[n];
			Set<Integer> seta = new HashSet<>();
			for (int i = 0; i < n; i++) {
				a[i] = Integer.parseInt(sa[i]);
				seta.add(a[i]);
			}
			sa = br.readLine().split(" ");
			int[] b = new int[m];
			Set<Integer> setb = new HashSet<>();
			for (int i = 0; i < m; i++) {
				b[i] = Integer.parseInt(sa[i]);
				setb.add(b[i]);
			}

			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]);
					}
				}
				Integer[] arr = seta.toArray(new Integer[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]);
					}
				}
			}
		}
		pw.flush();
		br.close();

	}
}
0