Problem:
 Score : 400 points    Problem Statement  We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:   For each i=1,2,...,N-1 , there is an edge between Vertex i and Vertex i+1 .  There is an edge between Vertex X and Vertex Y .   For each k=1,2,...,N-1 , solve the problem below:   Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k .       Constraints   3 \leq N \leq 2 \times 10^3  1 \leq X,Y \leq N  X+1 < Y  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  X  Y       Output  For each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.        Sample Input 1 5 2 4      Sample Output 1 5
4
1
0  The graph in this input is as follows:     There are five pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 1 : (1,2)\,,(2,3)\,,(2,4)\,,(3,4)\,,(4,5) . There are four pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 2 : (1,3)\,,(1,4)\,,(2,5)\,,(3,5) . There is one pair (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 3 : (1,5) . There are no pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 4 .       Sample Input 2 3 1 3      Sample Output 2 3
0  The graph in this input is as follows:           Sample Input 3 7 3 7      Sample Output 3 7
8
4
2
0
0       Sample Input 4 10 4 8      Sample Output 4 10
12
10
8
4
1
0
0
0

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
from collections import Counter
def key(x, y):
    return str(x)+str(y)
def main2():
    
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    M = {}
    for i in range(N):
        for j in range(i, N):
            M[key(i, j)] = j - i
    
    def helper(x, y, from_cost):
        if 0 <= x <= N-1 and 0 <= y <= N-1:
            if M[key(x,y)] > from_cost+1:
                M[key(x,y)] = from_cost + 1
                cost = from_cost + 1

                helper(x-1,y, cost)
                helper(x+1,y, cost)
                helper(x,y-1, cost)
                helper(x,y+1, cost)
        
    helper(X, Y, 0)

    cost_list = Counter(list(M.values()))
    for k in range(N-1):
        print(cost_list[k+1])

from collections import deque
INF = 1e10


def main3():
    
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    ans = [0 for _ in range(N)]
    for sv in range(N):
        dist = [INF for _ in range(N)]
        q = deque([])

        def push(v, d):
            if dist[v] != INF: return
            dist[v] = d
            q.append(v)

        push(sv, 0)

        while q:
            sv = q.popleft()
            d = dist[sv]
            if sv > 0:
                push(sv-1, d+1)
            if sv < N-1:
                push(sv+1, d+1)
            if sv == X:
                push(Y, d+1)
            if sv == Y:
                push(X, d+1)

        for d in dist:
            ans[d] += 1
    
    for k in range(1, N):
        print(ans[k] // 2)

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    dist = [0 for _ in range(N)]
    for i in range(N-1):
        for j in range(i+1, N):
            d = min(abs(X-i)+1+abs(j-Y), abs(i-j), abs(Y-i)+1+abs(j-Y))
            dist[d] += 1
    
    for k in range(1, N):
        print(dist[k])
 

main()

Solution (Python):
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**4
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N,X,Y = LI()

c = [0 for _ in range(N+1)]

for k in range(1,N):
    j = 1
    m = [0 for _ in range(N+1)]
    j = 1
    for i in range(k+1,N+1):
        m[i] = j
        j += 1
    if k <= X:
        j = X - k + 1
        a = 0
        while j + a < m[Y - a]:
            m[Y -a] = j + a
            a += 1
        a = 1
        if Y + a <= N:
            while j + a < m[Y + a]:
                m[Y + a] = j + a
                a += 1
                if Y + a > N : break
    elif k <= Y:
        j = k - X + 1
        a = 0
        while j + a < m[Y - a]:
            m[Y -a] = j + a
            a += 1
        a = 1
        if Y + a <= N:
            while j + a < m[Y + a]:
                m[Y + a] = j + a
                a += 1
                if Y + a > N : break
    for i in range(k+1,N+1):
        c[m[i]] += 1
for k in range(1,N):
    print (c[k])

Solution (Python):
n, x, y = map(int, input().split())
ans = [0 for _ in range(n)]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        ans[min(j-i, abs(i-x)+abs(j-y)+1)] += 1


for i in range(1, n):
    print(ans[i])

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    from collections import deque
    n,x,y = map(int,input().split())
    ans = [0]*(n)
    E = [[] for i in range(n)]
    E[0].append(1)
    E[n-1].append(n-2)
    for i in range(1,n-1):
        E[i].append(i-1)
        E[i].append(i+1)
    E[x-1].append(y-1)
    E[y-1].append(x-1)
    ans = [0]*(n)
    d = [[float("INF")]*n for i in range(n)]
    def search(x):
        d[x][x] = 0
        q = deque([])
        q.append((x,0))
        while q:
            bef,l = q.pop()

            for nex in E[bef]:
                if d[x][nex] > l+1:
                    d[x][nex] = l+1
                    q.append((nex,l+1))
        
        
    for i in range(n-1):
        search(i)
    for i in range(n-1):
        for j in range(i+1,n):
            if d[i][j] != float("INF"):
                ans[d[i][j]] += 1

    for i in ans[1:]:
        print(i)
if __name__ == "__main__":
    main()

Solution (Python):
N,X,Y = map(int, input().split())
D = [0] * N
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1)] += 1 
print (*D[1:], sep="\n")

