結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー gyozasukisukigyozasukisuki
提出日時 2023-05-19 22:36:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 2,399 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 176,732 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-12-21 03:20:19
合計ジャッジ時間 31,475 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 1 RE * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
const int INF = 1e9;
using ll = long long;
using inv = vector<int>;
using stv = vector<string>;
using pint = pair<int,int>;
#define FOR(i,l,r) for(int i=(l); i<(r); i++)
#define rep(i,r) for(int i=0; i<(r); i++)
#define repl(i,r) for(long long i=0; i<(r); i++)
#define FORl(i,l,r) for(long long i=(l); i<(r); i++)
#define INFL ((1LL<<62)-(1LL<<31))
#define pb(x) push_back(x)
#define CIN(x) cin >> x
int main(){
int T;
cin >> T;
rep(q,T){
int N,M;
cin >> N >> M;
set<ll> A,B;
rep(i,N){
ll c;
cin >> c;
A.insert(c);
}
rep(i,M){
ll c;
cin >> c;
B.insert(c);
}
if(!N || !M){
if(!N){
cout << "Yes" << endl;
for(auto b: B){
cout << "Blue " << b << endl;
}
continue;
}else{
cout << "Yes" << endl;
for(auto a: A){
cout << "Red " << a << endl;
}
continue;
}
}
set<ll> S; //
for(auto C:A){
if(B.find(C) != B.end()){
S.insert(C);
B.erase(C);
A.erase(C);
}
}
if(S.empty() && !A.empty() && !B.empty()){
cout << "No" << endl;
continue;
}
cout << "Yes" << endl;
bool nowA = true;
if(A.empty()){
nowA = false;
}
if(B.empty()){
nowA = true;
}
if(!nowA){
for(auto b:B){
cout << "Blue " << b << endl;
}
for(auto s:S){
cout << (nowA ? "Red ":"Blue ") << s << endl;
cout << (!nowA ? "Red ":"Blue ") << s << endl;
nowA = !nowA;
}
continue;
}
else if(B.empty()){
for(auto a:A){
cout << "Red " << a << endl;
}
for(auto s:S){
cout << (nowA ? "Red ":"Blue ") << s << endl;
cout << (!nowA ? "Red ":"Blue ") << s << endl;
nowA = !nowA;
}
continue;
}else{
bool first = true;
for(auto a:A){
cout << "Red " << a << endl;
}
for(auto s:S){
cout << (nowA ? "Red ":"Blue ") << s << endl;
cout << (!nowA ? "Red ":"Blue ") << s << endl;
if(first){
for(auto b: B){
cout << "Blue " << b << endl;
}
}
nowA = !nowA;
first = false;
}
}
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0