#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> bigger, smaller;
vector<int> pfs;
void init(int K, std::vector<int> r) {
n = r.size();
k = K;
smaller.assign(n,0);
bigger = r;
for (int i = 0; i<n; i++) {
smaller[i] = k-1-bigger[i];
}
pfs = {0};
for (int i=0; i<n; i++) {
pfs.push_back(pfs.back() + bigger[i]);
}
return;
}
int compare_plants(int x, int y) {
int res = 0;
int f;
int ff;
if (x<y) {
f = pfs[y+1]-pfs[x];
ff = y+1-x;
}
else {
f = pfs[n]-pfs[x] + pfs[y+1];
ff = n-x+y+1;
}
int s;
int ss;
if (y<x) {
s = pfs[x+1]-pfs[y];
ss = x+1-y;
}
else {
s = pfs[n]-pfs[y] + pfs[x+1];
ss = n-y+x+1;
}
if (f == 0) res = 1;
if (f == ff) res = -1;
if (s == 0) res = -1;
if (s == ss) res = 1;
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |