#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define NN 100100
using namespace std;
int h[NN], n;
set<int> adj[NN];
int upd[2*NN][2];
void init(int N, int D, int H[]) {
n = N;
for(int i = 0; i < N; i++)
h[i] = H[i];
}
void curseChanges(int U, int A[], int B[]) {
for(int i = 1; i <= U; i++) {
upd[i][0] = A[i-1], upd[i][1] = B[i-1];
}
for(int i = 1; i <= U; i++) {
int a= upd[i][0], b = upd[i][1];
if(adj[a].count(b)) adj[a].erase(b), adj[b].erase(a);
else adj[a].insert(b), adj[b].insert(a);
}
}
int calc(vector<int> a, vector<int> b){
int ans = 1e9;
for(int i = 0, j = 0; i < (int)a.size()&&j < (int)b.size();i++) {
if(a[i]>b[j]) swap(a, b), swap(i, j);
if(j) ans=min(ans,(int)abs(a[i]-b[j-1]));
ans = min(ans, abs(a[i] - b[j]));
}
return ans;
}
int question(int x, int y, int v) {
set<int> a = adj[x], b = adj[y];
vector<int> c, d;
for(auto i: a) c.push_back(h[i]);
for(auto i: b) d.push_back(h[i]);
sort(c.begin(), c.end());
sort(d.begin(), d.end());
return calc(c,d);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4944 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5072 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
246 ms |
27756 KB |
Output is correct |
2 |
Correct |
234 ms |
27604 KB |
Output is correct |
3 |
Correct |
147 ms |
8864 KB |
Output is correct |
4 |
Correct |
1966 ms |
17552 KB |
Output is correct |
5 |
Correct |
700 ms |
26760 KB |
Output is correct |
6 |
Execution timed out |
3057 ms |
14204 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
168 ms |
27676 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
6116 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4944 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |