結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-05-19 21:43:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 1,345 bytes
コンパイル時間 2,823 ms
コンパイル使用メモリ 212,228 KB
実行使用メモリ 18,000 KB
最終ジャッジ日時 2023-08-23 02:44:20
合計ジャッジ時間 37,616 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 205 ms
4,380 KB
testcase_03 AC 201 ms
4,376 KB
testcase_04 AC 199 ms
4,376 KB
testcase_05 AC 191 ms
4,384 KB
testcase_06 AC 203 ms
4,380 KB
testcase_07 AC 153 ms
4,380 KB
testcase_08 AC 216 ms
7,972 KB
testcase_09 AC 221 ms
7,452 KB
testcase_10 AC 191 ms
9,184 KB
testcase_11 AC 279 ms
8,792 KB
testcase_12 AC 187 ms
8,344 KB
testcase_13 AC 346 ms
9,060 KB
testcase_14 AC 231 ms
9,892 KB
testcase_15 AC 171 ms
6,724 KB
testcase_16 AC 282 ms
6,544 KB
testcase_17 AC 225 ms
8,848 KB
testcase_18 AC 372 ms
16,160 KB
testcase_19 AC 381 ms
16,592 KB
testcase_20 AC 382 ms
17,816 KB
testcase_21 AC 386 ms
17,712 KB
testcase_22 AC 370 ms
15,924 KB
testcase_23 AC 387 ms
17,948 KB
testcase_24 AC 377 ms
16,060 KB
testcase_25 AC 378 ms
16,092 KB
testcase_26 AC 377 ms
15,872 KB
testcase_27 AC 379 ms
15,920 KB
testcase_28 AC 375 ms
15,860 KB
testcase_29 AC 379 ms
16,104 KB
testcase_30 AC 372 ms
16,056 KB
testcase_31 AC 392 ms
17,808 KB
testcase_32 AC 391 ms
17,664 KB
testcase_33 AC 392 ms
17,920 KB
testcase_34 AC 388 ms
18,000 KB
testcase_35 AC 376 ms
16,652 KB
testcase_36 AC 373 ms
15,872 KB
testcase_37 AC 379 ms
16,180 KB
testcase_38 AC 209 ms
4,380 KB
testcase_39 AC 331 ms
4,384 KB
testcase_40 AC 330 ms
4,376 KB
testcase_41 AC 340 ms
4,380 KB
testcase_42 AC 365 ms
16,476 KB
testcase_43 AC 381 ms
16,592 KB
testcase_44 AC 384 ms
17,240 KB
testcase_45 AC 390 ms
17,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Vp = std::vector<pair<int, int>> ;
bool isOK(Vp& ret) {
	int N, M;
	scanf(" %d %d", &N, &M);
	vector<int> A(N), B(M);
	unordered_set<int> sta, stb;
	for (auto& a : A) {
		scanf(" %d", &a);
		sta.insert(a);
	}
	for (auto& a : B) {
		scanf(" %d", &a);
		stb.insert(a);
	}
	// sort(A.begin(), A.end());
	// sort(B.begin(), B.end());
	vector<int> aon, bon, ab;
	for (auto a : A) {
		if (stb.find(a) != stb.end()) {
			ab.push_back(a);
		} else {
			aon.push_back(a);
		}
	}
	for (auto a : B) {
		if (sta.find(a) == sta.end()) {
			bon.push_back(a);
		}
	}
	if (ab.empty() && N && M) {
		return false;
	}
	if (N + M == max(N, M)) {
		for (auto a : A) {
			ret.emplace_back(1, a);
		}
		for (auto a : B) {
			ret.emplace_back(0, a);
		}
		return true;
	}
	for (auto a : aon) {
		ret.emplace_back(1, a);
	}
	ret.emplace_back(1, ab[0]);
	ret.emplace_back(0, ab[0]);
	for (auto a : bon) {
		ret.emplace_back(0, a);
	}
	for (int i = 1; i < ab.size(); i ++) {
		int id = (i & 1) ^ 1;
		ret.emplace_back(id, ab[i]);
		ret.emplace_back(id ^ 1, ab[i]);
	}
	return true;
}
void solve() {
	Vp ret;
	if (isOK(ret)) {
		puts("Yes");
		for (auto [a, b] : ret) {
			cout << (a ? "Red" : "Blue") << " " << b << endl;
		}
	} else {
		puts("No");
	}
}
int main () {
	int n;
	cin >> n;
	while (n --) {
		solve();
	}
}
0