#include "plants.h"
#include <bits/stdc++.h>
#define N 200005
using namespace std;
int pre[2*N];
int revpre[2*N];
int n;
void init(int k, vector<int> r){
n = r.size();
for(int i = 0;i<n;i++){
pre[i] = r[i];
revpre[i] = !r[i];
if(i){
pre[i] += pre[i-1];
revpre[i] += revpre[i-1];
}
}
for(int i = 0;i<n;i++){
pre[i+n] = r[i];
revpre[i+n] = !r[i];
pre[i+n] += pre[i+n-1];
revpre[i+n] += revpre[i+n-1];
}
return;
}
int get(int l,int r){
return pre[r] - (l == 0?0:pre[l-1]);
}
int get2(int l,int r){
return revpre[r] - (l == 0?0:revpre[l-1]);
}
int compare_plants(int x, int y) {
if(get(x,y-1) == 0){
return 1;
}
if(get2(x,y-1) == 0){
return -1;
}
if(get(y,x+n-1) == 0){
return -1;
}
if(get2(y,x+n-1) == 0){
return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
59 ms |
4024 KB |
Output is correct |
7 |
Correct |
52 ms |
5676 KB |
Output is correct |
8 |
Correct |
75 ms |
10188 KB |
Output is correct |
9 |
Correct |
71 ms |
10220 KB |
Output is correct |
10 |
Correct |
71 ms |
10184 KB |
Output is correct |
11 |
Correct |
79 ms |
10224 KB |
Output is correct |
12 |
Correct |
88 ms |
10180 KB |
Output is correct |
13 |
Correct |
62 ms |
10188 KB |
Output is correct |
14 |
Correct |
66 ms |
10184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
312 KB |
Output is correct |
2 |
Correct |
1 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
312 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
59 ms |
4024 KB |
Output is correct |
7 |
Correct |
52 ms |
5676 KB |
Output is correct |
8 |
Correct |
75 ms |
10188 KB |
Output is correct |
9 |
Correct |
71 ms |
10220 KB |
Output is correct |
10 |
Correct |
71 ms |
10184 KB |
Output is correct |
11 |
Correct |
79 ms |
10224 KB |
Output is correct |
12 |
Correct |
88 ms |
10180 KB |
Output is correct |
13 |
Correct |
62 ms |
10188 KB |
Output is correct |
14 |
Correct |
66 ms |
10184 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |