結果
問題 | No.2900 Star Divine |
ユーザー | 👑 binap |
提出日時 | 2024-09-21 03:51:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 3,150 bytes |
コンパイル時間 | 4,134 ms |
コンパイル使用メモリ | 270,028 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2024-09-21 03:51:29 |
合計ジャッジ時間 | 5,724 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,248 KB |
testcase_01 | AC | 58 ms
5,376 KB |
testcase_02 | AC | 61 ms
5,376 KB |
testcase_03 | AC | 77 ms
6,940 KB |
testcase_04 | AC | 73 ms
5,376 KB |
testcase_05 | AC | 87 ms
10,368 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 74 ms
5,376 KB |
testcase_08 | AC | 74 ms
8,704 KB |
testcase_09 | AC | 42 ms
5,376 KB |
ソースコード
#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(u); } 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; }