Language: C++

#include <bits/stdc++.h>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

class UnionFind {
    public:
    int n;
    vector<int> par, rank;

    UnionFind(int n) {
        rep(n) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        return ((par[x] == x) ? x : par[x] = find(par[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

struct Edge{
    int from, to; ll cost;
    Edge(int from, int to, ll cost){
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
    bool operator<(const Edge &e) const{
        return cost < e.cost;
    }
};

class Graph{
    public:
    int V,E;
    vector<Edge> edges;
    Graph(int n, vector<Pll> x, vector<Pll> y){
        V = 2*n;
        E = 2*n-2;
        rep(n-1){
            edges.push_back(Edge(x[i+1].second, x[i].second, x[i+1].first - x[i].first));
            edges.push_back(Edge(y[i+1].second, y[i].second, y[i+1].first - y[i].first));
        }
    }

    ll kruskal(){
        ll ret = 0LL;
        UnionFind uf = UnionFind(V);
        sort(all(edges));
        for(Edge e: edges){
            if(!uf.is_same(e.from, e.to)){
                ret += e.cost;
                uf.unite(e.from, e.to);
            }
        }
        return ret;
    }
};

int main(){
    int n;
    cin >> n;
    vector< pair<ll, int> > x(n), y(n);
    rep(i){
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }

    sort(all(x)); sort(all(y));

    Graph g = Graph(n, x, y);
    cout << g.kruskal() << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:103:28: error: no matching function for call to 'Graph::Graph(int&, std::vector<std::pair<long long int, int> >&, std::vector<std::pair<long long int, int> >&)'
  103 |     Graph g = Graph(n, x, y);
      |                            ^
a.cc:68:5: note: candidate: 'Graph::Graph(int, std::vector<std::pair<long long int, long long int> >, std::vector<std::pair<long long int, long long int> >)'
   68 |     Graph(int n, vector<Pll> x, vector<Pll> y){
      |     ^~~~~
a.cc:68:30: note:   no known conversion for argument 2 from 'vector<pair<[...],int>>' to 'vector<pair<[...],long long int>>'
   68 |     Graph(int n, vector<Pll> x, vector<Pll> y){
      |                  ~~~~~~~~~~~~^
a.cc:64:7: note: candidate: 'Graph::Graph(const Graph&)'
   64 | class Graph{
      |       ^~~~~
a.cc:64:7: note:   candidate expects 1 argument, 3 provided
a.cc:64:7: note: candidate: 'Graph::Graph(Graph&&)'
a.cc:64:7: note:   candidate expects 1 argument, 3 provided