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):

from collections import deque
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(abs(ny-nx), D[x][y]+1)
                queue.append([nx, ny])
    ans = [0 for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
main()

Solution (Python):
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
L = [[i-1, i+1] for i in range(1, N+1)]
L[0] = [L[0][1]]
L[-1] = [L[-1][0]]
L[X-1].append(Y)
L[Y-1].append(X)

def bfs(i):
    ni = deque(L[i-1])
    c = 1
    C = [0] * N
    C[i-1] = -1
    while ni:
        nii = ni
        ni = deque([])
        for niii in nii:
            if C[niii-1] != 0:
                continue
            C[niii-1] = c
            if niii > i:
                D[c] += 1
            ni.extend(L[niii-1])
        c += 1
    return True

for n in range(1, N+1):
    bfs(n)

for n in range(1, N):
    print(D[n])

Solution (Python):

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






X -= 1
Y -= 1




def main(N, X, Y):
    ans = [0]*N
    for i in range(N):
        for j in range(i+1, N):
            d = min(j-i, abs(X-i)+abs(Y-j)+1)
            ans[d] += 1

    for a in ans[1:]:
        print(a)


main(N, X, Y)

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

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

main()

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

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

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

Solution (Python):
import collections
N, X, Y = map(int, input().split())
ans = collections.defaultdict(int)
for i in range(1,N):
    for j in range(i+1,N+1):
        minnum = min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[minnum]+=1

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

Solution (Python):
from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = [0] * n


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = deque()
    qu_append = qu.append
    qu_popleft = qu.popleft
    qu_append(start_v)
    
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        if dist[v] != BIG:
            
            return
        dist[v] = d
        qu_append(v)

    push(start_v, 0)

    while len(qu):
        v = qu_popleft()
        
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

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


if __name__ == '__main__':
    main()

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

from collections import defaultdict
d = defaultdict(int)

for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            dis = (x-i)+(j-y)+1
        elif j <= x or i >= y:
            dis = j - i
        elif i <= x and j >= x:
            dis = (x-i)+min(j-x, y-j+1)
        elif i <= y and j >= y:
            dis = min(y-i, i-x+1)+(j-y)
        elif i >= x and j <= y:
            dis = min(j-i, (i-x)+1+(y-j))
        d[dis] += 1
            

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

Solution (Python):
from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = {i: 0 for i in range(n)}


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = deque()
    qu_append = qu.append
    qu_popleft = qu.popleft
    qu_append(start_v)
    
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        if dist[v] != BIG:
            
            return
        dist[v] = d
        qu_append(v)

    push(start_v, 0)

    while len(qu):
        v = qu_popleft()
        
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        if dist[i] != 0:
            ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

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


if __name__ == '__main__':
    main()

Solution (Python):
N,X,Y=map(int,input().split())
def shortest(x,y,a,b):
    ans=min(y-x,abs(y-b)+1+abs(a-x),abs(y-a)+1+abs(b-x))
    return ans
distance=[0]*N
for x in range(1,N+1):
    for y in range(1,N+1):
        if y<=x:
            continue
        else:
            a=shortest(x,y,X,Y)
            distance[a-1]+=1
for i in range(N-1):
    print(distance[i])

Solution (Python):

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


ans = [0]*(N-1)
for i in range(N-1):
    for j in range(i+1, N):
        d1 = j-i - 1
        d2 = abs(Y-1-j) + abs(X-1-i)
        ans[min(d1, d2, N-2)] += 1


for a in ans:
    print(a)

Solution (Python):
n, x, y = map(int, input().split())
ans = [0]*n

for i in range(1, n):
    for j in range(i + 1, n + 1):
        diff1 = j - i
        diff2 = x + y - i - j + 1
        if i <= x and j >= y:
            diff2 = x - y - i + j + 1
        elif x <= i <= y and x <= j <= y:
            diff2 = -x + y + i - j + 1
        elif x < i < y and j > y:
            diff2 = -x - y + i + j + 1
        if diff2 < 1:
            diff2 = diff1
        diff = min(diff1, diff2)
        ans[diff] = ans[diff] + 1

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

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

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

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

Solution (Python):
from collections import defaultdict
INF = float('inf')
def main():
    N, X, Y = map(int, input().split())
    d = defaultdict(lambda: 0)
    for i in range(1,N+1):
        for j in range(1, N + 1):
            if i < j:
                dist = min(min(abs(j - i), abs(X - i) + 1 + abs(j - Y)), abs(Y - i) + 1 + abs(j - X))
                d[dist] += 1
    for i in range(1, N):
        print(d[i])

if __name__ == '__main__':
    main()

Solution (Python):
n, x, y = map(int, input().split())
x -= 1
y -= 1
ll = y-x+1
ans = [0]*(n-1)
for i in range(n-1):
  for j in range(i+1,n):
    if j <= x or i >= y:
      l = j - i
    elif i < x and x <= j <= y:
      l = x-i+min(j-x,ll-j+x)
    elif j > y and x <= i <= y:
      l = min(y-i,ll-y+i)+j-y
    elif i < x and j > y:
      l = j - y + x - i + 1
    else:
      l = min(j-i,ll-j+i)
    ans[l-1] += 1
for item in ans:
  print(item)

Solution (Python):
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

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

    ans = [0] * N
    for i in range(1, N+1):
        dist = [-1] * (N+1)
        dist[i] = 0
        q = deque()
        q.append(i)
        def push(l, m):
            if dist[l] > -1:
                return
            q.append(l)
            dist[l] = dist[m] + 1
            ans[dist[l]] += 1

        while q:
            j = q.popleft()
            if j < N: push(j+1, j)
            if j > 1: push(j-1, j)
            if j == X: push(Y, j)
            if j == Y: push(X, j)
    print(*[i // 2for i in ans[1:]], sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):








import numpy as np
from scipy.sparse.csgraph._shortest_path import dijkstra, floyd_warshall, bellman_ford, johnson, shortest_path
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x-1]
j = list(range(1,n)) + [y-1]


graph = csr_matrix((d, (i, j)), shape=(n, n)) 



dist = dijkstra(graph, directed=False).astype(int)



dist = dist.ravel() 


ans = np.bincount(dist, minlength=n) // 2  


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

Solution (Python):






from sys import stdin,setrecursionlimit










setrecursionlimit(10**6+1)
input=stdin.readline

def main():
    n,x,y=map(int,input().split())
    dis=[0]*(n-1)
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i>=j: continue
            now=min(abs(j-i),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y))
            
            dis[now-1]+=1

    for i in dis:
        print(i)

if __name__=="__main__":main()

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

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

ans = [0] * (N)

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

for a in ans[1:]:
    print(a)

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


count = [0] * (N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        routeA = abs(j-i)
        routeB = abs(X-i) + abs(Y-j) + 1
        min_route = min(routeA, routeB)
        count[min_route - 1] += 1

print('\n'.join(map(str, count)))

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

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

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

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

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)

Solution (Python):


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


answers = [ 0 for _ in range(n) ]


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



for ans in answers[1:]:
    print(ans)

Solution (Python):
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
ans.pop(0)
print('\n'.join(map(str,ans)))

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

dis = [0] * (n-1)


for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x:
            if j <= x:
                tmp = j-i
            if x < j < y:
                tmp = (x-i) + min(j-x, y-j+1)
            if j >= y:
                tmp = (x-i) + (j-y) + 1

        if x < i < y:
            if x < j < y:
                tmp = min(j-i, (i-x)+(y-j)+1)
            if j >= y:
                tmp = min(i-x+1, y-i) + (j-y)
        
        if i >= y:
            tmp = j-i

        dis[tmp-1] += 1

for ans in dis:
    print(ans)

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



for q in range(N):
    for i in range(q+1, N):
        
        cost = min(i-q, abs(q-X) + 1 + abs(i-Y)) 
        
        
        path[cost] += 1
        
        
for i in range(1,N):
    print(path[i])

Solution (Python):

N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in range(len(ans)):
    if _ == 0:
        continue
    print(ans[_])

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

dis = [0] * (n-1)


for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x:
            if j <= x:
                tmp = j-i
            if x < j < y:
                tmp = (x-i) + min(j-x, y-j+1)
            if j >= y:
                tmp = (x-i) + (j-y) + 1

        if x < i < y:
            if x < j < y:
                tmp = min(j-i, (i-x)+(y-j)+1)
            if j >= y:
                tmp = min(i-x+1, y-i) + (j-y)
        
        if i >= y:
            tmp = j-i

        dis[tmp-1] += 1

for ans in dis:
    print(ans)

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

for i in range(n):
  for j in range(i+1, n):
    a = min(j-i, abs(x-i) + abs(y-j) + 1)
    '''
    j-i                     :1～nまでの普通のルートでの距離
    abs(x-i) + abs(y-j) + 1 :ショートカットルートを使ったときの距離
    ''' 
    ans[a-1] += 1 
for p in ans:
  print(p)

Solution (Python):


n, x, y = map(int, input().split())
a = [0]*n

for i in range(n-1):
    for j in range(i+1, n):
        ans = 10000
        if j-i < ans:
            ans = j-i
        
        cut = abs(x-1-i) + abs(y-1-j) + 1
        if cut < ans:
            ans = cut
        
        a[ans-1] += 1

for i in range(n-1):
    print(a[i])

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,x,y = inpl()
x -= 1; y -= 1
g = [[] for _ in range(n)]
for i in range(n-1):
    g[i] += [i+1]; g[i+1] += [i]
g[x] += [y]; g[y] += [x]
res = [0] * (n-1)
def bfs(i):
    q = deque()
    q.append(i)
    while q:
        v = q.popleft()
        for nv in g[v]:
            if dist[nv] >= 0:
                continue
            dist[nv] = dist[v] + 1
            q.append(nv)

for i in range(n-1):
    dist = [-1] * n
    dist[i] = 0
    bfs(i)
    for j,cost in enumerate(dist):
        if j > i and cost > 0:
            res[cost-1] += 1
    
print(*res)

Solution (Python):
from itertools import *
n,x,y=map(int,input().split())
a=[0]*n
for i,j in combinations(range(1,n+1),2):
    b=min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
    a[b]+=1
print(*a[1:],sep="\n")

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


for i in range(1, N):
    for j in range(i+1, N+1):
        m = min(j-i, abs(X-i) + 1 + abs(Y-j))
        if d.get(m) is None:
            d[m] = 1
        else:
            d[m] += 1

for i in range(1, N):
    if d.get(i) is None:
        print(0)
    else:
        print(d[i])

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

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
a = list(range(N - 1)) + [X]
b = list(range(1, N)) + [Y]

matrix = csr_matrix(([1] * N, (a, b)), shape=(N, N))
distance = dijkstra(matrix, directed=False).astype(int)
answer = np.bincount(distance.flatten())[1:] // 2
answer = answer.tolist()
answer += [0] * (N - 1 - len(answer))
print('\n'.join(map(str, answer)))

Solution (Python):
s = input().split()
n=int(s[0])
x=int(s[1])-1
y=int(s[2])-1
inf=float('inf')
map={}
for i in range(n):
    map[i]=0
for i in range(n):
    for j in range(i+1,n):
        map[min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))]+=1
for i in range(1,n):
    print(map[i])

Solution (Python):

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


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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

for i in ans[1:]:
    print(i)

Solution (Python):
from collections import deque

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)
x -= 1
y -= 1
tree[x].append(y)
tree[y].append(x)

ans = [0] * (n - 1)

for i in range(n-1):
    
    dist = [-1] * n
    dist[i] = 0
    q = deque([i])
    while len(q):
        v = q.pop()
        for next_v in tree[v]:
            if dist[next_v] != -1:
                continue
            q.appendleft(next_v)
            dist[next_v] = dist[v] + 1
    for j in range(i+1, n):
        ans[dist[j] - 1] += 1

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

Solution (Python):


import collections


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

br = []

for i in range(N - 1):
  for j in range(i + 1, N):
    """
    
    """
    br.append(min(j - i, abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1))))

c = collections.Counter(br)

for k, v in c.items():
  print(v)

for _ in range(N - 1 - len(c)):
  print(0)

Solution (Python):
N,X,Y = map(int, input().split())
numbers = [0 for i in range(N-1)]
for i in range(N-1):
    for j in range(i+1,N):
        p = i+1
        q = j+1
        k = min(abs(X-p)+1+abs(Y-q),q-p)
        
        numbers[k-1] += 1


for i in range(N-1):
    print(numbers[i])

Solution (Python):
from collections import deque
INF = int(1e9) + 7
n, x, y = map(int, input().split())
x -= 1
y -= 1
d = [[INF] * n for i in range(n)]
ans = [0] * (n+1)
def bfs(i):
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([i])
    d[i][i] = 0

    while len(que) != 0:
        val = que.popleft()
        
        if val-1 >= 0 and d[i][val-1] == INF:
            que.append(val-1)
            d[i][val-1] = d[i][val] + 1
        if val+1 < n and d[i][val+1] == INF:
            que.append(val+1)
            d[i][val+1] = d[i][val] + 1
        if val == x and d[i][y] == INF:
            que.append(y)
            d[i][y] = d[i][val] + 1
        if val == y and d[i][x] == INF:
            que.append(x)
            d[i][x] = d[i][val] + 1
    return d[i]

for i in range(n-1):
    val = bfs(i)
    
    for j in range(i+1,n):
        ans[val[j]] += 1
for i in range(1, n):
    print(ans[i])

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

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

Solution (Python):
n,x,y=map(int,input().split())
cnt=[0]*n
d=0
x-=1
y-=1
for i in range(n):
  for j in range(i+1,n):
    if x<=i<j<=y:
      d=min(j-i,i-x+1+y-j)
    elif i<=x<y<=j:
      d=min(j-i,x-i+1+j-y)
    elif x<=i<y<=j:
      d=min(j-i,i-x+1+j-y)
    elif i<=x<=j<=y:
      d=min(j-i,x-i+1+y-j)
    else:
      d=j-i
    cnt[d]+=1
print(*cnt[1:],sep='\n')

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

d = [[0 for _ in range(n)] for _ in range(n)]
x-=1
y-=1
ans = [0 for _ in range(n)]

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

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

from heapq import heappush, heappop
def dks(g,start,num_v):
    INF=10**10
    visited = set()
    hq = []
    heappush(hq, (0,start))
    cost = [INF] * num_v
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        cost[i] = shortest
        for j, t in g[i]:
            if j in visited:
                continue
            heappush(hq, (shortest + t, j))
    return cost

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

ans=[0]*(n-1)
for i in range(n):
    res = dks(link,i,n)
    for r in res:
        ans[r]+=1
for i in range(1,len(ans)):
    print(ans[i]//2)

print(0)

Solution (Python):
from collections import defaultdict

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

d=defaultdict(int)


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

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

Solution (Python):
def solve(n, x, y):
    res_list = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = min(j - i, abs(i - x+1) + abs(j - y+1) + 1)
            res_list[d] += 1
    return res_list[1:]


n, x, y = map(int, input().split())
res_list = solve(n, x, y)
for res in res_list:
    print(res)

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

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

def dis(a,b):
    return min (b-a,abs(a-x)+1+abs(b-y))









ans=[0]*(n-1)

for i in range(1,n):
  for j in range(i+1,n+1):
    ans[dis(i,j)-1]+=1

print("\n".join(map(str,ans)))

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

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

for d in dis_n:
    print(d)

Solution (Python):


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

Solution (Python):


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

Solution (Python):

import sys
sys.setrecursionlimit(15000)
n,x,y = map(int,input().split())

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,X,Y=MI()
    X-=1
    Y-=1
    ans=[0]*N
    
    for i in range(N-1):
        for j in range(i+1,N):
            d=min(j-i,abs(X-i)+1+abs(Y-j))
            ans[d-1]+=1
            
    for i in range(N-1):
        print(ans[i])
                
    
    

main()

Solution (Python):
N,X,Y = map(int,input().split())
cnt = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        min0 = min(j-i,abs(X-i)+1+abs(j-Y))
        cnt[min0] += 1
for num,i in enumerate(cnt):
    if num == 0:continue
    else:print(i)

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

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

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

Solution (Python):
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *

input = lambda: sys.stdin.readline().rstrip()

N, X, Y = map(int, input().split())
data = [[] for i in range(N + 1)]
for i in range(1, N):
    a = i
    b = i + 1
    data[a].append(b)
    data[b].append(a)
data[X].append(Y)
data[Y].append(X)

dic = defaultdict(int)
for i in range(1,N+1):
    stack=deque([[i,0]])
    visited=set()
    visited.add(i)
    count=set()
    while stack:
        now, dist=stack.popleft()
        for j in data[now]:
            if not j in visited:
                
                visited.add(j)
                stack.append([j,dist+1])
                dic[dist+1]+=1
for k in range(1,N):
    print(dic[k]//2)

Solution (Python):
def resolve():
    from heapq import heappush, heappop

    
    
    def dijkstra(V, g, r):

        dist = [INF] * V
        queue = [(0, r)]  
        dist[r] = 0  

        while queue:
            c, v = heappop(queue)
            if dist[v] < c:  
                continue
            for cost, t in g[v]:
                if dist[v] + cost < dist[t]:
                    dist[t] = dist[v] + cost
                    heappush(queue, (dist[t], t))

        return dist

    N,X,Y=map(int,input().split())
    V, E= N,N
    g = [[] for i in range(V)]

    for i in range(N-1):
        g[i].append((1, i+1))
        g[i+1].append((1, i))  
        
    g[X-1].append((1, Y-1))
    g[Y-1].append((1, X-1))

    INF = 10 ** 10
    ans = [0] * N

    for r in range(N):
        for i in dijkstra(V, g, r):
            if i<INF:
                ans[i]+=1

    for j in range(1, N):
        print(ans[j] // 2)


resolve()

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

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

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

Solution (Python):



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




k_list = [0 for i in range(1,N)]
for i in range(1, N):
    diff_X_i = abs(X - i)
    diff_Y_i = abs(Y - i)
    for j in range(i+1, N+1):
        diff_j_i = abs(j - i)
        diff_j_X = abs(j - X)
        diff_j_Y = abs(j - Y)
        min_path = min([diff_j_i, diff_X_i+1+diff_j_Y, diff_Y_i+1+diff_j_X])
        k_list[min_path-1] += 1


for k in k_list:
    print(k)

Solution (Python):
import sys
import math
import numpy

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

k = [0] * (n-1)

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

[print(p) for p in k]

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

def dis(a,b):
    return min (b-a,abs(a-x)+1+abs(b-y))









ans=[0]*(n-1)

for i in range(1,n):
  for j in range(i+1,n+1):
    ans[dis(i,j)-1]+=1
print(*ans,sep="\n")

Solution (Python):
n, x, y = map(int, input().split())
x -= 1
y -= 1
GRAPH = [[0]*n for _ in range(n)]

def shortest_path(i, j):
    return min(j-i, abs(x-i)+abs(y-j)+1)

ans = [0]*(n-1)
for i in range(n):
    for j in range(i+1, n):
        path = shortest_path(i, j)-1
        ans[path] += 1
print(*ans, sep="\n")

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

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

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

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,1+n):
        d=min(j-i,abs(x-i)+abs(y-j)+1)
        ans[d-1]+=1

for i in ans:
    print(i)

Solution (Python):

from collections import deque,Counter
n,x,y=map(int,input().split())
G=[[] for i in range(n)]
dist=[-1]*n
for i in range(n-1):
    a=i
    b=i+1
    G[a].append([b,1])
    G[b].append([a,1])
G[x-1].append([y-1,1])
G[y-1].append([x-1,1])


ans=[]
for i in range(n-1):
    q=deque()
    q.append(i)
    dist=[-1]*n
    dist[i]=0
    while q:
        cur=q.popleft()
        for nx,nx_dist in G[cur]:
            if dist[nx]==-1:
                dist[nx]=dist[cur]+nx_dist
                q.append(nx)
    for j in range(i+1,n):
        ans.append(dist[j])

ans=Counter(ans)
for i in range(n-1):
    print(ans[i+1])

Solution (Python):
def dij(n,x,y,i,j):

    d=min((j-i),(abs(x-i)+1+abs(j-y)))
    return d

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

c=[0]*(n+1)

for i in range(1,n):
    for j in range(i+1,n+1):
        d=dij(n,x,y,i,j)
        c[d]=c[d]+1
        
for i in range(1,n):
    print(c[i])

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

for i in range(1, N):
  for j in range(i+1, N+1):
    Count[min(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(Count[i])

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

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

print(n)
for k in range(1, n-1):
    print(array[k])