# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
359950 | Sorting | Comparing Plants (IOI20_plants) | C++17 | 97 ms | 7276 KiB |
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;
const int N = 2e5 + 3;
int r[N], cnt[N], k, n;
void init(int _k, vector<int> _r) {
k = _k;
n = _r.size();
for(int i = 0; i < _r.size(); ++i)
r[i] = _r[i];
cnt[0] = 1;
for(int i = 1; i < n; ++i)
cnt[i] = (r[i] == r[i - 1]) ? cnt[i - 1] + 1 : 1;
if(r[0] == r[n - 1] && cnt[n - 1] != n){
int i = 0;
while(r[i] == r[0]){
cnt[i] += cnt[n - 1];
i++;
}
}
}
int compare_plants(int x, int y) {
if(cnt[y - 1] >= y - x) return r[x] ? -1 : 1;
if(cnt[(x - 1 + n) % n] >= x + n - y) return r[y] ? 1 : -1;
return 0;
}
Compilation message (stderr)
# | 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... |