Submission #429241

#TimeUsernameProblemLanguageResultExecution timeMemory
429241peuchMechanical Doll (IOI18_doll)C++17
37 / 100
100 ms11236 KiB
#include "doll.h" #include<bits/stdc++.h> using namespace std; int n; int maxProf; vector<int> X, Y, V; int create(); int tree(int prof, int val, bool flag); void create_circuit(int M, vector<int> A) { n = A.size(); maxProf = log2(n + 1); if(__builtin_popcount(n + 1) != 1) maxProf++; vector<int> C (M + 1, -1); V = A; tree(0, 0, 1); // for(int i = 0; i < X.size(); i++){ // printf("%d %d\n", -i - 1, X[i]); // printf("%d %d\n", -i - 1, Y[i]); // } answer(C, X, Y); } int create(){ X.push_back(0); Y.push_back(0); return X.size() - 1; } int tree(int prof, int val, bool flag){ if(val >= n && !flag) return -1; if(prof == maxProf){ if(flag) return 0; return V[val]; } int cur = create(); int eVal = val, dVal = val + (1 << prof); int e = tree(prof + 1, eVal, 0); X[cur] = e; int d = tree(prof + 1, dVal, flag); Y[cur] = d; return -cur - 1; }
#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...