結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー | shobonvip |
提出日時 | 2023-05-19 21:38:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 1,976 bytes |
コンパイル時間 | 4,603 ms |
コンパイル使用メモリ | 268,896 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-01 00:17:23 |
合計ジャッジ時間 | 27,887 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 46 ms
6,940 KB |
testcase_03 | AC | 51 ms
6,944 KB |
testcase_04 | AC | 50 ms
6,940 KB |
testcase_05 | AC | 49 ms
6,944 KB |
testcase_06 | AC | 50 ms
6,940 KB |
testcase_07 | AC | 47 ms
6,944 KB |
testcase_08 | AC | 55 ms
6,944 KB |
testcase_09 | AC | 55 ms
6,940 KB |
testcase_10 | AC | 52 ms
6,940 KB |
testcase_11 | AC | 59 ms
6,940 KB |
testcase_12 | AC | 50 ms
6,940 KB |
testcase_13 | AC | 63 ms
6,940 KB |
testcase_14 | AC | 53 ms
6,940 KB |
testcase_15 | AC | 50 ms
6,944 KB |
testcase_16 | AC | 58 ms
6,940 KB |
testcase_17 | AC | 54 ms
6,940 KB |
testcase_18 | AC | 67 ms
6,944 KB |
testcase_19 | AC | 69 ms
6,940 KB |
testcase_20 | AC | 64 ms
6,948 KB |
testcase_21 | AC | 64 ms
6,944 KB |
testcase_22 | AC | 66 ms
6,940 KB |
testcase_23 | AC | 63 ms
6,944 KB |
testcase_24 | AC | 69 ms
6,944 KB |
testcase_25 | AC | 68 ms
6,940 KB |
testcase_26 | AC | 64 ms
6,940 KB |
testcase_27 | AC | 67 ms
6,940 KB |
testcase_28 | AC | 65 ms
6,940 KB |
testcase_29 | AC | 65 ms
6,940 KB |
testcase_30 | AC | 70 ms
6,944 KB |
testcase_31 | AC | 63 ms
6,940 KB |
testcase_32 | AC | 63 ms
6,944 KB |
testcase_33 | AC | 65 ms
6,940 KB |
testcase_34 | AC | 68 ms
6,944 KB |
testcase_35 | AC | 70 ms
6,940 KB |
testcase_36 | AC | 65 ms
6,944 KB |
testcase_37 | AC | 68 ms
6,940 KB |
testcase_38 | AC | 44 ms
6,944 KB |
testcase_39 | AC | 69 ms
6,940 KB |
testcase_40 | AC | 55 ms
6,940 KB |
testcase_41 | AC | 60 ms
6,944 KB |
testcase_42 | AC | 69 ms
6,944 KB |
testcase_43 | AC | 68 ms
6,944 KB |
testcase_44 | AC | 62 ms
6,944 KB |
testcase_45 | AC | 62 ms
6,940 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; // importbisect template <typename T> int bisect_left(vector<T> &X, T v){ return lower_bound(X.begin(), X.end(), v) - X.begin(); } template <typename T> int bisect_right(vector<T> &X, T v){ return upper_bound(X.begin(), X.end(), v) - X.begin(); } // ----- void solve(){ 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]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); if (n == 0){ cout << "Yes\n"; for (int i=0; i<m; i++){ cout << "Blue " << b[i] << "\n"; } return; } if (m == 0){ cout << "Yes\n"; for (int i=0; i<n; i++){ cout << "Red " << a[i] << "\n"; } return; } vector<pair<int,int>> goodpair; vector<bool> usered(n), useblue(m); bool can = false; for (int i=0; i<n; i++){ int tmp = bisect_left(b, a[i]); if (tmp < m && b[tmp] == a[i]){ usered[i] = true; useblue[tmp] = true; goodpair.push_back(pair(i, tmp)); can = true; } } if (!can){ cout << "No\n"; return; } cout << "Yes\n"; for (int i=0; i<n; i++){ if (!usered[i]){ cout << "Red " << a[i] << "\n"; } } int x = goodpair.back().first; int y = goodpair.back().second; goodpair.pop_back(); cout << "Red " << a[x] << "\n"; cout << "Blue " << b[y] << "\n"; for (int i=0; i<m; i++){ if (!useblue[i]){ cout << "Blue " << b[i] << "\n"; } } bool mode = true; while(!goodpair.empty()){ x = goodpair.back().first; y = goodpair.back().second; goodpair.pop_back(); if (mode){ cout << "Blue " << b[y] << "\n"; cout << "Red " << a[x] << "\n"; mode = false; }else{ cout << "Red " << a[x] << "\n"; cout << "Blue " << b[y] << "\n"; mode = true; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--) solve(); }