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

#include <iostream>
#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> map(n * n);
  rep(i, n) {
    for (int j = i; j < n; j++) {
      map[i * n + j] = j - i;
      map[j * n + i] = j - i;
    }
  }
  map[(x - 1) * n + y - 1] = 1;
  map[(y - 1) * n + x - 1] = 1;
  rep(i, n) {
    rep(j, n) {
      map[i * n + j] =
          min(map[i * n + j], map[i * n + x - 1] + map[(x - 1) * n + j]);
    }
  }
  rep(i, n) {
    rep(j, n) {
      map[i * n + j] =
          min(map[i * n + j], map[i * n + (y - 1)] + map[(y - 1) * n + j]);
    }
  }
  /*
  rep(i,n){
          rep(j,n){
                  cout<<map[i*n+j]<<" ";
          }
          cout<<endl;
  }
  */

  vector<int> a(n, 0);
  rep(i, n) {
    for (int j = i + 1; j < n; j++) {
      a[map[i * n + j] - 1] += 1;
    }
  }
  rep(i, n - 1) { cout << a[i] << endl; }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> map(n * n, 9999999);
  rep(i, n - 1) {
    map[i * n + (i + 1)] = 1;
    map[(i + 1) * n + i] = 1;
  }
  map[(x - 1) * n + y - 1] = 1;
  map[(y - 1) * n + x - 1] = 1;
  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        map[i * n + j] = min(map[i * n + j], map[i * n + k] + map[k * n + j]);
      }
    }
  }
  vector<int> a(n, 0);
  rep(i, n) {
    for (int j = i + 1; j < n; j++) {
      a[map[i * n + j] - 1] += 1;
    }
  }
  rep(i, n - 1) { cout << a[i] << endl; }

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

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x, y) x = max(x, y)
#define gmin(x, y) x = min(x, y)
#define gadd(x, y) x = add(x, y)
#define gmul(x, y) x = mul(x, y)
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const int N = 2e3 + 5;

int cnt[N];

int n, x, y;

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> x >> y;
  rep(i, 1, n + 1) {
    rep(j, i + 1, n + 1) {
      int res = min(j - i, abs(i - x) + 1 + abs(y - j));
      ++cnt[res];
    }
  }
  rep(i, 1, n) cout << cnt[i] << '\\n';
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x, y) x = max(x, y)
#define gmin(x, y) x = min(x, y)
#define gadd(x, y) x = add(x, y)
#define gmul(x, y) x = mul(x, y)
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const int N = 1e3 + 5;

int cnt[N];

int n, x, y;

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> x >> y;
  rep(i, 1, n + 1) {
    rep(j, i + 1, n + 1) {
      int res = min(j - i, abs(i - x) + 1 + abs(y - j));
      ++cnt[res];
    }
  }
  rep(i, 1, n) cout << cnt[i] << '\\n';
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define forsn(i, s, n) for (tint i = (s); i < (tint)(n); i++)
#define forn(i, n) forsn(i, 0, n)
typedef long long tint;
using namespace std;
int main() {
  tint n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<tint> d(n);
  forn(j, n) forn(i, j) d[min(j - i, abs(i - x) + 1 + abs(j - y))]++;
  forsn(r, 1, n) cout << d[r] << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
// typedef pair<int, int> P;
// priority_queue<int, vector<int>, greater<int> > q;
#define MAX 2005
#define INFE 1 << 20

int N;
int mp[MAX][MAX], b[MAX], path[MAX][MAX]; // path[i][j]记录路径

void init() {
  int i, j;
  for (i = 1; i <= N; i++)
    for (j = 1; j <= N; j++) {
      mp[i][j] = INFE;
      path[i][j] = j;
    }
}

void floyd() {
  int i, j, k;
  for (k = 1; k <= N; k++)
    for (i = 1; i <= N; i++)
      for (j = 1; j <= N; j++)
        if (mp[i][j] > mp[i][k] + mp[k][j]) {
          mp[i][j] = mp[i][k] + mp[k][j];
          path[i][j] = path[i][k];
        }
}

int main() {
  int x, y;
  scanf("%d%d%d", &N, &x, &y);
  init();
  for (int i = 1; i < N; i++) {
    mp[i][i + 1] = mp[i + 1][i] = 1;
  }
  mp[x][y] = mp[y][x] = 1;
  floyd();
  // cout<<"de:"<<mp[4][5]<<endl;
  for (int k = 1; k <= N - 1; k++) {
    int temp = k;
    int sum = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        // cout<<i <<" "<< j<<" "<<mp[i][j]<<endl;
        if (mp[i][j] == temp) {
          ++sum;
          // cout << "de:" << i << " " << j << endl;
        }
      }
    }
    printf("%d\\n", sum);
  }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

#define ll long long
const int N = 1e4 + 5;

queue<int> q;
int n;
struct node {
  int from, to, next;
} f[2 * N];
int head[N], tot;
int ans[N], vis[N], dis[N];

void add(int a, int b) {
  f[++tot].from = a;
  f[tot].to = b;
  f[tot].next = head[a];
  head[a] = tot;
}

void clean() {
  memset(dis, 0x7f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
}

void spfa(int s) {
  dis[s] = 0;
  vis[s] = 1;
  q.push(s);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    // cout << head[now];
    for (int i = head[now]; i != -1; i = f[i].next) {
      int v = f[i].to;
      // cout << v;
      if (dis[v] > dis[now] + 1) {
        dis[v] = dis[now] + 1;
        if (!vis[v]) {
          vis[v] = 1;
          q.push(v);
        }
      }
    }
  }
}

int main() {
  int x, y;
  memset(head, -1, sizeof(head));
  cin >> n >> x >> y;
  for (int i = 2; i <= n; i++)
    add(i - 1, i), add(i, i - 1);
  add(x, y), add(y, x);
  for (int i = 1; i <= n; i++) {
    clean();
    spfa(i);
    // cout << i << "GG ";
    for (int j = i + 1; j <= n; j++)
      ans[dis[j]]++; // cout<<dis[j] << " ";
    // cout << endl;
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

#define ll long long
const int N = 1e3 + 5;

queue<int> q;
int n;
struct node {
  int from, to, next;
} f[2 * N];
int head[N], tot;
int ans[N], vis[N], dis[N];

void add(int a, int b) {
  f[++tot].from = a;
  f[tot].to = b;
  f[tot].next = head[a];
  head[a] = tot;
}

void clean() {
  memset(dis, 0x7f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
}

void spfa(int s) {
  dis[s] = 0;
  vis[s] = 1;
  q.push(s);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    // cout << head[now];
    for (int i = head[now]; i != -1; i = f[i].next) {
      int v = f[i].to;
      // cout << v;
      if (dis[v] > dis[now] + 1) {
        dis[v] = dis[now] + 1;
        if (!vis[v]) {
          vis[v] = 1;
          q.push(v);
        }
      }
    }
  }
}

int main() {
  int x, y;
  memset(head, -1, sizeof(head));
  cin >> n >> x >> y;
  for (int i = 2; i <= n; i++)
    add(i - 1, i), add(i, i - 1);
  add(x, y), add(y, x);
  for (int i = 1; i <= n; i++) {
    clean();
    spfa(i);
    // cout << i << "GG ";
    for (int j = i + 1; j <= n; j++)
      ans[dis[j]]++; // cout<<dis[j] << " ";
    // cout << endl;
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << endl;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> cnt(n, 0);
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int k = min(j - i, abs(i - x) + 1 + abs(j - y));
      cnt[k]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
#define INF 100000000
#define MAXN 20000

vector<vector<int>> G(MAXN, vector<int>(MAXN, INF));
vector<int> cnt(MAXN, 0);

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  for (int i = 0; i < N; i++) {
    G[i][i] = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    G[i][i + 1] = 1;
    G[i + 1][i] = 1;
  }
  X--;
  Y--;
  G[X][Y] = 1;
  G[Y][X] = 1;
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (G[i][k] != INF && G[k][j] != INF) {
          G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (G[i][j] != INF) {
        cnt[G[i][j]]++;
      }
    }
  }
  for (int i = 1; i <= N - 1; i++) {
    cout << cnt[i] / 2 << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;

  vector<int> data(N);

  for (int i = 1; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      int a = j - i;
      int b = abs(X - i) + 1 + abs(j - Y);
      int c = min(a, b);

      data.at(c - 1) += 1;
    }
  }

  for (int i = 0; i < N - 1; i++) {
    cout << data.at(i) << endl;
  }
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)


Fixed submission:

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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;

  vector<int> data(N - 1);

  for (int i = 1; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      int a = j - i;
      int b = abs(X - i) + 1 + abs(j - Y);
      int c = min(a, b);

      data.at(c - 1) += 1;
    }
  }

  for (int i = 0; i < N; i++) {
    cout << data.at(i) << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  int arr[n] = {0};
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int k = min(j - i, abs(x - i) + 1 + abs(j - y));
      arr[k]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << arr[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int inf = 0x3f3f3f3f;
int N, X, Y;
vector<vector<int>> graph;
vector<int> dist;
void read() {
  cin >> N >> X >> Y;
  dist.resize(N, 0);
  graph.resize(N, vector<int>(N, inf));

  for (int I = 0; I < N - 1; I++) {
    graph[I][I + 1] = 1;
    graph[I + 1][I] = 1;
  }
  graph[X - 1][Y - 1] = 1;
  graph[Y - 1][X - 1] = 1;
}

void FW() {
  for (int K = 0; K < N; K++) {
    graph[K][K] = 0;

    for (int I = 0; I < N; I++) {
      for (int J = 0; J < N; J++) {
        if (I == J)
          continue;
        if (graph[I][J] > graph[I][K] + graph[K][J]) {
          graph[I][J] = graph[I][K] + graph[K][J];
        }
      }
    }
  }
}

void print() {
  for (int I = 1; I < N; I++) {
    for (int J = 0; J < I; J++) {
      dist[graph[I][J] - 1]++;
    }
  }

  for (int I = 0; I < N - 1; I++) {
    cout << dist[I] << endl;
  }
}

int main() {
  read();
  FW();
  print();
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long LL;
inline LL read() {
  LL kk = 0, f = 1;
  char cc = getchar();
  while (cc < '0' || cc > '9') {
    if (cc == '-')
      f = -1;
    cc = getchar();
  }
  while (cc >= '0' && cc <= '9') {
    kk = (kk << 1) + (kk << 3) + cc - '0';
    cc = getchar();
  }
  return kk * f;
}
LL dis[2022][2022];
LL cun[2022];
int main() {
  LL n, x, y;
  n = read();
  x = read();
  y = read();
  for (LL i = 1; i <= n; ++i)
    for (LL j = 1; j <= n; ++j)
      dis[i][j] = abs(i - j);
  for (LL i = 1; i <= n; ++i)
    for (LL j = 1; j <= n; ++j) {
      dis[i][j] = min(dis[i][j], dis[i][x] + dis[y][j] + 1);
    }
  for (LL i = 1; i <= n; ++i)
    for (LL j = i + 1; j <= n; ++j)
      cun[dis[i][j]]++;
  for (int i = 1; i < n; ++i)
    printf("%d\\n", cun[i]);
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define lowbit(x) ((x) & (-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x) * (x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e3 + 7;
using namespace std;
vector<int> edge[maxn];
int dis[maxn][maxn];
int cnt[maxn];
queue<int> que;
int main(void) {
#ifdef ljxtt
  freopen("data.in", "r", stdin);
#endif
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    edge[i].push_back(i + 1);
    edge[i + 1].push_back(i);
  }
  int x, y;
  scanf("%d%d", &x, &y);
  edge[x].push_back(y);
  edge[y].push_back(x);
  mem(dis, -1);
  for (int i = 1; i <= n; i++) {
    que.push(i);
    dis[i][i] = 0;
    while (que.size()) {
      int now = que.front();
      que.pop();
      for (int j = 0; j < edge[now].size(); j++) {
        int next = edge[now][j];
        if (dis[i][next] != -1)
          continue;
        dis[i][next] = dis[i][now] + 1;
        que.push(next);
      }
    }
  }
  mem(cnt, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cnt[dis[i][j]]++;
    }
  }
  for (int i = 1; i < n; i++)
    printf("%d\\n", cnt[i]);
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
using namespace std;
#define INF 20000
int main() {
  long long N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<long long>> Graph(N, vector<long long>(N, INF));
  for (long long i = 0; i < N - 1; i++) {
    Graph.at(i).at(i + 1) = 1;
    Graph.at(i + 1).at(i) = 1;
  }
  for (int i = 0; i < N; i++) {
    Graph.at(i).at(i) = 0;
  }
  Graph.at(X - 1).at(Y - 1) = 1;
  Graph.at(Y - 1).at(X - 1) = 1;
  vector<long long> ans(30000, 0);
  for (long long i = 0; i < N - 1; i++) {
    for (long long j = i + 1; j < N; j++) {
      Graph.at(i).at(j) = min(j - i, abs(X - i - 1) + 1 + abs(Y - j - 1));
    }
  }
  for (long long i = 0; i < N - 1; i++) {
    for (long long j = i + 1; j < N; j++) {
      ans.at(Graph.at(i).at(j) - 1)++;
    }
  }
  for (long long i = 0; i < N - 1; i++) {
    cout << ans.at(i) << endl;
  }
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  long long N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<long long>> Graph(N, vector<long long>(N, 1e9));
  for (long long i = 0; i < N - 1; i++) {
    Graph.at(i).at(i + 1) = 1;
    Graph.at(i + 1).at(i) = 1;
  }
  Graph.at(X - 1).at(Y - 1) = 1;
  Graph.at(Y - 1).at(X - 1) = 1;
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        Graph.at(i).at(j) =
            min(Graph.at(i).at(j), Graph.at(i).at(k) + Graph.at(k).at(j));
      }
    }
  }
  for (long long k = 1; k < N; k++) {
    long long ans = 0;
    for (long long i = 0; i < N - 1; i++) {
      for (long long j = i + 1; j < N; j++) {
        if (Graph.at(i).at(j) == k)
          ans++;
      }
    }
    cout << ans << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  vector<int> d(n);
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int dist1 = j - i;
      int dist2 = labs(j - y) + labs(i - x) + 1;
      int dist = min(dist1, dist2);
      d[dist]++;
    }
  }

  for (int i = 1; i < n; i++)
    cout << d[i] << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  for (int d = 1; d < n; d++) {
    int pair = 0;
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j <= n; j++) {
        int dist1 = j - i;
        int dist2 = labs(j - y) + labs(i - x) + 1;
        int dist = min(dist1, dist2);
        if (d == dist)
          pair++;
      }
    }
    cout << pair << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int(i) = 0; i < (n); (i)++)
#define ll long long
#define INF 20000000

using namespace std;

// input
int n, x, y;
int ad_list[2001][2001];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> x >> y;

  rep(i, 2001) rep(j, 2001) ad_list[i][j] = INF;

  rep(i, n) {
    rep(j, n) {
      if (i == j)
        continue;
      ad_list[i][j] = min(abs(i - j), ad_list[i][j]);
      ad_list[i][j] = min(ad_list[i][j], abs(i - x + 1) + abs(j - y + 1) + 1);
      ad_list[i][j] = min(ad_list[i][j], abs(i - y + 1) + abs(j - x + 1) + 1);
    }
  }
  int ans[2001];
  rep(i, 2001) ans[i] = 0;
  rep(i, n) rep(j, n) {
    if (i == j)
      continue;
    ans[ad_list[i][j]] += 1;
  }

  rep(i, n - 1) { cout << ans[i + 1] / 2 << endl; }
}


