This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
void Ans(int u, int v){
if (u < v) Bridge(u, v);
else Bridge(v, u);
}
void Solve(vector <int> v){
if (v.size() < 2) return;
random_shuffle(v.begin(), v.end());
int l = v[0], r = v[1];
map <int, vector <int>> m;
m[l].push_back(l);
m[r].push_back(r);
vector <int> path;
for (auto k : v){
if (k == l || k == r) continue;
int x = Query(l, r, k);
if (!m.count(x)) path.push_back(x);
m[x].push_back(k);
}
sort(path.begin(), path.end(), [&](int x, int y){
return Query(v[0], x, y) == x;
});
for (auto k : path) Ans(l, k), l = k;
Ans(l, r);
for (auto it : m) Solve(it.second);
}
void Solve(int n){
srand(time(0));
vector <int> cur(n, 0);
for (int i = 1; i < n; ++ i) cur[i] = i;
Solve(cur);
}
# | 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... |