Submission #1081882

#TimeUsernameProblemLanguageResultExecution timeMemory
1081882woodComparing Plants (IOI20_plants)C++17
0 / 100
0 ms348 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> vi ranking; void init(int k, std::vector<int> r) { int n = r.size(); ranking.resize(n); bool done[n]; memset(done,0,sizeof done); for(int i = 0; i<n; i++){ int window = 0; for(int j = 0; j<k; j++){ window+=r[j+1]==0; r[j]--; r[j] = max(r[j],0); } int j = 0; if(!done[0]&&window==0) goto found; for(j = 1;j<n; j++){ window+=r[(j+k-1)%n]==0; window-=r[j-1]==0; r[(j+k-1)%n]--; r[(j+k-1)%n] = max(r[(j+k-1)%n],0); r[j-1]++; if(done[j]) continue; if(window==0) goto found; } found: done[j] = true; ranking[j] = i; } } int compare_plants(int x, int y) { if(ranking[x]<ranking[y]) return 1; return -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...
#Verdict Execution timeMemoryGrader output
Fetching results...