#include <bits/stdc++.h>
#ifndef SKY
#include "plants.h"
#endif // SKY
using namespace std;
#define N 400010
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back
int k,n,sum[N],a[N];
void init(int cc, vector<int> r)
{
k=cc;
n=r.size();
for(int i=0;i<n;i++)
{
a[i]=r[i];
a[i+n]=r[i];
}
for(int i=1;i<n*2;i++)
sum[i]+=a[i]+sum[i-1];
//cout<<sum[n-1]<<endl;
}
int compare_plants(int x, int y)
{
//cout<<x<<" "<<y<<endl;
if(x<y)
{
//cout<<sum[3]<<" "<<(x>0 ? sum[x-1] : 0)<<endl;
if(sum[y-1]-(x>0 ? sum[x-1] : 0)==0)
return 1;
if(sum[y-1]-(x>0 ? sum[x-1] : 0)==y-x)
return -1;
if(sum[x+n-1]-(y>0 ? sum[y-1] : 0)==0)
return -1;
if(sum[x+n-1]-(y>0 ? sum[y-1] : 0)==(x+n)-y)
return 1;
}else
{
swap(x,y);
if(sum[y-1]-(x>0 ? sum[x-1] : 0)==0)
return -1;
if(sum[y-1]-(x>0 ? sum[x-1] : 0)==y-x)
return 1;
if(sum[x+n-1]-(y>0 ? sum[y-1] : 0)==0)
return 1;
if(sum[x+n-1]-(y>0 ? sum[y-1] : 0)==(x+n)-y)
return -1;
}
return 0;
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
vector<int>r(n);
for(int i=0;i<n;i++)
cin>>r[i];//,cout<<r[i]<<endl;
init(k,r);
int q;
cin>>q;
while(q--)
{
int x,y;
cin>>x>>y;
cout<<compare_plants(x,y)<<endl;
}
return 0;
}
#endif
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Incorrect |
1 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 |
1 ms |
308 KB |
Output is correct |
3 |
Incorrect |
1 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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
4 |
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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |