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

import heapq

from collections import Counter as cl

def solve(N: int, X: int, Y: int):

    def dis(a,b):
        fw = abs(a-b)
        bw1 = abs(X-a)+abs(Y-b)+1
        bw2 = abs(X-b)+abs(Y-a)+1
        bw = min(bw1,bw2)
        return min(fw, bw)
    
    dist_l = [0]*(N-1)
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            dist_l[dis(i,j)-1] += 1


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




def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    solve(N, X, Y)

if __name__ == '__main__':
    main()

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

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





def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))





def main():
	n,x,y=MI()
	ans=[0]*(n)

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


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


















if __name__ == "__main__":
	main()

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





def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))





def main():
	n,x,y=MI()
	ans=[0]*(n)

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


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




if __name__ == "__main__":
	main()

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]


from collections import deque  
def main():
    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):
            dist1 = j - i 
            dist2 = abs(X - i) + abs(Y - j) + 1 
            d = min(dist1, dist2) 
            ans[d] += 1 
    for i in range(1, N):
        print(ans[i])


if __name__ == "__main__":
    main()

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

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

for i in ans:
    print(i)

Solution (Python):
N, X, Y = list(map(int, input().split()))
X -= 1
Y -= 1
res = 0
A = [0] * N
for i in range(N):
    for j in range(i, N):
        if i == j: continue
        
        A[min(j - i, abs(X - i) + 1 + abs(Y - j))-1] += 1
for x in range(N-1):
    print(A[x])

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

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

Solution (Python):
def main():
    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(j - X) + 1 + abs(Y - i),
                abs(j - Y) + 1 + abs(X - i)
            )
            ans[d] += 1

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


if __name__ == '__main__':
    main()

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

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

disset = [0]*(n-1)

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


for i in disset:
    print(i)

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


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

for i in l:
    print(i)

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

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

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

Solution (Python):
from collections import deque
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)

L = [0] * N
for i in range(N - 1):
    dist = [N] * N
    dist[i] = 0
    Q = deque()
    Q.append(i)
    while len(Q) > 0:
        q = Q.popleft()
        for j in G[q]:
            if dist[j] != N:
                continue
            dist[j] = min(dist[q] + 1, dist[j])
            Q.append(j)
    for k in range(i, N):
        if dist[k] != N and dist[k] != 0:
            L[dist[k]] += 1
for i in range(1, N):
    print(L[i])

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

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

Solution (Python):

from collections import deque

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

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


def bfs(start):
    inf = 1001001001
    dist = [inf for _ in range(n)]
    q = deque()
    q.append(start)
    dist[start] = 0 

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

    push(start, 0)
    while q:
        v = q.popleft()
        d = dist[v]
        if v-1 >= 0: push(v-1, d+1)
        if v+1 < n: push (v+1, d+1)
        if v==x: push(y, d+1)
        if v==y: push(x, d+1)
    
    for i in range(n):
        ans[dist[i]] += 1
    
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())
if X > Y:
    exc=X
    X=Y
    Y=exc
L=[0]*N
for i in range(N-1):
    for j in range(i+1,N):
        if i >= Y-1 or j <= X-1 or j-i ==1:
            L[j-i]+=1
        elif i <= X-1 and j >= Y-1:
            L[1+abs(X-1-i)+abs(Y-1-j)]+=1
        elif i >= X-1 and i-(X-1) > (Y-1)-i:
            L[j-i]+=1
        else:
            L1=j-i
            L2=min(j-i,1+abs(X-1-i)+abs(Y-1-j))
            L[min(L1,L2)]+=1

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

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

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

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

Solution (Python):


from collections import deque

n, x, y = map(int, input().split())
to = [[] for _ in range(n)]
for i in range(n):
    if i == 0:
        to[i].append(i+1)
    elif i == n-1:
        to[i].append(i-1)
    else:
        to[i].append(i+1) 
        to[n-i-1].append(n-i-2)
to[x-1].append(y-1)
to[y-1].append(x-1)

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


