Submission #296574

#TimeUsernameProblemLanguageResultExecution timeMemory
296574amiratouMechanical Doll (IOI18_doll)C++14
0 / 100
72 ms5044 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; int log_2(int x){ return 31-__builtin_clz(x); } bool state[270001]; int fi; void create_circuit(int M, vector<int> A) { int N = A.size(); int S=(1<<(log_2(N-1)+1))-1; vector<int> C(M + 1),X(S+1),Y(S+1); for (int i = 1; i <= S; ++i) { if((2*i)<=S)X[i]=-i*2; else{ X[i]=-i; if(!fi)fi=-i; } if((2*i+1)<=S)Y[i]=-i*2-1; else Y[i]=-i; } C[0]=-1,C[1]=-1; for (int i = 0; i < S+1; ++i) { int r=-1; while(r>fi){ state[-r]=(!state[-r]); if(state[-r])r=X[-r]; else r=Y[-r]; } //cerr<<r<<"\n"; if(i<N && i!=S){ if(!state[-r])X[-r]=1; else Y[-r]=1; } else if(i!=S){ if(!state[-r])X[-r]=-1; else Y[-r]=-1; } else{ if(!state[-r])X[-r]=0; else Y[-r]=0; } state[-r]=(!state[-r]); } /*for (int i = 1; i <= S; ++i) { cerr<<-i<<" : "; cerr<<X[i]<<","<<Y[i]<<"\n"; }*/ X.erase(X.begin()),Y.erase(Y.begin()); 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...