#include <bits/stdc++.h>
#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], nou[NMAX];
int a[NMAX];
int n;
void init(int N, int D, int H[]) {
n = N;
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]);
}
for(int i = 0; i < n; i++){
for(auto x : events[i])
nou[i].insert(a[x]);
}
}
int question(int x, int y, int v) {
int minim = 1e9;
if(nou[x].size() == 0 || nou[y].size() == 0)
return minim;
for(auto p : nou[y]){
int val = p;
auto it = nou[x].lower_bound(val);
if(it != nou[x].end()){
minim = min(minim, abs((*it) - val));
}
it = nou[x].upper_bound(val);
if(it != nou[x].begin()){
it = prev(it);
minim = min(minim, abs((*it) - val));
}
}
return minim;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
9680 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
9808 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
280 ms |
49612 KB |
Output is correct |
2 |
Correct |
296 ms |
49652 KB |
Output is correct |
3 |
Correct |
115 ms |
12104 KB |
Output is correct |
4 |
Correct |
1221 ms |
29932 KB |
Output is correct |
5 |
Correct |
464 ms |
48628 KB |
Output is correct |
6 |
Correct |
2118 ms |
22664 KB |
Output is correct |
7 |
Correct |
331 ms |
22588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
213 ms |
38968 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
11660 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
9680 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |