Submission #301533

#TimeUsernameProblemLanguageResultExecution timeMemory
301533TMJNMechanical Doll (IOI18_doll)C++17
53 / 100
138 ms15768 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; int c; vector<int>K; vector<int>X,Y,C; vector<vector<int>>P; int dfs(int num,int dep,vector<int>&v){ if(num+(1<<dep)>=v.size()){ return v[num]; } else{ int t=c; c++; int x=dfs(num,dep+1,v); int y=dfs(num+(1<<dep),dep+1,v); if(x==0xE869120&&y==0xE869120){ c--; return 0xE869120; } X[t]=x; Y[t]=y; return -t-1; } } void create_circuit(int M,vector<int>A){ c=0; K=A; K.push_back(0); reverse(K.begin(),K.end()); K.push_back(0); reverse(K.begin(),K.end()); P=vector<vector<int>>(M+1); C=vector<int>(M+1,0); X=Y=vector<int>(A.size()*2,0xE869120); for(int i=0;i<K.size()-1;i++){ P[K[i]].push_back(K[i+1]); } for(int i=0;i<=M;i++){ if(P[i].empty())continue; for(int j=0;;j++){ if(P[i].size()<=(1<<j)){ while(P[i].size()<(1<<j))P[i].push_back(0xE869120); for(int j=P[i].size()-1;;j--){ if(P[i][j]!=0xE869120){ swap(P[i][j],P[i].back()); break; } } int l,r; l=c; C[i]=dfs(0,0,P[i]); r=c; for(int k=l;k<r;k++){ if(X[k]==0xE869120){ X[k]=C[i]; } if(Y[k]==0xE869120){ Y[k]=C[i]; } } break; } } } while(!X.empty()&&X.back()==0xE869120){ X.pop_back(); Y.pop_back(); } vector<bool>B(400000,false); int p=0; vector<int>T; answer(C,X,Y); }

Compilation message (stderr)

doll.cpp: In function 'int dfs(int, int, std::vector<int>&)':
doll.cpp:11:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  if(num+(1<<dep)>=v.size()){
      |     ~~~~~~~~~~~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0;i<K.size()-1;i++){
      |              ~^~~~~~~~~~~
doll.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |    if(P[i].size()<=(1<<j)){
      |       ~~~~~~~~~~~^~~~~~~~
doll.cpp:46:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |     while(P[i].size()<(1<<j))P[i].push_back(0xE869120);
      |           ~~~~~~~~~~~^~~~~~~
doll.cpp:74:6: warning: unused variable 'p' [-Wunused-variable]
   74 |  int p=0;
      |      ^
#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...