Language: C++

#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int SIZE = 1e5+10;
VPLL pp,pp2;
bool used[SIZE];
int get(PLL X){
    return lower_bound(ALL(pp),X)-pp.begin();
}
LL dis(PII x,PII y){
    return max(abs((LL)x.F-y.F),abs((LL)x.S-y.S));
}
int main(){
    DRIII(n,id1,id2);id1--;id2--;
    REP(i,n){
        DRII(x,y);
        pp.PB(MP(x-y,x+y));
        pp2.PB(MP(x+y,x-y));
    }
    PII st1=pp[id1],st2=pp[id2];
    LL D=dis(st1,st2);
    sort(ALL(pp));
    sort(ALL(pp2));
    id1=get(st1);
    id2=get(st2);
    queue<int>qq;
    qq.push(id1);
    qq.push(id2);
    used[id1]=used[id2]=1;
    int an=0;
    while(SZ(qq)){
        PII me=pp[qq.front()];
        qq.pop();
        int it;
        it=lower_bound(ALL(pp),MP(me.F-D,me.S-D))-pp.begin();
        for(;it<SZ(pp)&&pp[it].F==me.F-D&&pp[it].S<=me.S+D;it++){
            an++;
            if(!used[it]){
                used[it]=1;
                qq.push(it);
            }
        }

        it=lower_bound(ALL(pp),MP(me.F+D,me.S-D))-pp.begin();
        for(;it<SZ(pp)&&pp[it].F==me.F+D&&pp[it].S<=me.S+D;it++){
            an++;
            if(!used[it]){
                used[it]=1;
                qq.push(it);
            }
        }

        it=lower_bound(ALL(pp2),MP(me.S-D,me.F-D+1))-pp2.begin();
        for(;it<SZ(pp2)&&pp2[it].F==me.S-D&&pp2[it].S<me.F+D;it++){
            an++;
            int it2=get(MP(pp2[it].S,pp2[it].F));
            if(!used[it2]){
                used[it2]=1;
                qq.push(it2);
            }
        }

        it=lower_bound(ALL(pp2),MP(me.S+D,me.F-D+1))-pp2.begin();
        for(;it<SZ(pp2)&&pp2[it].F==me.S+D&&pp2[it].S<me.F+D;it++){
            an++;
            int it2=get(MP(pp2[it].S,pp2[it].F));
            if(!used[it2]){
                used[it2]=1;
                qq.push(it2);
            }
        }
    }
    printf("%d\n",an/2);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:12: error: call of overloaded 'get(std::pair<int, int>&)' is ambiguous
   48 |     id1=get(st1);
      |         ~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'constexpr _Tp& std::get(pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
 1272 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
 1277 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'constexpr _Tp& std::get(pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
 1292 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
 1297 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
a.cc:31:5: note: candidate: 'int get(std::pair<long long int, long long int>)'
   31 | int get(PLL X){
      |     ^~~
a.cc:49:12: error: call of overloaded 'get(std::pair<int, int>&)' is ambiguous
   49 |     id2=get(st2);
      |         ~~~^~~~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'constexpr _Tp& std::get(pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
 1272 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
 1277 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'constexpr _Tp& std::get(pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
 1292 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
 1297 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
a.cc:31:5: note: candidate: 'int get(std::pair<long long int, long long int>)'
   31 | int get(PLL X){
      |     ^~~