結果
| 問題 |
No.2307 [Cherry 5 th Tune *] Cool 46
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-19 22:46:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,094 bytes |
| コンパイル時間 | 2,745 ms |
| コンパイル使用メモリ | 224,452 KB |
| 最終ジャッジ日時 | 2025-02-13 02:54:08 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 25 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
inline double time() {
return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}
void slv() {
int n,m; cin >> n >> m;
vector<int> a(n), b(m);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 0; i < m; ++i) {
cin >> b[i];
}
if (m == 0) {
cout << "Yes" << "\n";
for (int i = 0; i < n; ++i) {
cout << "Red" << " " << a[i] << "\n";
}
return;
}
if (n == 0) {
cout << "Yes" << "\n";
for (int i = 0; i < m; ++i) {
cout << "Blue" << " " << b[i] << "\n";
}
return;
}
vector<int> R,B,RB;
set<int> st;
for (int i = 0; i < n; ++i) {
st.insert(a[i]);
}
for (int i = 0; i < m; ++i) {
if (st.find(b[i]) != st.end()) {
RB.push_back(b[i]);
st.erase(b[i]);
}
else {
B.push_back(b[i]);
}
}
for (int i : st) {
R.push_back(i);
}
if (RB.size() == 0) {
cout << "No" << "\n";
return;
}
else if (B.size() == 0) {
cout << "Yes" << "\n";
for (int i : R) {
cout << "Red " << i << "\n";
}
for (int i = 0; i < RB.size(); ++i) {
if (i%2 == 0) {
cout << "Red " << RB[i] << "\n";
cout << "Blue " << RB[i] << "\n";
}
else {
cout << "Blue " << RB[i] << "\n";
cout << "Red " << RB[i] << "\n";
}
}
return;
}
else if (R.size() == 0) {
cout << "Yes" << "\n";
for (int i : B) {
cout << "Blue " << i << "\n";
}
for (int i = 0; i < RB.size(); ++i) {
if (i%2 == 1) {
cout << "Red " << RB[i] << "\n";
cout << "Blue " << RB[i] << "\n";
}
else {
cout << "Blue " << RB[i] << "\n";
cout << "Red " << RB[i] << "\n";
}
}
return;
}
else if (RB.size() % 2 == 0) {
auto p = RB.back(); RB.pop_back();
R.push_back(p);
B.push_back(p);
}
cout << "Yes" << "\n";
for (int i : R) {
cout << "Red " << i << "\n";
}
for (int i = 0; i < RB.size(); ++i) {
if (i%2 == 0) {
cout << "Red " << RB[i] << "\n";
cout << "Blue " << RB[i] << "\n";
}
else {
cout << "Blue " << RB[i] << "\n";
cout << "Red " << RB[i] << "\n";
}
}
for (int i : B) {
cout << "Blue " << i << "\n";
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int q; cin >> q;
while (q--) {
slv();
}
}