結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー KKT89KKT89
提出日時 2023-05-19 22:59:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 2,056 bytes
コンパイル時間 4,515 ms
コンパイル使用メモリ 219,288 KB
実行使用メモリ 13,616 KB
最終ジャッジ日時 2023-08-23 04:01:10
合計ジャッジ時間 29,259 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 54 ms
4,356 KB
testcase_03 AC 65 ms
4,352 KB
testcase_04 AC 59 ms
4,352 KB
testcase_05 AC 59 ms
4,356 KB
testcase_06 AC 61 ms
4,356 KB
testcase_07 AC 58 ms
4,352 KB
testcase_08 AC 86 ms
6,668 KB
testcase_09 AC 83 ms
6,688 KB
testcase_10 AC 71 ms
5,716 KB
testcase_11 AC 89 ms
6,192 KB
testcase_12 AC 83 ms
7,272 KB
testcase_13 AC 84 ms
5,312 KB
testcase_14 AC 95 ms
8,408 KB
testcase_15 AC 66 ms
4,656 KB
testcase_16 AC 75 ms
4,676 KB
testcase_17 AC 78 ms
6,536 KB
testcase_18 AC 126 ms
11,128 KB
testcase_19 AC 121 ms
8,704 KB
testcase_20 AC 83 ms
6,104 KB
testcase_21 AC 83 ms
6,076 KB
testcase_22 AC 130 ms
11,948 KB
testcase_23 AC 83 ms
6,040 KB
testcase_24 AC 147 ms
11,728 KB
testcase_25 AC 150 ms
11,196 KB
testcase_26 AC 85 ms
6,384 KB
testcase_27 AC 163 ms
12,208 KB
testcase_28 AC 96 ms
7,052 KB
testcase_29 AC 104 ms
7,536 KB
testcase_30 AC 141 ms
10,584 KB
testcase_31 AC 82 ms
5,980 KB
testcase_32 AC 82 ms
6,196 KB
testcase_33 AC 155 ms
13,616 KB
testcase_34 AC 170 ms
13,196 KB
testcase_35 AC 134 ms
9,376 KB
testcase_36 AC 94 ms
6,928 KB
testcase_37 AC 129 ms
10,544 KB
testcase_38 AC 46 ms
4,352 KB
testcase_39 AC 71 ms
4,352 KB
testcase_40 AC 49 ms
4,352 KB
testcase_41 AC 73 ms
4,356 KB
testcase_42 AC 124 ms
9,104 KB
testcase_43 AC 128 ms
9,256 KB
testcase_44 AC 49 ms
4,356 KB
testcase_45 AC 49 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

void slv() {
    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];
    }
    if (m == 0) {
        cout << "Yes" << "\n";
        for (int i = 0; i < n; ++i) {
            cout << "Red" << " " << a[i] << "\n";
        }
        return;
    }
    if (n == 0) {
        cout << "Yes" << "\n";
        for (int i = 0; i < m; ++i) {
            cout << "Blue" << " " << b[i] << "\n";
        }
        return;
    }
    vector<int> R,B,RB;
    set<int> st;
    for (int i = 0; i < n; ++i) {
        st.insert(a[i]);
    }
    for (int i = 0; i < m; ++i) {
        if (st.find(b[i]) != st.end()) {
            RB.push_back(b[i]);
            st.erase(b[i]);
        }
        else {
            B.push_back(b[i]);
        }
    }
    for (int i : st) {
        R.push_back(i);
    }

    if (RB.size() == 0) {
        cout << "No" << "\n";
        return;
    }
    cout << "Yes" << "\n";
    for (int i: R) {
        cout << "Red " << i << "\n";
    }
    cout << "Red " << RB[0] << "\n";
    cout << "Blue " << RB[0] << "\n";
    for (int i: B) {
        cout << "Blue " << i << "\n";
    }
    for (int i = 1; i < RB.size(); ++i) {
        if (i%2 == 1) {
            cout << "Blue " << RB[i] << "\n";
            cout << "Red " << RB[i] << "\n";
        }
        else {
            cout << "Red " << RB[i] << "\n";
            cout << "Blue " << RB[i] << "\n";
        }
    }
}

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