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>
#define MAX 305000
void create_circuit(int M, std::vector<int> A);
void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y);
bool tab[MAX*4];
std::vector<int> segue;
std::vector<int> con[MAX*4];
int indice[MAX];
int count=0;
int max=0;
void gera_ordem(int l,int r,int pos=1){
if(l==r){
// std::cout<<l<<" "<<segue[count]<<"\n";
indice[l]=segue[count];
++count;
return;
}
int m = (l+r)/2;
if(!tab[pos]){
gera_ordem(l,m,pos*2);
}else gera_ordem(m+1,r,(pos*2)+1);
tab[pos]=!tab[pos];
}
void build(int l,int r,int pos=1){
if(l==r)return;
int m =(l+r)/2;
max=std::max(max,pos);
// std::cout<<pos<<" "<<l<<" "<<r<<" "<<m<<"\n";
if(l!=m)
con[pos].push_back(-(pos*2));
else con[pos].push_back(indice[l]);
if(r!=m+1)
con[pos].push_back(-((pos*2)+1));
else con[pos].push_back(indice[r]);
//std::cout<<indice[l]<<" "<<indice[r]<<"\n";
// std::cout<<"Forja "<< con[pos][0]<<" "<<con[pos][1]<<"\n";
build(l,m,pos*2);
build(m+1,r,(pos*2)+1);
}
void create_circuit(int M, std::vector<int> A) {
int begin = A[0];
{
std::vector<int> novA;
for(int i=1;i!=A.size();++i)novA.push_back(A[i]);
A=novA;
}
int obj=0;
for(int i=1;;i*=2){
if(i>A.size()){
obj=i;break;
}
}
while(A.size()<obj-1){
A.push_back(-1);
}
A.push_back(0);
int N = A.size();
segue=A;
for(int i=0;i!=N;++i){
gera_ordem(0,N-1);
}
build(0,N-1);
std::vector<int> emp;
for(int i=0;i!=M+1;++i)emp.push_back(-1);
emp[0]=begin;
std::vector<int> a,b;
for(int i=1;i<=max;++i){
// std::cout<<con[i].size()<<"!!\n";
a.push_back(con[i][0]);
b.push_back(con[i][1]);
// std::cout<<i<<" "<<con[i][0]<<"\n";
// std::cout<<i<<" "<<con[i][1]<<"\n";
}
answer(emp,a,b);
}
Compilation message (stderr)
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i=1;i!=A.size();++i)novA.push_back(A[i]);
| ~^~~~~~~~~~
doll.cpp:55:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | if(i>A.size()){
| ~^~~~~~~~~
doll.cpp:59:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
59 | while(A.size()<obj-1){
| ~~~~~~~~^~~~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |