This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int n,m;
cin>>n>>m;
vector<int>a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
set<pair<int,int>> segments;
for(int i=0;i<n;){
int j=i;
while(j+1<n && a[j+1]>=a[j]){
j++;
}
segments.emplace(i,j);
i=j+1;
}
for(;m;m--){
int l, r;
cin>>l>>r;
l--;
r--;
auto it=segments.upper_bound({l,r});
if(it!=segments.begin()){
it--;
int lx=it->first;
int rx=it->second;
if(lx<=l && r<=rx){
cout<<1<<"\n";
} else {
cout<<0<<"\n";
}
}else{
assert(false);
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |