This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include "meetings.h"
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define X first
#define Y second
#define SZ(x) (int)(x).size()
unsigned seed=12345;
long long rnd(){
seed=seed^(seed<<7);
seed=seed^(seed>>4);
seed=seed^(seed>>3);
return seed;
}
map<vector<int>,int>mp;
int n;
int query(int a,int b,int c){
vector<int>vc={a,b,c};
sort(vc.begin(),vc.end());
if(vc[0]==vc[1]){return vc[0];}
if(vc[1]==vc[2]){return vc[2];}
if(mp[vc]){return mp[vc];}
mp[vc]=Query(vc[0]-1,vc[1]-1,vc[2]-1)+1;
return mp[vc];
}
set<pair<int,int>>ans;
int finmid(vector<int>&vc){
int a=rnd()%vc.size();
int b=rnd()%vc.size();
if(b==a){b++;b%=vc.size();}
int c=rnd()%vc.size();
if(c==a){
c++;c%=vc.size();
}
if(c==b){
c++;c%=vc.size();
}
return query(vc[0],vc[1],vc[2]);
}
void slv(vector<int>vc){
if(vc.size()==1){return;}
if(vc.size()==2){
ans.insert({min(vc[0],vc[1]),max(vc[0],vc[1])});
return;
}
random_shuffle(vc.begin(),vc.end());
random_shuffle(vc.begin(),vc.end());
vector<int>vcb;vector<int>vca;
int md=vc[0];
int w=vc[1];
//md=query(vc[0],vc[1],vc[2]);
/*
for(int i=0;i<vc.size();i++){
if(vc[i]==md){
swap(vc[i],vc[0]);
}
}
*/
set<int>st;
st.insert(w);
for(int i=2;i<vc.size();i++){
int v=vc[i];
if(v==w){
st.insert(v);
continue;
}
int vv=query(md,w,v);
if(vv==md){continue;}
st.insert(vc[i]);
w=vv;
}
for(int i=0;i<vc.size();i++){
if(st.find(vc[i])!=st.end()){
vca.push_back(vc[i]);
}else{
vcb.push_back(vc[i]);
}
}
ans.insert({min(md,w),max(md,w)});
slv(vca);
slv(vcb);
}
void Solve(int N){
n=N;
vector<int>vc;
for(int i=1;i<=n;i++){
vc.push_back(i);
}
slv(vc);
for(auto it=ans.begin();it!=ans.end();it++){
Bridge((*it).first-1, (*it).second-1);
}
}
Compilation message (stderr)
meetings.cpp: In function 'void slv(std::vector<int>)':
meetings.cpp:68:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for(int i=2;i<vc.size();i++){
| ~^~~~~~~~~~
meetings.cpp:79:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for(int i=0;i<vc.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... |