#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int NMAX = 100001;
const int VMAX = 101;
const int INF = 2e9;
const int MOD = 1000000007;
const int BLOCK = 447;
const int base = 117;
const int nr_of_bits = 24;
const int inv2 = 500000004;
set <int> events[NMAX];
int a[NMAX];
void init(int N, int D, int H[]) {
for(int i = 0; i < N; i++){
a[i] = H[i];
}
}
void baga(int a, int b){
if(events[a].find(b) == events[a].end())
events[a].insert(b);
else
events[a].erase(b);
}
void curseChanges(int U, int A[], int B[]) {
for(int i = 0; i < U; i++){
baga(A[i], B[i]);
baga(B[i], A[i]);
}
}
int question(int x, int y, int v) {
int minim = 1e9;
if(events[x].size() == 0 || events[y].size() == 0)
return minim;
set <int> nou;
for(auto p : events[x]){
nou.insert(a[p]);
}
for(auto p : events[y]){
int val = a[p];
auto it = nou.lower_bound(val);
if(it != nou.end()){
minim = min(minim, abs((*it) - val));
}
it = nou.upper_bound(val);
if(it != nou.begin()){
it = prev(it);
minim = min(minim, abs((*it) - val));
}
}
return minim;
}
# |
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 |
313 ms |
26104 KB |
Output is correct |
2 |
Correct |
257 ms |
26056 KB |
Output is correct |
3 |
Correct |
168 ms |
7632 KB |
Output is correct |
4 |
Execution timed out |
3054 ms |
15940 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
167 ms |
26136 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
6120 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 |
- |