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 "meetings.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void Answer(int x, int y)
{
if(x>y) swap(x,y);
Bridge(x,y);
}
void Solve(vector<int> v)
{
if(v.size()<2) return;
random_shuffle(v.begin(),v.end());
map<int,vector<int>> m;
m[v[0]].pb(v[0]);
m[v[1]].pb(v[1]);
vector<int> path;
for(int i=2;i<v.size();i++)
{
int x=Query(v[0],v[1],v[i]);
if(!m.count(x)) path.pb(x);
m[x].pb(v[i]);
}
sort(path.begin(),path.end(),[&](int x, int y){ return Query(v[0],x,y)==x;});
int last=v[0];
for(int x:path) Answer(last,x),last=x;
Answer(last,v[1]);
for(auto it:m)
{
Solve(it.second);
}
}
void Solve(int n)
{
srand(time(0));
vector<int> all(n);
for(int i=0;i<n;i++) all[i]=i;
Solve(all);
}
Compilation message (stderr)
meetings.cpp: In function 'void Solve(std::vector<int>)':
meetings.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=2;i<v.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... |