結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー otoshigootoshigo
提出日時 2023-05-19 22:56:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,851 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 92,996 KB
実行使用メモリ 22,564 KB
最終ジャッジ日時 2023-08-23 03:59:23
合計ジャッジ時間 30,063 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 79 ms
4,380 KB
testcase_03 AC 103 ms
4,380 KB
testcase_04 AC 97 ms
4,384 KB
testcase_05 AC 93 ms
4,380 KB
testcase_06 AC 100 ms
4,600 KB
testcase_07 AC 94 ms
4,380 KB
testcase_08 AC 148 ms
9,588 KB
testcase_09 AC 140 ms
9,892 KB
testcase_10 AC 137 ms
8,964 KB
testcase_11 AC 148 ms
8,740 KB
testcase_12 AC 149 ms
10,120 KB
testcase_13 AC 175 ms
8,720 KB
testcase_14 AC 163 ms
12,004 KB
testcase_15 AC 118 ms
6,732 KB
testcase_16 AC 129 ms
6,056 KB
testcase_17 AC 135 ms
9,100 KB
testcase_18 AC 227 ms
19,428 KB
testcase_19 AC 207 ms
14,184 KB
testcase_20 AC 224 ms
14,400 KB
testcase_21 AC 225 ms
13,804 KB
testcase_22 AC 237 ms
20,180 KB
testcase_23 AC 220 ms
13,828 KB
testcase_24 AC 244 ms
18,504 KB
testcase_25 AC 227 ms
18,956 KB
testcase_26 AC 227 ms
14,460 KB
testcase_27 AC 245 ms
19,452 KB
testcase_28 AC 201 ms
14,680 KB
testcase_29 AC 212 ms
15,700 KB
testcase_30 AC 221 ms
16,456 KB
testcase_31 AC 231 ms
14,332 KB
testcase_32 AC 232 ms
14,472 KB
testcase_33 AC 276 ms
21,724 KB
testcase_34 AC 285 ms
20,628 KB
testcase_35 AC 216 ms
15,220 KB
testcase_36 AC 215 ms
13,840 KB
testcase_37 AC 225 ms
18,160 KB
testcase_38 AC 53 ms
4,376 KB
testcase_39 AC 83 ms
4,380 KB
testcase_40 AC 98 ms
4,376 KB
testcase_41 AC 105 ms
4,376 KB
testcase_42 AC 207 ms
13,884 KB
testcase_43 AC 205 ms
13,796 KB
testcase_44 AC 254 ms
22,564 KB
testcase_45 AC 190 ms
13,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

void solve(){
    int N,M;
    cin>>N>>M;
    vector<int>a(N),b(M);
    map<int,int>mpa,mpb;
    rep(i,N){
        cin>>a[i];
        mpa[a[i]]++;
    }
    rep(i,M){
        cin>>b[i];
        mpb[b[i]]++;
    }
    vector<int>v;
    for(auto[x,la]:mpa){
        int lb=mpb[x];
        rep(i,min(la,lb)){
            v.push_back(x);
            mpa[x]--;
            mpb[x]--;
        }
    }
    if(v.empty()&&N>0&&M>0){
        cout<<"No"<<"\n";
    }else if(N==0||M==0){
        cout<<"Yes"<<"\n";
        if(N==0)rep(i,M)cout<<"Blue"<<" "<<b[i]<<"\n";
        if(M==0)rep(i,N)cout<<"Red"<<" "<<a[i]<<"\n";
    }else{
        cout<<"Yes"<<"\n";
        rep(i,(int)v.size()){
            if(i%2==0){
                if(i==0){
                    for(auto[x,la]:mpa){
                        rep(j,la)cout<<"Red"<<" "<<x<<"\n";
                    }
                }
                cout<<"Red"<<" "<<v[i]<<"\n";
                cout<<"Blue"<<" "<<v[i]<<"\n";
                if(i==0){
                    for(auto[x,lb]:mpb){
                        rep(j,lb)cout<<"Blue"<<" "<<x<<"\n";
                    }
                }
            }else{
                cout<<"Blue"<<" "<<v[i]<<"\n";
                cout<<"Red"<<" "<<v[i]<<"\n";
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
        solve();
    }
}
0