This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |