結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー inkyamaninkyaman
提出日時 2024-04-07 00:50:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 556 ms / 2,000 ms
コード長 1,672 bytes
コンパイル時間 2,920 ms
コンパイル使用メモリ 126,248 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-07 00:51:41
合計ジャッジ時間 44,129 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 255 ms
6,676 KB
testcase_03 AC 263 ms
6,676 KB
testcase_04 AC 257 ms
6,676 KB
testcase_05 AC 255 ms
6,676 KB
testcase_06 AC 262 ms
6,676 KB
testcase_07 AC 217 ms
6,676 KB
testcase_08 AC 320 ms
6,784 KB
testcase_09 AC 303 ms
7,424 KB
testcase_10 AC 315 ms
7,424 KB
testcase_11 AC 365 ms
6,676 KB
testcase_12 AC 285 ms
6,676 KB
testcase_13 AC 463 ms
7,424 KB
testcase_14 AC 335 ms
7,680 KB
testcase_15 AC 269 ms
6,676 KB
testcase_16 AC 385 ms
6,676 KB
testcase_17 AC 304 ms
6,676 KB
testcase_18 AC 499 ms
12,800 KB
testcase_19 AC 486 ms
9,088 KB
testcase_20 AC 501 ms
12,800 KB
testcase_21 AC 523 ms
12,032 KB
testcase_22 AC 498 ms
12,800 KB
testcase_23 AC 506 ms
12,416 KB
testcase_24 AC 482 ms
11,136 KB
testcase_25 AC 511 ms
12,032 KB
testcase_26 AC 524 ms
12,800 KB
testcase_27 AC 486 ms
12,288 KB
testcase_28 AC 544 ms
12,288 KB
testcase_29 AC 523 ms
12,672 KB
testcase_30 AC 471 ms
9,600 KB
testcase_31 AC 541 ms
12,800 KB
testcase_32 AC 556 ms
12,800 KB
testcase_33 AC 521 ms
12,800 KB
testcase_34 AC 461 ms
11,776 KB
testcase_35 AC 498 ms
9,472 KB
testcase_36 AC 523 ms
11,520 KB
testcase_37 AC 514 ms
12,288 KB
testcase_38 AC 341 ms
6,676 KB
testcase_39 AC 491 ms
6,676 KB
testcase_40 AC 371 ms
6,676 KB
testcase_41 AC 387 ms
6,676 KB
testcase_42 AC 485 ms
8,192 KB
testcase_43 AC 512 ms
8,192 KB
testcase_44 AC 490 ms
12,800 KB
testcase_45 AC 472 ms
12,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int T;

int main() {

    cin >> T;
    while(T--) {
        int N, M;
        cin >> N >> M;
        set<int> A,B,P;
        for(int i = 0; i < N; ++i) {
            int a; cin >> a;
            A.insert(a);
        }
        for(int i = 0; i < M; ++i) {
            int b; cin >> b;
            if(A.find(b) != A.end()) {
                A.erase(b);
                P.insert(b);
            }
            else B.insert(b);
        }

        if(N>0 && M>0 && P.empty()) {
            cout << "No" << endl;
            continue;
        } else cout << "Yes" << endl;

        if(!A.empty())for(auto v : A) cout << "Red " << v << endl;
        if(!P.empty()) {
            int x = *P.begin();
            cout << "Red " << x << endl;
            cout << "Blue " << x << endl;
        }
        if(!B.empty())for(auto v : B) cout << "Blue " << v << endl;
        if(P.size()>1) {
            int cnt = 0;
            for(int x : P) {
                if(*P.begin() == x) continue;
                if(cnt%2 == 0) {
                    cout << "Blue " << x << endl;
                    cout << "Red " << x << endl;
                } else {
                    cout << "Red " << x << endl;
                    cout << "Blue " << x << endl;
                }
                cnt++;
            }
        }

    }

}

0