#include <bits/stdc++.h>
#define N 200001
#define pb push_back
using namespace std;
int h[N],pre[N];
unordered_map<int,vector<int> >v[N];
vector<int>day[N];
void init(int N, int D, int H[]) {
}
void curseChanges(int u, int A[], int B[]){
for(int i=1;i<=u;i++){
int a=A[i-1],b=B[i-1];
day[a].pb(i);
day[b].pb(i);
if(pre[a]==0){
v[a][i].pb(b);
pre[a]=i;
}
else{
bool flag=0;
for(int j:v[a][pre[a]]){
if(j==b){
flag=1;
continue;
}
v[a][i].pb(j);
}
if(flag==0) v[a][i].pb(b);
pre[a]=i;
}
if(pre[b]==0){
v[b][i].pb(a);
pre[b]=i;
}
else{
bool flag=0;
for(int j:v[b][pre[b]]){
if(j==a){
flag=1;
continue;
}
v[b][i].pb(j);
}
if(flag==0) v[b][i].pb(a);
pre[b]=i;
}
}
}
int question(int x, int y, int z) {
int ans=1e9;
int id=upper_bound(day[x].begin(),day[x].end(),z)-day[x].begin();
--id;
if(id<0){
return ans;
}
int a=day[x][id];
id=upper_bound(day[y].begin(),day[y].end(),z)-day[y].begin();
--id;
if(id<0){
return ans;
}
int b=day[y][id];
// cout << a << ' ' << b << '\n';
if(v[x][a].size()==0 || v[y][b].size()==0){
return ans;
}
vector<int>xx,yy;
for(int V:v[y][b]){
yy.pb(h[V]);
}
sort(yy.begin(),yy.end());
for(int U:v[x][a]){
int id=lower_bound(yy.begin(),yy.end(),h[U])-yy.begin();
ans=min(ans,abs(h[U]-yy[max(0,id-1)]));
ans=min(ans,abs(yy[id]-h[U]));
}
return ans;
}
Compilation message
potion.cpp:2:11: error: expected ',' or '...' before numeric constant
2 | #define N 200001
| ^~~~~~
potion.cpp:8:15: note: in expansion of macro 'N'
8 | void init(int N, int D, int H[]) {
| ^