alexjercan/bugnet huggingface dataset:
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

void print_vec(vector<int> vec) {
  cout << "{ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i) + 1 << " ";
  }
  cout << "}" << endl;
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  Graph G(N);
  map<int, int> m;
  for (int i = 0; i < N; i++)
    m[i + 1] = 0;
  for (int i = 0; i < N - 1; i++) {
    G.at(i).push_back(i + 1);
    G.at(i + 1).push_back(i);
  }
  G.at(X - 1).push_back(Y - 1);
  G.at(Y - 1).push_back(X - 1);

  /*
      for(int i = 0; i < N; i++)
          print_vec(G.at(i));
          */

  for (int i = 0; i < N; i++) {
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    dist[i] = 0;
    que.push(i);

    while (!que.empty()) {
      int v = que.front();
      que.pop();
      m[dist.at(v)]++;

      for (int nv : G[v]) {
        if (dist[nv] != -1)
          continue;

        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }
    // for (int v = 0; v < N; ++v) cout << v+1 << ": " << dist[v] << endl;
  }

  for (int i = 0; i < N - 1; i++) {
    cout << m[i + 1] / 2 << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

void print_vec(vector<int> vec) {
  cout << "{ ";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i) + 1 << " ";
  }
  cout << "}" << endl;
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  Graph G(N);
  for (int i = 0; i < N - 1; i++) {
    G.at(i).push_back(i + 1);
    G.at(i + 1).push_back(i);
  }
  G.at(X - 1).push_back(Y - 1);
  G.at(Y - 1).push_back(X - 1);

  /*
      for(int i = 0; i < N; i++)
          print_vec(G.at(i));
          */

  for (int k = 1; k < N; k++) {
    // cout << k << endl;
    int count = 0;
    int seen = 0;
    vector<int> sub_dist(N);
    for (int i = 0; i < N; i++) {
      vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
      queue<int> que;

      dist[i] = 0;
      que.push(i);

      while (!que.empty()) {
        int v = que.front();
        que.pop();
        if (dist[v] == k) {
          // cout << "(" << i+1 << "," << v+1 << ")" << endl;
          count++;
        }

        for (int nv : G[v]) {
          if (dist[nv] != -1)
            continue;

          dist[nv] = dist[v] + 1;
          que.push(nv);
        }
      }
      // for (int v = 0; v < N; ++v) cout << v+1 << ": " << dist[v] << endl;
    }
    cout << count / 2 << endl;
  }

  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn = 2e3 + 10;
int A[maxn];
int n, a, b, huan, l, r;
void check1() {
  for (int i = 1; i <= l; i++) {
    int w = (huan - 1) / 2;
    for (int j = 1; j <= w; j++) {
      if (j == 1)
        A[i + j]--;
      A[i + j] += 2;
    }
  }
  for (int i = 1; i <= r; i++) {
    int w = (huan - 1) / 2;
    for (int j = 1; j <= w; j++) {
      if (j == 1)
        A[i + j]--;
      A[i + j] += 2;
    }
  }
}
void check2() {
  for (int i = 1; i <= l; i++) {
    int w = (huan) / 2;
    for (int j = 1; j <= w; j++) {
      if (j == 1 || j == w)
        A[i + j]--;
      A[i + j] += 2;
    }
  }
  for (int i = 1; i <= r; i++) {
    int w = (huan) / 2;
    for (int j = 1; j <= w; j++) {
      if (j == 1 || j == w)
        A[i + j]--;
      A[i + j] += 2;
    }
  }
}
int main() {

  cin >> n >> a >> b;
  huan = a - 1 + n - b;
  huan = n - huan;
  l = a - 1, r = n - b;
  if (huan & 1) {
    check1();
  } else {
    check2();
  }
  for (int i = 1; i <= l + r + 1; i++) {
    A[l + r + 2 - i] += i;
  }
  A[1]--;
  if (huan & 1) {
    for (int i = 1; i <= huan / 2; i++) {
      A[i] += huan;
    }
  } else {
    for (int i = 1; i <= huan / 2; i++) {
      if (i == huan / 2)
        A[i] += huan / 2;
      else
        A[i] += huan;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << A[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 2005;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
struct node {
  double x, y;
} g[N];
ll a[N][N], b[N];
int main() {
  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);
  memset(a, inf, sizeof(a));
  for (int i = 1; i < n; i++)
    a[i][i + 1] = a[i + 1][i] = 1;
  a[x][y] = a[y][x] = 1;
  //	for(int i=1;i<=n;i++)
  //	{
  //		for(int j=1;j<=n;j++)
  //		cout<<a[i][j]<<"	";
  //		cout<<endl;
  //	}
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (a[i][j] > a[i][k] + a[k][j]) {
          int t = a[i][j];
          a[i][j] = a[i][k] + a[k][j];
          if (i < j)
            b[a[i][j]]++;
          if (i < j && t != a[i][j] && t != inf) {
            b[t]--;
          }
        }
      }
    }
  }
  printf("%d\\n", n);
  for (int i = 2; i < n; i++)
    printf("%d\\n", b[i]);
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
const int N = 2e3 + 5, MAX = 1e9;
int n, x, y, dist[N][N];
map<int, int> mp;
void fw() {
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      dist[i][j] = j - i;
      dist[i][j] =
          min(dist[i][j],
              min(abs(i - x) + abs(y - j), abs(i - y) + abs(j - x)) + 1);
    }
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> x >> y;
  fw();
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      mp[dist[i][j]]++;
  for (int i = 0; i < n - 1; i++) {
    cout << mp[i + 1] << '\\n';
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
const int N = 2e3 + 5, MAX = 1e9;
int n, x, y, dist[N][N];
map<int, int> mp;
void fw() {
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      dist[i][j] = MAX;
  for (int i = 1; i < n; i++) {
    dist[i][i + 1] = 1;
    dist[i + 1][i] = 1;
  }
  dist[x][y] = dist[y][x] = 1;

  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (dist[i][k] + dist[k][j] < dist[i][j])
          dist[i][j] = dist[i][k] + dist[k][j];
      }
    }
  }
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> x >> y;
  fw();
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      mp[dist[i][j]]++;
  for (int i = 0; i < n - 1; i++) {
    cout << mp[i + 1] << '\\n';
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<ll> ans(n);

  rep(i, n) {
    queue<ll> q;
    vector<ll> dist(n, INF);
    auto push = [&](ll v, ll d) {
      if (dist[v] != INF)
        return;
      dist[v] = d;
      q.push(v);
    };
    push(i, 0);
    while (!q.empty()) {
      ll pos = q.front();
      q.pop();
      ll d = dist[pos];
      if (pos - 1 >= 0)
        push(pos - 1, d + 1);
      if (pos + 1 <= n - 1)
        push(pos + 1, d + 1);
      if (pos == x)
        push(y, d + 1);
      if (pos == y)
        push(x, d + 1);
    }
    rep(j, n) ans[dist[j]]++;
  }

  reps1(i, n) { cout << ans[i] / 2 << endl; }

  return 0;
}


Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<ll> ans(n);
  ll c[2] = {-1, 1};

  rep(i, n) {
    queue<ll> q;
    vector<ll> dist(n, INF);
    auto push = [&](ll v, ll d) {
      if (dist[v] != INF)
        return;
      dist[v] = d;
      q.push(v);
    };
    push(i, 0);

    while (!q.empty()) {
      ll d = q.front();
      q.pop();
      rep(i, 2) {
        ll nd = d + c[i];
        if (nd == -1 || nd == n)
          continue;
        push(nd, d + 1);
      }
      if (d == x)
        push(y, d + 1);
      if (d == y)
        push(x, d + 1);
    }
    rep(j, n) ans[dist[j]]++;
  }

  reps1(i, n) { cout << ans[i] / 2 << endl; }

  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int a[2010][2010];
int main() {
  int n, m, i, j, l, p, b[2010];
  cin >> n >> m >> p;
  memset(b, 0, sizeof(b));
  for (i = 1; i < n; i++) {
    for (j = i + 1; j <= n; j++) {
      a[i][j] = min(j - i, abs(i - m) + 1 + abs(j - p));
      b[a[i][j]]++;
    }
  }
  for (i = 1; i < n; i++)
    cout << b[i] << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << '\\n'
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 7;
int a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y, ans;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      ans = j - i;
      ans = min(ans, abs(x - i) + 1 + abs(y - j));
      a[ans]++;
    }
  for (int i = 1; i < n; i++)
    cout << a[i] << "\\n";
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
#define MAX_V 2001
int d[MAX_V][MAX_V];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x, y;
  cin >> n >> x >> y;
  vector<vector<ll>> g(n);
  int dist[n];
  rep(i, n - 1) {
    g[i].pb(i + 1);
    g[i + 1].pb(i);
  }

  g[x - 1].pb(y - 1);
  g[y - 1].pb(x - 1);

  map<ll, ll> cnt;

  queue<ll> q;
  rep(i, n - 1) {
    memset(dist, -1, sizeof(dist));
    dist[i] = 0;
    q.push(i);
    while (!q.empty()) {
      auto v = q.front();
      q.pop();
      rep(j, g[v].size()) {
        int nv = g[v][j];
        if (dist[nv] >= 0)
          continue;
        dist[nv] = dist[v] + 1;
        q.push(nv);
      }
    }
    reps(k, n, i + 1) { cnt[dist[k]]++; }
  }

  // rep(i,MAX_V){
  //     rep(j,MAX_V)d[i][j]=1000000;
  // }

  // rep(i,n-1){
  //     d[i][i+1]=1;
  //     d[i+1][i]=1;
  //     d[i][i]=0;
  // }
  // d[n-1][n-1]=0;
  // d[x-1][y-1]=1;
  // d[y-1][x-1]=1;

  // rep(k,n){
  //     rep(i,n){
  //         rep(j,n){
  //             d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  //         }
  //     }
  // }

  ll ans = 0;
  reps(k, n, 1) {
    if (cnt.count(k)) {
      cout << cnt[k] << endl;
    } else {
      cout << 0 << endl;
    }
  }
  // system("pause");
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
#define MAX_V 2001
int d[MAX_V][MAX_V];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x, y;
  cin >> n >> x >> y;

  rep(i, MAX_V) { rep(j, MAX_V) d[i][j] = 1000000; }
  rep(i, n - 1) {

    d[i][i + 1] = 1;
    d[i + 1][i] = 1;
    d[i][i] = 0;
  }
  d[n - 1][n - 1] = 0;
  d[x - 1][y - 1] = 1;
  d[y - 1][x - 1] = 1;

  rep(k, n) {
    rep(i, n) {
      rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
    }
  }
  map<ll, ll> cnt;
  rep(i, n) {
    reps(j, n, i + 1) { cnt[d[i][j]]++; }
  }
  ll ans = 0;
  reps(k, n, 1) {
    if (cnt.count(k)) {
      cout << cnt[k] << endl;
    } else {
      cout << 0 << endl;
    }
  }
  // system("pause");
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> VL;
typedef pair<ll, ll> PLL;
#define fr(i, x, y) for (ll i = x; i < y; i++)
#define inf 1000 * 1000 * 1000 + 5
const ll mod = 998244353;

vector<VL> adj;
VL ans;
map<PLL, ll> mp;
void bfs(int i, int p, int ct, VL visit) {
  if (p < i) {
    if (!mp.count({p, i})) {
      mp[{p, i}] = ct;
    } else {
      ll x = mp[{p, i}];
      mp[{p, i}] = min(x, (ll)ct);
    }
    // ans[ct]++;
  }
  visit[i] = 1;
  for (auto j : adj[i]) {
    if (visit[j] == 0) {
      bfs(j, p, ct + 1, visit);
    }
  }
}
void solve() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--, y--;

  ans.assign(n, 0);
  fr(i, 0, n) {
    VL temp(n, 0);
    ll ct = 0;
    fr(j, i, n) { temp[j] = ct++; }
    // ct=0;
    // for(int j=i;j>=0;j--)
    // {
    // 	temp[j]=ct++;
    // }
    if (i < y) {
      ll dist = abs(x - i);
      dist++;
      ll pav = dist;
      fr(j, y, n) {
        temp[j] = min(temp[j], dist);
        dist++;
      }

      dist = pav + 1;
      for (int j = y - 1; j >= x; j--) {
        temp[j] = min(dist, temp[j]);
        dist++;
      }
    }
    // cout<<i<<endl;
    // fr(i,0,n)
    // 	cout<<temp[i]<<" ";
    // cout<<"\\n";
    fr(i, 0, n) { ans[temp[i]]++; }
  }
  fr(i, 1, n) { cout << ans[i] << endl; }
  return;
}
int main() {
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> VL;
typedef pair<ll, ll> PLL;
#define fr(i, x, y) for (ll i = x; i < y; i++)
#define inf 1000 * 1000 * 1000 + 5
const ll mod = 998244353;

vector<VL> adj;
VL ans;
map<PLL, ll> mp;
void bfs(int i, int p, int ct, VL visit) {
  if (p < i) {
    if (!mp.count({p, i})) {
      mp[{p, i}] = ct;
    } else {
      ll x = mp[{p, i}];
      mp[{p, i}] = min(x, (ll)ct);
    }
    // ans[ct]++;
  }
  visit[i] = 1;
  for (auto j : adj[i]) {
    if (visit[j] == 0) {
      bfs(j, p, ct + 1, visit);
    }
  }
}
void solve() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--, y--;

  ans.assign(n, 0);
  adj.assign(n, VL());
  fr(i, 0, n - 1) {
    adj[i].push_back(i + 1);
    adj[i + 1].push_back(i);
  }
  adj[x].push_back(y);
  adj[y].push_back(x);
  fr(i, 0, n) {
    VL visit(n, 0);
    bfs(i, i, 0, visit);
  }
  for (auto i : mp) {
    ans[i.second]++;
  }
  fr(i, 1, n) { cout << ans[i] << endl; }
  return;
}
int main() {
  solve();
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e3 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int x;
int y;
int d[N];
int cnt[N];
int used[N][N];
vector<int> g[N];
int main() {
#ifdef FILEs
  freopen("input.txt", "r", stdin);
  /// freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);

  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      d[j] = n;
    }
    queue<int> q;
    q.push(i);
    d[i] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (auto to : g[v]) {
        if (d[to] == n) {
          d[to] = d[v] + 1;
          if (used[i][to] == 0) {
            cnt[d[to]]++;
            used[i][to] = used[to][i] = 1;
          }
          q.push(to);
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    cout << cnt[i] << "\\n";
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int x;
int y;
int cnt[N];
vector<int> g[N];
map<pair<int, int>, int> used;
int main() {
#ifdef FILEs
  freopen("input.txt", "r", stdin);
  /// freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);

  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);
  for (int i = 1; i <= n; i++) {
    vector<int> d(n + 1, inf);
    queue<int> q;
    q.push(i);
    d[i] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (auto to : g[v]) {
        if (d[to] == inf) {
          d[to] = d[v] + 1;
          if (used[{i, to}] == 0) {
            cnt[d[to]]++;
            used[{i, to}] = used[{to, i}] = 1;
          }
          q.push(to);
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    cout << cnt[i] << "\\n";
  }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long int
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

vector<int> adj[1000001];
int vis[1000001];
int dist[1000001];
map<int, int> my;

void bfs(int node) {
  queue<int> q;
  q.push(node);
  vis[node] = 1;
  dist[node] = 0;
  while (!q.empty()) {
    int c = q.front();
    q.pop();
    for (int child : adj[c]) {
      if (!vis[child]) {
        q.push(child);
        vis[child] = 1;
        dist[child] = dist[c] + 1;
        my[dist[child]]++;
      }
    }
  }
}

int main() {
  IOS;
  // #ifndef ONLINE_JUDGE
  // 	freopen("input.txt", "r", stdin);
  // 	freopen("output.txt", "w", stdout);
  // #endif
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    adj[i].pb(i + 1), adj[i + 1].pb(i);
  }
  adj[x].pb(y);
  adj[y].pb(x);
  for (int i = 1; i <= n; i++) {
    bfs(i);
    for (int i = 1; i <= n; i++) {
      vis[i] = 0, dist[i] = 0;
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    cout << my[i] / 2 << "\\n";
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

vector<int> adj[1000001];
int vis[1000001];
int dist[1000001];
map<int, int> my;

void bfs(int node) {
  queue<int> q;
  q.push(node);
  vis[node] = 1;
  dist[node] = 0;
  while (!q.empty()) {
    int c = q.front();
    q.pop();

    for (int child : adj[c]) {
      if (!vis[child]) {
        q.push(child);
        vis[child] = 1;
        dist[child] = dist[c] + 1;
        my[dist[child]]++;
      }
    }
  }
}

int main() {
  IOS;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    adj[i].pb(i + 1), adj[i + 1].pb(i);
  }
  adj[x].pb(y);
  adj[y].pb(x);
  // for (int i = 1; i <= n; i++) {
  // 	cout << i << " -> ";
  // 	for (auto x : adj[i]) {
  // 		cout << x << " ";
  // 	}
  // 	cout << endl;
  // }
  for (int i = 1; i <= n; i++) {
    bfs(i);
    for (int i = 1; i <= n; i++) {
      vis[i] = 0, dist[i] = 0;
    }
  }
  // 5- dist
  for (int i = 1; i <= n - 1; i++) {
    cout << my[i] / 2 << "\\n";
  }
  return 0;
}