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

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

res = [0 for _ in range(N)]

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

for i, ky in enumerate(res):
    if i == 0:
        continue
    print(ky)

Solution (Python):

import sys
sys.setrecursionlimit(10**8)

import heapq
from collections import defaultdict
INF = float("inf")


def solve(N: int, X: int, Y: int):
    if X > Y:
        X, Y = Y, X
    ans = [0]*N
    for i in range(N):
        for j in range(i+1, N):
            d = min(abs(j-i), abs(i-(X-1))+1+abs(j-(Y-1)))
            ans[d] += 1
    print(*ans[1:], sep="\n")
    return


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):
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 fractions import gcd
 
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()
graph = [[] for i in range(N)]

for i in range(N-1):
    graph[i].append(i+1)
    graph[i+1].append(i)

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

dic = defaultdict(int)

for i in range(N):
    q = deque()
    q.append(i)
    dist = [INF] * N
    dist[i] = 0
    while q:
        n = q.popleft()
        for node in graph[n]:
            if dist[node] == INF:
                dist[node] = dist[n] + 1
                q.append(node)
        
    for d in dist:
        dic[d] += 1

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

Solution (Python):

import sys
sys.setrecursionlimit(10**8)

import heapq
from collections import defaultdict
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, s, t, w=1):
        self.E[s].append((t, w))
        self.E[t].append((s, w))


def shortestPath(g: Graph, s: int):
    
    
    
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


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

    g = Graph(N)
    for i in range(1, N):
        g.add_edge(i-1, i)
    g.add_edge(X-1, Y-1)

    ans = [0]*N
    for i in range(N):
        dist, prev = shortestPath(g, i)
        for j, d in enumerate(dist):
            if i < j:
                ans[d] += 1
    print(*ans[1:], sep="\n")
    return


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):
import itertools as it
import collections
 
n, x, y = list(map(int, input().split(' ')))
 
dist_list = []
dist_a = dist_list.append
for i, j in it.combinations(list(range(n)), 2):
    warp_dist = abs(i - (x - 1)) + 1 + abs(j - (y - 1))
    if abs(j - i) < warp_dist:
        dist_a(abs(j - i))
    else:
        dist_a(warp_dist)
 
dist_c = collections.Counter(dist_list)
 
for i in range(1, n):
    print(dist_c[i])

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

    def dist(s,g):
        return min(abs(g-s), abs(g-y) + 1 + abs(x-s), abs(g-x) + 1 + abs(s-y))

    array = [0] * (n-1)
    for i in range(1,n+1):
        for j in range(1,i):
            array[dist(i,j)-1] += 1

    [print(i) for i in array]

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
N, X, Y = map(int,input().split())
def distance(i, j):
    return min(abs(i-j), abs(X-i)+1+abs(j-Y))

d = defaultdict(int)
for i in range(1,N):
    for j in range(i,N+1):
        d[distance(i,j)]+=1
for i in range(1,N):
    print(d[i])

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

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

for j in k:
  print(j)

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

Solution (Python):
n, x, y = map(int,input().split())
dist = [0] * n
x -= 1
y -= 1
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)] += 1
for d in dist[1:]:
  print(d)

Solution (Python):

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

M = (Y-X)//2

d = [0] * (N-1)

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

        d[dist-1] += 1

for s in d:
    print(s)

Solution (Python):
from collections import deque
INF = 10 ** 5
n, x, y = (int(_) for _ in input().split())
dict = {}
table = [[INF] * (n+1) for i in range(n+1)]
res = [0] * n

def bfs(i): 
  deq = deque()
  node_lst = [-1] * (n+1) 
  node_lst[i] = 0
  deq.extend(dict[i])
  for j in dict[i]:
    node_lst[j] = node_lst[i] + 1
  while deq:
    p = deq.popleft()
    for j in dict[p]:
      if node_lst[j] == -1:
        deq.append(j)
        node_lst[j] = node_lst[p] + 1
  for j in range(1, n+1):
    if node_lst[j] < 1:
      continue
    a, b = i, j
    if x > y:
      a, b = b, a
    table[a][b] = min(table[a][b], node_lst[j])
  

