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"
int col[2005];
int n;
using namespace std;
void solve(int par, int sz){
//printf("solving %d %d\n",par,sz);
vector<int> v(sz);
int ct = 0;
for (int i = 0; i < n; i++){
if (col[i] == par) {
col[i] = -2;
//printf("%d matches %d\n",i,par);
v[ct++] = i;
}
if (sz == 1 && ct == 1){
col[v[0]] = -1;
return;
}
if (sz == 2 && ct == 2){
if (v[0] > v[1]) swap(v[0],v[1]);
Bridge(v[0],v[1]);
col[v[0]] = col[v[1]] = -1;
return;
}
}
//printf("%d %d\n",sz,ct);
assert(ct == sz);
//printf("solving ");
//for (auto x : v) printf("%d ",x);
//printf("\n");
random_shuffle(v.begin(),v.end());
int p = v[0], q = v[1];
//printf("cur %d, root %d\n",cur,root);
int lct = 1, rct = 1;
for (auto x : v){
if (x == p || x == q) continue;
int Q = Query(p,q,x);
if (Q != p) {
q = Q;
}
else{
//printf("%d is p\n",x);
col[x] = p;
lct++;
}
}
//printf("set <%d,%d>\n",p,q);
Bridge(min(p,q),max(p,q));
for (auto x : v){
if (x == q || x == p) continue;
if (col[x] == -2) {
col[x] = q; rct++;
}
}
col[p] = p;
col[q] = q;
solve(p,lct);
solve(q,rct);
}
void Solve(int N) {
n = N;
for (int i = 0; i < N; i++) col[i] = 0;
solve(0,n);
}
# | 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... |