#include "bits/stdc++.h"
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif
#define ar array
const int N = 1e5 + 5;
vector<ar<int, 2>> edges[N];
set<int> S[N];
int h[N];
void init(int N, int D, int H[]) {
for(int i=0;i<N;i++){
h[i] = H[i];
}
}
void curseChanges(int U, int A[], int B[]) {
set<ar<int, 2>> ss;
for(int i=0;i<U;i++){
if(A[i] > B[i]) swap(A[i], B[i]);
int t = 1;
if(ss.count({A[i], B[i]})) t = -1;
if(t == 1){
S[A[i]].insert(B[i]);
S[B[i]].insert(A[i]);
} else {
S[A[i]].erase(B[i]);
S[B[i]].erase(A[i]);
}
//~ edges[A[i]].push_back({i + 1, (B[i] + 1) * t});
//~ edges[B[i]].push_back({i + 1, (A[i] + 1) * t});
if(t == 1) ss.insert({A[i], B[i]});
else ss.erase({A[i], B[i]});
}
}
int question(int x, int y, int v) {
multiset<int> a, b;
for(auto u : S[x]) a.insert(h[u]);
for(auto u : S[y]) b.insert(h[u]);
//~ cout<<"here"<<endl;
//~ for(auto u : edges[x]){
//~ if(u[0] > v) break;
//~ if(u[1] < 0){
//~ a.erase(a.find(h[-u[1] - 1]));
//~ } else {
//~ a.insert(h[u[1] - 1]);
//~ }
//~ }
//~ for(auto u : edges[y]){
//~ if(u[0] > v) break;
//~ if(u[1] < 0){
//~ b.erase(b.find(h[-u[1] - 1]));
//~ } else {
//~ b.insert(h[u[1] - 1]);
//~ }
//~ }
int res = 1e9;
for(auto x : a){
auto it = b.lower_bound(x);
if(it != b.end()){
res = min(res, *it - x);
} if(it != b.begin()){
it--;
res = min(res, x - *it);
}
}
return res;
}
/*
6 5 11 4
2 42 1000 54 68 234
0 1
2 0
3 4
3 5
3 5
1 3
5 3
0 5
3 0
1 3
3 5
0 3 4 26
3 0 8 0
0 5 5 1000000000
3 0 11 14
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
7248 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7524 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
549 ms |
37788 KB |
Output is correct |
2 |
Correct |
517 ms |
37868 KB |
Output is correct |
3 |
Correct |
226 ms |
9892 KB |
Output is correct |
4 |
Execution timed out |
3037 ms |
23008 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
377 ms |
37896 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
8912 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
7248 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |