結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー
提出日時 2023-05-19 21:43:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 4,490 bytes
コンパイル時間 3,631 ms
コンパイル使用メモリ 254,924 KB
実行使用メモリ 13,812 KB
最終ジャッジ日時 2023-08-23 02:45:46
合計ジャッジ時間 31,471 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 109 ms
4,376 KB
testcase_03 AC 114 ms
4,380 KB
testcase_04 AC 110 ms
4,376 KB
testcase_05 AC 109 ms
4,376 KB
testcase_06 AC 111 ms
4,380 KB
testcase_07 AC 107 ms
4,376 KB
testcase_08 AC 136 ms
6,776 KB
testcase_09 AC 134 ms
6,852 KB
testcase_10 AC 122 ms
6,024 KB
testcase_11 AC 139 ms
6,088 KB
testcase_12 AC 132 ms
7,032 KB
testcase_13 AC 137 ms
5,864 KB
testcase_14 AC 145 ms
8,032 KB
testcase_15 AC 116 ms
4,992 KB
testcase_16 AC 128 ms
5,048 KB
testcase_17 AC 127 ms
6,616 KB
testcase_18 AC 184 ms
12,044 KB
testcase_19 AC 175 ms
10,324 KB
testcase_20 AC 135 ms
7,964 KB
testcase_21 AC 136 ms
8,024 KB
testcase_22 AC 188 ms
11,956 KB
testcase_23 AC 138 ms
7,896 KB
testcase_24 AC 198 ms
12,236 KB
testcase_25 AC 192 ms
11,844 KB
testcase_26 AC 137 ms
8,020 KB
testcase_27 AC 193 ms
12,360 KB
testcase_28 AC 149 ms
8,976 KB
testcase_29 AC 151 ms
9,272 KB
testcase_30 AC 192 ms
11,616 KB
testcase_31 AC 135 ms
7,776 KB
testcase_32 AC 134 ms
7,836 KB
testcase_33 AC 207 ms
13,608 KB
testcase_34 AC 194 ms
13,276 KB
testcase_35 AC 177 ms
10,808 KB
testcase_36 AC 147 ms
8,828 KB
testcase_37 AC 179 ms
11,420 KB
testcase_38 AC 228 ms
4,380 KB
testcase_39 AC 286 ms
4,376 KB
testcase_40 AC 114 ms
4,376 KB
testcase_41 AC 129 ms
4,376 KB
testcase_42 AC 178 ms
10,388 KB
testcase_43 AC 176 ms
10,320 KB
testcase_44 AC 190 ms
13,812 KB
testcase_45 AC 100 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ull = uint64_t;
using ll = int64_t;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using ld = long double;
using P = pair<ll,ll>;
using G = vector<vector<int>>;

#define LO(...) (void)0
#define debug(x) (void)0

#define reps(i,a,n) for(ll i##_len = (ll)(n), i = (a); i < i##_len; ++i)
#define rep(i,n) reps(i,0,(n))
#define rrep(i,n) reps(i,1,(n)+1)
#define repd(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrepd(i,n) for(ll i=(n);i>=1;i--)

namespace std {template<typename T,typename U> istream &operator>>(istream &is, pair<T,U> &v){return is>>v.first>>v.second;}}

template<typename T>void input(T& a){cin>>a;}
template<typename T,typename... Ts>void input(T& a,Ts&... b){cin>>a;input(b...);}
#define inp(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define inps(...) string __VA_ARGS__;input(__VA_ARGS__)
#define inpp(p) cin >> (p).first >> (p).second
#define inpv(v,N) vll v(N);rep(i,N)cin>>v[i];
#define inpvs(v,N) vs v(N);rep(i,N)cin>>v[i];
#define all(v) begin(v),end(v)
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define allok(i,N,pred) [&]()->bool{bool allok_=1;rep(i,N)if(!(pred))allok_=0;return allok_;}()
#define anyok(i,N,pred) [&]()->bool{bool anyok_=0;rep(i,N)if(pred)anyok_=1;return anyok_;}()
inline void YESNO(bool b){cout<<(b?"YES\n":"NO\n");}inline void yesno(bool b){cout<<(b?"yes\n":"no\n");}inline void YesNo(bool b){cout<<(b?"Yes\n":"No\n");}

#define SP cout<<' '
#define ENDL cout<<'\n'
#define setfp cout<<fixed<<setprecision(16)
template<typename C>string join(const C &v){ostringstream s;bool f=1;for(auto &&e:v){if(!f)s<<' ';f=0;s<<e;}return s.str();}
template<typename C>string joinadd(const C &v){ostringstream s;bool f=1;for(auto &&e:v){if(!f)s<<' ';f=0;s<<e+1;}return s.str();}
template<typename C>void prv_(const C &v){cout<<join(v);}
template<typename C>void prvadd_(const C &v){cout<<joinadd(v);}
template<typename C>void prv(const C &v){prv_(v);ENDL;}
template<typename C>void prvadd(const C &v){prvadd_(v);ENDL;}

template<typename ...>using rr_void_t=void;
template<typename T,typename=void>struct is_container:false_type{};
template<typename T>struct is_container<T,rr_void_t<typename T::iterator>>:true_type{};

template<typename T,typename=enable_if_t<is_container<T>::value && !is_same<string,T>::value>>
void pr_(const T& a){prv_(a);}
template<typename T,typename=enable_if_t<!is_container<T>::value || is_same<string,T>::value>,typename=void>
void pr_(const T& a){cout<<a;}
inline void pr(){cout<<'\n';}
template<typename T>void pr(const T& a){pr_(a);cout<<'\n';}
template<typename T,typename... Ts>void pr(const T& a,const Ts&... b){pr_(a);cout<<' ';pr(b...);}
template<typename T>void prs(const T& a){pr_(a);SP;}

inline ll max(ll a, ll b){return max<ll>(a, b);}
inline ll min(ll a, ll b){return min<ll>(a, b);}
template<typename T>bool chmax(T &a,const T &b){return a<b?(a=b,1):0;}
template<typename T>bool chmin(T &a,const T &b){return b<a?(a=b,1):0;}

template<typename T,typename C=less<>>void so(T &a,C c=C{}){sort(begin(a),end(a),c);}
template<typename T,typename C=less<>>void rso(T &a,C c=C{}){sort(rbegin(a),rend(a),c);}
template<typename T>void rev(T &a){reverse(begin(a),end(a));}

constexpr ll INF = 1e18;

int main() {
    inp(T);
    while(T--){
        inp(N,M);
        inpv(a,N);
        inpv(b,M);
        set<ll> as;
        rep(i,N)as.insert(a[i]);
        ll co = 0;
        vll no;
        vll aa;
        rep(i,M){
            if(as.count(b[i])){
                as.erase(b[i]);
                aa.push_back(b[i]);
                co++;
            }else{
                no.push_back(b[i]);
            }
        }
        if(N==0){
            Yes;
            rep(i,M){
                prs("Blue");
                pr(b[i]);
            }
        }else if(M==0){
            Yes;
            rep(i,N){
                prs("Red");
                pr(a[i]);
            }
        }else if(co){
            Yes;
            for(ll c : as){
                prs("Red");
                pr(c);
            }
            ll t = 0;
            for(ll c : aa){
                prs(t%2 ? "Blue" : "Red");
                pr(c);
                prs(t%2 ? "Red" : "Blue");
                pr(c);
                if(t==0){
                    for(ll c : no){
                        prs("Blue");
                        pr(c);
                    }
                }
                t++;
            }
        }else{
            No;
        }
    }
}
0