#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define X first
#define Y second
#define ALL(v) v.begin(),v.end()
#define SZ(a) ((int)a.size())
#define pb push_back
vector<int> R,sum;
int n;
void init(int k, vector<int> r)
{
R.swap(r),n=SZ(R);
R.insert(R.begin(),0);
sum=R;
for(int i=1;i<=n;++i)
sum[i]+=sum[i-1];
}
int compare_plants(int x, int y)
{
++x,++y;
int rt=1;
if(x>y)
swap(x,y),rt*=-1;
if(sum[y-1]-sum[x-1]==y-x||sum[n]-sum[y-1]+sum[x-1]==0)
return -rt;
if(sum[y-1]-sum[x-1]==0||sum[n]-sum[y-1]+sum[x-1]==n-y+x)
return rt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
60 ms |
3192 KB |
Output is correct |
7 |
Correct |
77 ms |
3320 KB |
Output is correct |
8 |
Correct |
105 ms |
5480 KB |
Output is correct |
9 |
Correct |
107 ms |
5480 KB |
Output is correct |
10 |
Correct |
105 ms |
5480 KB |
Output is correct |
11 |
Correct |
106 ms |
5480 KB |
Output is correct |
12 |
Correct |
103 ms |
5508 KB |
Output is correct |
13 |
Correct |
98 ms |
5420 KB |
Output is correct |
14 |
Correct |
98 ms |
5608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
416 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
60 ms |
3192 KB |
Output is correct |
7 |
Correct |
77 ms |
3320 KB |
Output is correct |
8 |
Correct |
105 ms |
5480 KB |
Output is correct |
9 |
Correct |
107 ms |
5480 KB |
Output is correct |
10 |
Correct |
105 ms |
5480 KB |
Output is correct |
11 |
Correct |
106 ms |
5480 KB |
Output is correct |
12 |
Correct |
103 ms |
5508 KB |
Output is correct |
13 |
Correct |
98 ms |
5420 KB |
Output is correct |
14 |
Correct |
98 ms |
5608 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |