結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー hongrockhongrock
提出日時 2023-05-19 21:44:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,901 bytes
コンパイル時間 3,382 ms
コンパイル使用メモリ 212,524 KB
実行使用メモリ 24,276 KB
最終ジャッジ日時 2023-08-23 02:51:03
合計ジャッジ時間 28,235 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 53 ms
4,380 KB
testcase_03 AC 65 ms
4,380 KB
testcase_04 AC 60 ms
4,380 KB
testcase_05 AC 60 ms
4,376 KB
testcase_06 AC 63 ms
4,380 KB
testcase_07 AC 59 ms
4,388 KB
testcase_08 AC 96 ms
12,432 KB
testcase_09 AC 89 ms
8,756 KB
testcase_10 AC 81 ms
12,236 KB
testcase_11 AC 100 ms
12,548 KB
testcase_12 AC 88 ms
13,004 KB
testcase_13 AC 96 ms
9,948 KB
testcase_14 AC 101 ms
13,716 KB
testcase_15 AC 72 ms
7,196 KB
testcase_16 AC 83 ms
7,272 KB
testcase_17 AC 85 ms
12,024 KB
testcase_18 AC 138 ms
21,356 KB
testcase_19 AC 135 ms
19,332 KB
testcase_20 AC 94 ms
17,764 KB
testcase_21 AC 95 ms
16,596 KB
testcase_22 AC 150 ms
21,388 KB
testcase_23 AC 93 ms
17,600 KB
testcase_24 AC 155 ms
21,560 KB
testcase_25 AC 145 ms
21,744 KB
testcase_26 AC 95 ms
18,268 KB
testcase_27 AC 155 ms
22,832 KB
testcase_28 AC 106 ms
18,256 KB
testcase_29 AC 111 ms
18,248 KB
testcase_30 AC 160 ms
21,800 KB
testcase_31 AC 94 ms
17,364 KB
testcase_32 AC 94 ms
17,240 KB
testcase_33 AC 173 ms
24,276 KB
testcase_34 AC 170 ms
23,272 KB
testcase_35 AC 140 ms
20,492 KB
testcase_36 AC 104 ms
18,512 KB
testcase_37 AC 147 ms
20,440 KB
testcase_38 AC 46 ms
4,376 KB
testcase_39 AC 71 ms
4,380 KB
testcase_40 AC 61 ms
4,376 KB
testcase_41 AC 77 ms
4,376 KB
testcase_42 AC 133 ms
20,368 KB
testcase_43 AC 136 ms
20,544 KB
testcase_44 AC 145 ms
23,988 KB
testcase_45 AC 59 ms
16,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1
 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using ui = unsigned int;
 
constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1.0);

constexpr int N = 2e5 + 10;

int T, n, m, a[N], b[N];
set<int> st;
vector<pair<string,int>> ans;

bool ok(){
  st.clear();
  ans.clear();
  rep(i, 1, n + 1)  st.insert(a[i]);
  vector<int> same, x;
  rep(i, 1, m + 1){
    if(st.count(b[i])){
      same.pb(b[i]);
      st.erase(b[i]);
    } else {
      x.pb(b[i]);
    }
  }
  if(n && m && !same.size()){
    return 0;
  }
  if(!n){
    rep(i, 1, m + 1)  ans.pb("Blue", b[i]);
    return 1;
  }
  if(!m){
    rep(i, 1, n + 1)  ans.pb("Red", a[i]);
    return 1;
  }
  for(int v : st) ans.pb("Red", v);
  ans.pb("Red", same[0]);
  ans.pb("Blue", same[0]);
  for(int v : x)  ans.pb("Blue", v);
  rep(i, 1, same.size()){
    if(i & 1){
      ans.pb("Blue", same[i]);
      ans.pb("Red", same[i]);
    } else {
      ans.pb("Red", same[i]);
      ans.pb("Blue", same[i]);
    }
  }
  return 1;
}

void _main(){
  cin >> T;
  while(T--){
    cin >> n >> m;
    rep(i, 1, n + 1){
      cin >> a[i];
    }
    rep(i, 1, m + 1){
      cin >> b[i];
    }
    if(ok()){
      cout << "Yes\n";
      for(auto [s, v] : ans){
        cout << s << ' ' << v << '\n';
      }
    } else {
      cout << "No\n";
    }
  }
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  _main();
  return 0;
}
0