Submission #1045314

#TimeUsernameProblemLanguageResultExecution timeMemory
1045314mariaclaraComparing Plants (IOI20_plants)C++17
0 / 100
1 ms412 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mk make_pair #define pb push_back #define fr first #define sc second vector<int> h; void init(int k, vector<int> r) { int n = sz(r); h.resize(n); for(int i = 0; i < n; i++) r.pb(r[i]); for(int t = n; t >= 1; t--) { vector<int> to_erase; for(int i = 0, last = -k; i < 2*n; i++) { if(r[i] != 0) continue; if(i < n) { last = i; continue; } if(i - last >= k) to_erase.pb(i); } if(to_erase.empty()) break; for(int x : to_erase) { h[x%n] = t; for(int i = x; i > x-k; i--) r[i%n]--, r[i%n + n]--; } } return; } int compare_plants(int x, int y) { if(h[x] > h[y]) return 1; if(h[x] < h[y]) return -1; return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...