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

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

#define endl '\\n'

int const N = 2001, INF = (int)1e9;
vector<int> adj[N];
int n, dist[N];

void dijkstra(int x) {
  for (int i = 0; i < n; i++)
    dist[i] = INF;
  dist[x] = 0;
  priority_queue<int, vector<int>, greater<int>> pq;
  pq.push(x);
  while (!pq.empty()) {
    int top = pq.top();
    pq.pop();
    for (int f : adj[top]) {
      if (dist[f] > dist[top] + 1) {
        dist[f] = dist[top] + 1;
        pq.push(f);
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int x, y;
  cin >> n >> x >> y;

  for (int i = 0; i < n - 1; i++) {
    adj[i].push_back(i + 1);
    adj[i + 1].push_back(i);
  }
  adj[--x].push_back(--y);
  adj[--y].push_back(--x);

  int ans[n];
  memset(ans, 0, sizeof ans);
  for (int i = 0; i < n; i++) {
    dijkstra(i);
    for (int j = i + 1; j < n; j++) {
      ans[dist[j]]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << endl;
}

Error: TLE

Fixed submission:

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

#define endl '\\n'

int const N = 2001, INF = (int)1e9;
int dist[N][N], n;

void floyd() {
  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() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int x, y;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dist[i][j] = INF;
    }
  }
  dist[x][y] = 1;
  dist[y][x] = 1;
  for (int i = 1; i < n; i++) {
    dist[i][i + 1] = 1;
    dist[i + 1][i] = 1;
  }
  floyd();
  int ans[n];
  memset(ans, 0, sizeof ans);
  // cout << "oi\\n";
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      ans[dist[i][j]]++;
      // cout << "dist de " << i << " para " << j << " eh: " << dist[i][j] <<
      // endl;
    }
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << endl;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

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

  map<ll, ll> ans;
  REP(i, N) {
    FOR(j, i + 1, N - 1) {
      ll d1 = j - i;
      ll d2 = abs(X - i) + 1 + abs(Y - j);
      ans[min(d1, d2)]++;
    }
  }

  FOR(i, 1, N - 1) { cout << ans[i] << endl; }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

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

  ll **d = new ll *[N];
  REP(i, N) {
    d[i] = new ll[N];
    REP(j, N) { d[i][j] = INF; }
  }

  FOR(i, 0, N - 2) { d[i][i + 1] = d[i + 1][i] = 1; }
  d[X][Y] = d[Y][X] = 1;

  REP(k, N) {
    REP(i, N) {
      if (d[i][k] == INF)
        continue;

      REP(j, N) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
    }
  }

  vector<ll> ans(N);
  REP(i, N) {
    FOR(j, i + 1, N - 1) { ans[d[i][j]]++; }
  }

  FOR(i, 1, N - 1) { cout << ans[i] << endl; }

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

#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, x, y;
  cin >> n >> x >> y;

  vector<int> k(n, 0);
  vector<vector<int>> adj(n + 1, vector<int>(n + 1, 0));
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      adj[i][j] = min({adj[i][j - 1] + 1, abs(x - i) + abs(j - y) + 1});
      k[adj[i][j]]++;
    }
  }

  for (int i = 1; i <= n - 1; ++i) {
    cout << k[i] << '\\n';
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n, x, y;
  cin >> n >> x >> y;
  int d = y - x - 1;
  for (int k = 1; k <= n - 1; ++k) {
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        int cd = min({j - i, abs(x - i) + abs(y - j) + 1});
        if (cd == k)
          ++cnt;
      }
    }
    cout << cnt << '\\n';
  }
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e3 + 5, inf = 0x3f3f3f3f;
#define mst(a) memset(a, 0, sizeof a)
ll a[N][N], ans[N], n;
void init() {
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      a[i][j] = a[j][i] = j - i;
}
int main() {
  ll x, y;
  while (cin >> n >> x >> y) {
    mst(a), mst(ans);
    init();
    for (int i = 1; i < n; i++)
      for (int j = i + 1; j <= n; j++) {
        if (i <= x && j >= y) {
          a[i][j] = min(a[i][j], x - i + j - y + 1);
        }
        if (i >= x && j >= y) {
          a[i][j] = min(a[i][j], i - x + 1 + j - y);
        }
        if (i >= x && j <= y) {
          a[i][j] = min(a[i][j], i - x + 1 + y - j);
        }
        if (i <= x && j <= y) {
          a[i][j] = min(a[i][j], y - j + 1 + x - i);
        }
        ans[a[i][j]]++;
        // printf("a[%d][%d]=%d\\n",i,j,a[i][j]);
      }
    for (int i = 1; i < n; i++)
      printf(i == n - 1 ? "%lld\\n" : "%lld ", ans[i]);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 5, inf = 0x3f3f3f3f;
#define mst(a) memset(a, 0, sizeof a)
ll a[N][N], ans[N], n;
void init() {
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      a[i][j] = a[j][i] = j - i;
}
int main() {
  ll x, y;
  while (cin >> n >> x >> y) {
    mst(a), mst(ans);
    init();
    for (int i = 1; i < n; i++)
      for (int j = i + 1; j <= n; j++) {
        if (i <= x && j >= y) {
          a[i][j] = min(a[i][j], x - i + j - y + 1);
        }
        if (i >= x && j >= y) {
          a[i][j] = min(a[i][j], i - x + 1 + j - y);
        }
        if (i <= x && j <= y) {
          a[i][j] = min(a[i][j], y - j + 1 + x - i);
        }
        ans[a[i][j]]++;
        // printf("a[%d][%d]=%d\\n",i,j,a[i][j]);
      }
    for (int i = 1; i < n; i++)
      printf(i == n - 1 ? "%lld\\n" : "%lld ", ans[i]);
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define MAX_N 400

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;

// Input
int N, X, Y;

int main() {
  cin >> N >> X >> Y;
  vector<int> ans(N, 0);
  X--;
  Y--;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int d = min(min(abs(j - i), abs(X - i) + 1 + abs(j - Y)),
                  abs(Y - i) + 1 + abs(j - X));
      ans.at(d)++;
    }
  }
  for (int d = 1; d < N; d++) {
    cout << ans.at(d) << endl;
  }
}


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


Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define MAX_N 400

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;

// Input
int N, X, Y;

int main() {
  vector<int> ans(N, 0);
  cin >> N >> X >> Y;
  X--;
  Y--;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      int d = min(min(abs(j - i), abs(X - i) + 1 + abs(j - Y)),
                  abs(Y - i) + 1 + abs(j - X));
      ans.at(d)++;
    }
  }
  for (int d = 1; d < N; d++) {
    cout << ans.at(d) << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <stdio.h>
using namespace std;
int X, Y;
int n, m, u, v, w, in[2001][2001], cnt[2001];
int main() {
  scanf("%d%d%d", &n, &X, &Y);
  X--, Y--;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i - j)
        in[i][j] = 1e9;
  for (int i = 0; i < n - 1; i++)
    in[i][i + 1] = in[i + 1][i] = 1;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      in[i][j] = in[j][i] = j - i;
  for (int i = 0; i <= X; i++)
    for (int j = Y; j < n; j++) {
      in[i][j] -= Y - X - 1;
    }
  in[X][Y] = in[Y][X] = 1;
  for (int i = 0; i <= X; i++)
    for (int j = X + 1; j < Y; j++) {
      in[i][j] = min(in[i][j], in[i][X] + in[X][Y] + in[j][Y]);
    }
  for (int i = X + 1; i < Y; i++)
    for (int j = Y; j < n; j++) {
      in[i][j] = min(in[i][j], in[X][i] + in[X][Y] + in[Y][j]);
    }

  for (int i = X + 1; i < Y; i++)
    for (int j = X + 1; j < Y; j++) {
      in[i][j] = min(in[i][j], in[X][i] + in[X][Y] + in[Y][j]);
    }

  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      cnt[in[i][j]]++;
  for (int k = 0; k < n - 1; k++)
    printf("%d\\n", cnt[k + 1]);
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int X, Y;
int n, m, u, v, w, in[2001][2001], cnt[2001];
int main() {
  scanf("%d%d%d", &n, &X, &Y);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i - j)
        in[i][j] = 1e9;
  for (int i = 0; i < n - 1; i++)
    in[i][i + 1] = in[i + 1][i] = 1;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      in[i][j] = in[j][i] = j - i;
  in[X - 1][Y - 1] = in[Y - 1][X - 1] = 1;
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        in[i][j] = min(in[i][j], in[i][k] + in[k][j]);

  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      cnt[in[i][j]]++;
  for (int k = 0; k < n - 1; k++)
    printf("%d\\n", cnt[k + 1]);
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define MAX_N 2000
#define INF 1000000
int d[MAX_N][MAX_N];

void init() {
  rep(i, MAX_N) {
    rep(j, MAX_N) { d[i][j] = INF; }
  }
}

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void solve(int n, int x, int y) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = min(min(abs(i - j), abs(i - x) + 1 + abs(j - y)),
                    abs(i - y) + 1 + abs(j - x));
    }
  }
}

int main() {
  init();
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 0; i < n - 1; i++) {
    d[i][i + 1] = 1;
    d[i + 1][i] = 1;
  }
  x = x - 1;
  y = y - 1;
  d[x][y] = 1;
  d[y][x] = 1;
  solve(n, x, y);
  int *distance = new int[n];
  rep(i, n) distance[i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      distance[d[i][j] - 1]++;
    }
  }
  rep(i, n - 1) { cout << distance[i] / 2 << endl; }
  /*for(int k = 1; k <= n-1; k++){
          int ans = 0;
          for(int i = 0 ; i < n-1; i ++){
                  for(int j = i + 1; j < n; j++){
                          if(d[i][j] == k) ans++;
                  }
          }
          cout<<ans<<endl;
  }*/
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define MAX_N 2000
#define INF 1000000
int d[MAX_N][MAX_N];

void init() {
  rep(i, MAX_N) {
    rep(j, MAX_N) { d[i][j] = INF; }
  }
}

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void solve(int n, int x, int y) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = min(min(abs(i - j), abs(i - x) + 1 + abs(j - y)),
                    abs(i - y) + 1 + abs(j - x));
    }
  }
}

int main() {
  init();
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 0; i < n - 1; i++) {
    d[i][i + 1] = 1;
    d[i + 1][i] = 1;
  }
  x = x - 1;
  y = y - 1;
  d[x][y] = 1;
  d[y][x] = 1;
  solve(n, x, y);
  for (int k = 1; k <= n - 1; k++) {
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (d[i][j] == k)
          ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  //
  int num, x, y;

  cin >> num >> x >> y;
  x--;
  y--;

  // マスの状況を入れる配列
  vector<vector<int>> d(num, vector<int>(num, -1));

  // 1辺ずつ調べる
  for (int i = 0; i < num; i++) {
    // キュー
    queue<int> q;
    q.push(i);
    // 自分自身を0
    d.at(i).at(i) = 0;

    while (!q.empty()) {
      // キューの先頭の要素取り出し
      auto j = q.front();
      q.pop(); // ※先頭の要素削除

      vector<int> vec2;
      if (j > 0)
        vec2.push_back(j - 1);
      if (j < num - 1)
        vec2.push_back(j + 1);
      if (j == x)
        vec2.push_back(y);
      if (j == y)
        vec2.push_back(x);

      for (auto k : vec2) {
        if (d.at(i).at(k) == -1) {
          d.at(i).at(k) = d.at(i).at(j) + 1;
          q.push(k);
        }
      }
    }
  }

  vector<int> vecCnt(num, 0);
  for (int i = 0; i < num; i++) {
    for (int j = i + 1; j < num; j++) {
      //
      vecCnt.at(d.at(i).at(j))++;
    }
  }

  for (int i = 1; i < num; i++)
    cout << vecCnt.at(i) << endl;
  //
}


Error: TLE

Fixed submission:

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

vector<vector<int>> d(2000, vector<int>(2000, 10000));

// ワーシャルフロイド法
void warshall_floyd(int x) {
  for (int k = 0; k < x; k++) {
    // k=経由する超点数(0回移動したら、1回移動したら...)
    for (int i = 0; i < x; i++) {
      // i=始点(From)
      for (int j = 0; j < x; j++) {
        // j=終点(To)
        // From～Toの最短コストを取得
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  //
  int num, x, y;

  cin >> num >> x >> y;

  vector<int> vec(num, 0);
  for (int i = 0; i < num - 1; i++) {
    d.at(i).at(i + 1) = 1;
    d.at(i + 1).at(i) = 1;
  }

  d.at(x - 1).at(y - 1) = 1;
  d.at(y - 1).at(x - 1) = 1;
  for (int i = 0; i < num; i++)
    d.at(i).at(i) = 0;

  /*
      cout << "  1 2 3 4 5" << endl;
      for (int i = 0; i < num; i++) {
          cout << i + 1 << " ";
          for (int j = 0; j < num; j++) {
              m[d.at(i).at(j)]++;
              cout << d.at(i).at(j) << " ";
          }
          cout << endl;
      }
  */
  // コスト探索
  warshall_floyd(num);
  for (int i = 0; i < num; i++) {
    for (int j = i + 1; j < num; j++) {
      //
      vec.at(d.at(i).at(j)) += 1;
    }
  }

  for (int i = 1; i < num; i++)
    cout << vec.at(i) << endl;
  //
}
Problem p02726 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
int x, n, y, cnt[maxn];
int dis(int a, int b) { return min(b - a, abs(a - x) + abs(b - y) + 1); }
int main() {
  scanf("%d%d%d", &n, &x, &y);
  if (x > y)
    swap(x, y);
  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;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
typedef long long ll;
int x, n, y, cnt[maxn];
int dis(int a, int b) { return min(b - a, abs(a - x) + abs(b - y) + 1); }
int main() {
  scanf("%d%d%d", &n, &x, &y);
  if (x > y)
    swap(x, y);
  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 MOD 1000000007
typedef long long ll;

int main() {
  int n, x, y, temp, ans;
  cin >> n >> x >> y;
  int distance;
  int dist[n];
  for (int i = 0; i < n; i++) {
    dist[i] = 0;
  }
  int count = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      distance = (int)min(
          {j - i, abs(y - j) + 1 + abs(x - i), abs(y - i) + 1 + abs(x - j)});
      // if(distance == k) count++;
      dist[distance] += 1;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << dist[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;

int main() {
  int n, x, y, temp, ans;
  cin >> n >> x >> y;
  int distance;
  for (int k = 1; k < n; k++) {
    int count = 0;
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j <= n; j++) {
        distance = (int)min(
            {j - i, abs(y - j) + 1 + abs(x - i), abs(y - i) + 1 + abs(x - j)});
        if (distance == k)
          count++;
      }
    }
    cout << count << endl;
  }
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_ll(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> ans(n, 0);
  rep(sv, n) {
    vector<int> dis(n, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dis[v] != INF)
        return;
      q.push(v);
      dis[v] = d;
    };
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      int d = dis[v];
      if (v + 1 >= 0)
        push(v - 1, d + 1);
      if (v - 1 < n)
        push(v + 1, d + 1);
      if (v == x)
        push(y, d + 1);
      if (v == y)
        push(x, d + 1);
    }
    rep(i, n) ans[dis[i]]++;
  }
  rep(i, n) ans[i] /= 2;
  for (int i = 1; i <= n - 1; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_ll(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> ans(n, 0);
  rep(sv, n) {
    vector<int> dis(n, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      q.push(v);
      dis[v] = d;
    };
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      int d = dis[v];
      if (v > 0)
        push(v - 1, d + 1);
      if (v < n - 1)
        push(v + 1, d + 1);
      if (v == x)
        push(y, d + 1);
      if (v == y)
        push(x, d + 1);
    }
    rep(i, n) ans[dis[i]]++;
  }
  rep(i, n) ans[i] /= 2;
  for (int i = 1; i <= n - 1; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, a, b) for (int i = a; i < b; i++)
const int max_n = 2000;
const ll mod = 1e9 + 7;
const int INF = 1e5;
typedef long double ld;
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] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
struct edge {
  ll to, cost;
};
vector<edge> G[max_n];
map<ll, ll> ma;
ll d[max_n][max_n];
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  int ans[2010] = {0};
  rep(i, 0, n) rep(j, i + 1, n) {
    int k = min(j - i, abs(x - i) + 1 + abs(y - j));
    ans[k]++;
  }
  rep(i, 1, n) { cout << ans[i] << endl; }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, a, b) for (ll i = a; i < b; i++)
const int max_n = 2000;
const ll mod = 1e9 + 7;
const int INF = 1e5;
typedef long double ld;
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] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
struct edge {
  ll to, cost;
};
ll n;
vector<edge> G[max_n];
map<ll, ll> ma;
ll d[max_n][max_n];
void wa() {
  rep(k, 0, n) {
    rep(i, 0, n) {
      rep(j, 0, n) { d[i][j] = min(d[i][k] + d[k][j], d[i][j]); }
    }
  }
}
int main() {
  ll x, y;
  cin >> n >> x >> y;
  rep(i, 0, n) rep(j, 0, n) {
    d[i][j] = INF;
    if (i == j)
      d[i][j] = 0;
  }
  rep(i, 0, n - 1) {
    d[i][i + 1] = 1;
    d[i + 1][i] = 1;
  }
  --x;
  --y;
  d[x][y] = d[y][x] = 1;
  wa();
  rep(i, 0, n) rep(j, i + 1, n) {
    if (d[i][j] != INF) {
      ma[d[i][j]]++;
    }
  }
  rep(i, 1, n) { cout << ma[i] << endl; }
  return 0;
}