#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
#define REP(i,n) for (int i = 0; i < n; i++)
#define trav(a,x) for (auto &a : x)
#define all(x) (x).begin(), (x).end()
#define submit(a,b) cout << a << " " << b << endl
#define D(x) //cerr << #x << ": " << x << endl;
struct Collection {
vi nums;
void flip(int i) {
bool cont = 0;
trav(a,nums) {if (a == i) {cont = 1;}}
if (!cont) {
nums.push_back(i);
return;
}
vi nums2;
trav(a,nums) {
if (a != i) nums2.push_back(a);
}
nums = nums2;
}
vi get_all() {
return nums;
}
};
const int MAX_N = 2e5;
int n,d;
vi hs;
Collection fr[MAX_N];
int get_ans(vi a, vi b) {
int best = 1e9;
vi h1, h2;
trav(aa, a) {
h1.push_back(hs[aa]);
}
sort(all(h1));
trav(bb, b) {
h2.push_back(hs[bb]);
}
sort(all(h2));
int i = 0;
trav(hb, h2) {
while (h1[i] < hb && i != h1.size()-1) i++;
best = min(best, abs(hb - h1[i]));
if (i!=0) best = min(best, abs(hb - h1[i-1]));
}
return best;
}
void init(int N, int D, int H[]) {
n = N; d = D;
REP(i,n) hs.push_back(H[i]);
}
void curseChanges(int U, int A[], int B[]) {
REP(uu, U) {
int a = A[uu];
int b = B[uu];
fr[a].flip(b);
fr[b].flip(a);
}
}
int question(int x, int y, int v) {
return get_ans(fr[x].get_all(), fr[y].get_all());
}
Compilation message
potion.cpp: In function 'int get_ans(vi, vi)':
potion.cpp:57:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | while (h1[i] < hb && i != h1.size()-1) i++;
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
58 ms |
23400 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
11624 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
5464 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |