| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 965949 | anango | Mechanical Doll (IOI18_doll) | C++17 | 1 ms | 348 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 int long long
using namespace std;
int m;
int n;
int MAXN=1;
int depth=0;
vector<int> C;
vector<int> X;
vector<int> Y;
void update(int pos, int val) {
pos+=MAXN/2;
if (pos%2==0) {
X[pos] = val;
}
else {
Y[pos] = val;
}
pos/=2;
while (pos>1) {
int par=pos/2;
if (pos%2==0) {
X[par] = pos;
}
else {
Y[par] = pos;
}
pos=par;
}
}
int binrev(int v) {
unsigned int r = v;
int s = sizeof(v) * CHAR_BIT - 1;
for (v >>= 1; v; v >>= 1)
{
r <<= 1;
r |= v & 1;
s--;
}
r <<= s;
return r;
}
void create_circuit(signed M, vector<signed> A) {
int N = A.size();
N++;
A.push_back(0);
//top of the tree = 1
//sons of i are 2*i and 2*i+1
for (int i=1; i<100; i++) {
MAXN*=2;
if (MAXN>N) {
depth=i;
break;
}
}
int S=MAXN;
C=vector<int>(M+1);
X=vector<int>(S,1);
Y=vector<int>(S,1);
C[0] = -1;
int lef=MAXN/2;
int ri=N-MAXN;
for (int i=0; i<lef; i++) {
update(i,A[binrev(i)]);
}
for (int i=ri; i<MAXN; i++) {
update(i, A[i-ri+lef]);
}
vector<int32_t> C2(M+1,1);
vector<int32_t> X2(S,1);
vector<int32_t> Y2(S,1);
for (int i=0; i<C.size(); i++) {
C2[i] = C[i];
}
for (int i=0; i<X.size(); i++) {
X2[i] = X[i];
}
for (int i=0; i<Y.size(); i++) {
Y2[i] = Y[i];
}
answer(C2, X2, Y2);
}
Compilation message (stderr)
| # | 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... | ||||
