Submission #837949

#TimeUsernameProblemLanguageResultExecution timeMemory
837949tolbiMechanical Doll (IOI18_doll)C++17
37 / 100
200 ms20416 KiB
#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)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:18:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |  while (gez.size()<S+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...