Language: C++

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 5;
vector<int> adj[N];
int n, m, visit[N], pa[N];

void dfs(int node) {
	if(visit[node])
		return;
	visit[node] = 1;
	// pa[node] = p;
	for(int x: adj[node]) {
		dfs(x);
	}
}

void bfs() {
	clr(visit, 0);
	queue<int> q;
	q.push(0);
	while(!q.empty()) {
		int f = q.front();
		q.pop();
		for(int x: adj[f]) {
			if(!visit[x]) {
				visit[x] = 1;
				q.push(x);
				pa[x] = f;
			}
		}
	}
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    REP(i, 0, m) {
    	int x, y;
    	cin >> x >> y;
    	--x, --y;
    	adj[x].pb(y);
    	adj[y].pb(x);
    }
    dfs(0);
    REP(i, 0, n) {
    	pa[i] = 1e9;
    	if(!visit[i]) {
    		cout << "No\n";
    		return 0;
    	}
    }
    bfs();
    cout << "Yes\n";
    REP(i, 1, n) {
    	cout << pa[i]+1 << "\n";
    }
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:26:12: error: reference to 'visit' is ambiguous
   26 |         if(visit[node])
      |            ^~~~~
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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~
a.cc:28:9: error: reference to 'visit' is ambiguous
   28 |         visit[node] = 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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~
a.cc: In function 'void bfs()':
a.cc:36:13: error: reference to 'visit' is ambiguous
   36 |         clr(visit, 0);
      |             ^~~~~
a.cc:11:26: note: in definition of macro 'clr'
   11 | #define clr(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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~
a.cc:36:13: error: reference to 'visit' is ambiguous
   36 |         clr(visit, 0);
      |             ^~~~~
a.cc:11:39: note: in definition of macro 'clr'
   11 | #define clr(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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~
a.cc:43:29: error: reference to 'visit' is ambiguous
   43 |                         if(!visit[x]) {
      |                             ^~~~~
/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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~
a.cc:44:33: error: reference to 'visit' is ambiguous
   44 |                                 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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~
a.cc: In function 'int main()':
a.cc:66:13: error: reference to 'visit' is ambiguous
   66 |         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:23:11: note:                 'int visit [100005]'
   23 | int n, m, visit[N], pa[N];
      |           ^~~~~