結果
問題 | No.2900 Star Divine |
ユーザー | 👑 binap |
提出日時 | 2024-09-21 03:46:22 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,150 bytes |
コンパイル時間 | 4,612 ms |
コンパイル使用メモリ | 269,900 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2024-09-21 03:46:32 |
合計ジャッジ時間 | 6,191 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | WA | - |
testcase_04 | RE | - |
testcase_05 | WA | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using namespace atcoder; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<vector<int>> vvi; typedef vector<vector<long long>> vvl; typedef long double ld; typedef pair<int, int> P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template <int m> ostream& operator<<(ostream& os, const static_modint<m>& a) {os << a.val(); return os;} template <int m> ostream& operator<<(ostream& os, const dynamic_modint<m>& a) {os << a.val(); return os;} template<typename T> istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template<typename U, typename T> ostream& operator<<(ostream& os, const pair<U, T>& p){os << p.first << ' ' << p.second; return os;} template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template<typename T> ostream& operator<<(ostream& os, const set<T>& se){for(T x : se) os << x << " "; os << "\n"; return os;} template<typename T> ostream& operator<<(ostream& os, const unordered_set<T>& se){for(T x : se) os << x << " "; os << "\n"; return os;} template<typename S, auto op, auto e> ostream& operator<<(ostream& os, const atcoder::segtree<S, op, e>& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template<typename S, auto op, auto e, typename F, auto mapping, auto composition, auto id> ostream& operator<<(ostream& os, const atcoder::lazy_segtree<S, op, e, F, mapping, composition, id>& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template<typename T> void chmin(T& a, T b){a = min(a, b);} template<typename T> void chmax(T& a, T b){a = max(a, b);} int solve(){ int b, r, m; cin >> b >> r >> m; vector<int> end(b); vector<set<int>> G(r); rep(i, m){ int u, v; cin >> u >> v; u--; v--; chmax(end[u], v); G[v].insert(r); } vector<vector<int>> event(r); rep(ib, b){ event[end[ib]].push_back(ib); } vector<int> selected_r; vector<int> selected_b; vector<int> cnt(b); rep(ir, r){ auto& vec = event[ir]; vector<int> odd; vector<int> even; for(auto ib : vec){ if(cnt[ib] % 2) odd.push_back(ib); else even.push_back(ib); } if(int(even.size()) + 1 < int(odd.size())){ for(int ib : odd) selected_b.push_back(ib); }else{ for(int ib : G[ir]) cnt[ib]++; for(int ib : even) selected_b.push_back(ib); selected_r.push_back(ir); } } // cout << cnt; cout << int(selected_b.size()) << ' ' << int(selected_r.size()) << "\n"; for(int ib : selected_b) cout << ib + 1 << ' '; cout << "\n"; for(int ir : selected_r) cout << ir + 1 << ' '; cout << "\n"; return 0; }; int main(){ int t; cin >> t; rep(_, t) solve(); return 0; }