Error: TLE

Fixed submission:

#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int(i) = 0; i < (n); (i)++)
#define ll long long
#define INF 20000000

using namespace std;

// input
int n, x, y;
int ad_list[2001][2001];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> x >> y;

  rep(i, 2001) rep(j, 2001) ad_list[i][j] = INF;

  rep(i, n) {
    rep(j, n) {
      if (i == j)
        continue;
      ad_list[i][j] = min(abs(i - j), ad_list[i][j]);
      ad_list[i][j] = min(ad_list[i][j], abs(i - x + 1) + abs(j - y + 1) + 1);
      ad_list[i][j] = min(ad_list[i][j], abs(i - y + 1) + abs(j - x + 1) + 1);
    }
  }

  rep(i, n - 1) {
    int now = i + 1;
    int ans = 0;
    rep(i, n) rep(j, n) {
      if (i == j)
        continue;
      if (ad_list[i][j] == now)
        ans += 1;
    }
    cout << ans / 2 << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define mem(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define trace(x) cerr << #x << ":" << x << endl;
#define trace2(x, y) cerr << #x << ":" << x << "|" << #y << ":" << y << endl;
#define trace3(x, y, z)                                                        \\
  cerr << #x << ":" << x << "|" << #y << ":" << y << "|" << #z << ":" << z     \\
       << endl;
#define fast_io std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
const int maxn = 2e5 + 7;
const ll MOD = 1e9 + 7;
int n, x, y;
vi ans(maxn, 0);
int dist(int i, int j) {
  return min(abs(j - i), 1 + abs(x - i) + abs(y - j));
  // return min(abs(j-i), min(1+abs(x-i)+abs(y-j), 1+abs(y-i)+abs(x-j)));
}
int main() {
  fast_io;
  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int d = dist(i, j);
      ans[d]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << "\\n";
  // trace(cnt)
  // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\\n";
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define mem(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define trace(x) cerr << #x << ":" << x << endl;
#define trace2(x, y) cerr << #x << ":" << x << "|" << #y << ":" << y << endl;
#define trace3(x, y, z)                                                        \\
  cerr << #x << ":" << x << "|" << #y << ":" << y << "|" << #z << ":" << z     \\
       << endl;
#define fast_io std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
const int maxn = 2e5 + 7;
const ll MOD = 1e9 + 7;
int n, x, y;
vi ans(n + 1, 0);
int dist(int i, int j) {
  return min(abs(j - i), 1 + abs(x - i) + abs(y - j));
  // return min(abs(j-i), min(1+abs(x-i)+abs(y-j), 1+abs(y-i)+abs(x-j)));
}
int main() {
  fast_io;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int d = dist(i, j);
      ans[d]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << "\\n";
  // trace(cnt)
  // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\\n";
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  ll d[n][n];
  vector<ll> K(n - 1, 0);
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      d[i][j] = abs(i - j);
      d[j][i] = abs(i - j);
    }
  }
  d[x - 1][y - 1] = 1;
  d[y - 1][x - 1] = 1;

  for (ll i = 0; i < n; i++) {
    for (ll j = i + 1; j < n; j++) {
      d[i][j] = min(d[i][j], d[i][x - 1] + d[j][y - 1] + 1);
    }
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = i + 1; j < n; j++) {
      K[d[i][j] - 1]++;
    }
  }
  for (ll i = 0; i < n - 1; i++) {
    cout << K[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  ll d[n][n];
  vector<ll> K(n - 1, 0);
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      if (abs(i - j) == 1) {
        d[i][j] = 1;
      } else if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = n + 1;
      }
    }
  }
  d[x - 1][y - 1] = 1;
  d[y - 1][x - 1] = 1;

  for (ll k = 0; k < n; k++) {
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = i + 1; j < n; j++) {
      K[d[i][j] - 1]++;
    }
  }
  for (ll i = 0; i < n - 1; i++) {
    cout << K[i] << endl;
  }
}