# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298724 | inbarin | Mechanical Doll (IOI18_doll) | C++14 | 135 ms | 8612 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 <iostream>
#include <vector>
using namespace std;
#define fort(s,e) for(int i = s; i < e; i++)
void create_circuit(int m, vector<int> a){
int asc = a.size();
a.push_back(0);
vector<int>trig(m+1);
vector<int>x,y;
int cs = 0;
fort(0,m+1){
trig[i] = -1;
}
int asp = 1;
vector<int>dec;
int jl = 0;
while(asc){
jl++;
asp*=2;
dec.push_back(asc%2);
asc/=2;
}
asc = a.size();
for(int i = 0; i < asp/2-1;i++){
x.push_back(-(i+1)*2);
y.push_back(-(i+1)*2-1);
}
for(int i = asp/2 - 1;i < asp - 1;i++){
x.push_back(-1);
y.push_back(-1);
}
int xl = asp / 2 - asc / 2;
int yl = asp / 2 - asc / 2 - asc % 2;
int l = 0;
for(int i = 0; i < asp;i++){
int ci = i;
int rev = 0;
int j = 0;
while(j < jl){
rev *= 2;
rev += ci % 2;
ci/=2;
j++;
}
if(rev % 2){
if(asp/2 - 1 - rev/2 < xl){
continue;
}
l++;
x[asp - 2 - rev/2] = a[(int)a.size()-l];
} else {
if(asp/2 - 1 - rev/2 < yl){
continue;
}
l++;
y[asp - 2 - rev/2] = a[(int)a.size()-l];
}
if(l == (int)a.size()){
break;
}
}
answer(trig,x,y);
return;
}
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... |