Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> prev(n);
    vector<int> dist(n);
    // store distance and node
    priority_queue<int, pair<int, int>, greater<int>> que;

    // Dijkstra
    int MAX_DIST = 10000000;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            dist[i] = 0;
        } else {
            dist[i] = MAX_DIST;
        }
    }
    que.push(make_pair(0, 0));

    unordered_set<int> not_visited;
    for (int i = 0; i < n; i++) {
        not_visited.insert(i);
    }

    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int u = p.second;

        // visited
        if (not_visited.find(u) == not_visited.end()) {
            continue;
        }
        for (int v: to[u]) {
            int d = dist[u] + 1;
            if (dist[v] > d) {
                dist[v] = d;
                prev[v] = u;
                que.push(make_pair(d, v));
            }
        }
        not_visited.erase(u);
        if (not_visited.size() == 0) {
            break;
        }
    }

    // for (int i = 0; i < n; i++) {
    //     if (dist[i] >= MAX_DIST) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            cout << "Yes" << endl;
        } else {
            cout << (prev[i] + 1) << endl;
        }
    }
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<int, std::pair<int, int>, std::greater<int> >':
a.cc:19:55:   required from here
   19 |     priority_queue<int, pair<int, int>, greater<int>> que;
      |                                                       ^~~
/usr/include/c++/14/bits/stl_queue.h:520:67: error: no type named 'value_type' in 'struct std::pair<int, int>'
  520 |       static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
      |                                                                   ^~~~~
/usr/include/c++/14/bits/stl_queue.h:526:57: error: no type named 'value_type' in 'struct std::pair<int, int>'
  526 |       typedef typename  _Sequence::value_type           value_type;
      |                                                         ^~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:527:57: error: no type named 'reference' in 'struct std::pair<int, int>'
  527 |       typedef typename  _Sequence::reference            reference;
      |                                                         ^~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:528:57: error: no type named 'const_reference' in 'struct std::pair<int, int>'
  528 |       typedef typename  _Sequence::const_reference      const_reference;
      |                                                         ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:529:57: error: no type named 'size_type' in 'struct std::pair<int, int>'
  529 |       typedef typename  _Sequence::size_type            size_type;
      |                                                         ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:30:9: error: 'class std::priority_queue<int, std::pair<int, int>, std::greater<int> >' has no member named 'push'
   30 |     que.push(make_pair(0, 0));
      |         ^~~~
a.cc:38:22: error: 'class std::priority_queue<int, std::pair<int, int>, std::greater<int> >' has no member named 'top'; did you mean 'pop'?
   38 |         auto p = que.top();
      |                      ^~~
      |                      pop
a.cc:51:21: error: 'class std::priority_queue<int, std::pair<int, int>, std::greater<int> >' has no member named 'push'
   51 |                 que.push(make_pair(d, v));
      |                     ^~~~