#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(odd.count(temp) == 0 && arr[j-1] != arr[j]) {
dp[i][j] = 1;
if(even.count(temp) == 0) {
even.insert(temp);
}
} else {
break;
}
} else {
if(even.count(temp) == 0 && arr[j-1] != arr[j]) {
dp[i][j] = 1;
if(odd.count(temp) == 0) {
odd.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 |
210 ms |
38276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
145 ms |
9552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
260 ms |
35488 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
210 ms |
38276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |