#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10, maxn = 1e6 + 10;
int n, d, h[maxn], a[maxn], b[maxn];
bool mark[maxn];
vector<int> pos[maxn], val[maxn];
void init(int N, int D, int H[]) {
n = N, d = D;
for(int i = 0; i < n; i++) h[i] = H[i];
}
void curseChanges(int U, int A[], int B[]) {
for(int i = 0; i < U; i++) {
a[i] = A[i], b[i] = B[i];
pos[a[i]].push_back(b[i]), pos[b[i]].push_back(a[i]);
}
for(int i = 0; i < n; i++) {
sort(pos[i].begin(), pos[i].end());
int cnt = 0;
for(int j = 0; j < pos[i].size(); j++) {
cnt++;
if(j == pos[i].size() - 1 || pos[i][j] != pos[i][j + 1]) {
if(cnt % 2 == 1) val[i].push_back(h[pos[i][j]]);
cnt = 0;
continue;
}
}
sort(val[i].begin(), val[i].end());
}
}
int question(int x, int y, int v) {
int ans = 1e9;
for(auto i : val[x]) {
int pos = lower_bound(val[y].begin(), val[y].end(), i) - val[y].begin();
if(pos != val[y].size()) ans = min(ans, val[y][pos] - i);
}
for(auto i : val[y]) {
int pos = lower_bound(val[x].begin(), val[x].end(), i) - val[x].begin();
if(pos != val[x].size()) ans = min(ans, val[x][pos] - i);
}
return ans;
}
Compilation message
potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int j = 0; j < pos[i].size(); j++) {
| ~~^~~~~~~~~~~~~~~
potion.cpp:26:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | if(j == pos[i].size() - 1 || pos[i][j] != pos[i][j + 1]) {
| ~~^~~~~~~~~~~~~~~~~~~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:41:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(pos != val[y].size()) ans = min(ans, val[y][pos] - i);
| ~~~~^~~~~~~~~~~~~~~~
potion.cpp:45:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(pos != val[x].size()) ans = min(ans, val[x][pos] - i);
| ~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
47184 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
47312 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
58728 KB |
Output is correct |
2 |
Correct |
178 ms |
58652 KB |
Output is correct |
3 |
Correct |
120 ms |
53172 KB |
Output is correct |
4 |
Correct |
589 ms |
53524 KB |
Output is correct |
5 |
Correct |
210 ms |
55672 KB |
Output is correct |
6 |
Correct |
1216 ms |
56832 KB |
Output is correct |
7 |
Correct |
231 ms |
57072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
114 ms |
58712 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
48072 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
47184 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |