# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885731 | JakobZorz | Mechanical Doll (IOI18_doll) | C++17 | 117 ms | 13344 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<algorithm>
using namespace std;
vector<int>sx,sy;
vector<int>arr;
int new_switch(){
sx.push_back(0);
sy.push_back(0);
return(int)sx.size()-1;
}
pair<vector<int>,vector<int>>split(vector<int>vec){
pair<vector<int>,vector<int>>res;
for(int i=0;i<vec.size();i++){
if(i%2==0)
res.first.push_back(vec[i]);
else
res.second.push_back(vec[i]);
}
return res;
}
int build(vector<int>exits){
if(exits.size()==1)
return exits[0];
int root=new_switch();
pair<vector<int>,vector<int>>res=split(exits);
sx[root]=build(res.first);
sy[root]=build(res.second);
return -root-1;
}
void create_circuit(int m,vector<int>_arr){
arr=_arr;
int n=(int)arr.size();
vector<int>ans(m+1);
vector<int>exits=arr;
exits.push_back(0);
reverse(exits.begin(),exits.end());
int pow2=1;
while(pow2<(int)exits.size())
pow2*=2;
while(exits.size()<pow2)
exits.push_back(-1);
reverse(exits.begin(),exits.end());
int root=build(exits);
for(int&i:ans)
i=root;
answer(ans,sx,sy);
}
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... |