# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123025 | teki | Mechanical Doll (IOI18_doll) | C++11 | 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>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define mn 1000000
using namespace std;
int n,sw,p=1;
vector<int> x(1<<20),y(1<<20);
bitset <(1<<20)> b;
int build(int left, int right) {
if (left >= right) return 0;
else if (right < p-n) return -1;
int ts = sw;
sw++;
int mid = (left+right)/2;
x[ts-1] = build(left, mid);
y[ts-1] = build(mid+1, right);
return ts;
}
void pt (int i, int j) {
int a;
if (b[-i]) a = y[-i-1];
else a = x[-i-1];
b[-i] = !b[-i];
if (a <= 0) a = j;
else pt(a,j);
}
void create_circuit(int m, vector<int> a) {
n = (int)a.size();
while (p < n) p*=2;
build(0, p-1);
for (int i = 1; i<n; i++) pt(-1,a[i]);
if (n == 1) pt(-1,-1);
pt(-1,0);
vector<int> c(m+1, 1);
x.resize(sw);
y.resize(sw);
c[0] = a[0];
answer(c,x,y);
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
return 0;
}