Submission #463722

#TimeUsernameProblemLanguageResultExecution timeMemory
463722tomsydMechanical Doll (IOI18_doll)C++17
11 / 100
94 ms7988 KiB
#include "doll.h" #include<bits/stdc++.h> using namespace std; void create_circuit(int M, vector<int> A) { if (M == 1){ int pow2 = 1, N = A.size(); vector<int> C(M+1); if(N == 1){ vector<int> da,db; C[0] = 1; C[1] = 0; answer(C,da,db); return; } while (pow2 < N) pow2 *= 2; pow2 /= 2; vector<int> X(2*pow2-1,-1),Y(2*pow2-1,-1); for (int i=0; i<pow2-1; ++i){ X[i] = -(2*(i+1)); Y[i] = -(2*(i+1)+1); } C[0] = 1; C[1] = -1; int crt = N-1; if (crt > 1){ crt--; X[X.size()-1] = 1; } Y[Y.size()-1] = 0; int idx = X.size()-2; while (crt > 0){ X[idx] = 1; --crt; if (crt > 0){ --crt; Y[idx] = 1; } idx--; } answer(C,X,Y); return; } vector<int> C(M + 1); C[0] = A[0]; int N = A.size(); for (int i = 0; i<N-1; ++i) { C[A[i]] = A[i+1]; } C[A[N-1]] = 0; vector<int> X,Y; 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...