Language: C++

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

vector <int> v[N];
int par[N];
bool visit[N];

int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    fill(visit, false);
    fill(par, -1);
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    queue <int> q;
    q.push(1);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        //visit[u]=true;
        int l=v[u].size();
        for(int i=0;i<l;i++)
        {
            if(!visit[v[u][i]])
            {
                visit[v[u][i]]=true;
                q.push(v[u][i]);
                par[v[u][i]]=u;
            }
        }
    }
    int f=0;
    for(int i=2;i<=n;i++)
    {
        if(!visit[i])
        {
            f=1;
            break;
        }
    }
    if(f==1)
    cout<<"No";
    else
    {
        cout<<"Yes\n";
        for(int i=2;i<=n;i++)
        cout<<par[i]<<"\n";
    }
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:53:10: error: reference to 'visit' is ambiguous
   53 |     fill(visit, false);
      |          ^~~~~
a.cc:21:26: note: in definition of macro 'fill'
   21 | #define fill(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:7:
/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:46:6: note:                 'bool visit [200005]'
   46 | bool visit[N];
      |      ^~~~~
a.cc:53:10: error: reference to 'visit' is ambiguous
   53 |     fill(visit, false);
      |          ^~~~~
a.cc:21:39: note: in definition of macro 'fill'
   21 | #define fill(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:46:6: note:                 'bool visit [200005]'
   46 | bool visit[N];
      |      ^~~~~
a.cc:72:17: error: reference to 'visit' is ambiguous
   72 |             if(!visit[v[u][i]])
      |                 ^~~~~
/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:46:6: note:                 'bool visit [200005]'
   46 | bool visit[N];
      |      ^~~~~
a.cc:74:17: error: reference to 'visit' is ambiguous
   74 |                 visit[v[u][i]]=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:46:6: note:                 'bool visit [200005]'
   46 | bool visit[N];
      |      ^~~~~
a.cc:83:13: error: reference to 'visit' is ambiguous
   83 |         if(!visit[i])
      |             ^~~~~
/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:46:6: note:                 'bool visit [200005]'
   46 | bool visit[N];
      |      ^~~~~