Problem p02726 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define fastcin()                                                              \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rep1(i, n) for (int i = 1; i <= int(n); i++)
#define per(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define per1(i, n) for (int i = int(n); i > 0; i--)
#define foreach(i, n) for (auto &&i : n)
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x)                                                                 \\
  int x;                                                                       \\
  cin >> x
#define cill(x)                                                                \\
  LL x;                                                                        \\
  cin >> x
#define cis(x)                                                                 \\
  string x;                                                                    \\
  cin >> x
#define co(x) cout << x << endl
#define dump(x) cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template <class T, class U> bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U> bool chmin(T &a, const U &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U> void vcin(T &v, U n) {
  rep(i, n) {
    typename T::value_type a;
    cin >> a;
    v.pb(a);
  }
}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
  fastcin();
  cout << fixed << setprecision(10);
  cii(n);
  cii(x);
  cii(y);
  VI vi(n + 10);
  rep1(j, n - 1) {
    for (int k = j + 1; k <= n; ++k) {
      vi[min(k - j, abs(x - j) + 1 + abs(y - k))]++;
    }
  }
  rep1(i, n - 1) { co(vi[i]); }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define fastcin()                                                              \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rep1(i, n) for (int i = 1; i <= int(n); i++)
#define per(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define per1(i, n) for (int i = int(n); i > 0; i--)
#define foreach(i, n) for (auto &&i : n)
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x)                                                                 \\
  int x;                                                                       \\
  cin >> x
#define cill(x)                                                                \\
  LL x;                                                                        \\
  cin >> x
#define cis(x)                                                                 \\
  string x;                                                                    \\
  cin >> x
#define co(x) cout << x << endl
#define dump(x) cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template <class T, class U> bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U> bool chmin(T &a, const U &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U> void vcin(T &v, U n) {
  rep(i, n) {
    typename T::value_type a;
    cin >> a;
    v.pb(a);
  }
}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
  fastcin();
  cout << fixed << setprecision(10);
  cii(n);
  cii(x);
  cii(y);
  vector<PII> vpii;
  rep1(i, n - 1) {
    int ans = 0;
    if (i == 1) {
      rep1(j, n - 1) {
        for (int k = j + 1; k <= n; ++k) {
          vpii.emplace_back(mp(j, k));
        }
      }
      co(n);
      continue;
    }
    for (PII pii : vpii) {
      if (pii.F == 0) {
        continue;
      }
      if (min(pii.S - pii.F, abs(x - pii.F) + 1 + abs(y - pii.S)) == i) {
        ans++;
        pii.F = 0;
      }
    }
    co(ans);
  }
  return 0;
}