#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 |
1 |
Correct |
272 ms |
73836 KB |
Output is correct |
2 |
Correct |
289 ms |
83112 KB |
Output is correct |
3 |
Correct |
282 ms |
82964 KB |
Output is correct |
4 |
Correct |
123 ms |
7184 KB |
Output is correct |
5 |
Correct |
136 ms |
9340 KB |
Output is correct |
6 |
Correct |
292 ms |
82756 KB |
Output is correct |
7 |
Correct |
292 ms |
82884 KB |
Output is correct |
8 |
Correct |
286 ms |
83180 KB |
Output is correct |
9 |
Correct |
296 ms |
82984 KB |
Output is correct |
10 |
Correct |
300 ms |
83372 KB |
Output is correct |
11 |
Correct |
299 ms |
83888 KB |
Output is correct |
12 |
Correct |
277 ms |
83412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
5536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
73836 KB |
Output is correct |
2 |
Correct |
289 ms |
83112 KB |
Output is correct |
3 |
Correct |
282 ms |
82964 KB |
Output is correct |
4 |
Correct |
123 ms |
7184 KB |
Output is correct |
5 |
Correct |
136 ms |
9340 KB |
Output is correct |
6 |
Correct |
292 ms |
82756 KB |
Output is correct |
7 |
Correct |
292 ms |
82884 KB |
Output is correct |
8 |
Correct |
286 ms |
83180 KB |
Output is correct |
9 |
Correct |
296 ms |
82984 KB |
Output is correct |
10 |
Correct |
300 ms |
83372 KB |
Output is correct |
11 |
Correct |
299 ms |
83888 KB |
Output is correct |
12 |
Correct |
277 ms |
83412 KB |
Output is correct |
13 |
Incorrect |
161 ms |
5536 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |