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 <vector>
#include <map>
#include <algorithm>
#include "meetings.h"
using namespace std;
struct cmp{
int a;
cmp(int b){
a=b;
}
bool operator()(int x, int y){
if(x==a) return y!=a;
if(y==a) return false;
return Query(a, x, y)==x;
}
};
void SolveSubTree(vector<int> nodes){
if(nodes.size()<=1) return;
int a=nodes[0], b=nodes[1];
map<int, vector<int>> sts;
sts[a].push_back(a);
sts[b].push_back(b);
for(int j=2;j<nodes.size();++j){
int x = Query(a, b, nodes[j]);
sts[x].push_back(nodes[j]);
}
vector<int> path;
for(auto i:sts){
path.push_back(i.first);
}
sort(path.begin(), path.end(), cmp(a));
for(int i=1;i<path.size();++i){
int x=min(path[i-1], path[i]);
int y=max(path[i-1], path[i]);
Bridge(x, y);
}
for(auto i:sts){
SolveSubTree(i.second);
}
}
void Solve(int N) {
vector<int> s;
for(int i=0;i<N;++i) s.push_back(i);
SolveSubTree(s);
}
Compilation message (stderr)
meetings.cpp: In function 'void SolveSubTree(std::vector<int>)':
meetings.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=2;j<nodes.size();++j){
~^~~~~~~~~~~~~
meetings.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<path.size();++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... |