結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー random contestantrandom contestant
提出日時 2023-05-19 22:18:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 1,474 bytes
コンパイル時間 5,913 ms
コンパイル使用メモリ 268,408 KB
実行使用メモリ 16,184 KB
最終ジャッジ日時 2023-08-23 03:35:34
合計ジャッジ時間 48,601 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 257 ms
4,384 KB
testcase_03 AC 270 ms
4,380 KB
testcase_04 AC 268 ms
4,380 KB
testcase_05 AC 255 ms
4,380 KB
testcase_06 AC 268 ms
4,376 KB
testcase_07 AC 223 ms
4,380 KB
testcase_08 AC 328 ms
8,020 KB
testcase_09 AC 332 ms
8,792 KB
testcase_10 AC 319 ms
8,608 KB
testcase_11 AC 390 ms
7,596 KB
testcase_12 AC 309 ms
7,996 KB
testcase_13 AC 511 ms
8,804 KB
testcase_14 AC 357 ms
9,396 KB
testcase_15 AC 280 ms
6,792 KB
testcase_16 AC 383 ms
6,312 KB
testcase_17 AC 337 ms
7,872 KB
testcase_18 AC 594 ms
15,952 KB
testcase_19 AC 506 ms
11,812 KB
testcase_20 AC 555 ms
15,944 KB
testcase_21 AC 550 ms
15,004 KB
testcase_22 AC 568 ms
15,948 KB
testcase_23 AC 555 ms
15,496 KB
testcase_24 AC 542 ms
13,872 KB
testcase_25 AC 562 ms
14,992 KB
testcase_26 AC 563 ms
16,004 KB
testcase_27 AC 573 ms
15,324 KB
testcase_28 AC 585 ms
15,288 KB
testcase_29 AC 575 ms
15,748 KB
testcase_30 AC 529 ms
12,348 KB
testcase_31 AC 580 ms
15,948 KB
testcase_32 AC 578 ms
15,948 KB
testcase_33 AC 576 ms
15,932 KB
testcase_34 AC 570 ms
14,820 KB
testcase_35 AC 528 ms
12,468 KB
testcase_36 AC 546 ms
14,324 KB
testcase_37 AC 578 ms
15,392 KB
testcase_38 AC 356 ms
4,376 KB
testcase_39 AC 490 ms
4,376 KB
testcase_40 AC 386 ms
4,376 KB
testcase_41 AC 381 ms
4,380 KB
testcase_42 AC 501 ms
10,660 KB
testcase_43 AC 499 ms
10,480 KB
testcase_44 AC 534 ms
16,184 KB
testcase_45 AC 540 ms
15,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行


void solve(){
  int n, m; cin >> n >> m;
  map<int, int> mp;
  rep(i, n) {
    int x; cin >> x;
    mp[x] += 1;
  }
  rep(i,m) {
    int x; cin >> x;
    mp[x] += 2;
  }
  if (n == 0 || m == 0){
    cout << "Yes" << endl;
    for(auto [x, ab] : mp){
      if (ab & 1) cout << "Red " << x << endl;
      if (ab & 2) cout << "Blue " << x << endl;
    }
    return;
  }
  vl three;
  for(auto [x, ab] : mp) if (ab == 3) three.push_back(x);
  if (!three.size()) {cout << "No" << endl; return;}
  cout << "Yes" << endl;
  for(auto [x, ab] : mp){
    if (ab == 1) cout << "Red " << x << endl;
  }
  cout << "Red " << three[0] << endl;
  cout << "Blue " << three[0] << endl;
  for(auto [x, ab] : mp){
    if (ab == 2) cout << "Blue " << x << endl;
  }
  int c = 1;
  auto teban = [&]() -> string {
    if (c) return "Blue ";
    else return "Red ";
  };
  for(int i = 1; i < three.size(); i++){
    cout << teban() << three[i] << endl;
    c ^= 1;
    cout << teban() << three[i] << endl;
  }
}

signed main(){
  int t; cin >> t;
  rep(_,t){
    solve();
  }
}
0