#include<bits/stdc++.h>
#define MAXN 200007
using namespace std;
int n,perm[MAXN],k,minpos,maxpos;
int pref[MAXN],sum,inv;
void init(int K,vector<int> R){
n=int(R.size()); k=K;
for(int i=0;i<n;i++){
pref[i+1]=R[i];
pref[i+1]+=pref[i];
sum+=R[i];
}
}
int compare_plants(int x, int y){
if(x>y){
swap(x,y); inv=-1;
}else{
inv=1;
}
x++; y++;
if(pref[y-1]-pref[x-1]==0)return 1*inv;
if(pref[y-1]-pref[x-1]==y-x)return -1*inv;
if(sum-(pref[y-1]-pref[x-1])==0)return -1*inv;
if(sum-(pref[y-1]-pref[x-1])==n-(y-x))return 1*inv;
return 0;
}
/*
int main(){
init(1,{1,0,0,1,0,0});
cout<<compare_plants(0,4)<<"\n";
cout<<compare_plants(1,3)<<"\n";
cout<<compare_plants(2,1)<<"\n";
cout<<compare_plants(2,0)<<"\n";
cout<<compare_plants(3,4)<<"\n";
}
*/
# |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
37 ms |
4024 KB |
Output is correct |
7 |
Correct |
42 ms |
5408 KB |
Output is correct |
8 |
Correct |
54 ms |
7916 KB |
Output is correct |
9 |
Correct |
55 ms |
7884 KB |
Output is correct |
10 |
Correct |
56 ms |
7888 KB |
Output is correct |
11 |
Correct |
54 ms |
7900 KB |
Output is correct |
12 |
Correct |
55 ms |
7884 KB |
Output is correct |
13 |
Correct |
60 ms |
7908 KB |
Output is correct |
14 |
Correct |
53 ms |
7900 KB |
Output is correct |
# |
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 |
Incorrect |
0 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 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
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 |
0 ms |
212 KB |
Output isn't correct |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
37 ms |
4024 KB |
Output is correct |
7 |
Correct |
42 ms |
5408 KB |
Output is correct |
8 |
Correct |
54 ms |
7916 KB |
Output is correct |
9 |
Correct |
55 ms |
7884 KB |
Output is correct |
10 |
Correct |
56 ms |
7888 KB |
Output is correct |
11 |
Correct |
54 ms |
7900 KB |
Output is correct |
12 |
Correct |
55 ms |
7884 KB |
Output is correct |
13 |
Correct |
60 ms |
7908 KB |
Output is correct |
14 |
Correct |
53 ms |
7900 KB |
Output is correct |
15 |
Correct |
0 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 |
- |