結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー ks2mks2m
提出日時 2023-05-19 23:27:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,096 ms / 2,000 ms
コード長 2,163 bytes
コンパイル時間 3,006 ms
コンパイル使用メモリ 80,672 KB
実行使用メモリ 107,772 KB
最終ジャッジ日時 2023-08-23 04:12:21
合計ジャッジ時間 63,922 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
50,724 KB
testcase_01 AC 56 ms
50,208 KB
testcase_02 AC 566 ms
61,892 KB
testcase_03 AC 551 ms
59,972 KB
testcase_04 AC 541 ms
62,160 KB
testcase_05 AC 553 ms
63,068 KB
testcase_06 AC 586 ms
62,720 KB
testcase_07 AC 552 ms
60,292 KB
testcase_08 AC 784 ms
74,692 KB
testcase_09 AC 844 ms
80,700 KB
testcase_10 AC 725 ms
73,880 KB
testcase_11 AC 839 ms
72,308 KB
testcase_12 AC 763 ms
77,168 KB
testcase_13 AC 834 ms
81,108 KB
testcase_14 AC 780 ms
80,388 KB
testcase_15 AC 695 ms
68,368 KB
testcase_16 AC 689 ms
72,684 KB
testcase_17 AC 750 ms
74,752 KB
testcase_18 AC 1,096 ms
103,316 KB
testcase_19 AC 998 ms
93,776 KB
testcase_20 AC 1,000 ms
107,012 KB
testcase_21 AC 895 ms
97,880 KB
testcase_22 AC 1,008 ms
99,204 KB
testcase_23 AC 987 ms
100,052 KB
testcase_24 AC 1,042 ms
98,888 KB
testcase_25 AC 1,017 ms
99,132 KB
testcase_26 AC 954 ms
93,284 KB
testcase_27 AC 1,041 ms
100,808 KB
testcase_28 AC 1,031 ms
98,144 KB
testcase_29 AC 961 ms
94,084 KB
testcase_30 AC 1,075 ms
101,800 KB
testcase_31 AC 929 ms
99,452 KB
testcase_32 AC 935 ms
97,744 KB
testcase_33 AC 987 ms
97,868 KB
testcase_34 AC 1,012 ms
97,068 KB
testcase_35 AC 1,065 ms
95,472 KB
testcase_36 AC 1,028 ms
107,772 KB
testcase_37 AC 1,031 ms
99,832 KB
testcase_38 AC 1,001 ms
63,936 KB
testcase_39 AC 1,033 ms
68,060 KB
testcase_40 AC 615 ms
62,532 KB
testcase_41 AC 614 ms
66,884 KB
testcase_42 AC 931 ms
91,912 KB
testcase_43 AC 1,034 ms
91,596 KB
testcase_44 AC 864 ms
105,100 KB
testcase_45 AC 844 ms
95,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
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]);
			List<Long> a = new ArrayList<>();
			List<Long> b = new ArrayList<>();
			Set<Long> seta = new HashSet<>();
			Set<Long> setb = new HashSet<>();
			sa = br.readLine().split(" ");
			for (int i = 0; i < sa.length; i++) {
				try {
					long ai = Long.parseLong(sa[i]);
					a.add(ai);
					seta.add(ai);
				} catch (Exception e) {
				}
			}
			sa = br.readLine().split(" ");
			for (int i = 0; i < sa.length; i++) {
				try {
					long bi = Long.parseLong(sa[i]);
					b.add(bi);
					setb.add(bi);
				} catch (Exception e) {
				}
			}
			int n = a.size();
			int m = b.size();
			for (long i : a) {
				if (!setb.contains(i)) {
					seta.remove(i);
				}
			}

			if (seta.isEmpty()) {
				if (n == 0 || m == 0) {
					pw.println("Yes");
					if (n == 0) {
						for (long i : b) {
							pw.println("Blue " + i);
						}
					} else {
						for (long i : a) {
							pw.println("Red " + i);
						}
					}
				} else {
					pw.println("No");
				}
			} else {
				pw.println("Yes");
				for (long i : a) {
					if (!seta.contains(i)) {
						pw.println("Red " + i);
					}
				}
				Long[] arr = seta.toArray(new Long[0]);
				pw.println("Red " + arr[0]);
				pw.println("Blue " + arr[0]);
				for (long i : b) {
					if (!seta.contains(i)) {
						pw.println("Blue " + 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