Submission #1081942

#TimeUsernameProblemLanguageResultExecution timeMemory
1081942woodComparing 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); for(int i = 0; i<n; i++){ int window = 0; for(int l = 0;l<k; l++){ window+=(r[l]==0); } int j; for(j = k; j<n+k; j++){ int pos = j%n; if(r[pos]==0&&window==0) goto found; window-=r[j-k]==0; window+=(r[pos]==0); } found: for(int l = 1; l<k; l++) r[(j-l+n)%n]--; r[j%n]=INT_MAX; ranking[j%n] = 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...