#include "plants.h"
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll , ll > ii;
typedef pair<ii,ll> tri;
const ll mod=1e9+7;
const ll MAX=1e6;
ll A[MAX];
ll n;
void init(ll k, std::vector<ll> s) {
A[1]=s[0];
n=sz(s);
for(int i=2; i<=2*n+1; i++){
A[i]=A[i-1]+s[(i-1)%n];
}
return;
}
ll lock(ll l, ll r){
return A[r]-A[l-1];
}
ll compare_plants(ll x, ll y) {
x++;
y++;
if(x<=y){
ll a=lock(x,y-1);
if(a==y-x){
return -1;
}
if(a==0){
return 1;
}
//cout<<"nel"<<'\n';
x+=n;
ll b=lock(y,x-1);
if(b==x-y){
return 1;
}
if(b==0){
return -1;
}
}
else{
ll a=lock(y,x-1);
//cout<<a<<'\n';
if(a==x-y){
return 1;
}
if(a==0){
return -1;
}
//cout<<"nel"<<'\n';
y+=n;
ll b=lock(x,y-1);
//cout<<b<<'\n';
if(b==y-x){
//cout<<"aja"<<'\n';
return -1;
}// queseso?
if(b==0){
return 1;
}
}
return 0;
}
/*
int main(){
vector<ll>c;
ll a, q,b;
cin>>n>>q;
for(int i=0; i<n; i++) {
cin>>a;
c.pb(a);
}
init(2, c);
for(int i=0; i<n*2; i++){
cout<<A[i]<<' ';
}
cout<<endl;
while(q--){
cin>>a>>b;
cout<<compare_plants(a, b)<<'\n';
}
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
30 ms |
4048 KB |
Output is correct |
7 |
Correct |
37 ms |
5732 KB |
Output is correct |
8 |
Correct |
48 ms |
8788 KB |
Output is correct |
9 |
Correct |
43 ms |
8784 KB |
Output is correct |
10 |
Correct |
45 ms |
8792 KB |
Output is correct |
11 |
Correct |
41 ms |
8796 KB |
Output is correct |
12 |
Correct |
43 ms |
8784 KB |
Output is correct |
13 |
Correct |
44 ms |
8788 KB |
Output is correct |
14 |
Correct |
42 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
30 ms |
4048 KB |
Output is correct |
7 |
Correct |
37 ms |
5732 KB |
Output is correct |
8 |
Correct |
48 ms |
8788 KB |
Output is correct |
9 |
Correct |
43 ms |
8784 KB |
Output is correct |
10 |
Correct |
45 ms |
8792 KB |
Output is correct |
11 |
Correct |
41 ms |
8796 KB |
Output is correct |
12 |
Correct |
43 ms |
8784 KB |
Output is correct |
13 |
Correct |
44 ms |
8788 KB |
Output is correct |
14 |
Correct |
42 ms |
8912 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |