結果
| 問題 |
No.2307 [Cherry 5 th Tune *] Cool 46
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-08 18:16:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 620 ms / 2,000 ms |
| コード長 | 1,312 bytes |
| コンパイル時間 | 4,759 ms |
| コンパイル使用メモリ | 258,800 KB |
| 最終ジャッジ日時 | 2025-02-20 23:11:55 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;
void solve() {
int N, M; cin >> N >> M;
set<int> r, b, c, d, e;
for (int i = 1; i <= N; i++) {
int x; cin >> x;
r.insert(x);
}
for (int i = 1; i <= M; i++) {
int x; cin >> x;
b.insert(x);
}
set_intersection(r.begin(), r.end(), b.begin(), b.end(), inserter(c, c.end()));
set_difference(r.begin(), r.end(), c.begin(), c.end(), inserter(d, d.end()));
set_difference(b.begin(), b.end(), c.begin(), c.end(), inserter(e, e.end()));
if (c.size() == 0 && (d.size() > 0 && e.size() > 0)) {
cout << "No" << endl;
return;
}
cout << "Yes" << endl;
for (auto x: d) {
cout << "Red " << x << endl;
}
if (c.size() > 0) {
cout << "Red " << *c.begin() << endl;
cout << "Blue " << *c.begin() << endl;
c.erase(*c.begin());
}
for (auto x: e) {
cout << "Blue " << x << endl;
}
int pos = 0;
for (auto x: c) {
if (pos % 2 == 0) {
cout << "Blue " << x << endl;
cout << "Red " << x << endl;
} else {
cout << "Red " << x << endl;
cout << "Blue " << x << endl;
}
pos++;
}
}
int main() {
int T; cin >> T;
while (T--) solve();
return 0;
}