結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー |
|
提出日時 | 2023-02-23 21:03:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,301 bytes |
コンパイル時間 | 1,995 ms |
コンパイル使用メモリ | 177,064 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-20 03:31:11 |
合計ジャッジ時間 | 17,818 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 41 |
ソースコード
#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; } if(!a.empty())a.back() = -1145141919; 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(); }