結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー |
|
提出日時 | 2023-05-19 22:09:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 155 ms / 2,000 ms |
コード長 | 2,793 bytes |
コンパイル時間 | 1,991 ms |
コンパイル使用メモリ | 200,604 KB |
最終ジャッジ日時 | 2025-02-13 02:01:40 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18; void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);} void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);} void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);} void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); } #define debug1(a) { cerr<<#a<<":"<<a<<endl; } #define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; } #define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; } #define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; } // clang-format on void solve() { ll N, M; cin >> N >> M; unordered_set<ll> A; unordered_set<ll> B; for (ll i = 0; i < N; i++) { ll x; cin >> x; A.insert(x); } for (ll i = 0; i < M; i++) { ll x; cin >> x; B.insert(x); } unordered_set<ll> p; unordered_set<ll> aa; unordered_set<ll> bb; for (auto x : A) { if (B.count(x)) { p.insert(x); } else { aa.insert(x); } } for (auto x : B) { if (A.count(x)) { ; } else { bb.insert(x); } } if (p.size() == 0) { if (aa.size() == 0) { print("Yes"); for (auto x : bb) { print("Blue", x); } } else if (bb.size() == 0) { print("Yes"); for (auto x : aa) { print("Red", x); } } else { print("No"); } } else { print("Yes"); for (auto x : aa) { print("Red", x); } ll xp = -1; for (auto x : p) { xp = x; print("Red", x); print("Blue", x); break; } for (auto x : bb) { print("Blue", x); } bool blue = true; for (auto x : p) { if (x == xp) continue; if (blue) { print("Blue", x); print("Red", x); } else { print("Red", x); print("Blue", x); } blue = !blue; } } } int main() { ioinit(); ll T; cin >> T; while (T--) { solve(); } return 0; }