結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-18 01:10:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 636 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 3,222 ms
コンパイル使用メモリ 211,896 KB
実行使用メモリ 29,576 KB
最終ジャッジ日時 2023-09-07 20:01:46
合計ジャッジ時間 51,482 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 264 ms
4,380 KB
testcase_03 AC 274 ms
4,380 KB
testcase_04 AC 272 ms
4,428 KB
testcase_05 AC 263 ms
4,512 KB
testcase_06 AC 276 ms
4,608 KB
testcase_07 AC 225 ms
4,696 KB
testcase_08 AC 332 ms
12,064 KB
testcase_09 AC 349 ms
13,768 KB
testcase_10 AC 337 ms
13,844 KB
testcase_11 AC 388 ms
11,104 KB
testcase_12 AC 313 ms
12,640 KB
testcase_13 AC 501 ms
13,720 KB
testcase_14 AC 365 ms
14,836 KB
testcase_15 AC 286 ms
10,168 KB
testcase_16 AC 385 ms
9,108 KB
testcase_17 AC 338 ms
11,744 KB
testcase_18 AC 562 ms
28,732 KB
testcase_19 AC 545 ms
18,796 KB
testcase_20 AC 622 ms
29,008 KB
testcase_21 AC 604 ms
27,064 KB
testcase_22 AC 619 ms
29,576 KB
testcase_23 AC 603 ms
27,728 KB
testcase_24 AC 592 ms
24,424 KB
testcase_25 AC 618 ms
26,364 KB
testcase_26 AC 611 ms
29,048 KB
testcase_27 AC 604 ms
28,344 KB
testcase_28 AC 601 ms
27,440 KB
testcase_29 AC 619 ms
29,080 KB
testcase_30 AC 561 ms
20,572 KB
testcase_31 AC 636 ms
28,744 KB
testcase_32 AC 631 ms
28,808 KB
testcase_33 AC 630 ms
28,960 KB
testcase_34 AC 612 ms
26,644 KB
testcase_35 AC 554 ms
20,532 KB
testcase_36 AC 587 ms
25,756 KB
testcase_37 AC 605 ms
27,352 KB
testcase_38 AC 367 ms
4,380 KB
testcase_39 AC 511 ms
4,376 KB
testcase_40 AC 391 ms
4,376 KB
testcase_41 AC 386 ms
4,376 KB
testcase_42 AC 500 ms
16,620 KB
testcase_43 AC 489 ms
16,420 KB
testcase_44 AC 556 ms
28,568 KB
testcase_45 AC 550 ms
28,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(M);
    vector<ll> r, b, p;
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<M; i++) cin >> B[i];

    map<ll, vector<ll>> mp;
    for (int i=0; i<N; i++) mp[A[i]].push_back(0);
    for (int i=0; i<M; i++) mp[B[i]].push_back(1);

    for (auto &[x, y] : mp){
        if (y.size() == 1){
            if (y[0] == 0) r.push_back(x);
            else b.push_back(x);
        }
        else if (y.size() == 2) p.push_back(x);
    }

    if (N == 0 || M == 0){
        cout << "Yes" << endl;
        for (int i=0; i<N; i++) cout << "Red " << A[i] << endl;
        for (int i=0; i<M; i++) cout << "Blue " << B[i] << endl;
        return;
    }
    if (p.size() == 0){
        cout << "No" << endl;
        return;
    }
    
    cout << "Yes" << endl;
    for (auto x : r) cout << "Red " << x << endl;
    cout << "Red " << p[0] << endl;
    cout << "Blue " << p[0] << endl;
    for (auto x : b) cout << "Blue " << x << endl;
    for (int i=1; i<p.size(); i++){
        if (i % 2 == 1){
            cout << "Blue " << p[i] << endl;
            cout << "Red " << p[i] << endl;
        }
        else{
            cout << "Red " << p[i] << endl;
            cout << "Blue " << p[i] << endl;
        }
    }
}

int main(){

    int T;
    cin >> T;
    while(T){
        T--;
        solve();
    }

    return 0;
}
0