結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー ks2mks2m
提出日時 2023-05-19 22:12:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,144 ms / 2,000 ms
コード長 1,983 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 77,384 KB
実行使用メモリ 100,228 KB
最終ジャッジ日時 2023-08-23 03:28:00
合計ジャッジ時間 61,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
50,572 KB
testcase_01 AC 50 ms
34,152 KB
testcase_02 AC 550 ms
60,276 KB
testcase_03 AC 559 ms
60,968 KB
testcase_04 AC 541 ms
47,832 KB
testcase_05 AC 510 ms
60,296 KB
testcase_06 AC 538 ms
59,940 KB
testcase_07 AC 538 ms
60,700 KB
testcase_08 AC 751 ms
71,196 KB
testcase_09 AC 704 ms
58,904 KB
testcase_10 AC 693 ms
62,876 KB
testcase_11 AC 745 ms
60,164 KB
testcase_12 AC 733 ms
79,044 KB
testcase_13 AC 796 ms
81,260 KB
testcase_14 AC 715 ms
77,112 KB
testcase_15 AC 663 ms
67,792 KB
testcase_16 AC 675 ms
68,524 KB
testcase_17 AC 701 ms
68,176 KB
testcase_18 AC 951 ms
77,980 KB
testcase_19 AC 935 ms
86,300 KB
testcase_20 AC 974 ms
98,044 KB
testcase_21 AC 853 ms
94,548 KB
testcase_22 AC 1,022 ms
90,436 KB
testcase_23 AC 966 ms
93,176 KB
testcase_24 AC 1,060 ms
95,368 KB
testcase_25 AC 1,010 ms
94,200 KB
testcase_26 AC 846 ms
92,096 KB
testcase_27 AC 987 ms
92,276 KB
testcase_28 AC 1,144 ms
100,228 KB
testcase_29 AC 1,049 ms
92,472 KB
testcase_30 AC 1,121 ms
87,408 KB
testcase_31 AC 867 ms
92,064 KB
testcase_32 AC 897 ms
91,336 KB
testcase_33 AC 852 ms
86,236 KB
testcase_34 AC 955 ms
93,372 KB
testcase_35 AC 1,037 ms
86,532 KB
testcase_36 AC 911 ms
93,712 KB
testcase_37 AC 1,015 ms
93,344 KB
testcase_38 AC 604 ms
59,564 KB
testcase_39 AC 736 ms
60,252 KB
testcase_40 AC 567 ms
60,440 KB
testcase_41 AC 606 ms
66,472 KB
testcase_42 AC 881 ms
87,044 KB
testcase_43 AC 936 ms
87,116 KB
testcase_44 AC 867 ms
99,332 KB
testcase_45 AC 789 ms
91,128 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(" ");
			long[] a = new long[n];
			Set<Long> seta = new HashSet<>();
			for (int i = 0; i < n; i++) {
				a[i] = Long.parseLong(sa[i]);
				seta.add(a[i]);
			}
			sa = br.readLine().split(" ");
			long[] b = new long[m];
			Set<Long> setb = new HashSet<>();
			for (int i = 0; i < m; i++) {
				b[i] = Long.parseLong(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]);
					}
				}
				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]);
					}
				}
			}
		}
		pw.flush();
		br.close();

	}
}
0