Language: C++

#include<bits/stdc++.h>

using namespace std;

set<int>gr[2][2010];
int depth[2][2010];
int spTab[2][15][2010];

void dfs(int gn, int u, int p, int d)
{
    depth[gn][u] = d;
    spTab[gn][0][u] = p;
    for(int v:gr[gn][u]){
        if(v != p)
            dfs(gn, v, u, d+1);
    }
}
int n;

void fill(){
    for(int gn = 0; gn < 2; gn++){
        for(int i = 1; i < 15; i++){
            for(int j = 1; j <= n; j++){
                if(spTab[gn][i-1][j] != -1){
                    spTab[gn][i][j] = spTab[gn][i-1][spTab[gn][i-1][j]];
                }
            }
        }
    }
}

int lca(int gn, int u, int v){
    if(depth[gn][u] > depth[gn][v]){
        swap(u, v);
    }
    for(int i = 14; i >= 0; i--){
        if(depth[gn][v]-(1<<i) >= depth[gn][u])
            v = spTab[gn][i][v];
    }
    if(u == v)return u;
    for(int i = 14; i >= 0; i--){
        if(spTab[gn][i][u] != spTab[gn][i][v]){
            u = spTab[gn][i][u];
            v = spTab[gn][i][v];
        }
    }
    return spTab[gn][0][u];
}

int dist(int u, int v){
    int d = max(u, v) - min(u, v);
    int l0 = lca(0, u, v);
    int l1 = lca(1, u, v);
    int d0 = depth[0][u] + depth[0][v] - 2*depth[0][l0];
    int d1 = depth[1][u] + depth[1][v] - 2*depth[1][l1];
    return min(d, min(d0, d1));
}

int main()
{
    cin >> n;
    for(int i = 1; i < n; i++){
        gr[0][i].insert(i+1);
        gr[1][i].insert(i+1);
        
        gr[0][i+1].insert(i);
        gr[1][i+1].insert(i);
    }
    int x, y;
    cin >> x >> y;
    gr[0][x].insert(y);
    gr[0][y].insert(x);
    gr[1][x].insert(y);
    gr[1][y].insert(x);
    memset(spTab, -1, sizeof(spTab));
    gr[0][x].erase(x+1);
    gr[0][x+1].erase(x);
    dfs(0, x, -1, 0);
    gr[1][y].erase(y-1);
    gr[1][y-1].erase(y);
    dfs(1, y, -1, 0);
    
    fill();
    vector<int>len;
    len.resize(n);
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            //int d = dist(i, j);
            //cerr << i << " " << j << ": " << d << endl;
          d = min({j-i, abs(Y-j)+1+abs(X-i), abs(Y-i)+1+abs(X-j)});
            len[d]++;
        }
    }
    for(int i = 1; i < n; i++){
        cout << len[i] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:11: error: 'd' was not declared in this scope
   90 |           d = min({j-i, abs(Y-j)+1+abs(X-i), abs(Y-i)+1+abs(X-j)});
      |           ^
a.cc:90:29: error: 'Y' was not declared in this scope
   90 |           d = min({j-i, abs(Y-j)+1+abs(X-i), abs(Y-i)+1+abs(X-j)});
      |                             ^
a.cc:90:40: error: 'X' was not declared in this scope
   90 |           d = min({j-i, abs(Y-j)+1+abs(X-i), abs(Y-i)+1+abs(X-j)});
      |                                        ^
a.cc:90:18: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   90 |           d = min({j-i, abs(Y-j)+1+abs(X-i), abs(Y-i)+1+abs(X-j)});
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided