Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
vector<P> vx[N], vy[N];
vector<ll> x, y, x2, y2, x3, y3;
ll n, a, b, d;
map<P, ll> cnt;
map<ll, ll> ix, iy;
bool used[N];
set<P> usedx[N], usedy[N];

ll dist(int a, int b){
	return max(abs(x[a]-x[b]), abs(y[a]-y[b]));
}

void comp(vector<int> &x, const vector<int> &y, vector<int> &z, map<ll, ll> &ix){
	z = vector<int>(y);
	sort(all(z));
	UNIQUE(z);
	x = vector<int>(y.size());
	rep(i, y.size()){
		x[i] = lower_bound(z.begin(), z.end(), y[i])-z.begin();
	}
	rep(i, z.size()) ix[z[i]] = i;
}

int main(){
	cin>>n>>a>>b; a--; b--;
	x = y = vector<int>(n);
	rep(i, n){
		ll xx, yy;
		cin>>xx>>yy;
		x[i] = xx+yy;
		y[i] = xx-yy;
		++cnt[P(x[i], y[i])];
	}
	d = dist(a, b);
	comp(x2, x, x3, ix); comp(y2, y, y3, iy);
	rep(i, n){
		vy[x2[i]].push_back(P(y[i], i));
		vx[y2[i]].push_back(P(x[i], i));
	}
	rep(i, x3.size()) sort(all(vy[i]));
	rep(i, y3.size()) sort(all(vx[i]));
	ll res = 0;
	queue<int> q;
	q.push(a);
	used[a] = true;
	while(!q.empty()){
		int u = q.front(); q.pop();
		ll lx = x[u]-d, rx = lx+2*d, ly = y[u]-d, ry = ly+2*d;;
		for(ll xx = lx; xx <= rx; xx+=2*d){
			if(!ix.count(xx)) continue;
			int px = ix[xx];
			ll l = lower_bound(all(vy[px]), P(ly+1, 0))-vy[px].begin();
			ll r = upper_bound(all(vy[px]), P(ry-1, INF))-vy[px].begin();
			//cerr<<u<<" "<<l<<" "<<r<<endl;
			//cerr<<xx<<" "<<vy[px].size()<<endl;
			res += r-l;
			//res -= cnt[P(xx, ly)]+cnt[P(xx, ry)];
			auto p = usedy[px].lower_bound(P(l, 0));
			auto p2 = p;
			if(p2!=usedy[px].begin()) --p2;
			if(p!=usedy[px].end()) r = min(r, p->fst);
			if(p2!=usedy[px].end()) l = max(l, p2->snd);
			if(l<r) usedy[px].insert(P(l, r));
			for(int i = l; i < r; i++){
				int v = vy[px][i].snd;
				if(used[v]) continue;
				used[v] = true;
				q.push(v);
			}
		}
		for(ll yy = ly; yy <= ry; yy+=2*d){
			if(!iy.count(yy)) continue;
			int py = iy[yy];
			ll l = lower_bound(all(vx[py]), P(lx, 0))-vx[py].begin();
			ll r = upper_bound(all(vx[py]), P(rx, INF))-vx[py].begin();
			res += r-l;
			auto p = usedx[py].lower_bound(P(l, 0));
			auto p2 = p;
			if(p2!=usedx[py].begin()) --p2;
			if(p!=usedx[py].end()) r = min(r, p->fst);
			if(p2!=usedx[py].end()) l = max(l, p2->snd);
			if(l<r) usedx[py].insert(P(l, r));
			for(int i = l; i < r; i++){
				int v = vx[py][i].snd;
				if(used[v]) continue;
				used[v] = true;
				q.push(v);
			}
		}
		//cout<<u<<"'s res: "<<res-res2<<endl;
	}
	cout<<res/2<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:30: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   67 |         x = y = vector<int>(n);
      |                              ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from a.cc:9:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:76:14: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   76 |         comp(x2, x, x3, ix); comp(y2, y, y3, iy);
      |              ^~
a.cc:54:24: note: in passing argument 1 of 'void comp(std::vector<int>&, const std::vector<int>&, std::vector<int>&, std::map<long long int, long long int>&)'
   54 | void comp(vector<int> &x, const vector<int> &y, vector<int> &z, map<ll, ll> &ix){
      |           ~~~~~~~~~~~~~^
a.cc:76:35: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   76 |         comp(x2, x, x3, ix); comp(y2, y, y3, iy);
      |                                   ^~
a.cc:54:24: note: in passing argument 1 of 'void comp(std::vector<int>&, const std::vector<int>&, std::vector<int>&, std::map<long long int, long long int>&)'
   54 | void comp(vector<int> &x, const vector<int> &y, vector<int> &z, map<ll, ll> &ix){
      |           ~~~~~~~~~~~~~^