Submission #1126774

#TimeUsernameProblemLanguageResultExecution timeMemory
1126774koukirocksHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
13 / 100
832 ms123768 KiB
#include<bits/stdc++.h> #define speed ios_base::sync_with_stdio(0);cin.tie(0) #define F first #define S second using namespace std; template<typename T> using vvector = vector<vector<T>>; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INF=0x3f3f3f3f; const ll P=1e9+7; int main() { speed; int n,m; cin>>n>>m; vector<int> a(n+1); for (int i=1;i<=n;i++) { cin>>a[i]; } for (int i=n;i>=1;i--) { a[i]-=a[i-1]; } vvector<int> spt(n+1,vector<int>(21,-INF)); for (int i=n;i>=1;i--) { spt[i][0]=a[i]; for (int k=1;k<=20;k++) { if (i+(1<<k)-1>n) break; spt[i][k]=min(spt[i][k-1],spt[i+(1<<k-1)][k-1]); } } while (m--) { int l,r,k; cin>>l>>r>>k; if (l==r) { cout<<"1\n"; continue; } l++; int cnt=0; while (l+(1<<cnt)-1<=r) { cnt++; } cnt--; // cout<<l<<" "<<r<<" "<<cnt<<"\n"; if (min(spt[l][cnt],spt[r-(1<<cnt)+1][cnt])<0) cout<<"0\n"; else cout<<"1\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...