Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

struct place{int i,x,y;};
struct edge{int u,v,cost;};

int par[200000]; //union-find
int ranks[200000]; //union-find
void init(int n){ //union-find 
    for(int i=0;i<n;i++){
        par[i]=i;
        ranks[i]=0;
    }
}
 
int find(int x){ //union-find
    if(par[x]==x){
        return x;
    }
    else{
        return par[x]=find(par[x]);
    }
}
 
void unite(int x, int y){ //union-find
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(ranks[x]<ranks[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(ranks[x]==ranks[y]) ranks[x]++;
    }
}
 
bool same(int x, int y){ //union-find
    return find(x) == find(y);
}

bool comp(const edge & e1,const edge& e2)
{
  return e1.cost<e2.cost;
}
bool sx(const place &a,const place &b)
{
  return a.x < b.x;
}

bool sy(const place &a,const place &b)
{
  return a.y < b.y;
}




void solve(void)
{
  int N;
  vector<place> V;
  vector<edge>G;
  vector<int>X(N),Y(N);
  for (int i = 0; i < N; i++)
  {
    int xx, yy;
    cin>>xx>>yy;
    V.emplace_back((int)i,xx,yy);
  }
  sort(V.begin(),V.end(),sx);

  for (int i = 0; i < N-1; i++)
  {
    edge  e = {V[i].i,V[i+1].i,V[i+1].x - V[i].x}; 
    G.push_back(e);
  }
  
    sort(V.begin(),V.end(),sy);

  for (int i = 0; i < N-1; i++)
  {


  }
  init(N);
  sort(G.begin(),G.end(),comp);

  int res = 0;
  for (int i = 0; i < G.size(); i++)
  {
    edge e = G[i];
    if(!same(e.u,e.v))
    {
      unite(e.u,e.v);
      res+=e.cost;
    }
  }
  cout<<res<<endl;
  
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 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/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = place; _Args = {long long int, long long int&, long long int&}; _Tp = place]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = place; _Args = {long long int, long long int&, long long int&}; _Tp = place; allocator_type = std::allocator<place>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int, long long int&, long long int&}; _Tp = place; _Alloc = std::allocator<place>; reference = place&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:109:19:   required from here
  109 |     V.emplace_back((int)i,xx,yy);
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'place::place(long long int&)'
a.cc:44:8: note: candidate: 'place::place()'
   44 | struct place{int i,x,y;};
      |        ^~~~~
a.cc:44:8: note:   candidate expects 0 arguments, 1 provided
a.cc:44:8: note: candidate: 'constexpr place::place(const place&)'
a.cc:44:8: note:   no known conversion for argument 1 from 'long long int' to 'const place&'
a.cc:44:8: note: candidate: 'constexpr place::place(place&&)'
a.cc:44:8: note:   no known conversion for argument 1 from 'long long int' to 'place&&'