Submission #1050236

#TimeUsernameProblemLanguageResultExecution timeMemory
1050236TahirAliyevComparing Plants (IOI20_plants)C++17
14 / 100
100 ms9964 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int MAX = 5005; int id[MAX]; int pre[MAX]; int n; int ask(int l, int r){ if(r < l){ return pre[n] - (pre[l - 1] - pre[r]); } return pre[r] - pre[l - 1]; } void init(int k, vector<int> r) { n = r.size(); vector<int> zer; r.insert(r.begin(), 0); for(int i = 1; i <= n; i++){ if(!r[i]) zer.push_back(i); } int t = n; while(zer.size()){ for(int i = 1; i <= n; i++){ pre[i] = pre[i - 1] + (!r[i]); } int f = 0, l = 0; for(int a : zer){ l = a - k + 1; if(l <= 0) l += n; if(!ask(l, a - 1)){ f = a; break; } } l = f - k + 1; if(l <= 0) l += n; r[f] = 1e9; id[f] = t--; for(int i = l; ; i++){ if(i == f) break; if(i > n){ i = 0; continue; } r[i]--; if(r[i] == 0) zer.push_back(i); } zer.erase(find(zer.begin(), zer.end(), f)); } // for(int i = 1; i <= n; i ++){ // cout << id[i] << ' '; // } // cout << '\n'; } int compare_plants(int x, int y) { x++, y++; if(id[x] > id[y]) return 1; else 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...