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;
#define int long long
inline int rd(){
int x=0,w=1;
char ch=getchar();
for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') w=-1;
for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
return x*w;
}
void solve(){
int n,k,q; cin>>n>>k>>q;
vector<int> a(n);
for(auto&x:a) cin>>x;
int ok[n+1][n+1];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
ok[i][j]=0;
}
}
for(int i=0;i<n;i++){
ok[i][i]=1;
for(int j=i+1;j<n;j++){
if(a[j]!=a[j-1]) ok[i][j]|=ok[i][j-1];
else{
ok[i][j]=0; break;
}
}
}
for(int queries=0;queries<q;queries++){
int l,r; cin>>l>>r;
l--;r--;
if(ok[l][r]) cout<<"YES\n";
else cout<<"NO\n";
}
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int tt=1; //cin>>tt;
while(tt--){
solve();
}
}
# | 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... |