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

#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n + 1); ++(i))
#define REPR(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = (m)-1; i >= (n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>());
#define BIT(n) (1LL << (n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x, y) __gcd(x, y)
#define LCM(x, y) x / __gcd(x, y) * y
#define PB push_back
#define MP make_pair
#define endl "\\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x)                                                                \\
  for (auto iter : x)                                                          \\
  p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<pair<int, int>>>;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T> void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back())
      cout << " ";
  }
  cout << endl;
}
template <class T> void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  int ans = 0;

  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5])
    yes;
  else
    no;

  return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc160/abc160_a && sh
shellscripts/test_cpp.sh cd
~/Desktop/Programming/AtCoder/contest/abc160/abc160_a && sh
shellscripts/etest_cpp.sh cd
~/Desktop/Programming/AtCoder/contest/abc160/abc160_a && sh
shellscripts/submit_cpp.sh
*/


Error: -11

Fixed submission:

#include "bits/stdc++.h"
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define ALL(v) v.begin(), v.end()
#define FS first
#define SC second
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(), (c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define SQR(x) ((x) * (x))
#define BIT(n) (1LL << (n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x, y) __gcd(x, y)
#define LCM(x, y) x / __gcd(x, y) * y
#define PB push_back
#define MP make_pair
#define endl "\\n"
using namespace std;
typedef long long lint;
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<LL>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const LL MOD = 1000000007ll;
const LL INF = 2000000000ll;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

long power(long a, long b) {
  return b ? power(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD : 1;
}

long perm(int N, int K) {
  long x = 1;
  for (int i = 1; i <= K; i++) {
    x = x * (N - i + 1) % MOD;
  }
  return x % MOD;
}

long factorial(int N) { return perm(N, N); }

long comb(int N, int K) {
  long x = 1, y = 1;
  for (int i = 1; i <= K; i++) {
    x = x * (N - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * power(y, MOD - 2) % MOD;
}

long hcomb(int N, int K) { return comb(N + K - 1, N - 1); }

int dtoi(double d) {
  if ((double)2 * d - floor(d) - ceil(d) >= 0)
    return ceil(d);
  else
    return floor(d);
}

bool isprime(int n) {
  if (n < 2)
    return false;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0)
      return false;
  }
  return true;
}

void eratosthenes(int n) {
  // エラトステネスのふるい
  bitset<1000000> is_prime(0); // 十分大きなサイズを確保します
  for (int i = 2; i <= n; ++i)
    is_prime.set(i); // とりあえず全部ふるいに入れます
  for (int i = 2; i <= n; ++i) {
    if (is_prime[i]) { // 素数 i を発見したら
      for (int j = i * 2; j <= n; j += i) {
        is_prime.reset(j); // i の倍数をふるい落とす
      }
    }
  }
  for (int i = 2; i <= n; ++i) {
    if (is_prime[i])
      cout << i << endl;
  }
}

void dfs(const vector<vector<int>> &G, int v, vector<int> &seen) {
  seen[v] = true; // v を訪問済にする

  // v から行ける各頂点 next_v について
  for (int next_v : G[v]) {
    if (seen[next_v])
      continue;           // next_v が探索済だったらスルー
    dfs(G, next_v, seen); // 再帰的に探索
  }
}

void bfs(const vector<vector<int>> &G, int v, vector<int> &dist) {
  REP(i, SZ(dist)) dist[i] = -1; // 全頂点を「未訪問」に初期化
  queue<int> que;

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

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

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

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

int knapsack01(int N, int W, vector<int> &value, vector<int> &weight) {
  VVI dp(N + 1, VI(W + 1, 0));
  REP(i, N) REP(j, W + 1) {
    if (j - weight[i] >= 0)
      dp[i + 1][j] = max(dp[i][j - weight[i]] + value[i], dp[i][j]);
    else
      dp[i + 1][j] = dp[i][j];
  }
  return dp[N][W];
}

int knapsack01_reuse(int N, int W, vector<int> &value, vector<int> &weight) {
  VI dp(W + 1, 0);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = W; j > 0; j--) {
      if (j - weight[i] >= 0)
        dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
    }
  }
  return dp[W];
}

int knapsack(int N, int W, vector<int> &value, vector<int> &weight) {
  VVI dp(N + 1, VI(W + 1, 0));
  REP(i, N) REP(j, W + 1) {
    dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
    if (j - weight[i] >= 0)
      dp[i + 1][j] = max(dp[i + 1][j - weight[i]] + value[i], dp[i + 1][j]);
  }
  return dp[N][W];
}

int knapsack_reuse(int N, int W, vector<int> &value, vector<int> &weight) {
  VI dp(W + 1, 0);
  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int w = weight[i]; w <= W; ++w) {
      dp[w] = max(dp[w], dp[w - weight[i]] + value[i]);
    }
  }
  return dp[W];
}

int longest_increasing_subsequence(int n, vector<int> &A) {
  vector<int> L(n + 1, 0);
  L[0] = A[0];
  int length = 1;

  FOR(i, 1, n) {
    if (L[length - 1] < A[i])
      L[length++] = A[i];
    else
      *lower_bound(L.begin(), next(L.begin(), length), A[i]) = A[i];
  }

  return length;
}

int longest_common_subsequence(string X, string Y) {
  int m = X.length();
  int n = Y.length();
  int res = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  VVI c(m + 1, VI(n + 1, 0));
  FOR(i, 1, m + 1) FOR(j, 1, n + 1) {
    if (X[i] == Y[j])
      c[i][j] = c[i - 1][j - 1] + 1;
    else
      c[i][j] = max(c[i - 1][j], c[i][j - 1]);
    res = max(res, c[i][j]);
  }
  return res;
}

void dijkstra(int n, const vector<vector<pair<int, int>>> &G, int v,
              vector<int> &dist) {
  priority_queue<pair<int, int>> pq;
  vector<int> color(n, 0);
  REP(i, n) dist[i] = INF;
  dist[v] = 0;
  pq.push(make_pair(0, v));
  color[v] = 1;

  while (!pq.empty()) {
    pair<int, int> f = pq.top();
    pq.pop();
    int u = f.second;
    color[u] = 2;

    if (dist[u] < f.first * (-1))
      continue;

    REP(j, G[u].size()) {
      v = G[u][j].first;
      if (color[v] == 2)
        continue;
      if (dist[v] > dist[u] + G[u][j].second) {
        dist[v] = dist[u] + G[u][j].second;
        pq.push(make_pair(dist[v] * (-1), v));
        color[v] = 1;
      }
    }
  }
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) { // 最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x);        // xの根をrx
    int ry = root(y);        // yの根をry
    if (rx == ry)
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry; // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  VVI G(N);
  REP(i, N - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);
  VVI d(N, VI(N, -1));
  REP(i, N) { bfs(G, i, d[i]); }
  VI mp(N, 0);
  REP(i, N) FOR(j, i + 1, N) { mp[d[i][j]]++; }
  REP(i, N - 1) cout << mp[i + 1] << endl;
}