This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// vaghan ide i nadaram chi benevisam dige :/
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
const int maxn5 = 2e5 + 10;
int n, ps[maxn5];
int get_sum(int l, int r){
if(l < r)
return ps[r - 1] - (l ? ps[l - 1] : 0);
return (r ? ps[r - 1] : 0) + ps[n - 1] - ps[l - 1];
}
void init(int k, vector<int> r) {
n = r.size();
ps[0] = r[0];
for(int i = 1; i < n; i++)
ps[i] = r[i] + ps[i - 1];
return;
}
int compare_plants(int x, int y) {
int sum = get_sum(x, y);
if(sum == 0)
return 1;
if(sum == (y - x + n) % n)
return -1;
sum = get_sum(y, x);
if(sum == 0)
return -1;
if(sum == (x - y + n) % n)
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... |