Language: C++

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

using namespace std;
#include <string>



void dijkstra(vector<ll> & S, vector<bool> & visit, vector<ll> & D, vector<ll> & mother, vector<vector<ll>> A)
{

    while (!S.empty())
    {

 

        ll kasu = INFINITY;
        ll smallest_cost;

        ll erase_num = 0;

        for (int i = 0; i < S.size(); i++)
        {

            if (kasu > D[i])
            {

                smallest_cost = S[i];
                erase_num = i;
            }
        }

       

        visit[smallest_cost] = 1;

        S.erase(erase_num);

        for (int i = 0; i < A.size(); i++)
        {

            if (A[smallest_cost][i] == 1 && visit[i] == 0)
            {

                S[i] = 1;

                if (D[smallest_cost] + 1 < D[i])
                {

                    D[i] = D[smallest_cost] + 1;

                    mother[i] = smallest_cost;


                    bool kan = 0;


                    for(int j=0;j<S.size();j++){

                        if(i ==S[j]){

                            kan =1;
                        } 
                    }
                    if(kan ==0){

                        S.push_back(i);
                    }
                }
            }
        }
    }
}

int main()
{

    ll N, M;

    cin >> N >> M;

    vector<vector<ll>> A(N, vector<ll>(N, 0));

    vector<bool> visit(N, 0);
    vector<ll> mother(N, -1);

    vector<ll> S(0);

    vector<ll> D(N, INFINITY);

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

        ll b, c;

        cin >> b >> c;

        A[b - 1][c - 1] = 1;
        A[c - 1][b - 1] = 1;
    }

    S.push_back(0);
    D[0] = 0;

    dijkstra(S, visit, D, mother, A);

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

        if(visit[i] == 0){

            cout << "No" << endl;

            return 0;
        }
        
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++)
    {

        cout << mother[i] + 1 << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'void dijkstra(std::vector<long long int>&, std::vector<bool>&, std::vector<long long int>&, std::vector<long long int>&, std::vector<std::vector<long long int> >)':
a.cc:17:19: warning: overflow in conversion from 'float' to 'll' {aka 'long long int'} changes value from '+Inff' to '9223372036854775807' [-Woverflow]
   17 |         ll kasu = INFINITY;
      |                   ^~~~~~~~
a.cc:37:16: error: no matching function for call to 'std::vector<long long int>::erase(ll&)'
   37 |         S.erase(erase_num);
      |         ~~~~~~~^~~~~~~~~~~
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,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = long long int; _Alloc = std::allocator<long long int>; iterator = std::vector<long long int>::iterator; const_iterator = std::vector<long long int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::vector<long long int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = long long int; _Alloc = std::allocator<long long int>; iterator = std::vector<long long int>::iterator; const_iterator = std::vector<long long int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
a.cc: In function 'int main()':
a.cc:89:21: warning: overflow in conversion from 'float' to 'std::vector<long long int>::value_type' {aka 'long long int'} changes value from '+Inff' to '9223372036854775807' [-Woverflow]
   89 |     vector<ll> D(N, INFINITY);
      |                     ^~~~~~~~