Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
vector<ll>adj[1000000];
bool visit[1000000];
ll arr[1000000];
queue<ll>num;
void bfs(ll s,vector<ll>adj[])
{
    if(visit[s]==true)
    return;
    visit[s]=true;
    for(int i=0;i<adj[s].size();i++)
    {
        if(visit[adj[s][i]]==0 && arr[adj[s][i]]==0)
        {
            arr[adj[s][i]]=s;
            num.push(adj[s][i]);
        }
    }
    num.pop();
    bfs(num.front(),adj);
}
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll x,y;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    num.push(1);
    bfs(1,adj);
    for(int i=2;i<=n;i++)
    {
        if(visit[i]==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<"\n";
    for(int i=2;i<=n;i++)
    cout<<arr[i]<<"\n";

    

    return 0;
}

Compiler output:
a.cc: In function 'void bfs(long long int, std::vector<long long int>*)':
a.cc:12:8: error: reference to 'visit' is ambiguous
   12 |     if(visit[s]==true)
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc: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:7:6: note:                 'bool visit [1000000]'
    7 | bool visit[1000000];
      |      ^~~~~
a.cc:14:5: error: reference to 'visit' is ambiguous
   14 |     visit[s]=true;
      |     ^~~~~
/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:7:6: note:                 'bool visit [1000000]'
    7 | bool visit[1000000];
      |      ^~~~~
a.cc:17:12: error: reference to 'visit' is ambiguous
   17 |         if(visit[adj[s][i]]==0 && arr[adj[s][i]]==0)
      |            ^~~~~
/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:7:6: note:                 'bool visit [1000000]'
    7 | bool visit[1000000];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:43:12: error: reference to 'visit' is ambiguous
   43 |         if(visit[i]==0)
      |            ^~~~~
/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:7:6: note:                 'bool visit [1000000]'
    7 | bool visit[1000000];
      |      ^~~~~