# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
837949 | tolbi | Mechanical Doll (IOI18_doll) | C++17 | 200 ms | 20416 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>
using namespace std;
#define coutarr(x) for(auto &it : x) cout<<it<<" ";cout<<endl;
#define tol(bi) (1LL<<((long long)(bi)))
void create_circuit(int M, vector<int> A) {
int n = A.size();
vector<int> X(tol(ceil(log2(n+1)))-1);
vector<int> Y(X.size());
int S = X.size();
for (int i = 0; i < S; i++){
X[i]=(i+1)*2;
Y[i]=(i+1)*2+1;
}
vector<int> gez;
vector<bool> swit(S,false);
int node = 1;
while (gez.size()<S+1){
if (node>S){
gez.push_back(node);
node=1;
}
else {
if (swit[node-1]) swit[node-1]=false;
else swit[node-1]=true;
if (!swit[node-1]){
node=Y[node-1];
}
else {
node=X[node-1];
}
}
}
map<int,int> mp;
for (int i = 0; i < n; ++i)
{
mp[gez[i]]=A[i];
}
mp[gez.back()]=0;
for (int i = 0; i < S; ++i)
{
if (mp.count(X[i])){
X[i]=mp[X[i]];
}
else if (X[i]<=S){
X[i]=-X[i];
}
else X[i]=-1;
if (mp.count(Y[i])){
Y[i]=mp[Y[i]];
}
else if (Y[i]<=S){
Y[i]=-Y[i];
}
else Y[i]=-1;
}
vector<int> C(M+1,-1);
answer(C,X,Y);
}
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... |