Solution (Python):
N,X,Y = map(int, input().split())
D = [0] * N
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1)] += 1 
print (*D[1:], sep="\n")

Solution (Python):
import heapq
def set_heapq(que, edge, used, v, add_dist=0):
    '''
    確定地点vからつながる辺を全てqueに設定し、返却する

    Parameters
    que : heapque(touple or list)
        辺を管理するキュー (距離、次の行き先)のtopuleまたはlistにて管理
    edge : list
        全ての辺を格納する二次元のリスト edge[0]にてノード0から伸びる辺であることを表し、
        edge[0] → [距離、次の行き先] を表すlistが格納されている
    v : int
        グラフ上のノード ダイクストラでは確定したノードがvにあたる
    add_dist : int
        確定した地点に足し合わせる距離 スタート地点以外では何かしらの値が追加されることになる

    Returns
    que : heapque(touple or list)
        引数queにvからつながる辺を追加したキュー
    '''
    for a,b in edge[v]:
        if used[b]:
            heapq.heappush(que,(a+add_dist,b))
    return que

def dijkstra_heap(n, s, edge):
    '''
    ダイクストラ法でsで指定された地点からの全てのノードまでの最短距離を返却
    
    Parameters
    n : int
        ノードの数
    s : int
        スタート地点
    edge : list
        全ての辺を格納する二次元のリスト edge[0]にてノード0から伸びる辺であることを表し、
        edge[0] → [距離、次の行き先] を表すlistが格納されている

    Returns
    d : list
        スタート地点から全てのノードの最短距離のリスト
    '''
    d = [float("inf")] * n
    used = [True] * n 
    d[s], used[s] = 0, False
    edgelist = set_heapq([], edge, used, s)
    while len(edgelist):
        a, b = heapq.heappop(edgelist)
        
        if not used[b]:
            continue
        d[b], used[b] = a, False
        
        edgelist = set_heapq(edgelist, edge, used, b, d[b])
    return d

N, X, Y = map(int, input().split())
X, Y = X-1, Y-1
edge = [[] for _ in range(N)]
for i in range(N-1):
    x, y = i, i+1
    edge[x].append((1, y))
    edge[y].append((1, x))

edge[X].append((1, Y))
edge[Y].append((1, X))

tmp = []
for i in range(N):
    tmp.append(dijkstra_heap(N, i, edge))


ans = []
for i in range(N):
    for j in range(i+1,N):
        ans.append(tmp[i][j])

from collections import Counter
c = Counter(ans)
for i in range(1, N):
    print(c[i])

Solution (Python):
N, x, y = map(int, input().split())

out = [0] * (N)

for i in range(1,N):
    for j in range(i+1,N+1):
        
        
        
        
        dist = min(abs(j-i), abs(i-x)+1+abs(j-y), abs(i-y)+1+abs(j-x))
        out[dist] += 1

for i in range(1,N):
    print(out[i])

Solution (Python):
N,X,Y = map(int,input().split())
X = X -1
Y = Y -1
L = [0]*(N-1)
for i in range(N-1):
  for j in range(i+1,N):
    min_dist = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
    L[min_dist-1] += 1
for out in L:
  print(out)

Solution (Python):
n,x,y = map(int, input().split())
b=[[] for i in range(n)]

for i in range(n-1):
    b[i].append(i+1)
    b[i+1].append(i)

