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;
int n,temp;
bool func(int a,int b) {
return Query(temp,a,b) == a;
}
void Ans(int a,int b){
if(a > b) swap(a,b);
Bridge(a,b);
}
void sol(vector<int> v){
if(v.size() < 2) return;
//random_shuffle(v.begin(),v.end());
int a = v[0], b = v[1];
map<int,vector<int> > mp;
mp[a].push_back(a), mp[b].push_back(b);
vector<int> adj;
for(int i=2;i<v.size();i++){
int c = Query(a,b,v[i]);
if(!mp.count(c) ) adj.push_back(c);
mp[c].push_back(v[i]);
}
temp = a;
sort(adj.begin(), adj.end(), func);
int now = a;
for(auto x : adj) Ans(now,x), now = x;
Ans(now,b);
for(auto it : mp) sol(it.second);
}
void Solve(int N) {
n = N;
vector<int> v(n);
iota(v.begin(),v.end(),0);
sol(v);
}
Compilation message (stderr)
meetings.cpp: In function 'void sol(std::vector<int>)':
meetings.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | 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... |