Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 100005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
vector<ll>adj[MAX];
ll level[MAX],ans[MAX];
bool visit[MAX];
void bfs()
{
    ms(level,-1);
    ms(visit,false);
    visit[1]=true;
    level[1]=0;
    ll i,j,k,l,n,m,r;
    queue<ll>pq;
    pq.push(1LL);
    while(!pq.empty())
    {
        n=pq.front();
        pq.pop();
        for(i=0;i<adj[n].size();i++)
        {
            m=adj[n][i];
            if(level[m]==-1||level[m]>level[n]+1)
            {
                level[m]=level[n]+1;
                ans[m]=n;
            }
            if(!visit[m])
            {
                visit[m]=true;
                pq.push(m);
            }
        }
    }
}
int main()
{
    ll i,j,k,l,n,m;
    in(n);in(m);
    ll u,v;
    for(i=0;i<m;i++)
    {
        in(u);in(v);
        adj[u].pb(v);
        adj[v].pb(u);
    }
    bfs();
    bool ok=true;
    for(i=2;i<=n;i++)
    {
        if(level[i]==-1)
        {
            ok=false;
            break;
        }
    }
    if(!ok)
    {
        puts("No");
        return 0;
    }
    puts("Yes");
    for(i=2;i<=n;i++){out(ans[i]);endl;}
}


Compiler output:
a.cc: In function 'void bfs()':
a.cc:31:8: error: reference to 'visit' is ambiguous
   31 |     ms(visit,false);
      |        ^~~~~
a.cc:9:24: note: in definition of macro 'ms'
    9 | #define ms(a,b) memset(a, b, sizeof(a))
      |                        ^
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:27:6: note:                 'bool visit [100005]'
   27 | bool visit[MAX];
      |      ^~~~~
a.cc:31:8: error: reference to 'visit' is ambiguous
   31 |     ms(visit,false);
      |        ^~~~~
a.cc:9:37: note: in definition of macro 'ms'
    9 | #define ms(a,b) memset(a, b, sizeof(a))
      |                                     ^
/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:27:6: note:                 'bool visit [100005]'
   27 | bool visit[MAX];
      |      ^~~~~
a.cc:32:5: error: reference to 'visit' is ambiguous
   32 |     visit[1]=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:27:6: note:                 'bool visit [100005]'
   27 | bool visit[MAX];
      |      ^~~~~
a.cc:49:17: error: reference to 'visit' is ambiguous
   49 |             if(!visit[m])
      |                 ^~~~~
/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:27:6: note:                 'bool visit [100005]'
   27 | bool visit[MAX];
      |      ^~~~~
a.cc:51:17: error: reference to 'visit' is ambiguous
   51 |                 visit[m]=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:27:6: note:                 'bool visit [100005]'
   27 | bool visit[MAX];
      |      ^~~~~