def bfs(start):
    inf = 1001001001
    dist = [inf for _ in range(n)]
    q = deque()
    q.append(start)
    dist[start] = 0 

    while q:
        v = q.popleft()
        for u in to[v]:
            if dist[u] == inf:
                dist[u] = dist[v]+1
                q.append(u)
    

    
    
    
    

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

Solution (Python):
from collections import deque, defaultdict
n, x, y = map(int, input().split())
inf = 10**10
dp = [[inf]*n for _ in range(n)]
dic = defaultdict(int)


    

for i in range(n):
    l=1
    dp[i][i] = 0
    if i==0 and x==1:
        queue = deque([1, y-1])
        dp[i][1]=1
        dp[i][y-1]=1
        dic[1]+=2
    elif i==0:
        queue = deque([1])
        dp[i][1]=1
        dic[1]+=1
    elif i==n-1 and y==n:
        queue = deque([n-2, x-1])
        dp[i][n-2]=1
        dp[i][x-1]=1
        dic[1]+=2
    elif i==n-1:
        queue = deque([n-2])
        dp[i][n-2]=1
        dic[1]+=1
    elif i==x-1:
        queue = deque([i-1, i+1, y-1])
        dp[i][i+1]=1
        dp[i][i-1]=1
        dp[i][y-1]=1
        dic[1]+=3
    elif i==y-1:
        queue = deque([i-1, i+1, x-1])
        dp[i][i+1]=1
        dp[i][i-1]=1
        dp[i][x-1]=1
        dic[1]+=3
    else:
        queue = deque([i-1, i+1])
        dp[i][i-1]=1
        dp[i][i+1]=1
        dic[1]+=2
    while queue:
        
        t = queue.popleft()
        
        if t == x-1 and dp[i][y-1]==inf:
            queue.append(y-1)
            dp[i][y-1]=dp[i][t]+1
            dic[dp[i][t]+1]+=1
        if t == y-1 and dp[i][x-1]==inf:
            queue.append(x-1)
            dp[i][x-1]=dp[i][t]+1
            dic[dp[i][t]+1]+=1
        if not t==0:
            if dp[i][t-1]==inf:
                queue.append(t-1)
                dp[i][t-1]=dp[i][t]+1
                dic[dp[i][t]+1]+=1
        if not t==n-1:
            if dp[i][t+1]==inf:
                queue.append(t+1)
                dp[i][t+1]=dp[i][t]+1
                dic[dp[i][t]+1]+=1

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

Solution (Python):
n,x,y = [int(x) for x in input().split()]
d = {x: 0 for x in range(1, n)}
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 v in d.values():
    print(v)

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

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

c = [0 for _ in range(N)]
for i in range(1,N):
  for j in range(i+1,N+1):
    x = abs(X-i)
    y = abs(Y-j)
    a = min(x+y+1, j-i)
    c[a] += 1

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

Solution (Python):
n,x,y=map(int,input().split())
from collections import Counter
c=Counter()
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))
    c[d]+=1

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

Solution (Python):

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

shortest=[0 for i in range(n-1)]

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

for i in shortest:
    print(i)

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X, Y = MAP()
dic = defaultdict(int)
for i in range(1, N+1):
    for j in range(1, N+1):
        tmp = min(abs(i - j), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(X-j))
        dic[tmp] += 1
for i in range(1, N):
    print(dic[i]//2)

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(i-x) + abs(j-y) + 1)
        ans[dist] += 1

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

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

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

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

for i in range(1,N):
  ans = c[i]
  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 + 1, N + 1):
        d = min(
            j - i,
            abs(i - X) + 1 + abs(j - Y),
            abs(j - X) + 1 + abs(i - Y)
        )
        ans[d] += 1

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

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


for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x - 1:
            if j <= x - 1:  
                cnt[j - i] += 1
            elif j <= y - 1:
                cnt[min(j - i, x + y - i - j - 1)] += 1
            else:
                cnt[x - y - i + j + 1] += 1
        elif x - 1 < x <= y - 1:
            if j <= y - 1:
                cnt[min(j - i, 1 + (i - x + 1) + (y - 1 - j))] += 1
            else:
                cnt[min((j - i), 1 + (i - x + 1) + (j - y + 1))] += 1
        else:
            cnt[j - i] += 1

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

Solution (Python):
from collections import deque
N, X, Y = map(int, input().split())
X-=1;Y-=1
d = [[] for _ in range(N)]
for i in range(N):
  if i == 0:
    d[i].append(i+1)
  elif i == N-1:
    d[i].append(i-1)
  else:
    d[i].append(i+1)
    d[i].append(i-1)
  if i == X:
    d[i].append(Y)
  elif i == Y:
    d[i].append(X)

INF = float("inf")
ans = [0 for _ in range(N)]
for i in range(N):
  reach = [INF for _ in range(N)]
  reach[i] = 0
  Q = deque([])
  Q.append(i)
  while Q:
    v = Q.popleft()
    for u in d[v]: 
      if reach[u] != INF:
        continue
      reach[u] = reach[v] + 1
      ans[reach[u]] += 1
      Q.append(u)

for i in range(1,N):
  temp = ans[i]//2
  print(temp)

Solution (Python):
from collections import deque
N,X,Y = map(int,input().split())
G = [[] for i in range(N+1)] 
for i in range(1,N+1):
  if i-1 >= 1:
    G[i].append(i-1)
  if i+1 <= N:
    G[i].append(i+1)

G[X].append(Y)
G[Y].append(X)

dl = [0]*(N+1)
def bfs(p):
  seen = [False]*(N+1)
  seen[p] = True
  dist = [0]*(N+1)
  d = deque([p])
  while len(d) > 0:
    v = d.popleft()
    for i in G[v]:
      if seen[i] == False:
        seen[i] = True
        dist[i] = dist[v]+1
        dl[dist[i]] += 1
        d.append(i)      


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

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

import collections
def resolve():
    N,P,Q=pin()
    P-=1
    Q-=1
    ans=[0]*N
    
    
    for i in range(N):
        seen=[0]*N 
        d=collections.deque()
        d.append((i,0))
        for j in range(1,N*10):
            if len(d)==0:break
            a,b=d.popleft()
            if a<0 or a>=N or seen[a]:
                continue
            seen[a]=1
            ans[b]+=1
            d.append((a+1,b+1))
            d.append((a-1,b+1))
            if a==P:
                d.append((Q,b+1))
            if a==Q:
                d.append((P,b+1))
    for n,a in enumerate(ans):
        if n!=0:print(a//2)
        
                
            

resolve()

Solution (Python):
N, X, Y = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(1, N):
    graph[i-1].append(i)
    graph[i].append(i-1)
graph[X-1].append(Y-1)
graph[Y-1].append(X-1)
from collections import deque, defaultdict
dic = defaultdict(int)

def bfs(s):
    checked = [0]*N
    queue = deque([(s, 0)])
    while queue:
        v, c = queue.pop()
        if checked[v]:
            continue
        checked[v] = 1
        dic[c] += 1
        for i in graph[v]:
            if not checked[i]:
                queue.appendleft((i, c+1))

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

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

Solution (Python):
import heapq
INFTY = 10**4
N,X,Y = map(int,input().split())
C = {k:0 for k in range(N)}
G = {i:[] for i in range(1,N+1)}
G[1].append(2)
G[N].append(N-1)
for i in range(2,N):
    G[i].append(i-1)
    G[i].append(i+1)
G[X].append(Y)
G[Y].append(X)
for i in range(1,N+1):
    heap = [(0,i)]
    dist = [INFTY for _ in range(N+1)]
    dist[i] = 0
    hist = [0 for _ in range(N+1)]
    while heap:
        d,x = heapq.heappop(heap)
        if dist[x]<d:continue
        hist[x]=1
        for y in G[x]:
            if hist[y]==0 and dist[y]>d+1:
                dist[y] = d+1
                heapq.heappush(heap,(dist[y],y))
    for j in range(1,N+1):
        C[dist[j]] += 1
for k in range(1,N):
    print(C[k]//2)

Solution (Python):
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, x, y = map(int, input().split())
    tree = [[] for _ in range(n)]
    for i in range(1, n):
        tree[i - 1].append(i)
        tree[i].append(i - 1)

    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

    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

    res = [0 for _ in range(n)]
    for i in range(n):
        bfs(i)

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


if __name__ == '__main__':
    resolve()

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):
        d = min(j-i, abs(i-X)+1+abs(j-Y))
        ans[d] += 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-1):
    for j in range(i+1,N):
        d = min(j-i, abs(i-X) + abs(j-Y) + 1)
        ans[d] += 1
