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 Solve(int N) {
//force 0 to be the root
//for every C, we try every B to determine parenthood
vector<int> ancestors[N+7];
for (int C = 1; C < N; C++){
ancestors[C].push_back(0);
for (int B = 1; B < N; B++){
if (B == C) continue;
if (Query(0, B, C) == B){
ancestors[C].push_back(B);
}
}
}
/*
for (int x = 0; x < N; x++){
cout << "anc " << x << '\n';
for (auto y : ancestors[x]) cout << y << ' ';
cout << "\n\n";
}
* */
int par[N+7];
for (int C = 1; C < N; C++){
int largestPar = -1;
int largestParLoc = -1;
for (auto anc : ancestors[C]){
if ( ((int)(ancestors[anc].size())) >= largestPar){
largestPar = ancestors[anc].size();
largestParLoc = anc;
}
}
par[C] = largestParLoc;
}
for (int x = 1; x < N; x++){
//cerr << x << ' ' << par[x] << '\n';
if (x < par[x]) Bridge(x, par[x]);
else Bridge(par[x], x);
}
}
# | 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... |