Language: C++

#define f first
#define s second
#define loop(a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ll long long
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define loop2(a,b) for(int j=a;j<b;j++)
#define str_in cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define sz(a) int(a.size())
#define displaymatrix(a,m,n) for(int i=0;i<m;i++)\
{for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vl a(n);loop(0,n)cin>>a[i]
#define ainput(a,n) loop(0,n)cin>>a[i]

//#define all(c) c.begin(),c.end()
#define tr(container,it)\
for(__typeof(container.begin()) it=container.begin();it!=container.end();it++)
#include<bits/stdc++.h>

using namespace std;
int visit[200005];
int parent[200005];
queue<int> bfsq;

const int mod=1e+9+7;

void bfs(vvi& g, int node){
    bfsq.push(node);
    visit[node] = 1;
    while(sz(bfsq) > 0){
        int q = bfsq.front();
        bfsq.pop();
        for (auto x:g[q]){
            if (visit[x]) continue;
//            cout << q << " " << x << " ";
            bfsq.push(x);
            visit[x] = 1;
            parent[x] = q;
        }
//        printf("\n");
    }
}

void solve(){
    int n,m;cin>>n>>m;
    memset(visit,0,n);
    memset(parent,-1,n);
    vi a;
    vvi g = vvi(n,a);
    loop(0,m){
        int e1,e2;cin>>e1>>e2;
        g[e1-1].pb(e2-1);g[e2-1].pb(e1-1);
    }
    bfs(g,0);
    cout << "Yes\n";
    loop(1,n) cout << parent[i]+1 << "\n";
//    printf("\n");
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t=1;
    //    cin>>t;
    while(t--) solve();
    return 0;
}

Compiler output:
a.cc: In function 'void bfs(std::vector<std::vector<int> >&, int)':
a.cc:37:5: error: reference to 'visit' is ambiguous
   37 |     visit[node] = 1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:26:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:5: note:                 'int visit [200005]'
   29 | int visit[200005];
      |     ^~~~~
a.cc:42:17: error: reference to 'visit' is ambiguous
   42 |             if (visit[x]) continue;
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:5: note:                 'int visit [200005]'
   29 | int visit[200005];
      |     ^~~~~
a.cc:45:13: error: reference to 'visit' is ambiguous
   45 |             visit[x] = 1;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:5: note:                 'int visit [200005]'
   29 | int visit[200005];
      |     ^~~~~
a.cc: In function 'void solve()':
a.cc:54:12: error: reference to 'visit' is ambiguous
   54 |     memset(visit,0,n);
      |            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:5: note:                 'int visit [200005]'
   29 | int visit[200005];
      |     ^~~~~