# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
601763 | enerelt14 | Mechanical Doll (IOI18_doll) | C++14 | 0 ms | 0 KiB |
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;
int x[40], y[40];
vector<int>a;
bool is[40];
int tree[100], q;
void go(int id, int l, int r){
if(l==r){
if (q==16)tree[id]=-(k+q);
else tree[id]=a[q];
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 create_circuit(int M, vector<int>A){
a=A;
vector<int>c, X, Y;
c.pb(a[0]);
for (int i=1;i<=M;i++)c.pb(-1);
for (int i=1;i<=16;i++){
q=i;
go(1, 1, 16);
}
x[16]=-16;
y[16]=0;
for (int i=1;i<=16;i++)X.pb(x[i]);
for (int i=1;i<=16;i++)Y.pb(y[i]);
answer(c, X, Y);
}