Language: C++

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<string>
#define INF 100093100
using namespace std;
vector<tuple<int,int,int>> road;
int x[100005],y[100005],n,root[100005],size[100005],dix,diy,q,w,e,ans=0,finish=1;
int find(int a){
    if(root[a]==a)
        return root[a];
    else
        return root[a]=find(root[a]);
}
bool same(int a,int b){
    return find(a)==find(b);
}
void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(size[b]>size[a])
        swap(a,b);
    size[a]+=size[b];
    root[b]=a;
}
bool cmp(tuple<int,int,int>a,tuple<int,int,int>b){
    int o=get<2>(a);
    int p=get<2>(b);
    return o<p;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++){
            dix=abs(x[i]-x[j]);
            diy=abs(y[i]-y[j]);
            road.push_back({i,j,min(dix,diy)});
        }
    sort(road.begin(),road.end(),cmp);
    for(int i=1;i<=n;i++){
        root[i]=i;
        size[i]=1;
    }
    for(auto k:road){
        tie(q,w,e)=k;
        if(!same(q,w)){
            unite(q,w);
            ans+=e;
            finish++;
        }
        if(finish==n)
            break;
    }
    printf("%d",ans);
}


Compiler output:
a.cc: In function 'void unite(int, int)':
a.cc:27:8: error: reference to 'size' is ambiguous
   27 |     if(size[b]>size[a])
      |        ^~~~
In file included from /usr/include/c++/14/vector:69,
                 from a.cc:5:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:14:40: note:                 'int size [100005]'
   14 | int x[100005],y[100005],n,root[100005],size[100005],dix,diy,q,w,e,ans=0,finish=1;
      |                                        ^~~~
a.cc:27:16: error: reference to 'size' is ambiguous
   27 |     if(size[b]>size[a])
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:14:40: note:                 'int size [100005]'
   14 | int x[100005],y[100005],n,root[100005],size[100005],dix,diy,q,w,e,ans=0,finish=1;
      |                                        ^~~~
a.cc:29:5: error: reference to 'size' is ambiguous
   29 |     size[a]+=size[b];
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:14:40: note:                 'int size [100005]'
   14 | int x[100005],y[100005],n,root[100005],size[100005],dix,diy,q,w,e,ans=0,finish=1;
      |                                        ^~~~
a.cc:29:14: error: reference to 'size' is ambiguous
   29 |     size[a]+=size[b];
      |              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:14:40: note:                 'int size [100005]'
   14 | int x[100005],y[100005],n,root[100005],size[100005],dix,diy,q,w,e,ans=0,finish=1;
      |                                        ^~~~
a.cc: In function 'int main()':
a.cc:50:9: error: reference to 'size' is ambiguous
   50 |         size[i]=1;
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:14:40: note:                 'int size [100005]'
   14 | int x[100005],y[100005],n,root[100005],size[100005],dix,diy,q,w,e,ans=0,finish=1;
      |                                        ^~~~