| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357017 | veyis_116 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t; cin>>t;
while(t--){
ll n; cin>>n;
ll a[n+1]; for(ll i=1;i<=n;i++) cin>>a[i];
ll pre[n+1]; pre[0]=0;
for(ll i=1;i<=n;i++){
if(a[i]>a[i+1]) pre[i]=pre[i-1]-1;
else pre[i]=pre[i-1];
}
while(m--){
ll l,r,v; cin>>l>>r;
if(pre[r-1]-pre[l-1]<0) cout<<1<<endl;
else cout<<0<<endl;
}
}
}