b[x-1].append(y-1)
b[y-1].append(x-1)
ans=[0]*(n-1)

import collections
from collections import deque
def tree(s):

    INF=-10**9
    dis = [INF for i in range(n)]
    dis[s]=0
    def bfs():
        d = deque()
        d.append(s)

        while len(d):
            x = d.popleft()

            for i in range(len(b[x])):
                y=b[x][i]
                if dis[y] == INF:
                    d.append(y)
                    dis[y]=dis[x]+1
                    ans[dis[y]-1]+=1
        return dis
    return bfs()


for i in range(n):
    tree(i)

for i in ans:
    print(i//2)

Solution (Python):
from collections import Counter
N,X,Y = map(int, input().split())
X -= 1
Y -= 1
L = []
for i in range(N-1):
  for j in range(i+1,N):
    L.append(min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1))
D = Counter(L)
for k in range(1,N):
  print (D[k])

Solution (Python):
def resolve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    from collections import defaultdict, deque
    matrix = defaultdict(list)
    for i in range(N-1):
        matrix[i].append(i+1)
        matrix[i+1].append(i)
    matrix[X].append(Y)
    matrix[Y].append(X)

    ans = [0] * N
    for i in range(N):
        queue = deque([(i, 0)])
        d = [float('inf')] * N
        while queue:
            node, dist = queue.popleft()
            if d[node] != float('inf'):
                continue
            d[node] = dist
            for adj in matrix[node]:
                queue.append([adj, dist+1])
        for j in range(N):
            ans[d[j]] += 1
    for i in range(1, N):
        print(ans[i]//2)
resolve()

Solution (Python):
def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline


    def bfs(v):
        dist = [f_inf for _ in range(n)]
        dist[v] = 0
        q = deque()
        q.append(v)
        while q:
            u = q.popleft()
            for nv in tree[u]:
                if dist[nv] == f_inf:
                    dist[nv] = dist[u] + 1
                    q.append(nv)
        for d in dist:
            res[d] += 1


    n, x, y = map(int, input().split())

    tree = [[] for _ in range(n)]
    for i in range(n - 1):
        tree[i].append(i + 1)
        tree[i + 1].append(i)
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

    f_inf = float("inf")
    res = [0 for _ in range(n)]
    for i in range(n):
        bfs(i)

    for i in range(1, n):
        print(res[i] // 2)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict as dd
N,X,Y = map(int, input().split())
D = dd(int)
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1)] += 1 
for k in range(1,N):
  print (D[k])

