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"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
mt19937 rnd(time(NULL));
map<pair<int,pair<int,int> >,int> mp;
int get(int a,int b,int c){
if(a>b){
swap(a,b);
}
if(b>c){
swap(b,c);
}
if(a>b){
swap(a,b);
}
if(a==b || b==c){
return b;
}
if(mp.find({a,{b,c}})!=mp.end()){
return mp[{a,{b,c}}];
}
return mp[{a,{b,c}}]=Query(a,b,c);
}
void dc(vector<int>& v){
int n=v.size();
if(n<=1){
return;
}
if(n==2){
Bridge(min(v[0],v[1]),max(v[0],v[1]));
return;
}
int x=v[0],y=v[1];
map<int,vector<int> > m;
vector<int> g;
for(auto h:v){
int a=get(x,y,h);
m[a].push_back(h);
if(a==h){
g.push_back(h);
}
}
for(auto h:m){
dc(h.sc);
}
sort(g.begin(),g.end(),[&](int a,int b){
return get(x,a,b)==a;
});
for(int i=0;i+1<g.size();i++){
Bridge(min(g[i],g[i+1]),max(g[i],g[i+1]));
}
}
void Solve(int n){
vector<int> v(n);
iota(v.begin(),v.end(),0);
shuffle(v.begin(),v.end(),rnd);
dc(v);
}
Compilation message (stderr)
meetings.cpp: In function 'void dc(std::vector<int>&)':
meetings.cpp:55:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=0;i+1<g.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... |