#include "bits/stdc++.h"
#include "plants.h"
using namespace std;
#define pb push_back
#define endl "\n"
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int N = 200005;
int pre[N][2];
// 0 >
// 1 <
int n;
int query(int l,int r)
{
l++;r++;
int uz=r-l;
if(pre[r-1][0]-pre[l-1][0]==uz) return 1;
if(pre[r-1][1]-pre[l-1][1]==uz) return -1;
int cur = pre[n][0] - pre[r-1][0] + pre[l-1][0];
if(cur==n-r+l) return -1;
cur = pre[n][1] - pre[r-1][1] + pre[l-1][1];
if(cur==n-r+l) return 1;
return 0;
}
void init(int k,vector<int> r) {
n = sz(r);
for(int i=1;i<=n;i++)
{
pre[i][0]+=pre[i-1][0];
pre[i][1]+=pre[i-1][1];
if(r[i-1]==0) pre[i][0]++;
else pre[i][1]++;
}
return;
}
int compare_plants(int x, int y){
return query(x,y);
}
# |
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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
42 ms |
4028 KB |
Output is correct |
7 |
Correct |
46 ms |
5504 KB |
Output is correct |
8 |
Correct |
60 ms |
8652 KB |
Output is correct |
9 |
Correct |
57 ms |
8692 KB |
Output is correct |
10 |
Correct |
59 ms |
8676 KB |
Output is correct |
11 |
Correct |
58 ms |
8652 KB |
Output is correct |
12 |
Correct |
63 ms |
8652 KB |
Output is correct |
13 |
Correct |
56 ms |
8652 KB |
Output is correct |
14 |
Correct |
58 ms |
8660 KB |
Output is correct |
# |
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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
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 |
Incorrect |
1 ms |
212 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 |
0 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 |
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 |
256 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 |
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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
42 ms |
4028 KB |
Output is correct |
7 |
Correct |
46 ms |
5504 KB |
Output is correct |
8 |
Correct |
60 ms |
8652 KB |
Output is correct |
9 |
Correct |
57 ms |
8692 KB |
Output is correct |
10 |
Correct |
59 ms |
8676 KB |
Output is correct |
11 |
Correct |
58 ms |
8652 KB |
Output is correct |
12 |
Correct |
63 ms |
8652 KB |
Output is correct |
13 |
Correct |
56 ms |
8652 KB |
Output is correct |
14 |
Correct |
58 ms |
8660 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |