Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;//(|xa-xb|==d&&|ya-yb|[-d,d])||(|xa-xb|[-d,d]&&|ya-yb|==d)
const int N=100001;
int n,a,b,mx=0,my=0,ans=0;
int head[N],next[2*N],adj[2*N],tot=0;
int f[N];
set <pair<int,int> >	s;
int findr(int x)
{
    if(x==f[x]) return f[x];
    return f[x]=findr(f[x]);
}
void uniont(int x,int y)
{
    if(findr(x)!=findr(y))
        f[findr(x)]=findr(y);
    return;
}
struct node
{
    int x;
    int y;
    int s;
    bool operator<(const node &p)const
    {
        if(x<p.x)  return true;
        if(x==p.x&&y<p.y)   return true;
        return false;
    };
}t[N];
void addedge(int u,int v)
{
    tot++;
    next[tot]=head[u];
    adj[tot]=v;
    head[u]=tot;
    return;
}
int finds(int x,int l,int r)
{
    int le=l,ri=r;
    while(le<=ri)
    {
        int mid=(le+ri)/2;
        if(t[mid].x>=x)  ri=mid-1;
        else le=mid+1;
    }
    return le;
}
int findt(int x,int l,int r)
{
    int le=l,ri=r;
    while(le<=ri)
    {
        int mid=(le+ri)/2;
        if(t[mid].x>x)  ri=mid-1;
        else le=mid+1;
    }
    return ri;
}
int ss(int x,int l,int r)
{
    int le=l,ri=r;
    while(le<=ri)
    {
        int mid=(le+ri)/2;
        if(t[mid].y>=x)  ri=mid-1;
        else le=mid+1;
    }
    return le;
}
int st(int x,int l,int r)
{
    int le=l,ri=r;
    while(le<=ri)
    {
        int mid=(le+ri)/2;
        if(t[mid].y>x)  ri=mid-1;
        else le=mid+1;
    }
    return ri;
}
int cmp(const void *a,const void *b)
{
	struct node *c=(node *)a;
	struct node *d=(node *)b;
	if(c->y>d->y)	return true;
	if(c->y==d->y&&c->x>d->x)	return true;
	return false;
}
int main()
{
    int i,j,d,tmp,in,out;
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
        f[i]=i;
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&t[i].x,&t[i].y);
        tmp=t[i].x+t[i].y;
        t[i].y=t[i].x-t[i].y;
        t[i].x=tmp;
        t[i].s=i;
        mx=max(mx,t[i].x);
        my=max(my,t[i].y);
    }
    d=max(abs(t[a].x-t[b].x),abs(t[a].y-t[b].y));
    sort(t+1,t+n+1);
    for(i=1;i<=n;i++)
    {
        if(t[i].x+d>mx) continue;
        in=finds(t[i].x+d,1,n),out=findt(t[i].x+d,1,n);
        if((t[in].x-t[i].x)!=d) continue;
        int x1=ss(t[i].y-d,in,out),x2=st(t[i].y+d,in,out);
        if(x2<x1)   continue;
        uniont(t[i].s,t[x1].s);
        for(j=x1;j<x2;j++)
            uniont(t[j].s,t[j+1].s);
        for(j=x1;j<=x2;j++)
        	s.insert(make_pair(max(t[i].s,t[j].s),min(t[i].s,t[j].s)));
    }
    qsort(t+1,n,sizeof(t[0]),cmp);
	for(i=1;i<=n;i++)
    {
        if(t[i].y+d>my) continue;
        in=ss(t[i].y+d,1,n),out=st(t[i].y+d,1,n);
        if((t[in].y-t[i].y)!=d) continue;
        int x1=finds(t[i].x-d,in,out),x2=findt(t[i].x+d,in,out);
        if(x2<x1)   continue;
        uniont(t[i].s,t[x1].s);
        for(j=x1;j<x2;j++)
            uniont(t[j].s,t[j+1].s);
        for(j=x1;j<=x2;j++)
        	s.insert(make_pair(max(t[i].s,t[j].s),min(t[i].s,t[j].s)));
    }
    int num=findr(a);
    for(set<pair<int,int> >::iterator l=s.begin();l!=s.end();l++)
    	if(findr(l->first)==findr(l->second)&&findr(l->first)==num)
    		ans++;
    	//cout<<l->first<<' '<<l->second<<endl;
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:42:5: error: reference to 'next' is ambiguous
   42 |     next[tot]=head[u];
      |     ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:13:13: note:                 'int next [200002]'
   13 | int head[N],next[2*N],adj[2*N],tot=0;
      |             ^~~~