Submission #1029959

#TimeUsernameProblemLanguageResultExecution timeMemory
1029959happy_nodeComparing Plants (IOI20_plants)C++17
14 / 100
139 ms11980 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int MX=5005; bool vis[MX]; int N; vector<int> ord, rev; void init(int k, std::vector<int> r) { N=r.size(); vector<int> pos; for(int i=0;i<N;i++) if(!r[i]) pos.push_back(i); for(int i=0;i<N;i++) { int p=-1; for(int j=0;j+1<pos.size();j++) { if(pos[j+1]-pos[j]>=k) { p=pos[j+1]; } } if(p==-1) p=pos[0]; ord.push_back(p); for(int j=0;j<k;j++) { int np=p-j; if(np<0) np+=N; if(vis[np]) continue; r[np]-=1; } vis[p]=1; vector<int> npos; for(int j=0;j<N;j++) { if(vis[j]) continue; if(r[j]==0) npos.push_back(j); } swap(pos,npos); } rev.assign(N,0); for(int i=0;i<N;i++) rev[ord[i]]=i; } int compare_plants(int x, int y) { if(rev[x]<rev[y]) return 1; return -1; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int j=0;j+1<pos.size();j++) {
      |               ~~~^~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...