Submission #200055

#TimeUsernameProblemLanguageResultExecution timeMemory
200055EntityITMeetings (JOI19_meetings)C++14
29 / 100
2323 ms1144 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() ); void bridge(int u, int v) { 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) { if (u != l && u != r) 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) { 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...