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"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int p[2009];
void calc(int root, vector<int> all){
if(all.size() <= 1) return;
vector<pair<vector<int>, int>> groups;
for(auto u : all){
if(u == root) continue;
int put = 0;
for(auto &v : groups){
if(v.ss == u){
put = 1;
v.ff.pb(u);
continue;
}
int tmp = Query(root, u, v.ss);
if(tmp == root) continue;
put = 1;
v.ss = tmp;
v.ff.pb(u);
}
if(put == 0){
groups.pb({{u}, u});
}
}
for(auto v : groups){
p[v.ss] = root;
calc(v.ss, v.ff);
}
}
void Solve(int n){
vector<int> all;
for(int i = 0; i < n; ++i)
all.pb(i);
calc(0, all);
for(int i = 1; i < n; ++i)
Bridge(min(i, p[i]), max(i, p[i]));
}
# | 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... |