Solution (Python):
def resolve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    from collections import defaultdict, deque
    ans = [0] * N
    for i in range(N):
        queue = deque([(i, 0)])
        d = [float('inf')] * N
        while queue:
            node, dist = queue.popleft()
            if d[node] != float('inf'):
                continue
            d[node] = dist
            if node == X:
                queue.append([Y, dist+1])
            if node == Y:
                queue.append([X, dist+1])
            if node + 1 < N:
                queue.append([node+1, dist+1])
            if node - 1 >= 0:
                queue.append([node-1, dist+1])
        for j in range(N):
            ans[d[j]] += 1
    for i in range(1, N):
        print(ans[i]//2)
resolve()

Solution (Python):
from heapq import *
from collections import Counter
import itertools


n, x, y = map(int,input().split())
edges = [[] for _ in range(n)]

def dijkstra(s, edges):
    d = [float('inf')] * n
    d[s] = 0
    heap = [(0, s)]
    while heap:
        c, node = heappop(heap)
        for cost, v in edges[node]:
            if c + cost < d[v]:
                d[v] = c + cost
                heappush(heap, (d[v], v))
    return d

for i in range(n-1):
    u, v = i, i+1
    edges[u].append([1,v])
    edges[v].append([1,u])
edges[x-1].append([1, y-1])
edges[y-1].append([1, x-1])

ans = []

for s in range(n):
    ans.append(dijkstra(s, edges))

f_ans = []
for i in range(n):
    f_ans.append(ans[i][i+1:])
f_ans = Counter(list(itertools.chain.from_iterable(f_ans)))

for i in range(1, n):
    print(f_ans[i])

Solution (Python):
import heapq
import sys
from collections import defaultdict

input = sys.stdin.readline

def dijkstra_heap(s,edge,n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        edge[i].append((1,i+1))
        edge[i+1].append((1,i))
    
    edge[X].append((1,Y))
    edge[Y].append((1,X))
    d = []
    for i in range(N):
        tmp = dijkstra_heap(i, edge, N)
        d.append(tmp)

    e = defaultdict(int)
    for i in range(N):
        for j in range(i,N):
            if i == j:
                continue
            e[d[i][j]] += 1

    for i in range(1,N):
        print(e[i])

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import deque
input = sys.stdin.buffer.readline

def bfs(v):
    dist = [-1 for _ in range(n)]
    dist[v] = 0
    q = deque()
    q.append(v)

    while len(q) > 0:
        u = q.popleft()
        for nv in g[u]:
            if dist[nv] == -1:
                dist[nv] = dist[u] + 1
                q.append(nv)
    for d in dist:
        ans[d] += 1
n, x, y = map(int,input().split())
g = [[] for _ in range(n)]
for i in range(n - 1):
    g[i].append(i + 1)
    g[i+1].append(i)
g[x - 1].append(y - 1)
g[y - 1].append(x - 1)
ans = [0]*n
for i in range(n):
    bfs(i)
for i in range(1,n):
    print(ans[i]//2)

Solution (Python):
n,x,y = map(int,input().split())
ans = [0] * (n - 1)
for i in range(1,n):
         for j in range(i + 1,n+1):
                  a = min(abs(j - i),abs(x - i) + abs(j - y) + 1,abs(y - i) + abs(j - x) + 1)
                  ans[a-1] += 1
for k in range(len(ans)):
         print(ans[k])

Solution (Python):
n,x,y=map(int,input().split())
G=[[i,i+2] for i in range(n)]
G[0],G[-1]=[2],[n-1]
G[x-1].append(y)
G[y-1].append(x)

ans=[0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        temp1=j-i
        temp2=abs(x-(i+1))+1+abs(y-(j+1))
        dis=min(temp1,temp2)
        ans[dis-1]+=1
print(*ans,sep='\n')

Solution (Python):



N, X, Y = map(int, input().split())


INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)


for i in range(N):
    for j in range(i+1, N):
        
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)))
        


for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1


for k in kosu_list:
    print(k)

Solution (Python):
n,x,y=map(int,input().split())
G=[[i,i+2] for i in range(n)]
G[0],G[-1]=[2],[n-1]
G[x-1].append(y)
G[y-1].append(x)

ans=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
    
        temp1=j-i
        temp2=abs(x-(i+1))+1+abs(y-(j+1))
        dis=min(temp1,temp2)
        ans[dis-1]+=1
print(*ans,sep='\n')

Solution (Python):



N, X, Y = map(int, input().split())


INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)


for i in range(N):
    for j in range(i+1, N):
        
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))


for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1


for k in kosu_list:
    print(k)

Solution (Python):



N, X, Y = map(int, input().split())


INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)
for i in range(N):
    for j in range(i+1, N):
        if j==i+1:
            kyori_graph[i][j] = 1
        else:
            kyori_graph[i][j] = INF
kyori_graph[X-1][Y-1] = 1


for i in range(N):
    for j in range(i+1, N):
        
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))


for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1


for k in kosu_list:
    print(k)

Solution (Python):
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix

n, x, y = map(int, input().split())

v = [x-1]
u = [y-1]
for i in range(n-1):
    v.append(i)
    u.append(i+1)

csr = csr_matrix(([1]*n, (v, u)), shape=(n, n))
result = shortest_path(csr, method='D', directed=False).astype(int)
ans = np.bincount(result.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

Solution (Python):
N,X,Y=map(int,input().split())
l=[0]*~-N
for i in range(1,N):
    for j in range(i):
        l[min(abs(i-j-1),abs(X-j-1)+abs(Y-i-1))]+=1
print(*l,sep="\n")

Solution (Python):
n,x,y = map(int,input().split())
 
root = [[] for i in range(n)]
for i in range(1,n):
    root[i-1].append(i)
    root[i].append(i-1)
root[x-1].append(y-1)
root[y-1].append(x-1)
memo = [0]*(n-1)
for j in range(n):
    stack=[j]
    check = [-1]*n
    check[j] = 0
    while len(stack):
        v = stack.pop(0)
        for i in root[v]:
            if check[i] == -1:
                check[i]=check[v]+1
                memo[check[i]-1]+=1
                stack.append(i)
for i in memo:
    print(i//2)

Solution (Python):
N, X, Y = map(int, input().split())
Graph = [[] for _ in range(N)]
for i in range(N):
    if i < N - 1:
        Graph[i].append(i + 1)
        Graph[i + 1].append(i)
    if X == i:
        Graph[X - 1].append(Y - 1)
        Graph[Y - 1].append(X - 1)

ans = [0] * (N - 1)
from collections import deque
for i in range(N):
    dist = [-1]*N
    que = deque([i])
    dist[i] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in Graph[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    
    for d in dist:
        if d > 0:
            ans[d - 1] += 1
for a in ans:
    print(a // 2)

Solution (Python):
N, X, Y = map(int, input().split())
Graph = [[] for _ in range(N)]
for i in range(N):
    if i < N - 1:
        Graph[i].append(i + 1)
        Graph[i + 1].append(i)
    if X == i:
        Graph[X - 1].append(Y - 1)
        Graph[Y - 1].append(X - 1)

ans = [0] * (N - 1)
from collections import deque, Counter

for i in range(N):
    dist = [-1] * N
    que = deque([i])
    dist[i] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in Graph[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    
    dist_Counter = Counter(dist)
    for key, val in dist_Counter.items():
        if key != 0:
            ans[key - 1] += val

for a in ans:
    print(a // 2)

Solution (Python):
n, x, y = map(int, input().split())

count = {k:0 for k in range(1, n)}
for i in range(1, n+1):
    for j in range(1, i):
        k = min(abs(i-j), abs(x-i) + 1 + abs(j-y),abs(y-i) + 1 + abs(x-j))
        count[k] += 1
for i in count.values():
    print(i)

Solution (Python):
import collections

N, X, Y = map(int, input().split())

distance_list = []

for i in range(1, N + 1):
    
    for j in range(i + 1, N + 1):
        
        dis_xy = abs(i - X) + 1 + abs(j - Y)
        dis = min(j - i, dis_xy)
        
        distance_list.append(dis)

count = collections.Counter(distance_list)


for i in range(1, N):
    cnt = count[i]
    print(cnt)

Solution (Python):
N, X, Y = map(int, input().split())
k_list = [0]*N

for p in range(1, N):
  for q in range(p, N+1):
    p2X = abs(p-X)
    q2Y = abs(q-Y)
    
    distance = min(q-p, p2X+q2Y+1)
    k_list[distance] += 1
    
for k in range(1, N):
  print(k_list[k])

Solution (Python):
N, X, Y = map(int, input().split())

mind = [[N] * N for i in range(N)]
    
for i in range(N):
    for j in range(i+1, N):
        mind[i][j] = min(abs(j-i), abs((X-1)-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

mindcnt = [0] * N
for i in range(N):
    for j in range(i+1, N):
        d = mind[i][j]
        mindcnt[d] += 1

for k in range(1, N):
    print(mindcnt[k])

Solution (Python):
import itertools
 
N, X, Y = map(int, input().split())
 
n_iter = itertools.combinations(list(range(1,N+1)), 2)
 
count_list = [0]*(N-1)
 
for i, j in n_iter:
  
  
  
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(j - i)
  )
  count_list[x-1] += 1
 
for i in count_list:
  print(i)

Solution (Python):
from collections import defaultdict
N, X, Y = [int(i) for i in input().split()]
X, Y = X-1, Y-1

dd = defaultdict(int)
for i in range(N):
    for j in range(N):
        ans = min(abs(j - i),
                  abs(X - i)+1+abs(j-Y),
                  abs(Y - i)+1+abs(j-X))
        dd[ans] += 1

for i in range(1, N):
    print(dd[i] // 2)

Solution (Python):
n,x,y = map(int,input().split())
dist = [0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    dist[min(abs(j-i),abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)-1] += 1
for i in range(n-1):
  print(dist[i])

Solution (Python):
import itertools

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = [0]*(N-1)

for i, j in n_iter:
  
  
  
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list[x-1] += 1

for i in count_list:
  print(i)

Solution (Python):
N, X, Y = map(int, input().split())
dist = [0]*N
for i in range(1, N):
    for j in range(i+1,N+1):
        a = min(j-i, abs(i-X)+abs(Y-j)+1)
        dist[a] += 1
for i in range(1, N):
    print(dist[i])

Solution (Python):
n, x, y = map(int, input().split())

dist = [0]*n

for i in range(1, n):
    for j in range(i+1, n+1):
        a = min(j-i, abs(i-x)+abs(y-j)+1)
        dist[a] += 1

for i in range(1, n):
    print(dist[i])

Solution (Python):
n, x, y = map(int, input().split())
a = [0 for i in range(n-1)]
for ii in range(n):
	for jj in range(ii+1,n):
		i = ii+1
		j = jj+1
		if i < x and j < x:
			b = j-i
		elif i < x and j >= x and j <= y:
			b = min(j-i, y-j+1+x-i)
		elif i < x and j > y:
			b = j-i-(y-x)+1
		elif i >= x and i <= y and j >= x and j <= y:
			b = min(j-i,i-x+y-j+1)
		elif i >= x and i <= y and j > y:
			b = min(j-i,i-x+1+j-y)
		else:
			b = j-i
		
		a[b-1] += 1
for i in a:
	print (i)

Solution (Python):
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
     dis=min(abs(i-j),abs(x-i)+1+abs(y-j))-1
     ans[dis]+=1
for i in ans:
    print(i)

Solution (Python):
n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0] * n

for j in range(n):
  for i in range(j):
    d = min(j-i, abs(x-i)+1+abs(j-y))
    ans[d] += 1

print( "\n".join( [str(d) for d in ans][1:] ))

Solution (Python):
n,x,y=map(int,input().split())
c=[0]*~-n
for i in range(n):
 for j in range(i):c[min(~j+i,abs(~j+x)+abs(~i+y))]+=1
print(*c)

Solution (Python):
n,x,y=map(int,input().split())
x-=1; y-=1
C=[0]*(n-1)

for i in range(n):
  for j in range(i+1,n):
    d=min(j-i,abs(x-i)+abs(y-j)+1)
    C[d-1]+=1

print(*C)

Solution (Python):

from collections import deque
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    inf = 10**5
    ans = [0]*n
    q = deque()
    for i in range(n):
        dist = [inf]*n
        q.appendleft(i)
        dist[i] = 0
        while q:
            v = q.pop()
            d = dist[v]
            if v-1 >= 0 and dist[v-1] == inf:
                q.appendleft(v-1)
                dist[v-1] = d+1
            if v+1 <= n-1 and dist[v+1] == inf:
                q.appendleft(v+1)
                dist[v+1] = d+1
            if v == x and dist[y] == inf:
                q.appendleft(y)
                dist[y] = d + 1
            if v == y and  dist[x] == inf:
                q.appendleft(x)
                dist[x] = d + 1
        for di in dist:
            ans[di] += 1
    for a in ans[1:]:
        print(a//2)

if __name__ == "__main__":
    main()

Solution (Python):
N, X, Y = map(int, input().split())

g = [[]  for i in range(N)]
for i in range(N):
    u = i
    v = i + 1
    if v < N:
        g[u].append(v)
        g[v].append(u)

g[X - 1].append(Y - 1)
g[Y - 1].append(X - 1)

from collections import deque
dis = [[float('Inf')] * N for _ in range(N)]
count = [0] * (N - 1)
def bfs(i):
    d = [False] * N
    que = deque()
    
    que.append(i)
    d[i] = True
    dis[i][i] = 0
    pre = i
    while que:
        p = que.popleft()

        for k in g[p]:
            if d[k]:
                continue
            else:
                d[k] = True
                que.append(k)
                dis[i][k] = dis[i][p] + 1
                dis[k][i] = dis[i][p] + 1
                count[dis[i][k] - 1] += 1 
                
        pre = p

for i in range(N):
    bfs(i)

for i in range(N - 1):
    print(count[i] // 2)

Solution (Python):
n, x, y = [int(i) for i in input().split()]

ans = [0]*n
for i in range(1, n):
    for j in range(i+1, n+1):
        ans[min(j-i, abs(x-i)+abs(j-y)+1)] += 1

print(*ans[1:], sep='\n')

Solution (Python):
n,x,y=[int(j) for j in input().split()]
l=[[0]*n for i in range(n)]
ans=[0]*n
x-=1
y-=1
s=y-x-1
for i in range(n):
    for j in range(n):
        if i<j:
            ans[min(j-i,abs(i-x)+abs(j-y)+1,)]+=1

print('\n'.join(map(str,ans[1:])))

Solution (Python):
n, x, y = [int(i) for i in input().split()]
ans = [0]*n
for i in range(n-1):
    for j in range(i+1, n):
        ans[min(j-i, abs(x-(i+1))+abs((j+1)-y)+1)] += 1

print(*ans[1:], sep='\n')

Solution (Python):
import sys
input = sys.stdin.readline

n, x, y = map(int, input().split())
x -= 1
y -= 1
d = [0] * n
for i in range(n - 1):
    for j in range(i + 1, n):
        k = min(j - i, abs(i - x) + abs(j - y) + 1)
        d[k] += 1
for i in range(1, n):
    print(d[i])

Solution (Python):
n,x,y=map(int,input().split())
mxN=3005
ans=[0]*mxN
x-=1
y-=1
for i in range(n):
    for j in range(i+1,n):
        x1=min(j-i,(abs(i-x)+abs(j-y)+1))
        ans[x1]+=1
for i in range(1,n):
    print(ans[i])

Solution (Python):
n,x,y = list(map(int,input().split()))

ans = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        dis = min(abs(j-i),abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
        ans[dis-1]+=1

for i in ans:
    print(i)

Solution (Python):
import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype = int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X-1, Y-1] = 1
lil[Y-1, X-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
ans = np.bincount(lil2.ravel(), minlength = N) // 2
for i in range(1,N):
    print(ans[i])

Solution (Python):
import heapq
class Graph:
    def __init__(self,w_v,w_e):
        super().__init__()
        self.size = len(w_v)
        self.w_v = [v_i for v_i in w_v]
        self.w_e = [{} for _ in [0]*self.size]

        self.maxw = 0

        self.neighbor = [[] for _ in [0]*self.size]
        for a_i,b_i,w_i in w_e:
            self.w_e[a_i][b_i] = w_i
            self.w_e[b_i][a_i] = w_i

            self.neighbor[a_i].append(b_i)
            self.neighbor[b_i].append(a_i)
            self.maxw+=w_i

    def dijkstra(self,v_n):
        d = [self.maxw]*self.size
        d[v_n] = 0
        prev = [-1]*self.size

        queue = []
        for i,d_i in enumerate(d): heapq.heappush(queue,(d_i,i))
        
        while len(queue)>0:
            d_u,u = queue.pop()
            if d[u]<d_u :continue
            for v in self.neighbor[u]:
                alt = d[u]+self.w_e[u][v]
                if d[v]>alt:
                    d[v] = alt
                    prev[v] = u
                    heapq.heappush(queue,(alt,v))

        return d,prev

def main():
    n,x,y = tuple([int(t)for t in input().split()])

    w_v = [0]*n
    w_e = [(i,i+1,1) for i in range(n-1)]
    w_e.append((x-1,y-1,1))

    g = Graph(w_v,w_e)

    distance = [g.dijkstra(i)[0] for i in range(n)]

    res = [0]*n
    for dmin_ in distance:
        for d in dmin_:
            res[d] += 1

    for r in res[1:n]:
        print(r//2)

if __name__ == "__main__":
    main()

Solution (Python):
import heapq

def dijkstra_heap(s,edge):
    
    d = [10**10]*n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


N,X,Y = map(int,input().split())
n = N
w = N

edge = tuple([] for i in range(n))

for i in range(w):
    if i == 0:
        edge[i].append([1,i+1])
    elif i == w-1:
        edge[i].append([1,i-1])
    else:
        edge[i].append([1,i+1])
        edge[i].append([1,i-1])
edge[X-1].append([1,Y-1])
edge[Y-1].append([1,X-1])

ans = [0]*(N+1)
tmp = []
for i in range(N):
    tmp.append(dijkstra_heap(i,edge)[i+1:])

for i in range(N):
    for j in tmp[i]:
        ans[j] += 1

for i in range(1,N):
    print(ans[i])

Solution (Python):

def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[min(j - i, abs(X - i) + abs(j - Y) + 1)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(Y - y) + 1)  
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(Y - y) + 1)  
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()