Problem p02678 (C++) — buggy submission, verdict: Runtime Error

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

using LL = long long;
using VL = vector<LL>;
using VVL = vector<vector<LL>>;
using STR = string;

#define REP(i, n) for (LL i = 0, i##_size = n; i < i##_size; ++i)
#define RREP(i, n) for (LL i = LL(n) - 1; i >= 0; --i)

template <class T> void chmin(T &a, T b) {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, T b) {
  if (b > a) {
    a = b;
  }
}

#define SZ(var) (LL)(var.size())
#define pb push_back

#define IN_LL(var)                                                             \\
  LL var;                                                                      \\
  cin >> var;
#define IN_LL2(var0, var1)                                                     \\
  LL var0, var1;                                                               \\
  cin >> var0 >> var1;
#define IN_LL3(var0, var1, var2)                                               \\
  LL var0, var1, var2;                                                         \\
  cin >> var0 >> var1 >> var2;
#define IN_LL4(var0, var1, var2, var3)                                         \\
  LL var0, var1, var2, var3;                                                   \\
  cin >> var0 >> var1 >> var2 >> var3;

#define IN_VL(var, n)                                                          \\
  VL var(n);                                                                   \\
  REP(i, n) { cin >> var[i]; };
#define IN_STR(var)                                                            \\
  STR var;                                                                     \\
  cin >> var;

#define OUT(var) cout << (var) << '\\n';

void myMain();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(16);
  myMain();
  return 0;
}

void myMain() {
  IN_LL2(N, M);
  VVL R(N);
  REP(i, M) {
    IN_LL2(a, b);
    R[a - 1].pb(b - 1);
    R[b - 1].pb(a - 1);
  }

  VL froms(N, -1);

  VL points;
  points.pb(0);
  froms[0] = 0;

  for (LL d = 1;; ++d) {
    VL nexts;

    for (LL p : points) {
      for (LL n : R[p]) {
        if (froms[n] != -1) {
          continue;
        }

        froms[n] = p;
        nexts.pb(n);
      }
    }

    if (SZ(nexts) == 0) {
      break;
    }

    points = move(nexts);
  }

  OUT("Yes");
  for (LL i = 1; i < N; ++i) {
    OUT(froms[i] + 1);
  }
}

Error: 0

Fixed submission:

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

using LL = long long;
using VL = vector<LL>;
using VVL = vector<vector<LL>>;
using STR = string;

#define REP(i, n) for (LL i = 0, i##_size = n; i < i##_size; ++i)
#define RREP(i, n) for (LL i = LL(n) - 1; i >= 0; --i)

template <class T> void chmin(T &a, T b) {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, T b) {
  if (b > a) {
    a = b;
  }
}

#define SZ(var) (LL)(var.size())
#define pb push_back

#define IN_LL(var)                                                             \\
  LL var;                                                                      \\
  cin >> var;
#define IN_LL2(var0, var1)                                                     \\
  LL var0, var1;                                                               \\
  cin >> var0 >> var1;
#define IN_LL3(var0, var1, var2)                                               \\
  LL var0, var1, var2;                                                         \\
  cin >> var0 >> var1 >> var2;
#define IN_LL4(var0, var1, var2, var3)                                         \\
  LL var0, var1, var2, var3;                                                   \\
  cin >> var0 >> var1 >> var2 >> var3;

#define IN_VL(var, n)                                                          \\
  VL var(n);                                                                   \\
  REP(i, n) { cin >> var[i]; };
#define IN_STR(var)                                                            \\
  STR var;                                                                     \\
  cin >> var;

#define OUT(var) cout << (var) << '\\n';

void myMain();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(16);
  myMain();
  return 0;
}

void myMain() {
  IN_LL2(N, M);
  VVL R(M);
  REP(i, M) {
    IN_LL2(a, b);
    R[a - 1].pb(b - 1);
    R[b - 1].pb(a - 1);
  }

  VL froms(N, -1);

  VL points;
  points.pb(0);
  froms[0] = 0;

  for (LL d = 1;; ++d) {
    VL nexts;

    for (LL p : points) {
      for (LL n : R[p]) {
        if (froms[n] != -1) {
          continue;
        }

        froms[n] = p;
        nexts.pb(n);
      }
    }

    if (SZ(nexts) == 0) {
      break;
    }
    points = move(nexts);
  }

  OUT("Yes");
  for (LL i = 1; i < N; ++i) {
    OUT(froms[i] + 1);
  }
}