for i in range(1, n+1):
  if i == 1:
    dict[i] = [2]
  elif i == n:
    dict[i] = [n - 1]
  else:
    dict[i] = [i-1, i+1]
dict[x] += [y]
dict[y] += [x]


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

for i in range(1, n+1):
  for j in range(i, n+1):
    if table[i][j] == INF:
      continue
    res[table[i][j]] += 1
for i in range(1, n):
  print(res[i])

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

min_xy = min(X,Y)
max_xy = max(X,Y)

ans = [0]*(N-1)
for i in range(1,N+1):
    for j in range(i+1, N+1):
        k = min(j-i, abs(min_xy-i)+abs(max_xy-j)+1)
        ans[k-1] += 1

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

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


def solve():
    N, X, Y = map(int, input().split())
    d = defaultdict(list)
    for i in range(1, N):
        d[i].append(i+1)
        d[i+1].append(i)
    d[X].append(Y)
    d[Y].append(X)
    ans = [0]*N

    for i in range(1, N+1):
        dist = [-1]*(N+1)
        dist[i] = 0
        q = [i]

        while q:
            s = q.pop()
            for t in d[s]:
                if dist[t]==-1 or dist[t] > dist[s]+1:
                    dist[t] = dist[s]+1
                    q.append(t)
        for j in range(i+1, N+1):
            ans[dist[j]] += 1

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


if __name__ == "__main__":
    solve()

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


def solve():
    N, X, Y = map(int, input().split())
    d = defaultdict(list)
    for i in range(N-1):
        a, b = i+1, i+2
        d[a].append(b)
        d[b].append(a)
    d[X].append(Y)
    d[Y].append(X)

    ans = [0]*N

    for i in range(1, N+1):
        dist = [-1]*(N+1)
        dist[i] = 0
        q = [i]

        while q:
            s = q.pop()
            for t in d[s]:
                if dist[t]==-1:
                    dist[t] = dist[s]+1
                    q.append(t)
                elif dist[t] > dist[s]+1:
                    dist[t] = dist[s]+1
                    q.append(t)
        for j in range(i+1, N+1):
            ans[dist[j]] += 1

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


if __name__ == "__main__":
    solve()

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

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

cnt = [0] * n

dist = []
for i in range(n):
    dist.append([-1] * n)
for i in range(n):
    dist[i][x] = abs(i-x)
    dist[i][y] = abs(i-y)
    dist[x][i] = abs(i-x)
    dist[y][i] = abs(i-y)

for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dis = min(j - i, dist[i][x] + 1 + dist[y][j])
        cnt[dis] += 1
for i in range(1, n):
    print(cnt[i])

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

cnt = [0] * n

dist = []
for i in range(n):
    dist.append([-1] * n)
for i in range(n):
    dist[i][x] = abs(i-x)
    dist[i][y] = abs(i-y)
    dist[x][i] = abs(i-x)
    dist[y][i] = abs(i-y)

for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dis = min(j - i, dist[j][y] + 1 + dist[i][x], dist[j][x] + 1 + dist[i][y])
        cnt[dis] += 1
for i in range(1, n):
    print(cnt[i])

Solution (Python):
from collections import defaultdict

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

x -= 1
y -= 1

storage = defaultdict(int)

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

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

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

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

l = [0] * n


for i in range(1,n):
    for j in range(i+1,n+1):
        if j < x or i > y:
            a = j-i
            l[a] += 1
        else:
            p = j-i
            q = abs(j-y)+abs(i-x)+1
            a = min(p,q)
            l[a] +=1

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

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

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

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

Solution (Python):




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

ndist = [0] * n  
for p in range(1, n):
    for q in range(p + 1, n + 1):
        
        d = min(q - p, abs(x - p) + 1 + abs(y - q))
        ndist[d] += 1

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

Solution (Python):




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

ndist = [0] * n  
for p in range(1, n):
    for q in range(p + 1, n + 1):
        
        d = min(q - p, abs(x - p) + 1 + abs(y - q))
        ndist[d] += 1

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

Solution (Python):
n,x,y = map(int,input().split())
ans = {}
s = (y-x+1)//2
s = x+s
for i in range(1,n):
    for j in range(i+1,n+1):
        if i <= s:
            dist = min(j-i,abs(i-x)+abs(j-y)+1)
        else:
            dist = j-i
        if dist in ans.keys():
            ans[dist] += 1
        else:
            ans[dist] = 1
for k in range(1,n):
    if k in ans.keys():
        print(ans[k])
    else:
        print(0)

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

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

dis = [0]*n

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

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

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

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

Solution (Python):
n,x,y = map(int, input().split())
p = [[100000000 for j in range(n)] for i in range(n)]
dp = [(-1,0),(1,0),(0,-1),(0,1)]
c = [[] for i in range(n)]

for i in range(n):
  for j in range(n-i):
    j += i
    if i==j:
      p[i][j] = 0
    if abs(i-j)==1:
      p[i][j] = 1
      c[1].append((i,j))
    if i==x-1 and j==y-1:
      p[i][j] = 1
      c[1].append((i,j))
    if i==y-1 and j==x-1:
      p[i][j] = 1
      c[1].append((i,j))
    
print(len(c[1]))

for i in range(n-2):
  i += 2
  for (a,b) in c[i-1]:
    for (da,db) in dp:
      aa = a + da
      bb = b + db
      if not (0 <= aa < n and 0 <= bb < n):
        continue
      if p[aa][bb] > i:
        p[aa][bb] = i
        c[i].append((aa,bb))
  print(len(c[i]))

Solution (Python):
from collections import deque

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

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            elif v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

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


if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque

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

    ans = [0 for _ in range(N)]
    for s in range(N):
        dist = [-1 for _ in range(N)]
        dist[s] = 0

        d = deque([s])
        while(len(d) > 0):
            v = d.popleft()
            if v == X:
                if dist[Y] == -1:
                    d.append(Y)
                    dist[Y] = dist[v] + 1
            if v == Y:
                if dist[X] == -1:
                    d.append(X)
                    dist[X] = dist[v] + 1
            if v + 1 < N:
                if dist[v+1] == -1:
                    d.append(v+1)
                    dist[v+1] = dist[v] + 1
            if v - 1 >= 0:
                if dist[v-1] == -1:
                    d.append(v-1)
                    dist[v-1] = dist[v] + 1

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


if __name__ == "__main__":
    main()

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

for i in range(N-1):
  ans.append(0)

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

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

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

answer = {}
for i in range(1, n):
    answer[i] = 0

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

for i in answer.keys():
    print(answer[i])

Solution (Python):
import math
S = input().split(" ")
N = int(S[0])
X = int(S[1])
Y = int(S[2])


def calculate(n, x, y):
    result = []
    x = x - 1
    y = y - 1
    for i in range(1, n):
        result.append(0)

    for i in range(n):
        for j in range(i+1,n):
            distance1 = int(math.fabs(x-i) + math.fabs(y-j) + 1)
            distance2 = j - i
            distance = min(distance1,distance2)

            result[distance-1] = result[distance-1] + 1


    for res in result:
        print(res)


calculate(N, X, Y)

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

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

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

ans = dict.fromkeys(range(1, n), 0)

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

for v in ans.values():
    print(v)

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

Solution (Python):
def shortests(n, x, y):
	short_lengths = {}
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			shortest = min(j - i, abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1)
			short_lengths[shortest] = short_lengths.get(shortest, 0) + 1
	for leng in range(1, n):
		if leng not in short_lengths:
			print(0)
		else:
			print(short_lengths[leng])

