Language: C++

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using ll = long long;
using namespace std;
const ll INF = 10000000000000;
int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> road(M, vector<ll>(2));
	for (int i = 0; i < M; i++) {
		for (int j = 0; i < 2; j++) cin >> road[i][j];
	}
	map<int, int> ans(N - 1);
	ll cnt = 1; ll count = 0;
	for(int j = 0;j < N;j++) {
		int i = 0;
		for (int k = 0; k < M; k++) {
			for (int l = 0; l < 2; l++) {
				if (road[k][l] == cnt) {
					ans[road[k][1 - l]] = cnt;
					i = ans[road[k][1 - l]];
					count++;
				}
			}
		}
		cnt = i;
	}
	if (ans.size() == N - 1) {
		cout << "Yes" << endl;
		for (int i = 0; i < N; i++) {
			cout << ans[N + 2] << endl;
		}
	}
	else cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:32: error: no matching function for call to 'std::map<int, int>::map(ll)'
   30 |         map<int, int> ans(N - 1);
      |                                ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _InputIterator> std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator, const _Compare&, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  302 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:302:9: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _InputIterator> std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  285 |         map(_InputIterator __first, _InputIterator __last)
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:285:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _InputIterator> std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  268 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:268:9: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::initializer_list<std::pair<const _Key, _Tp> >, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  262 |       map(initializer_list<value_type> __l, const allocator_type& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:262:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::map<_Key, _Tp, _Compare, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::__type_identity_t<_Alloc> = std::allocator<std::pair<const int, int> >]'
  256 |       map(map&& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:256:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp, _Compare, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::__type_identity_t<_Alloc> = std::allocator<std::pair<const int, int> >]'
  252 |       map(const map& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:252:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:248:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  248 |       map(const allocator_type& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:248:33: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const std::map<int, int>::allocator_type&' {aka 'const std::allocator<std::pair<const int, int> >&'}
  248 |       map(const allocator_type& __a)
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Compare&, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  240 |       map(initializer_list<value_type> __l,
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:240:40: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::initializer_list<std::pair<const int, int> >'
  240 |       map(initializer_list<value_type> __l,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  227 |       map(map&&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:227:11: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::map<int, int>&&'
  227 |       map(map&&) = default;
      |           ^~~~~
/usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  219 |       map(const map&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:219:11: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const std::map<int, int>&'
  219 |       map(const map&) = default;
      |           ^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:206:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const _Compare&, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
  206 |       map(const _Compare& __comp,
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:206:27: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const std::less<int>&'
  206 |       map(const _Compare& __comp,
      |           ~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map() [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  197 |       map() = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:197:7: note:   candidate expects 0 arguments, 1 provided