#include <set>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int n;
set<pair<int, int>> m;
vector<int> h, adj[100006];
void init(int N, int D, int H[]) {
n = N;
for (int i = 0; i < N; i++) h.push_back(H[i]);
}
bool cmp(const int &a, const int &b) {
return h[a] < h[b];
}
void curseChanges(int U, int A[], int B[]) {
for (int i = 0; i < U; i++) {
int a = A[i], b = B[i];
if (a > b) swap(a, b);
if (m.count({ a, b })) m.erase({ a, b });
else m.insert({ a, b });
}
auto it = m.begin();
while (it != m.end()) {
adj[it->first].push_back(it->second);
adj[it->second].push_back(it->first);
it = next(it);
}
for (int i = 0; i < n; i++) sort(adj[i].begin(), adj[i].end(), cmp);
}
int question(int x, int y, int v) {
int i = 0, j = 0;
int res = 1e9;
while (i < (int)adj[x].size() && j < (int)adj[y].size()) {
res = min(res, abs(h[adj[x][i]] - h[adj[y][j]]));
if (h[adj[x][i]] <= h[adj[y][j]]) i++;
else j++;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2668 KB |
Incorrect |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2796 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
345 ms |
18668 KB |
Output is correct |
2 |
Correct |
319 ms |
18512 KB |
Output is correct |
3 |
Correct |
147 ms |
5228 KB |
Output is correct |
4 |
Correct |
348 ms |
10092 KB |
Output is correct |
5 |
Correct |
329 ms |
16492 KB |
Output is correct |
6 |
Correct |
554 ms |
9708 KB |
Output is correct |
7 |
Correct |
257 ms |
9828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
282 ms |
18504 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
3560 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2668 KB |
Incorrect |