結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー | HIcoder |
提出日時 | 2023-07-08 15:07:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,178 bytes |
コンパイル時間 | 1,880 ms |
コンパイル使用メモリ | 116,884 KB |
実行使用メモリ | 21,640 KB |
最終ジャッジ日時 | 2023-09-29 16:29:34 |
合計ジャッジ時間 | 41,501 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 368 ms
9,392 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 470 ms
21,520 KB |
testcase_19 | WA | - |
testcase_20 | AC | 501 ms
21,420 KB |
testcase_21 | AC | 521 ms
21,640 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 494 ms
21,588 KB |
testcase_28 | WA | - |
testcase_29 | AC | 492 ms
21,392 KB |
testcase_30 | WA | - |
testcase_31 | AC | 514 ms
21,484 KB |
testcase_32 | WA | - |
testcase_33 | AC | 474 ms
21,408 KB |
testcase_34 | AC | 506 ms
21,264 KB |
testcase_35 | AC | 554 ms
20,796 KB |
testcase_36 | WA | - |
testcase_37 | AC | 499 ms
21,428 KB |
testcase_38 | AC | 355 ms
4,376 KB |
testcase_39 | AC | 492 ms
4,380 KB |
testcase_40 | AC | 371 ms
4,380 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 547 ms
15,488 KB |
testcase_44 | AC | 461 ms
13,164 KB |
testcase_45 | AC | 445 ms
12,968 KB |
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<ll,ll> P; typedef pair<int,P> PP; const ll MOD=998244353; const double PI=acos(-1); void solve(){ 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]; } set<int> stA,stB; deque<pair<string,int>> deq; for(int i=0;i<N;i++){ stA.insert(A[i]); } for(int i=0;i<M;i++){ stB.insert(B[i]); } bool flag=false; int s=0; for(int i=0;i<M;i++){ if(stA.count(B[i])){//Aに B[i]が含まれる場合 flag=true; if(s==0){ deq.emplace_back("Red",B[i]); deq.emplace_back("Blue",B[i]); s^=1; }else{ //s==1 deq.emplace_back("Blue",B[i]); deq.emplace_back("Red",B[i]); s^=1; } stA.erase(B[i]); stB.erase(B[i]); } } if(flag){ for(int v:stA){ deq.emplace_front("Red",v); } if(s==1){ for(int v:stB){ deq.emplace_back("Blue",v); } cout<<"Yes"<<endl; for(auto [str,v]:deq){ cout<<str<<' '<<v<<endl; } }else{ bool is= true; for(auto [str,v]:deq){ cout<<str<<' '<<v<<endl; if(str=="Blue" && is){ is=false; for(int v:stB){ cout<<"Blue"<<' '<<v<<endl; } } } } /* if(s==1){ //最初にredをfrontで全部いれて //最後にbackで全部入れる for(int v:stA){ deq.emplace_front("Red",v); } for(int v:stB){ deq.emplace_back("Blue",v); } }else{ //最初にblueをfrontで全部いれて //最後にredで全部入れる for(int v:stB){ deq.emplace_front("Blue",v); } for(int v:stA){ deq.emplace_back("Red",v); } } */ } if(!flag){ if(N>0 && M>0){ cout<<"No"<<endl; }else{ cout<<"Yes"<<endl; if(N>0){ for(int i=0;i<N;i++){ cout<<"Red"<<' '<<A[i]<<endl; } }else{ //M>0 for(int i=0;i<M;i++){ cout<<"Blue"<<' '<<B[i]<<endl; } } } }else{ /* cout<<"Yes"<<endl; for(auto [str,v]:deq){ cout<<str<<' '<<v<<endl; } */ } } int main(){ int T; cin>>T; for(int t=0;t<T;t++){ solve(); } }