#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define NN 100100
using namespace std;
int h[NN], n;
set<int> adj[NN];
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++) {
int a= A[i-1], b = B[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 |
223 ms |
26148 KB |
Output is correct |
2 |
Correct |
215 ms |
26108 KB |
Output is correct |
3 |
Correct |
144 ms |
7300 KB |
Output is correct |
4 |
Correct |
2037 ms |
15980 KB |
Output is correct |
5 |
Correct |
631 ms |
25268 KB |
Output is correct |
6 |
Execution timed out |
3098 ms |
12632 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
148 ms |
26244 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
6096 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 |
- |