#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxN = 100000, maxU = 200000, INF = 1000000000;
int a[maxU], b[maxU], h[maxN], n, u, d;
vector<int> g[maxN];
void init(int N, int D, int H[]) {
n = N, d = D;
memcpy(h, H, sizeof(h[0]) * n);
}
void curseChanges(int U, int A[], int B[]) {
u = U;
memcpy(a, A, sizeof(a[0]) * u), memcpy(b, B, sizeof(b[0]) * u);
set<pair<int, int>> adj;
for (int i = 0; i < u; ++i) {
if (a[i] > b[i]) {
swap(a[i], b[i]);
}
if (adj.count({a[i], b[i]})) {
adj.erase({a[i], b[i]});
} else {
adj.insert({a[i], b[i]});
}
}
for (auto [x, y]: adj) {
g[x].push_back(y);
g[y].push_back(x);
}
for (int i = 0; i < n; ++i) {
sort(g[i].begin(), g[i].end(), [](int i, int j) {
return h[i] < h[j];
});
}
}
int question(int x, int y, int v) {
//i suppose that v == u
assert(v == u);
int ans = INF;
for (int to : g[x]) {
auto it = lower_bound(g[y].begin(), g[y].end(), to, [](int i, int j) {
return h[i] < h[j];
});
if (it != g[y].end()) {
ans = min(ans, h[*it] - h[to]);
}
if (it != g[y].begin()) {
ans = min(ans, h[to] - h[*prev(it)]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
5200 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
5456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
19904 KB |
Output is correct |
2 |
Correct |
268 ms |
19976 KB |
Output is correct |
3 |
Correct |
118 ms |
6592 KB |
Output is correct |
4 |
Correct |
481 ms |
11664 KB |
Output is correct |
5 |
Correct |
248 ms |
18080 KB |
Output is correct |
6 |
Correct |
786 ms |
11104 KB |
Output is correct |
7 |
Correct |
219 ms |
11256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
220 ms |
40284 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
14 ms |
7244 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
5200 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |