結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー pointNpointN
提出日時 2023-05-19 22:00:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,894 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 139,188 KB
実行使用メモリ 6,464 KB
最終ジャッジ日時 2023-08-23 03:06:28
合計ジャッジ時間 25,801 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 47 ms
4,376 KB
testcase_03 AC 52 ms
4,380 KB
testcase_04 AC 51 ms
4,380 KB
testcase_05 AC 52 ms
4,376 KB
testcase_06 AC 51 ms
4,380 KB
testcase_07 AC 49 ms
4,376 KB
testcase_08 AC 56 ms
4,380 KB
testcase_09 AC 57 ms
4,464 KB
testcase_10 AC 55 ms
4,424 KB
testcase_11 AC 62 ms
4,380 KB
testcase_12 AC 51 ms
4,916 KB
testcase_13 AC 66 ms
4,784 KB
testcase_14 AC 55 ms
4,396 KB
testcase_15 AC 54 ms
4,396 KB
testcase_16 AC 59 ms
4,380 KB
testcase_17 AC 56 ms
4,376 KB
testcase_18 AC 70 ms
6,424 KB
testcase_19 AC 71 ms
4,940 KB
testcase_20 AC 66 ms
6,048 KB
testcase_21 AC 66 ms
6,428 KB
testcase_22 AC 69 ms
5,988 KB
testcase_23 AC 66 ms
6,136 KB
testcase_24 AC 70 ms
5,408 KB
testcase_25 AC 70 ms
5,692 KB
testcase_26 AC 66 ms
6,052 KB
testcase_27 AC 70 ms
6,252 KB
testcase_28 AC 69 ms
6,272 KB
testcase_29 AC 69 ms
6,464 KB
testcase_30 AC 71 ms
5,556 KB
testcase_31 AC 65 ms
6,044 KB
testcase_32 AC 65 ms
6,140 KB
testcase_33 AC 65 ms
5,836 KB
testcase_34 AC 67 ms
6,280 KB
testcase_35 AC 71 ms
5,300 KB
testcase_36 AC 69 ms
6,220 KB
testcase_37 AC 71 ms
6,416 KB
testcase_38 AC 40 ms
4,380 KB
testcase_39 AC 61 ms
4,376 KB
testcase_40 AC 41 ms
4,380 KB
testcase_41 AC 60 ms
4,376 KB
testcase_42 AC 70 ms
4,904 KB
testcase_43 AC 70 ms
4,816 KB
testcase_44 AC 42 ms
4,376 KB
testcase_45 AC 42 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

void solve(){
  int N,M; cin >> N >> M;
  vector<int> A(N), B(M);
  rep(i,N) cin >> A[i];
  rep(i,M) cin >> B[i];
  if(N==0 || M==0){
    cout << "Yes\n";
    rep(i,N) cout << "Red " << A[i] << '\n';
    rep(i,M) cout << "Blue " << B[i] << '\n';
    return;
  }
  sort(all(A));
  sort(all(B));
  vector<ll> RR, BB, RB;
  rep(i,N){
    if(binary_search(all(B),A[i])) RB.pb(A[i]);
    else RR.pb(A[i]);
  }
  rep(i,M){
    if(!binary_search(all(A),B[i])) BB.pb(B[i]);
  }
  if(RB.empty()) cout << "No\n";
  else{
    cout << "Yes\n";
    rep(i,sz(RR)) cout << "Red " << RR[i] << '\n';
    cout << "Red " << RB[0] << '\n';
    cout << "Blue " << RB[0] << '\n';
    rep(i,sz(BB)) cout << "Blue " << BB[i] << '\n';
    for(int i=1;i<sz(RB);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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T; cin >> T;
  while(T--) solve();
  return 0;
}
0