Language: C++

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

bool BFS(vector<int> adj[], int src, int dest, int v, int pred[], int dist[])

    list<int> queue;

    bool visited[v];

    for (int i = 0; i < v; i++) {
        visited[i] = false;
        dist[i] = INT_MAX;
        pred[i] = -1;
    }

    visited[src] = true;
    dist[src] = 0;
    queue.push_back(src);

    while (!queue.empty()) {
        int u = queue.front();
        queue.pop_front();
        for (int i = 0; i < adj[u].size(); i++) {
            if (visited[adj[u][i]] == false) {
                visited[adj[u][i]] = true;
                dist[adj[u][i]] = dist[u] + 1;
                pred[adj[u][i]] = u;
                queue.push_back(adj[u][i]);

                if (adj[u][i] == dest)
                    return true;
            }
        }
    }

    return false;
}

int printShortestDistance(vector<int> adj[], int s, int dest, int v)
{
    int pred[v], dist[v];

    if (BFS(adj, s, dest, v, pred, dist) == false) {
        return -1;
    }

    vector<int> path;
    int crawl = dest;
    path.push_back(crawl);
    while (pred[crawl] != -1) {
        path.push_back(pred[crawl]);
        crawl = pred[crawl];
    }
  return path[1];
}

void addEdge(vector <int> edges[], int u, int v)
{
   edges[u].push_back(v);
   edges[v].push_back(u);
}

int main()
{
    int n,e;
    cin>>n>>e;

    vector <int> edges[n];
    int flag=1;
    vector<int> v;

    for(int i=0;i<e;i++)
    {
        int a,b;
        cin>>a>>b;
        addEdge(edges, a-1, b-1);
    }

    for(int i=1;i<n;i++)
    {
        int x=printShortestDistance(edges,0,i,e);
        if(x==-1)
        {
            flag=0;
            break;
        }

        else
            v.push_back(x+1);
    }

    if(flag==0)
        cout<<"No";
    else
    {
        cout<<"Yes \n";
        for(int i=0;i<v.size();i++)
            cout<<v[i]<<"\n";
    }
    
    return 0;
}


Compiler output:
a.cc:7:5: error: expected initializer before 'list'
    7 |     list<int> queue;
      |     ^~~~
a.cc:9:18: error: 'v' was not declared in this scope
    9 |     bool visited[v];
      |                  ^
a.cc:11:5: error: expected unqualified-id before 'for'
   11 |     for (int i = 0; i < v; i++) {
      |     ^~~
a.cc:11:21: error: 'i' does not name a type
   11 |     for (int i = 0; i < v; i++) {
      |                     ^
a.cc:11:28: error: 'i' does not name a type
   11 |     for (int i = 0; i < v; i++) {
      |                            ^
a.cc:17:5: error: 'visited' does not name a type
   17 |     visited[src] = true;
      |     ^~~~~~~
a.cc:18:5: error: 'dist' does not name a type
   18 |     dist[src] = 0;
      |     ^~~~
a.cc:19:10: error: expected unqualified-id before '.' token
   19 |     queue.push_back(src);
      |          ^
a.cc:21:5: error: expected unqualified-id before 'while'
   21 |     while (!queue.empty()) {
      |     ^~~~~
a.cc:37:5: error: expected unqualified-id before 'return'
   37 |     return false;
      |     ^~~~~~
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^
a.cc: In function 'int printShortestDistance(std::vector<int>*, int, int, int)':
a.cc:44:9: error: 'BFS' was not declared in this scope
   44 |     if (BFS(adj, s, dest, v, pred, dist) == false) {
      |         ^~~