Submission #413391

#TimeUsernameProblemLanguageResultExecution timeMemory
413391Ahmadsm2005Mechanical Doll (IOI18_doll)C++14
9 / 100
160 ms11496 KiB
#include "doll.h" //#include "grader.cpp" #include<bits/stdc++.h> using namespace std; int seg[800002],state[800002],depth,TOTSTATE,X[800002],Y[800002]; void upd(int v,int idx=0,int DEPTH=0){ if(DEPTH==depth){ if(!state[idx]){ X[idx]=v,TOTSTATE++,state[idx]=1; } else{ state[idx]=0,TOTSTATE--,Y[idx]=v; } return; } if(!state[idx]){ state[idx]=1,TOTSTATE++,upd(v,idx*2+1,DEPTH+1); } else{ state[idx]=0,TOTSTATE--,upd(v,idx*2+2,DEPTH+1); } X[idx]=-(idx*2+2),Y[idx]=-(idx*2+3); } void create_circuit(int M,vector<int>A){ int Q=1; while(Q<=A.size()) Q*=2,depth++; if(M==-1){ int N = A.size(); vector<int> C(M + 1); C[0] = -1; for (int i = 1; i <= M; ++i) { C[i] = -1; } vector<int>X,Y; string s; while(N){ s+=('0'+N%2); N/=2; } reverse(s.begin(),s.end()); for(int i=0;i<s.size();i++){ if(s[i]=='1') X.push_back(1); else X.push_back(-1); if(i+1!=s.size()) Y.push_back((-i)-2); } Y.push_back(0); /*for(int i=0;i<X.size();i++) cout<<X[i]<<' '; cout<<endl; for(int i=0;i<Y.size();i++) cout<<Y[i]<<' ';*/ answer(C, X, Y); return; } vector<int> C(M + 1); for(int i=0;i<=M;i++) C[i]=-1; int TOT=Q; TOT--; depth--; reverse(A.begin(),A.end()); for(int i=0;i<A.size();i++){ upd(A[i]); TOT--; } while(TOT){ upd(-1); TOT--; } upd(0); vector<int>XX,YY; for(int i=0;i<Q-1;i++) XX.push_back(X[i]),YY.push_back(Y[i]); answer(C,XX,YY); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:26:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 | while(Q<=A.size())
      |       ~^~~~~~~~~~
doll.cpp:42:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 | for(int i=0;i<s.size();i++){
      |             ~^~~~~~~~~
doll.cpp:47:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 | if(i+1!=s.size())
      |    ~~~^~~~~~~~~~
doll.cpp:66:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 | for(int i=0;i<A.size();i++){
      |             ~^~~~~~~~~
#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...