結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー HIcoderHIcoder
提出日時 2023-07-08 14:57:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,474 bytes
コンパイル時間 1,289 ms
コンパイル使用メモリ 117,160 KB
実行使用メモリ 21,744 KB
最終ジャッジ日時 2023-09-29 16:17:31
合計ジャッジ時間 39,353 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
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 363 ms
9,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 466 ms
21,516 KB
testcase_19 WA -
testcase_20 AC 502 ms
21,392 KB
testcase_21 AC 518 ms
21,372 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 488 ms
21,488 KB
testcase_28 WA -
testcase_29 AC 485 ms
21,484 KB
testcase_30 WA -
testcase_31 AC 510 ms
21,344 KB
testcase_32 WA -
testcase_33 AC 485 ms
21,612 KB
testcase_34 AC 513 ms
21,212 KB
testcase_35 AC 536 ms
20,748 KB
testcase_36 WA -
testcase_37 AC 497 ms
21,340 KB
testcase_38 AC 362 ms
4,376 KB
testcase_39 AC 505 ms
4,376 KB
testcase_40 AC 379 ms
4,376 KB
testcase_41 AC 414 ms
4,376 KB
testcase_42 AC 536 ms
15,580 KB
testcase_43 AC 540 ms
15,452 KB
testcase_44 AC 446 ms
13,380 KB
testcase_45 AC 436 ms
13,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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){

        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();
    }
}
0