Language: C++

#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include"basic.hpp"
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

struct Node{
    vector<Node*> dests;
    int x, y;
    void count(set<Node*>& visited){
        if(visited.count(this)){ return; }
        visited.insert(this);
        for(Node* d : dests){
            d -> count(visited);
        }
    }
};

struct Elem{
    int intercept, x, idx;
    Elem(int in, int x, int id):intercept(in), x(x), idx(id){}
};

vector<Node> nodes;
set<Node*> visited;
set<pair<Node*, Node*>> answer;
void connect(Node* node, int yint, map<int, vector<pair<int, int>>>& rd, int xb, int xl, vector<Node*>& connected){
    prints(node - &nodes[0]);
    printd(yint);
    auto& vrd = rd[yint];
    auto beg = lower_bound(vrd.begin(), vrd.end(), pair<int, int>{xb, -M}),
         ed = lower_bound(vrd.begin(), vrd.end(), pair<int, int>{xl, M});
    for(; beg != ed; beg++){
        auto* n = &nodes[beg -> second];
        // if(visited.count(n)){ continue; }
        // visited.insert(n);
        node -> dests.push_back(n);
        n -> dests.push_back(node);
        if(answer.count({node, n})){ continue; }
        answer.emplace(node, n);
        answer.emplace(n, node);
        prints("add", node - &nodes[0], n - &nodes[0]);
        connected.push_back(n);
    }
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    a--; b--;
    nodes.resize(n);
    nodes[a].dests.push_back(&nodes[b]);
    nodes[b].dests.push_back(&nodes[a]);
    map<int, vector<pair<int, int>>> ru, rd;
    vector<Elem> ds, us;
    vector<Node*> connected = {&nodes[a], &nodes[b]};
    vector<int> ys, xs;
    for(int i=0;i<n;i++){
        int x, y;
        cin >> x >> y;
        nodes[i].x = x;
        nodes[i].y = y;
        rd[y + x].emplace_back(x, i);
        ru[y - x].emplace_back(x, i);
        if(a == i || b == i){
            ds.emplace_back(x + y, x, i);
            us.emplace_back(y - x, x, i);
            ys.push_back(y);
            xs.push_back(x);
        }
    }
    int len = abs(ys[0] - ys[1]) + abs(xs[0] - xs[1]);
    // cout << len << '\n';
    printd(len);
    for(auto& p : ru){ sort(p.second.begin(), p.second.end()); }
    for(auto& p : rd){ sort(p.second.begin(), p.second.end()); }
    printd(ru);
    printd(rd);

    // while(ds.size() || us.size()){
    //     set<int> ans = {a, b};
    //     for(int h=0;h<2;h++){
    //         set<int> visited1;
    //         while(ds.size()){
    //             auto d = ds.back(); ds.pop_back();
    //             if(visited1.count(d.intercept)){ continue; }
    //             visited1.insert(d.intercept);
    //             for(int i=0;i<2;i++){
    //                 auto& v1 = rd[d.intercept + len * (i ? 1 : -1)];
    //                 auto beg = lower_bound(v1.begin(), v1.end(), pair<int, int>{d.x - (i ^ h ? 0 : len), -2*M});
    //                 auto ed = lower_bound(v1.begin(), v1.end(), pair<int, int>{d.x + (i ^ h ? len : 0), 2*M});
    //                 for(auto ite=beg;ite!=ed;ite++){
    //                     ds.emplace_back(d.intercept + len * (i ? 1 : -1), ite -> first, ite -> second);
    //                     us.emplace_back(d.intercept + len * (i ? 1 : -1) + ite -> first * (h ? 2 : -2), ite -> first, ite -> second);
    //                     ans.insert(ite -> second);
    //                     nodes[d.idx].dests.push_back(&nodes[ite -> second]);
    //                     nodes[ite -> second].dests.push_back(&nodes[d.idx]);
    //                     cout<<"ite->second "<<ite->second<<'\n';
    //                 }
    //             }
    //         }
    //         // ds = us;
    //         ds.swap(us);
    //     }
    // }
    answer.emplace(&nodes[a], &nodes[b]);
    answer.emplace(&nodes[b], &nodes[a]);
    while(connected.size()){
        Node* n = connected.back(); connected.pop_back();
        connect(n, n -> y + n -> x + len, rd, n -> x, n -> x + len, connected);
        connect(n, n -> y + n -> x - len, rd, n -> x - len, n -> x, connected);
        connect(n, n -> y - n -> x + len, ru, n -> x - len, n -> x, connected);
        connect(n, n -> y - n -> x - len, ru, n -> x, n -> x + len, connected);
    }
    // cout << ans.size() << '\n';
    // nodes[a].count(visited);
    // for(auto p : visited){
    //     cout << p - &nodes[0] << '\n';
    // }
    // cout << visited.size() << '\n';
    printl([](ostream& out, Node* a){ out << a - &nodes[0]; }, answer);
    // printl(answer);
    // prints(answer);
    cout << answer.size() / 2 << '\n';
    return 0;
}


Compiler output:
a.cc:10:9: fatal error: basic.hpp: No such file or directory
   10 | #include"basic.hpp"
      |         ^~~~~~~~~~~
compilation terminated.