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 "doll.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
vector<int>a;
int c[100005], x[400005], y[400005];
bool is[400005];
int m, k, la, q;
int tree[400005];
void go(int id, int l, int r){
if(l==r){
if (q==(1<<la))tree[id]=-(k+q);
else tree[id]=a[q+k-1];
return;
}
else tree[id]=-(k+id);
int mid=(l+r)/2;
if (!is[id]){
go(id*2, l, mid);
x[id+k]=tree[id*2];
is[id]=1;
}
else{
go(id*2+1, mid+1, r);
y[id+k]=tree[id*2+1];
is[id]=0;
}
}
void solve(){
la=0;
while((1<<(la+1))<=m+1)la++;
for (int i=1;i<(1<<la);i++){
c[a[i+k-1]]=-(k+1);
q=i;
go(1, 1, (1<<la));
}
q++;
go(1, 1, (1<<la));
m-=((1<<la)-1);
k+=((1<<la)-1);
if (m==0){
x[k+1]=-(k+1);
y[k+1]=0;
}
}
void create_circuit(int M, vector<int>A){
for (int i=1;i<=M;i++)c[i]=0;
a=A;
m=A.size();
while(m!=0){
solve();
}
vector<int>X, Y, C;
C.pb(-1);
for (int i=1;i<=M;i++){
C.pb(c[i]);
cout<<c[i]<<" ";
}
cout<<"\n";
for (int i=1;i<=A.size()+1;i++){
X.pb(x[i]);
cout<<x[i]<<" ";
}
cout<<"\n";
for (int i=1;i<=A.size()+1;i++){
Y.pb(y[i]);
cout<<y[i]<<" ";
}
cout<<"\n";
answer(C, X, Y);
}
Compilation message (stderr)
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for (int i=1;i<=A.size()+1;i++){
| ~^~~~~~~~~~~~
doll.cpp:65:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for (int i=1;i<=A.size()+1;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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |