結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー |
|
提出日時 | 2023-05-19 22:18:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 516 ms / 2,000 ms |
コード長 | 1,474 bytes |
コンパイル時間 | 4,455 ms |
コンパイル使用メモリ | 258,356 KB |
最終ジャッジ日時 | 2025-02-13 02:09:32 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
// #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(); } }