#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define sp " "
//#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
vector<pair<pii, int>> curr[100005];
int arr[100005], n;
void init(int N, int D, int H[]) {
n = N;
for (int i = 0; i < N; i++)
arr[i] = H[i];
}
void curseChanges(int U, int A[], int B[]) {
map<int, int> last[n + 5];
for (int i = 0; i < U; i++)
{
int u = A[i], v = B[i];
if (last[u][v])
{
curr[u].pb({{last[u][v], i + 1}, arr[v]});
curr[v].pb({{last[u][v], i + 1}, arr[u]});
last[u][v] = 0;
last[v][u] = 0;
}
else last[u][v] = i + 1, last[v][u] = i + 1;
}
for (int i = 0; i < n; i++)
{
for (auto j : last[i])
{
if (j.nd != 0) curr[i].pb({{j.nd, U + 2}, arr[j.st]});
}
}
}
int question(int x, int y, int v) {
vector<int> k, l;
v++;
for (auto i : curr[x])
if (i.st.st < v && i.st.nd >= v) k.pb(i.nd);
for (auto i : curr[y])
if (i.st.st < v && i.st.nd >= v) l.pb(i.nd);
sort(k.begin(), k.end());
sort(l.begin(), l.end());
int ans = 1e9;
int i = 0, j = 0;
cout<<x<<" : ";
for (auto i : k) cout<<i<<sp;
cout<<endl;
cout<<y<<" : ";
for (auto i : l) cout<<i<<sp;
cout<<endl;
while(i < k.size() && j < l.size())
{
int a = k[i], b = l[j];
ans = min(ans, abs(a - b));
if (a < b) i++;
else if (b < a) j++;
else return ans;
}
return ans;
}
Compilation message
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:64:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | while(i < k.size() && j < l.size())
| ~~^~~~~~~~~~
potion.cpp:64:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | while(i < k.size() && j < l.size())
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2768 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
227 ms |
35980 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
236 ms |
35900 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
4616 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |