結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー | KKT89 |
提出日時 | 2023-05-19 22:59:46 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 2,056 bytes |
コンパイル時間 | 3,319 ms |
コンパイル使用メモリ | 222,672 KB |
実行使用メモリ | 14,052 KB |
最終ジャッジ日時 | 2024-12-21 03:33:44 |
合計ジャッジ時間 | 29,597 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } void slv() { int n,m; cin >> n >> m; vector<int> a(n), b(m); for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int i = 0; i < m; ++i) { cin >> b[i]; } if (m == 0) { cout << "Yes" << "\n"; for (int i = 0; i < n; ++i) { cout << "Red" << " " << a[i] << "\n"; } return; } if (n == 0) { cout << "Yes" << "\n"; for (int i = 0; i < m; ++i) { cout << "Blue" << " " << b[i] << "\n"; } return; } vector<int> R,B,RB; set<int> st; for (int i = 0; i < n; ++i) { st.insert(a[i]); } for (int i = 0; i < m; ++i) { if (st.find(b[i]) != st.end()) { RB.push_back(b[i]); st.erase(b[i]); } else { B.push_back(b[i]); } } for (int i : st) { R.push_back(i); } if (RB.size() == 0) { cout << "No" << "\n"; return; } cout << "Yes" << "\n"; for (int i: R) { cout << "Red " << i << "\n"; } cout << "Red " << RB[0] << "\n"; cout << "Blue " << RB[0] << "\n"; for (int i: B) { cout << "Blue " << i << "\n"; } for (int i = 1; i < RB.size(); ++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() { cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while (q--) { slv(); } }