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

/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
        DON'T ADJUST THE GOALS,
        ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU
UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b) {
  ll ans = 1;

  while (b > 0) {
    if (b & 1)
      ans *= a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}

ll powm(ll a, ll b) {
  a %= MOD;
  ll ans = 1;

  while (b > 0) {
    if (b & 1)
      ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ans;
}

//================================

int main() {
  FAST;

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

  int A[n + 1], vis[n + 1][n + 1] = {0};
  clr(A);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (vis[i][j] || vis[j][i])
        continue;

      vis[i][j] = 1;
      int mn = min(abs(j - i), min(abs(x - i) + abs(y - j) + 1,
                                   abs(y - i) + abs(x - j) + 1));
      // cout << mn << " ";
      A[mn]++;
    }
  }

  for (int i = 1; i < n; i++)
    cout << A[i] << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
        DON'T ADJUST THE GOALS,
        ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU
UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b) {
  ll ans = 1;

  while (b > 0) {
    if (b & 1)
      ans *= a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}

ll powm(ll a, ll b) {
  a %= MOD;
  ll ans = 1;

  while (b > 0) {
    if (b & 1)
      ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ans;
}

//================================

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

  int A[n + 1];
  clr(A);
  map<pii, bool> vis;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (vis[{i, j}] || vis[{j, i}])
        continue;

      vis[{i, j}] = true;
      int mn = min(abs(j - i), min(abs(x - i) + abs(y - j) + 1,
                                   abs(y - i) + abs(x - j) + 1));
      // cout << mn << " ";
      A[mn]++;
    }
  }

  for (int i = 1; i < n; i++)
    cout << A[i] << "\\n";
  return 0;
}