結果
| 問題 |
No.2307 [Cherry 5 th Tune *] Cool 46
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-06-18 01:10:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 675 ms / 2,000 ms |
| コード長 | 1,457 bytes |
| コンパイル時間 | 2,294 ms |
| コンパイル使用メモリ | 207,864 KB |
| 最終ジャッジ日時 | 2025-02-14 22:26:20 |
|
ジャッジサーバーID (参考情報) |
judge7 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(){
ll N, M;
cin >> N >> M;
vector<ll> A(N), B(M);
vector<ll> r, b, p;
for (int i=0; i<N; i++) cin >> A[i];
for (int i=0; i<M; i++) cin >> B[i];
map<ll, vector<ll>> mp;
for (int i=0; i<N; i++) mp[A[i]].push_back(0);
for (int i=0; i<M; i++) mp[B[i]].push_back(1);
for (auto &[x, y] : mp){
if (y.size() == 1){
if (y[0] == 0) r.push_back(x);
else b.push_back(x);
}
else if (y.size() == 2) p.push_back(x);
}
if (N == 0 || M == 0){
cout << "Yes" << endl;
for (int i=0; i<N; i++) cout << "Red " << A[i] << endl;
for (int i=0; i<M; i++) cout << "Blue " << B[i] << endl;
return;
}
if (p.size() == 0){
cout << "No" << endl;
return;
}
cout << "Yes" << endl;
for (auto x : r) cout << "Red " << x << endl;
cout << "Red " << p[0] << endl;
cout << "Blue " << p[0] << endl;
for (auto x : b) cout << "Blue " << x << endl;
for (int i=1; i<p.size(); i++){
if (i % 2 == 1){
cout << "Blue " << p[i] << endl;
cout << "Red " << p[i] << endl;
}
else{
cout << "Red " << p[i] << endl;
cout << "Blue " << p[i] << endl;
}
}
}
int main(){
int T;
cin >> T;
while(T){
T--;
solve();
}
return 0;
}
srjywrdnprkt