제출 #173066

#제출 시각아이디문제언어결과실행 시간메모리
173066LinusTorvaldsFanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
3028 ms10228 KiB
#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; vector<int>lefts; vector<int>rights; for(int i=0;i<n;){ int j=i; while(j+1<n && a[j+1]>=a[j]){ j++; } //segments.emplace(i,j); lefts.emplace_back(i); rights.emplace_back(j); i=j+1; } for(;m;m--){ int l, r,k; cin>>l>>r>>k; l--; r--; //auto it=segments.upper_bound({l,r}); auto it1=upper_bound(lefts.begin(),lefts.end(),l)-lefts.begin(); auto it2=upper_bound(rights.begin(),rights.end(),r)-rights.begin(); if(it1==it2){ cout<<1<<"\n"; } else { cout<<0<<"\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...