Language: C++

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n, m;
  cin >> n >> m;
  vll a(m), b(m);

  for (ll i = 0; i < m; ++i)
  {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  ll O = 0;
  rep(i, n)
  {
    O += pow(2, n);
  }

  while(O)
  {
    Graph G(n);
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    vb flag(n, false), RL(m, true);
    ll tmp = O;
    ll now = 0;
    while(tmp)
    {
      if(tmp % 2 == 1) flag[now] = true;
      now++;
      tmp /= 2;
    }
    for (ll i = 0; i < m; ++i)
    {
      if(flag[i]) G[a].push_back(b);
      else G[b].push_back(a);
    }
    // BFS のためのデータ構造
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty())
    {
      int v = que.front(); // キューから先頭頂点を取り出す
      que.pop();

      // v から辿れる頂点をすべて調べる
      for (int nv : G[v])
      {
        if (dist[nv] != -1)
          continue; // すでに発見済みの頂点は探索しない

        // 新たな白色頂点 nv について距離情報を更新してキューに追加する
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }

    bool ans = true;
    for(ll i = 1; i < n; i++)
    {
      if (dist[i] == -1)
        ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    if (ans)
    {
      for (ll i = 1; i < n; i++)
      {
        cout << dist[i] << endl;
      }
    }
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Compiler output:
a.cc: In function 'void Main()':
a.cc:98:20: error: no match for 'operator[]' (operand types are 'Graph' {aka 'std::vector<std::vector<int> >'} and 'vll' {aka 'std::vector<long long int>'})
   98 |       if(flag[i]) G[a].push_back(b);
      |                    ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/queue:63,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<long long int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; const_reference = const std::vector<int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<long long int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:99:13: error: no match for 'operator[]' (operand types are 'Graph' {aka 'std::vector<std::vector<int> >'} and 'vll' {aka 'std::vector<long long int>'})
   99 |       else G[b].push_back(a);
      |             ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<long long int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; const_reference = const std::vector<int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'vll' {aka 'std::vector<long long int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:102:17: error: redeclaration of 'std::vector<int> dist'
  102 |     vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
      |                 ^~~~
a.cc:83:17: note: 'std::vector<int> dist' previously declared here
   83 |     vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
      |                 ^~~~
a.cc:103:16: error: redeclaration of 'std::queue<int> que'
  103 |     queue<int> que;
      |                ^~~
a.cc:84:16: note: 'std::queue<int> que' previously declared here
   84 |     queue<int> que;
      |                ^~~