#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
vector<int> ps;
void init(int k, vector<int> r) {
n = r.size();
a = r;
assert(k == 2);
ps.resize(n);
ps[0] = a[0];
for (int i = 1; i < n; ++i) {
ps[i] = ps[i - 1] + a[i];
}
}
int compare_plants(int x, int y) {
assert(x != y);
int disxy = x < y ? y - x : n - (x - y);
int disyx = y < x ? x - y : n - (y - x);
int mn = min(x, y);
int mx = max(x, y);
int frsum = ps[mx - 1] - (mn ? ps[mn - 1] : 0);
int bcksum = ps[n - 1] - frsum;
//cout << disxy << ' ' << disyx << ' ' << frsum << ' ' << bcksum << endl;
if (x < y) {
if (frsum == 0) return 1;
if (frsum == disxy) return -1;
if (bcksum == 0) return -1;
if (bcksum == disyx) return 1;
return 0;
} else {
if (frsum == 0) return -1;
if (frsum == disxy) return 1;
if (bcksum == 0) return 1;
if (bcksum == disyx) return -1;
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
41 ms |
4020 KB |
Output is correct |
7 |
Correct |
44 ms |
5540 KB |
Output is correct |
8 |
Correct |
58 ms |
8660 KB |
Output is correct |
9 |
Correct |
57 ms |
8676 KB |
Output is correct |
10 |
Correct |
58 ms |
8668 KB |
Output is correct |
11 |
Correct |
66 ms |
8640 KB |
Output is correct |
12 |
Correct |
58 ms |
8672 KB |
Output is correct |
13 |
Correct |
57 ms |
8660 KB |
Output is correct |
14 |
Correct |
70 ms |
8624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
41 ms |
4020 KB |
Output is correct |
7 |
Correct |
44 ms |
5540 KB |
Output is correct |
8 |
Correct |
58 ms |
8660 KB |
Output is correct |
9 |
Correct |
57 ms |
8676 KB |
Output is correct |
10 |
Correct |
58 ms |
8668 KB |
Output is correct |
11 |
Correct |
66 ms |
8640 KB |
Output is correct |
12 |
Correct |
58 ms |
8672 KB |
Output is correct |
13 |
Correct |
57 ms |
8660 KB |
Output is correct |
14 |
Correct |
70 ms |
8624 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
18 |
Halted |
0 ms |
0 KB |
- |