Submission #954852

#TimeUsernameProblemLanguageResultExecution timeMemory
954852Trisanu_DasMechanical Doll (IOI18_doll)C++17
37 / 100
57 ms11168 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; vector<int> seq, X, Y, C; int sz, dpth, layer; void dfs(int u, int d, int v){ if(d < dpth){ dfs(u * 2, d + 1, v); dfs(u * 2 + 1, d + 1, v + (1 << (d - 1))); X[u - 1] = -u * 2; Y[u - 1] = X[u - 1] - 1; }else{ X[u - 1] = (v >= sz - 1 ? -1 : seq[v]); if(v + (1 << (d - 1)) == (1 << dpth) - 1) Y[u - 1] = 0; else Y[u - 1] = (v + (1 << (d - 1)) >= sz - 1 ? -1 : seq[v + (1 << (d - 1))]); } } void create_circuit(int M, vector<int> A){ seq.clear(), X.clear(), Y.clear(), C.clear(); seq = A; sz = seq.size() + 1; dpth = log2(sz); if((1 << dpth) != sz) dpth++; layer = (1 << dpth) - 1; X.resize(layer), Y.resize(layer), C.resize(M + 1); dfs(1, 1, 0); for(int i = 0; i <= M; i++) C[i] = -1; answer(C, X, Y); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...