結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー t98slidert98slider
提出日時 2023-02-21 23:23:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,252 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 173,416 KB
実行使用メモリ 5,228 KB
最終ジャッジ日時 2023-08-23 02:19:30
合計ジャッジ時間 26,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 43 ms
4,376 KB
testcase_03 AC 45 ms
4,376 KB
testcase_04 AC 45 ms
4,376 KB
testcase_05 AC 45 ms
4,376 KB
testcase_06 AC 45 ms
4,376 KB
testcase_07 AC 43 ms
4,376 KB
testcase_08 AC 50 ms
4,380 KB
testcase_09 AC 49 ms
4,380 KB
testcase_10 AC 48 ms
4,376 KB
testcase_11 AC 53 ms
4,380 KB
testcase_12 AC 48 ms
4,380 KB
testcase_13 AC 58 ms
4,380 KB
testcase_14 AC 49 ms
4,376 KB
testcase_15 AC 46 ms
4,376 KB
testcase_16 AC 52 ms
4,376 KB
testcase_17 AC 49 ms
4,376 KB
testcase_18 AC 59 ms
5,228 KB
testcase_19 AC 60 ms
4,480 KB
testcase_20 AC 60 ms
4,848 KB
testcase_21 AC 60 ms
5,016 KB
testcase_22 AC 59 ms
4,888 KB
testcase_23 AC 60 ms
4,836 KB
testcase_24 AC 60 ms
4,588 KB
testcase_25 AC 61 ms
4,656 KB
testcase_26 AC 59 ms
4,964 KB
testcase_27 AC 60 ms
4,848 KB
testcase_28 AC 61 ms
5,048 KB
testcase_29 AC 60 ms
4,976 KB
testcase_30 AC 60 ms
4,588 KB
testcase_31 AC 60 ms
5,048 KB
testcase_32 AC 59 ms
5,056 KB
testcase_33 AC 60 ms
4,888 KB
testcase_34 AC 60 ms
4,968 KB
testcase_35 AC 60 ms
4,444 KB
testcase_36 AC 60 ms
4,988 KB
testcase_37 AC 59 ms
5,196 KB
testcase_38 AC 48 ms
4,384 KB
testcase_39 AC 71 ms
4,376 KB
testcase_40 AC 51 ms
4,376 KB
testcase_41 AC 51 ms
4,380 KB
testcase_42 AC 59 ms
4,512 KB
testcase_43 AC 59 ms
4,556 KB
testcase_44 AC 61 ms
5,092 KB
testcase_45 AC 60 ms
4,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M), ab, a, b;
    for(auto &v : A) cin >> v;
    for(auto &v : B) cin >> v;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(ab, ab.end()));
    set_difference(A.begin(), A.end(), ab.begin(), ab.end(), inserter(a, a.end()));
    set_difference(B.begin(), B.end(), ab.begin(), ab.end(), inserter(b, b.end()));
    if(!a.empty() && !b.empty() && ab.empty()){
        cout << "No" << '\n';
        return;
    }
    cout << "Yes" << '\n';
    for(auto &v : a)cout << "Red " << v << '\n';
    if(!ab.empty()){
        cout << "Red " << ab[0] << '\n';
        cout << "Blue " << ab[0] << '\n';
    }
    for(auto &v : b)cout << "Blue " << v << '\n';
    for(int i = 1; i < ab.size(); i++){
        if(i & 1){
            cout << "Blue " << ab[i] << '\n';
            cout << "Red " << ab[i] << '\n';
        }else{
            cout << "Red " << ab[i] << '\n';
            cout << "Blue " << ab[i] << '\n';
        }
    }
}

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