Language: C++

#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

typedef pair<ll, ll> P;

struct edge
{
    ll from, end, cost
};

ll prim(vector<bool> &visit, vector<vector<P>> &E)
{
    ll total_cost = 0;

    priority_queue<P, vector<P>, greater<P>> S;
    visit[0] = 1;

    ll num0 = 0;
    ll cost0 = INFNITY;
    for (P u_pair : E[0])
    {

        S.push(u_pair);
    }

    while (!S.empty())
    {

        ll cost = S.top().first;
        ll u = S.top().second();
        S.pop();

        if (visit[u] == 0)
        {
             visit[[u] =1;
             total_cost +=cost;
        }

        for (P v_pair : E[u])
        {
            if (visit[v_pair.second] == 0)
            {
                S.push(v_pair);
            }
        }
    }

    return total_cost;
}

int main()
{

    int N;

    vector<P> xs(N);
    vector<P> ys(N);

    vector<ll> xi(N);
    vector<ll> yi(N);

    vector<pair<>> xs;

    cin >> N;

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

        ll x, y;

        cin >> x >> y;

        xs[i] = P(x, i);
        ys[i] = P(y, i);

        xi[i] = x;
        yi[i] = y;
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    vector<vector<edge>> E(N, vector<P>(0));
    for (int i = 0; i < N - 1; i++)
    {
        P e1;
        e1.second = xs[i + 1].second;
        e1.first = abs(xi[xs[i + 1].second] - xi[xs[i].second]);

        P e2;
        e2.second = xs[i].second;
        e2.first = abs(xi[xs[i + 1].second] - xi[xs[i].second]);

        E[xs[i + 1].second].push_back(e2);
        E[xs[i].second].push_back(e1);
    }

    for (int i = 0; i < N - 1; i++)
    {
        P e1;
        e1.second = ys[i + 1].second;
        e1.first = abs(yi[ys[i + 1].second] - yi[ys[i].second]);

        P e2;
        e2.second = ys[i].second;
        e2.first = abs(yi[ys[i + 1].second] - yi[ys[i].second]);

        E[ys[i + 1].second].push_back(e2);
        E[ys[i].second].push_back(e1);
    }

    vector<bool> vist(N, 0);

    ll ans = prim(visit, E);

    cout << ans << endl;
}

Compiler output:
a.cc:10:19: error: expected ';' at end of member declaration
   10 |     ll from, end, cost
      |                   ^~~~
      |                       ;
a.cc: In function 'll prim(std::vector<bool>&, std::vector<std::vector<std::pair<long long int, long long int> > >&)':
a.cc:21:16: error: 'INFNITY' was not declared in this scope; did you mean 'INFINITY'?
   21 |     ll cost0 = INFNITY;
      |                ^~~~~~~
      |                INFINITY
a.cc:32:30: error: expression cannot be used as a function
   32 |         ll u = S.top().second();
      |                ~~~~~~~~~~~~~~^~
a.cc:37:19: error: two consecutive '[' shall only introduce an attribute before '[' token
   37 |              visit[[u] =1;
      |                   ^
a.cc: In function 'int main()':
a.cc:64:16: error: wrong number of template arguments (0, should be 2)
   64 |     vector<pair<>> xs;
      |                ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:64:17: error: template argument 1 is invalid
   64 |     vector<pair<>> xs;
      |                 ^~
a.cc:64:17: error: template argument 2 is invalid
a.cc:64:20: error: conflicting declaration 'int xs'
   64 |     vector<pair<>> xs;
      |                    ^~
a.cc:58:15: note: previous declaration as 'std::vector<std::pair<long long int, long long int> > xs'
   58 |     vector<P> xs(N);
      |               ^~
a.cc:85:43: error: no matching function for call to 'std::vector<std::vector<edge> >::vector(int&, std::vector<std::pair<long long int, long long int> >)'
   85 |     vector<vector<edge>> E(N, vector<P>(0));
      |                                           ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]'
  707 |         vector(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note:   template argument deduction/substitution failed:
a.cc:85:43: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<std::pair<long long int, long long int> >')
   85 |     vector<vector<edge>> E(N, vector<P>(0));
      |                                           ^
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >]'
  678 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<edge> >'
  678 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<edge> >]'
  659 |       vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<edge> >&&'
  659 |       vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
      |              ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >; std::false_type = std::false_type]'
  640 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >; std::true_type = std::true_type]'
  635 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<edge> >]'
  624 |       vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<edge> >&'
  624 |       vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]'
  620 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]'
  601 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; size_type = long unsigned int; value_type = std::vector<edge>; allocator_type = std::allocator<std::vector<edge> >]'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:47: note:   no known conversion for argument 2 from 'std::vector<std::pair<long long int, long long int> >' to 'const std::vector<std::vector<edge> >::value_type&' {aka 'const std::vector<edge>&'}
  569 |       vector(size_type __n, const value_type& __value,
      |                             ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<edge> >]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note:   no known conversion for argument 2 from 'std::vector<std::pair<long long int, long long int> >' to 'const std::vector<std::vector<edge> >::allocator_type&' {aka 'const std::allocator<std::vector<edge> >&'}
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >; allocator_type = std::allocator<std::vector<edge> >]'
  542 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<edge>; _Alloc = std::allocator<std::vector<edge> >]'
  531 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note:   candidate expects 0 arguments, 2 provided
a.cc:96:38: error: no matching function for call to 'std::vector<edge>::push_back(P&)'
   96 |         E[xs[i + 1].second].push_back(e2);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<long long int, long long int>'} to 'const std::vector<edge>::value_type&' {aka 'const edge&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<long long int, long long int>'} to 'std::vector<edge>::value_type&&' {aka 'edge&&'}
 1300 |       push_b