Problem p02726 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define setbit0(n, i) ((n) & (~(1LL << (i))))
#define setbit1(n, i) ((n) | (1LL << (i)))
#define togglebit(n, i) ((n) ^ (1LL << (i)))
#define lastone(n) ((n) & (-(n)))
#define read freopen("debug\\in.txt", "r", stdin)
#define write freopen("debug\\out.txt", "w", stdout)
#define fi first
#define se second
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define PI (acos(-1))
#define fastread                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
vector<ll> v[200005];
ll dis[2005][2005];
ll vis[2005];
ll cnt[5000005];
queue<ll> q;
int main() {
  fastread;
  ll n, i, j, k, l, m;
  cin >> n >> k >> l;
  for (i = 1; i < n; i++) {
    v[i].pb(i + 1);
    v[i + 1].pb(i);
  }
  v[k].pb(l);
  v[l].pb(k);
  for (i = 1; i <= n; i++) {
    memset(vis, 0, (n + 10) * sizeof(ll));
    q.push(i);
    vis[i] = 1;
    dis[i][i] = 0;
    while (!q.empty()) {
      ll temp = q.front();
      q.pop();
      for (auto x : v[temp]) {
        if (vis[x] == 0) {
          vis[x] = 1;
          dis[i][x] = dis[i][temp] + 1;
          q.push(x);
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      cnt[dis[i][j]]++;
    }
  }
  for (i = 1; i < n; i++)
    cout << cnt[i] / 2 << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define setbit0(n, i) ((n) & (~(1LL << (i))))
#define setbit1(n, i) ((n) | (1LL << (i)))
#define togglebit(n, i) ((n) ^ (1LL << (i)))
#define lastone(n) ((n) & (-(n)))
#define read freopen("debug\\in.txt", "r", stdin)
#define write freopen("debug\\out.txt", "w", stdout)
#define fi first
#define se second
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define PI (acos(-1))
#define fastread                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
vector<ll> v[200005];
ll dis[2005][2005];
ll vis[2005];
ll cnt[5000005];
queue<ll> q;
int main() {
  fastread;
  ll n, i, j, k, l, m;
  cin >> n >> k >> l;
  for (i = 1; i < n; i++) {
    v[i].pb(i + 1);
    v[i + 1].pb(i);
  }
  v[k].pb(l);
  v[l].pb(k);
  for (i = 1; i <= n; i++) {
    memset(vis, 0, (n + 1) * sizeof(ll));
    q.push(i);
    vis[i] = 1;
    dis[i][i] = 0;
    while (!q.empty()) {
      ll temp = q.front();
      q.pop();
      for (auto x : v[temp]) {
        if (vis[x] == 0) {
          vis[x] = 1;
          dis[i][x] = dis[i][temp] + 1;
          q.push(x);
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      cnt[dis[i][j]]++;
    }
  }
  for (i = 1; i < n; i++)
    cout << cnt[i] / 2 << "\n";
  return 0;
}