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>
#define int long long
using namespace std;
const int N=1e6+5;
int n,m, tree[4*N], a[N];
struct book{
int x, mood, ind;
};
struct books {
int x, y;
int sum;
bool operator<(books const& other) {
return y < other.y;
}
};
int ans[N];
vector<book> q[N];
vector<books> v;
stack<int> st;
void update(int i, int x, int y, int k, int val){
if(y<k || x>k) return;
if(k>=x && k<=y) {
tree[i]=max(tree[i], val);
if(x==y) return;
}
int mid=(x+y)/2;
update(2*i+1, x, mid, k, val);
update(2*i+2, mid+1, y, k,val);
}
int getmax(int i, int x, int y, int l , int r){
if(r<x || l>y) return 0;
if(x>=l && y<=r) return tree[i];
int mid=(x+y)/2;
if(x!=y){
return max(getmax(2*i+1,x, mid , l, r), getmax(2*i+2, mid+1, y, l, r));
}
return 0;
}
main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>m;
for(int i=0; i<n; i++){
cin>>a[i];
}
for(int i=0; i<m; i++){
int l, r, k;
cin>>l>>r>>k;
l--; r--;
//q[r].push_back({l,k,i});
}
/*
for(int i=n-1; i>=0; i--){
while(st.size()!=0 && a[st.top()]<a[i]){
v.push_back({i, st.top(), a[i]+a[st.top()] });
st.pop();
}
st.push(i);
}
v.push_back({n+1, n+1, n+1});
/*
//sort(v.begin(), v.end());
/*for(int j=0; j<min(n,v[0].y); j++){
for(auto k: q[j]){
int mx=getmax(0,0,n-1,k.x, j);
//cout<<i<<" "<<k.x<<" "<<k.mood<<" "<<k.ind<<" "<<mx<<endl;
if(mx<=k.mood) ans[k.ind]=1;
else ans[k.ind]=0;
}
}
for(int i=0; i<v.size()-1; i++){
//update(0,0,n-1,v[i].x, v[i].sum);
//for(int j=v[i].y; j<v[i+1].y; j++){
int j=v[i].y;
for(auto k: q[j]){
//int mx=getmax(0,0,n-1,k.x, j);
int mx=5;
if(mx<=k.mood) ans[k.ind]=1;
else ans[k.ind]=0;
}
//}
}
*/
for(int i=0; i<m; i++){
cout<<ans[i]<<endl;
}
}
/*
i wanna win a medal in IZHO
wir werden gegen unser schickas ankampfen
if you watch shingeki no kyojin(AOT) you can take my code
*/
Compilation message (stderr)
sortbooks.cpp:62:2: warning: "/*" within comment [-Wcomment]
62 | /*
|
sortbooks.cpp:66:2: warning: "/*" within comment [-Wcomment]
66 | /*for(int j=0; j<min(n,v[0].y); j++){
|
sortbooks.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
40 | main(){
| ^
# | 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... |