inputs = input().split(' ')
inputs = [int(x) for x in inputs]
n = inputs[0]
x = inputs[1]
y = inputs[2]

shortests(n, x, y)

Solution (Python):
def shortests(n, x, y):
	short_lengths = {}
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			shortest = min(j - i, abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1)
			if shortest in short_lengths:
				short_lengths[shortest] += 1
			else:
				short_lengths[shortest] = 1
	for leng in range(1, n):
		if leng not in short_lengths:
			print(0)
		else:
			print(short_lengths[leng])

inputs = input().split(' ')
inputs = [int(x) for x in inputs]
n = inputs[0]
x = inputs[1]
y = inputs[2]

shortests(n, x, y)

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

Solution (Python):








inf = 100000
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] *N
for i in range(N):
    queue = []
    dist = [inf] *N
    def push(n, d):
        if dist[n] == inf:
            dist[n] = d
            queue.append(n)
    push(i, 0)
    for q in queue:
        if q-1 >=0:
            push(q-1, dist[q] + 1)
        if q+1 <N:
            push(q+1, dist[q] + 1)
        if q == X:
            push(Y, dist[q] + 1)
        if q == Y:
            push(X, dist[q] + 1)
    for d in dist:
        ans[d] += 1
for i in range(1, N):
    print(int(ans[i]/2))

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

def push(a,b,q,distance):
    if distance[a-1]==-1:
        distance[a-1]=b
        q.append(a)

    return (q,distance)

for i in range (1,n+1):
    distance=[-1]*n
    q=[]
    q.append(i)
    distance[i-1]=0
    while len(q) > 0:
        a=q.pop(0)
        if a>=2:
            q,distance=push(a-1,distance[a-1]+1,q,distance)
        if a<=n-1:
            q, distance = push(a + 1, distance[a-1] + 1, q, distance)
        if a==x:
            q, distance = push(y, distance[a-1] + 1, q, distance)
        if a==y:
            q, distance = push(x, distance[a-1] + 1, q, distance)

    for i in range(n):
        count[distance[i]]+=1

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

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

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

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

Solution (Python):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

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

ma[x-1][y-1] = 1
ma[y-1][x-1] = 1
a = csr_matrix(ma)
b = dijkstra(a, directed=False).astype(int)
ans = np.bincount(b.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

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

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

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

graph[x - 1].append((1, y - 1))
graph[y - 1].append((1, x - 1))


from heapq import heappop, heappush
def dijkstra_with_heap(graph, start, v):
    distance = [float('infinity')] * v
    distance[start] = 0
    stack = [[0, start]] 
    while stack:
        _, vertex = heappop(stack)
        edges = graph[vertex]
        for d, t in edges:
            if d + distance[vertex] < distance[t]:
                distance[t] = d + distance[vertex]
                heappush(stack, (d, t))
    return distance
table = [0] * n
for i in range(n):
    distance = dijkstra_with_heap(graph, i, n)
    for j in range(i, n):
        d = distance[j]
        table[d] += 1

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

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

bucket = [0]*2001

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

Solution (Python):


import sys
import collections
sys.setrecursionlimit(10**6)

class Run:

    def build(gv):
        gv.N, gv.X, gv.Y = map(int, sys.stdin.readline().split(' '))

    def solve(gv):
        ans = [0 for _ in range(1, gv.N+1)]
        for start in range(1, gv.N):
            for end in range (start +1, gv.N +1):
                pass_1 = end - start
                pass_2 = abs(gv.X -start) + abs(gv.Y -end) + 1
                ans[min(pass_1, pass_2)] += 1
        
        for i in range(1, gv.N):
            print(ans[i])

if __name__ == '__main__':
    run = Run()
    run.build()
    run.solve()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)



def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))


n, x, y = in_ints()


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


for xx in dis[1:]:
    print(xx)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)



def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))


n, x, y = in_ints()


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


for xx in dis[1:]:
    print(xx)

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

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

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

Solution (Python):
import math
nxy=list(map(int, input().split()))
n=nxy[0]
x=nxy[1]-1
y=nxy[2]-1
ans=[0]*(n-1)
for i in range(0,n):
    for j in range(i+1,n):
        mindis=min(j-i, abs(i-x)+abs(j-y)+1, abs(j-x)+abs(i-y)+1)
        
        ans[mindis-1]+=1
for k in range(n-1):
    print(ans[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, n + 1):
        d = min(j - i, abs(j - y) + 1 + abs(x - i))
        ans[d - 1] += 1
for i in ans:
    print(i)

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

Solution (Python):

N, X, Y = map(int, input().split())
values_hm = N * [0]
for i in range(1, N):
    for j in range(i+1, N+1):
        if not ((i < X and j < X) or (i > Y and j > Y)):
            shorter_route = abs(i - X) + abs(j - Y) + 1
            difference = min(j - i, shorter_route)
        else:
            difference = j - i
        values_hm[difference] += 1
print("\n".join([str(ans) for ans in values_hm[1:]]))

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):
        d = j - i - 1
        if (i < x and j < x) or (i > y and j > y):
            pass
        else:
            sc = abs(i - x) + abs(j - y)
            d = min(d, sc)
        ans[d] += 1
for k in ans:
    print(k)

Solution (Python):
def readInt():
    return list(map(int,input().split()))

n,x,y = readInt()
x -= 1
y -= 1
D = dict()
for i in range(n-1):
    for j in range(i+1,n):
        d = min(j-i, abs(x-i)+1+abs(y-j))
        if d not in D:
            D[d] = 1
        else:
            D[d] += 1
        

for k in range(1,n):
    if k in D:
        print(D[k])
    else:
        print(0)

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

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

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

for i in range(len(ans)):
    print(ans[i])

Solution (Python):
def main():
  n,x,y = map(int,input().split())
  a = [0 for _ in range(n-1)]
  for i in range(1,n):
    for j in range(i+1,n+1):
      l = min(j-i,abs(x-i)+1+abs(j-y))
      a[l-1] += 1
  print("\n".join(map(str,a)))

main()

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

Solution (Python):
n,x,y = map(int,input().split())
a = [0 for _ in range(n-1)]
def di(i,j):
  if i <= x:
    if j <= (x+y)//2:
      return j-i
    elif j < y:
      return y-j+1+x-i
    else:
      return j-y+1+x-i
  elif i < y:
    if j <= y:
      return min(j-i,y-j+1+i-x)
    else:
      return min(j-i,j-y+1+i-x)
  else:
    return j-i
for i in range(1,n):
  for j in range(i+1,n+1):
    a[di(i,j)-1] += 1
for i in a:
  print(i)

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

dis_list = [0] * (n - 1)

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

for i in dis_list:
    print(i)

Solution (Python):
N , X , Y = [int(i) for i in input().split()]

distance = []
for i in range(N-1):
  distance.append(0)
  

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

for k in ans:
    print(k)

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

dis = [0]*n

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

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

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

import numpy as np
mat=np.array([[0]*N]*N)

for i in range(N-1):
    mat[i][i+1]=1
    mat[i+1][i]=1
mat[X-1][Y-1]=1
mat[Y-1][X-1]=1

from scipy.sparse.csgraph import shortest_path

from collections import Counter
ans=np.array(list(Counter(shortest_path(mat).reshape(-1,N*N)[0]).values()))

ans=np.pad(ans,[0,N-len(ans)],"constant")

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

Solution (Python):
[N, X, Y] = [int(item) for item in input().split()]
X -= 1
Y -= 1
count=[0 for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        count[min(abs(i-j),abs(i-X)+1+abs(Y-j),abs(i-Y)+1+abs(X-j))]+=1



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