제출 #200054

#제출 시각아이디문제언어결과실행 시간메모리
200054EntityITMeetings (JOI19_meetings)C++14
29 / 100
2379 ms1024 KiB
#include<bits/stdc++.h> #include "meetings.h" using namespace std; #define all(x) (x).begin(), (x).end() #define sz(x) ( (int)(x).size() ) using LL = long long; mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() ); int cnt = 0, n; void bridge(int u, int v) { ++cnt; assert(cnt < n); Bridge(min(u, v), max(u, v) ); } void solve(const vector<int> &vSet) { if (sz(vSet) == 1) return ; int l = vSet[0], r = vSet[1]; vector<int> path; map<int, vector<int> > nVSet; for (int i = 2; i < sz(vSet); ++i) { int u = vSet[i]; int pr = Query(l, r, u); if (pr == u) path.emplace_back(u); else nVSet[pr].emplace_back(u); } if (sz(path) ) { sort(all(path), [&](int u, int v) { return Query(l, u, v) == u; }); bridge(l, path[0]); bridge(r, path.back() ); for (int i = 0; i + 1 < sz(path); ++i) bridge(path[i], path[i + 1]); } else bridge(l, r); for (auto &aVSet : nVSet) { aVSet.second.insert(aVSet.second.begin(), aVSet.first); solve(aVSet.second); } } void Solve(int N) { n = N; vector<int> vSet(N); iota(all(vSet), 0); solve(vSet); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...