Language: C++

#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
#include<queue>
#include <set>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

int N, M;


 
bool visited[100005];
queue<int> q;
vector<int> ans(100005);

vector<int> v(100005);

int32_t  main() {

	IOS;

	

	cin >> N >> M;
	//vector<vector<int> > v(N + 1, vector<int>(N + 1, 0));
	bool flag = false;
	for (int i = 0; i < M; i++) {

		int r1, r2;

		cin >> r1 >> r2;

		v[r1].push_back(r2);

		v[r2].push_back(r1);

		if (r1 == 1 || r2 == 1)
			flag = true;

	}

	if (!flag) {
		cout << "No" << endl;
	}
	else {

		

		q.push(1);


		while (q.size()) {

			int tmp = q.front();
			q.pop();

			if (!visited[tmp]) {

				visited[tmp] = true;

				for (int i : v[tmp]) {

					q.push(i);
					if (ans[i] == 0) {
						ans[i] = tmp;
					}

				}

			}

		}
		cout << "Yes" << endl;

		for (int i = 2; i <= N; i++) {

			cout << ans[i] << endl;
		}

	}

 

}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:47:23: error: request for member 'push_back' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)r1))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   47 |                 v[r1].push_back(r2);
      |                       ^~~~~~~~~
a.cc:49:23: error: request for member 'push_back' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)r2))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   49 |                 v[r2].push_back(r1);
      |                       ^~~~~~~~~
a.cc:75:51: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   75 |                                 for (int i : v[tmp]) {
      |                                                   ^
      |                                                   std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:75:51: error: 'end' was not declared in this scope; did you mean 'std::end'?
   75 |                                 for (int i : v[tmp]) {
      |                                                   ^
      |                                                   std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~