結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー |
|
提出日時 | 2023-02-21 23:23:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 1,980 ms |
コンパイル使用メモリ | 177,584 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 03:29:30 |
合計ジャッジ時間 | 24,898 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve(){ int N, M; cin >> N >> M; vector<int> A(N), B(M), ab, a, b; for(auto &v : A) cin >> v; for(auto &v : B) cin >> v; sort(A.begin(), A.end()); sort(B.begin(), B.end()); set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(ab, ab.end())); set_difference(A.begin(), A.end(), ab.begin(), ab.end(), inserter(a, a.end())); set_difference(B.begin(), B.end(), ab.begin(), ab.end(), inserter(b, b.end())); if(!a.empty() && !b.empty() && ab.empty()){ cout << "No" << '\n'; return; } cout << "Yes" << '\n'; for(auto &v : a)cout << "Red " << v << '\n'; if(!ab.empty()){ cout << "Red " << ab[0] << '\n'; cout << "Blue " << ab[0] << '\n'; } for(auto &v : b)cout << "Blue " << v << '\n'; for(int i = 1; i < ab.size(); i++){ if(i & 1){ cout << "Blue " << ab[i] << '\n'; cout << "Red " << ab[i] << '\n'; }else{ cout << "Red " << ab[i] << '\n'; cout << "Blue " << ab[i] << '\n'; } } } int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--) solve(); }