print(*ans[1:], sep='\n')

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

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):
        if j <= X or Y <= i:
            a = j - i
        elif i <= X and Y <= j:
            a = X-i + 1 + j-Y
        elif i <= X and j <= Y:
            a = min(j-i,X-i + 1 + Y-j)
        elif X <= i and j <= Y:
            a = min(j-i,i-X+1+Y-j)
        else:
            a = min(j-i,i-X+1+j-Y)
        ans[a] += 1

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

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

cost = [0 for _ in range(N - 1)]



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

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

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

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

for i in range(1, len(list_length)):
    print(list_length[i])

Solution (Python):
N,X,Y = map(int,input().split())
from itertools import combinations
counter = [0]*(N+1)

for com in combinations(range(N),2):
    i,j = com
    min_path = min(j-i,abs(X-1-i)+abs(Y-1-j)+1)
    counter[min_path]+=1

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

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

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

Solution (Python):
from collections import defaultdict
from collections import deque

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

for i in range(1,n+1):
    if i!=x:
        if i == 1:
            graph[i-1].append(i+1)
        elif i == n:
            graph[i-1].append(i-1)
        else:
            graph[i-1].append(i-1)
            graph[i-1].append(i+1)
    else:
        graph[i-1].append(y)
        if i == 1:
            graph[i-1].append(i+1)
        elif i == n:
            graph[i-1].append(i-1)
        else:
            graph[i-1].append(i-1)
            graph[i-1].append(i+1)
k_dic=defaultdict(int)

for i in range(1,n):
    q = deque([[i]])
    prev = [0]*n
    prev[i-1] = 1
    dic=defaultdict(int)
    while q:
        now_l = q.popleft()
        tu = []
        for now in now_l:
            nex = graph[now-1]
            
            for ne in nex:
                if prev[ne-1] == 0:
                
                    tu.append(ne)
                    q.append(tu)
                    prev[ne-1] = 1
                    dic[ne] = dic[now]+1
                    if ne > i:
                        k_dic[dic[ne]] += 1

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

Solution (Python):
from collections import deque

N,X,Y=map(int,input().split())
ans=[0]*(N+1)

for i in range(1,N+1):
    que=deque([(i,0)])
    used=[False]*(N+1)
    used[i]=True
    while que:
        v,dist=que.popleft()
        ans[dist]+=1
        if v!=1 and not used[v-1]:
            que.append((v-1,dist+1))
            used[v-1]=True
        if v!=N and not used[v+1]:
            que.append((v+1,dist+1))
            used[v+1]=True
        if v==X and not used[Y]:
            que.append((Y,dist+1))
            used[Y]=True
        if v==Y and not used[X]:
            que.append((X,dist+1))
            used[X]=True

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

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

x-=1
y-=1

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

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

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

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

row,col,w=[],[],[]
for i in range(n-1):
  row.append(i)
  col.append(i+1)
  w.append(1)

row.append(x-1)
col.append(y-1)
w.append(1)

g=csr_matrix((w, (row, col)), shape=(n, n))

d=dijkstra(g,directed=False)

l=list(np.ravel(d))

c=Counter(l)
for i in range(1,n):
  print(c[i]//2)

Solution (Python):
from collections import deque, Counter

def BFS(st,c):

  dist=[-1 for i in range(n)]
  dist[st]=0

  que=deque()
  que.append(st)

  while que:
    x=que.popleft()
    for i in tree[x]:
      if dist[i]==-1:
        dist[i]=dist[x]+1
        que.append(i)

  c+=dist

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

tree=[[] for i 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)

c=[]

for i in range(n):
  BFS(i,c)

count=Counter(c)

for i in range(1,n):
  print(count[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):
        num = min(j-i, abs(i-X)+abs(j-Y)+1)
        ans[num-1] += 1

for i in ans:
    print(i)

Solution (Python):


import itertools
from collections import deque













def bfs(s, N, edge):
    d = [-1 for _ in range(N)]
    d[s] = 0
    q = deque()
    q.append(s)

    while q:
        v = q.popleft()
        edgelist = edge[v]
        for e in edgelist:
            if d[e] == -1:
                d[e] = d[v] + 1
                q.append(e)

    return d


def main():

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

    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        edge[i].append(i + 1)
        edge[i + 1].append(i)

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

    dist = [[] for _ in range(N)]
    for i in range(N):
        dist[i] = bfs(i, N, edge)

    comb = tuple(itertools.combinations(range(N), 2))
    ans = [0 for _ in range(N)]

    for c in comb:
        v1, v2 = c[0], c[1]
        ans[dist[v1][v2]] += 1

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter
from collections import defaultdict
from collections import deque 
def main():
    N, X, Y = map(int, readline().split())
    to = [[] for _ in range(N)] 

    for i in range(N-1):
        to[i].append(i+1)
        to[i+1].append(i)
    to[X-1].append(Y-1)
    to[Y-1].append(X-1)
    INF = int(1e9)
    ans = defaultdict(int)
    for si in range(N):
        dq = deque()
        dq.append(si)
        dist = [INF for _ in range(N)]
        dist[si] = 0
        while len(dq)>0:
            v = dq.popleft()
            for nx in to[v]:
                if dist[nx] != INF:
                    continue
                dq.append(nx)
                dist[nx] = dist[v]+1
        for i in dist:
            ans[i] += 1
    
    for i in range(1, N):
        print(ans[i]//2)
if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  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):
      num = min(j-i, abs(i-x)+abs(j-y)+1)
      ans[num-1] += 1
  for i in ans:
    print(i)
  return 0
 
if __name__ == "__main__":
  solve()

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

Solution (Python):
import sys
import math
import numpy as np
import copy
import collections

def main():
    n, x, y = map(int, input().split())
    x, y = x-1, y-1

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

    cnt = collections.Counter(dist)
    for i in range(1, n):
        print(cnt[i])


    return 0

if __name__ == '__main__':
    sys.exit(main())

Solution (Python):
from collections import deque

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

ans = [0] * (n+1)

g = [[i+1, i-1] for i in range(n+1)]

g[1].pop(1)
g[n].pop(0)

g[x].append(y)
g[y].append(x)

for i in range(1,n+1):
    q = deque()
    time = 0
    visit = [False] * (n+1)
    q.append((i, time))

    while(len(q) > 0):
        item = q.popleft()

        if visit[item[0]] == False:
            visit[item[0]] = True
            ans[item[1]] += 1
            for k in g[item[0]]:
                q.append((k, item[1]+1))

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

Solution (Python):

import collections as col


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

cnt = col.Counter(dist)
for i in range(1,n): print(cnt[i])

Solution (Python):
import collections as col


n,x,y = map(int,input().split())
dist = []
for i in range(1,n+1):
    for j in range(i+1,n+1):
        a = abs(i - j)
        b = abs(i - x) + 1 + abs(j - y)
        c = abs(i - y) + 1 + abs(j - x)
        dist.append(min(a,b,c))

cnt = col.Counter(dist)
for i in range(1,n): print(cnt[i])

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

dist = [0 for _ in range(n - 1)]

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

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

Solution (Python):
def D():
    n,x,y = list(map(int, input().split()))
    d_num = [0]*(n-1)
    for i in range(1,n):
        for j in range(i+1,n+1):
            d = []
            d.append(j-i)
            if x < j and i < y:
                d.append(abs(x-i)+1+abs(y-j))
            d_num[min(d)-1] += 1
    print("\n".join(map(str,d_num)))
D()

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(j-i,abs(x-i)+1+abs(y-j))]+=1
for i in ans[1:]:
  print(i)

Solution (Python):
from itertools import combinations

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

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

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