This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using vi = V<int>;
const int nax = 2005;
vi can[nax];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int piv;
int cmp(int x, int y) {
// x < y
return Query(piv, x, y) == x;
}
void solve(vi A) {
if (sz(A) <= 1) return;
shuffle(begin(A), end(A), rng);
int u = A[0], v = A[1];
for(auto x : A) can[x] = {};
vi P;
can[u].pb(u); can[v].pb(v);
for(auto x : A) {
if (x == u || x == v) continue;
int r = Query(x, u, v);
if (r == x) P.pb(r);
can[r].pb(x);
}
piv = u;
stable_sort(begin(P), end(P), cmp);
P.insert(begin(P), u); P.pb(v);
for(int i = 1; i < sz(P); i++) Bridge(min(P[i], P[i-1]), max(P[i], P[i-1]));
for(auto i : P) solve(can[i]);
}
void Solve(int N) {
vi A(N); iota(begin(A), end(A), 0);
solve(A);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |