#include "plants.h"
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
vector<int>R;
int K, n;
vector<int>pref;
int getSum(int l, int r){
l++;
r++;
return pref[r] - pref[l-1];
}
void init(int k, std::vector<int> r) {
R = r;
K = k;
n = r.size();
pref.pb(0);
for(int i = 0 ; i < n ; i ++){
pref.pb(pref.back() + r[i]);
}
for(int i = 0 ; i < n ; i ++){
pref.pb(pref.back() + r[i]);
}
return;
}
int compare_plants(int x, int y) {
//cout << "ask " << x << " " << y << endl;
int ret = 0;
if(getSum(x, y-1) == 0 or getSum(y, x + n - 1) == (x+n - y)){
ret = 1;
}else if(getSum(x, y-1) == (y-x) or getSum(y, x + n-1) == 0){
ret = -1;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
37 ms |
3532 KB |
Output is correct |
7 |
Correct |
41 ms |
4136 KB |
Output is correct |
8 |
Correct |
57 ms |
7588 KB |
Output is correct |
9 |
Correct |
56 ms |
7640 KB |
Output is correct |
10 |
Correct |
56 ms |
7640 KB |
Output is correct |
11 |
Correct |
58 ms |
7616 KB |
Output is correct |
12 |
Correct |
60 ms |
7676 KB |
Output is correct |
13 |
Correct |
55 ms |
7600 KB |
Output is correct |
14 |
Correct |
59 ms |
7656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Incorrect |
1 ms |
296 KB |
Output isn't correct |
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 |
300 KB |
Output is correct |
3 |
Incorrect |
1 ms |
296 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 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 |
37 ms |
3532 KB |
Output is correct |
7 |
Correct |
41 ms |
4136 KB |
Output is correct |
8 |
Correct |
57 ms |
7588 KB |
Output is correct |
9 |
Correct |
56 ms |
7640 KB |
Output is correct |
10 |
Correct |
56 ms |
7640 KB |
Output is correct |
11 |
Correct |
58 ms |
7616 KB |
Output is correct |
12 |
Correct |
60 ms |
7676 KB |
Output is correct |
13 |
Correct |
55 ms |
7600 KB |
Output is correct |
14 |
Correct |
59 ms |
7656 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
300 KB |
Output is correct |
17 |
Incorrect |
1 ms |
296 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |