結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー t98slidert98slider
提出日時 2023-02-23 21:00:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,294 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 173,404 KB
実行使用メモリ 5,352 KB
最終ジャッジ日時 2023-08-23 02:23:50
合計ジャッジ時間 20,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 48 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 51 ms
4,380 KB
testcase_42 AC 58 ms
4,376 KB
testcase_43 AC 58 ms
4,392 KB
testcase_44 WA -
testcase_45 AC 59 ms
4,832 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;
    }

    if(!a.empty())a.back() = a[0];

    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