#include <bits/stdc++.h>
using namespace std;
int n, k, q, arr[3010], dp[3010][3010], x, y;
set<pair<int, int>> odd, even;
pair<int, int> temp;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k >> q;
for(int i=1; i<=n; i++) {
cin >> arr[i];
}
for(int i=1; i<=n; i++) {
even.clear();
odd.clear();
for(int j=i+1; j<=n; j++) {
temp = make_pair(min(arr[j-1], arr[j]), max(arr[j-1], arr[j]));
if(j%2 == 0) {
if(even.count(temp) == 0 && arr[j-1] != arr[j]) {
dp[i][j] = 1;
even.insert(temp);
} else {
break;
}
} else {
if(odd.count(temp) == 0 && arr[j-1] != arr[j]) {
dp[i][j] = 1;
even.insert(temp);
} else {
break;
}
}
}
}
while(q--) {
cin >> x >> y;
if(x == y || dp[x][y]) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
200 ms |
43296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
131 ms |
13676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
95 ms |
35452 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
200 ms |
43296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |