# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
787046 | APROHACK | Mechanical Doll (IOI18_doll) | C++17 | 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 <bits/stdc++.h>
#include "doll.h"
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
int n, m, cur;
vector<int>c, x, y;
vector<int>a;
int generar(int desde, int cada, int div, bool lastt){
if(div == 0){
return a[desde];
}
if(a[desde] == -1 and ! lastt){
return a[desde];
}
int posi = cur;
int real = -(cur + 1);
x.pb(0);
y.pb(0);
cur ++ ;
x[posi] = generar(desde, cada*2, div-1, false);
y[posi] = generar(desde + cada, cada*2, div-1, lastt);
return real;
}
void create_circuit(int M, std::vector<int> A) {
cur = 0;
a = A;
n = A.size();
m = M;
c.pb(A[0]);
for(int i = 1 ; i <= M ; i ++)c.pb(-1);
int k = 1, pot = 0;
while(k <= a.size()-1 ){
k *= 2;
pot ++;
}
while(a.size()-1 < k)a.pb(-1);
a.pop_back();
a.push_back(0);
c[A[0]] = generar(1, 1, pot, true);
answer(c, x, y);
}
#include <bits/stdc++.h>
#include "doll.h"
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
int n, m, cur;
vector<int>c, x, y;
vector<int>a;
int generar(int desde, int cada, int div, bool lastt){
if(div == 0){
return a[desde];
}
if(a[desde] == -1 and ! lastt){
return a[desde];
}
int posi = cur;
int real = -(cur + 1);
x.pb(0);
y.pb(0);
cur ++ ;
x[posi] = generar(desde, cada*2, div-1, false);
y[posi] = generar(desde + cada, cada*2, div-1, lastt);
return real;
}
void create_circuit(int M, std::vector<int> A) {
cur = 0;
a = A;
n = A.size();
m = M;
c.pb(A[0]);
for(int i = 1 ; i <= M ; i ++)c.pb(-1);
int k = 1, pot = 0;
while(k <= a.size()-1 ){
k *= 2;
pot ++;
}
while(a.size()-1 < k)a.pb(-1);
a.pop_back();
a.push_back(0);
c[A[0]] = generar(1, 1, pot, true);
answer(c, x, y);
}