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 collections

def solve(N: int, X: int, Y: int):
    def len_shortest_path(i, j, X, Y):
        return min(abs(j-i), abs(X-i) + abs(Y-j) + 1)
    result = collections.defaultdict(int)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            shortest_path = len_shortest_path(i, j, X, Y)
            result[shortest_path] += 1

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


def solve_slow(N: int, X: int, Y: int):
    d = [[100000000 for i in range(N)] for j in range(N)]
    X -= 1
    Y -= 1

    for i in range(N):
        d[i][i] = 0
        if i < N-1:
            d[i][i+1] = 1
            d[i+1][i] = 1
    d[X][Y] = 1
    d[Y][X] = 1

    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    count_dict = collections.defaultdict(int)
    for row in d:
        for i in row:
            count_dict[i] += 1
    for i in range(1, N):
        print(count_dict[i])
    return


def solve_slow(N: int, X: int, Y: int):
    d = [[100000000 for i in range(N)] for j in range(N)]
    X -= 1
    Y -= 1

    for i in range(N):
        d[i][i] = 0
        if i < N-1:
            d[i][i+1] = 1
            d[i+1][i] = 1
    d[X][Y] = 1
    d[Y][X] = 1

    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    count_dict = collections.defaultdict(int)
    for row in d:
        for i in row:
            count_dict[i] += 1
    for i in range(1, N):
        print(count_dict[i])
    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):
from collections import Counter
n, x, y = map(int, input().split())
dist = []
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(y - i) + 1 + abs(x - j))
		dist.append(d)

counter = Counter(dist)
for k in range(1, n):
	print(counter[k])

Solution (Python):

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

cs = [0 for i in range(n)]

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(j - y))
        cs[d] += 1

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

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 abs(X-i)+abs(j-Y)+1 < j-i:
            cnt[abs(X-i)+abs(j-Y)+1] += 1
        else:
            cnt[j-i] += 1
for i in range(1,N):
    print(int(cnt[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):
   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):
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

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

queue = deque()

edges = [[] for _ in range(N)]

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

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

ans = [0] * N

for i in range(N):
    visited = [0] * N
    visited[i] = 1
    queue.append((i,0))
    while queue:
        current, dist = queue.popleft()
        ans[dist] += 1

        for e in edges[current]:
            if visited[e] != 1:
                queue.append((e, dist+1))
                visited[e] = 1

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

Solution (Python):

def check_distance(i,j):

    if j<=X or i>=Y:
        dis = j - i
    else:
        dis1 = j - i
        dis2 = abs(i-X) + 1 + abs(j - Y)
        dis = min(dis1,dis2) 
    return dis


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

K = []
for i in range(1,N):
    K.append(0)

for i in range(1,N):
    for j in range(i+1,N+1):
        dis = check_distance(i,j)
        K[dis-1] += 1
for k in K:
    print(k)

Solution (Python):


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

cs = [0 for i in range(n)]

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(j - y))
        cs[d] += 1

for i in range(1, n):
    print(cs[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 i in range(N-1):
    print(ans[i])

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

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

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

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

Solution (Python):

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



adjl=[[0 for i in range(n)] for j in range(n)]

dic={}

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

for i in range(n):
    for j in range(i,n):
        
        
        dis=adjl[i][j]
        dic[dis]=dic.get(dis,0)+1
for k in range(1,n):
    print(dic.get(k,0))

Solution (Python):

from collections import deque
N,X,Y = map(int,input().split())
dist = [0 for _ in range(N)]

for i in range(N):
    s = i+1
    sdist = [-1 for _ in range(N)]
    d = deque([])
    d.append([s,0])
    while d:
        x,n = d.popleft()
        if sdist[x-1] == -1:
            sdist[x-1] = n
            
            if x < N:
                d.append([x+1,n+1])
            if x > 1:
                d.append([x-1,n+1])
            if x == X:
                d.append([Y,n+1])
            if x == Y:
                d.append([X,n+1])
    
    for sd in sdist:
        dist[sd]+=1
        
for i in range(N-1):
    print(dist[i+1]//2)

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

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

ret = [0] * (n-1)
for s in range(1,n):
    for e in range(s+1,n+1):
        d = min(e-s, abs(s-x) + abs(e-y) +1)
        ret[d-1] += 1
for r in ret:
    print(r)

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

ret = [0] * (n-1)
for s in range(1,n):
    for e in range(s+1,n+1):
        d = min(e-s, abs(s-x) + abs(e-y) +1)
        ret[d-1] += 1
for r in ret:
    print(r)

Solution (Python):





import functools

if __debug__:
    def debug(arg):
        pass
else:
    import sys
    def debug(arg):
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        if dd1 < dd2:
            d[dd1] += 1
        else:
            d[dd2] += 1
        debug(d)

for n in d.values():
    print(n)

Solution (Python):
from collections import deque
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

q = deque()

ans = [0] * N

def BFS(x, cnt):
    if dist[x] != (N + 1):
        return
    cnt += 1
        
    dist[x] = cnt
    if x + 1 < N:
        q.append((x + 1, cnt))
    if x - 1 >= 0:
        q.append((x - 1, cnt))
    if x == X:
        q.append((Y, cnt))
    if x == Y:
        q.append((X, cnt))


for x in range(N):
    dist = [N + 1] * N
    q.append((x, -1))
    while q:
        BFS(*q.popleft())

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

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

Solution (Python):
x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

ans = [0] * N

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

[print(int(x)) for x in ans[1:]]

Solution (Python):
from collections import deque, Counter

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

inf = 100100100
x -= 1
y -= 1

ans = [0] * n

for i in range(n):
    dist = [inf] * n
    queue = deque()
    queue.append(i)
    dist[i] = 0
    while queue:
        current = queue.popleft()
        d = dist[current]

        if current - 1 >= 0 and dist[current - 1] == inf:
            queue.append(current - 1)
            dist[current - 1] = d + 1
        if current + 1 < n and dist[current + 1] == inf:
            queue.append(current + 1)
            dist[current + 1] = d + 1
        if current == x and dist[y] == inf:
            queue.append(y)
            dist[y] = d + 1
        if current == y and dist[x] == inf:
            queue.append(x)
            dist[x] = d + 1

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

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

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

a = [0]*(n-1)
for i in range(n):
    for j in range(n):
        if i < j:
            dis1 = j-i
            dis2 = abs(x-1-i)+abs(y-1-j)+1
            dis = min(dis1, dis2)
            a[dis-1] += 1
            
for i in a:
    print(i)

Solution (Python):

def D_160():
    N, X, Y = map(int, input().split())
    
    ans = [0 for i in range(N-1)]
    for i in range(0,N):
        for j in range(1+i,N):
            ans_i = min(j-i,abs((X-1)-i) + abs(j-(Y-1)) + 1)
            ans[ans_i-1] += 1
    
    
    for i in ans:
        print(i)

D_160()

Solution (Python):

def D_160():
    N, X, Y = map(int, input().split())
    
    ans = [0 for i in range(N-1)]
    for i in range(0,N):
        for j in range(1+i,N):
            ans_i = min(j-i,abs((X-1)-i) + abs(j-(Y-1)) + 1)
            ans[ans_i-1] += 1
    
    
    for i in ans:
        print(i)

D_160()

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

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

Solution (Python):
from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1


edges = [[] for _ in range(n)]
for i, e in enumerate(edges):
    if i == y:
        e.append(x)
    if i > 0:
        e.append(i - 1)
    if i < n - 1:
        e.append(i + 1)
    if i == x:
        e.append(y)

ans = [0] * n  

for v in range(n):
    que = deque()  
    que_append = que.append
    que_popleft = que.popleft
    dist = [-1] * n  

    dist[v] = 0
    que_append(v)

    while len(que):
        new_v = que_popleft()

        for adjacent in edges[new_v]:
            if dist[adjacent] != -1:
                continue
            que_append(adjacent)
            dist[adjacent] = dist[new_v] + 1

    for d in dist:
        ans[d] += 1

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

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

d=[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  d[i][i]=0
num=[0 for i in range(n)]
g=[[i+1] for i in range(n-1)]
g.append([])
for i in range(1,n):
  g[i].append(i-1)
x-=1
y-=1
g[x].append(y)
g[y].append(x)

def bfs(start):
  
  
  q=[start]
  while q:
    now=q.pop(0)
    
    for i in g[now]:
      if d[start][i]!=-1:
        continue
      else:
        d[start][i]=d[start][now]+1
        q.append(i)
 
for i in range(n):
  bfs(i)

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

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

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

d=[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  d[i][i]=0
num=[0 for i in range(n)]
g=[[i+1] for i in range(n-1)]
g.append([])
for i in range(1,n):
  g[i].append(i-1)
x-=1
y-=1
g[x].append(y)
g[y].append(x)

def bfs(start,dist=0):
  
  
  q=[start]
  while q:

    dist+=1
    now=q.pop(0)
    
    for i in g[now]:
      if d[start][i]!=-1:
        continue
      else:
        d[start][i]=d[start][now]+1
        q.append(i)
 
for i in range(n):
  bfs(i)

for i in range(n-1):
  for j in range(i+1,n):
    if d[i][j]>=n:
      continue
    num[d[i][j]]+=1

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

Solution (Python):
from collections import Counter
n, x, y = map(int, input().split())

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

count = []
for i in range(1,n):
  for j in range(i+1, n+1):
    count.append(func(i,j))
    
counted = Counter(count)
for i in range(1,n):
    print(str(counted[i]))

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

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

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

Solution (Python):
N, X, Y = map(int, input().split())
ls = [0] * N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        dis = min([abs(j-i), abs(X-i) + 1 + abs(j-Y), abs(Y-i) + 1 + abs(j-X)])
        ls[dis] += 1
for i in range(1, len(ls)):
    print(ls[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):
        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])

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())
dist_list = [0]*N

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

for k in range(N-1):
    print(dist_list[k+1])

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

distance_list =[0]*n

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

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

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

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

Solution (Python):



from sys import stdin
import collections


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

    cost = collections.defaultdict(lambda: 0)
    for i in range(N):
        for j in range(i + 1, N):
            
            min1 = j - i
            
            min2 = abs(X - i) + 1 + abs(j - Y)
            
            min3 = abs(Y - i) + 1 + abs(X - j)
            shortest = min(min1, min2, min3)
            cost[shortest] = cost[shortest] + 1
    for i in range(1, N):
        print(cost[i])


if __name__ == "__main__":
    main()

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

ans = [0 for i in range(n)]
for s in range(n) :
  for g in range(s,n) :
    if s == g :
      continue
    dis = min(abs(g-s),abs(abs(x-s)+1+abs(y-g)),abs(abs(y-s)+1+abs(x-g)))
    ans[dis] += 1
    
for i in range(1,n) :
  print(ans[i])

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bfs(nodes, src):
    """ BFS(一般グラフ、重みなし) """
    from collections import deque

    N = len(nodes)
    que = deque([(src, 0)])
    dist = [INF] * N
    dist[src] = 0
    while que:
        u, c = que.popleft()
        for v in nodes[u]:
            if dist[v] != INF:
                continue
            dist[v] = c + 1
            que.append((v, c+1))
    return dist

N, x, y = MAP()
x -= 1; y -= 1

nodes = [[] for i in range(N)]
for i in range(N-1):
    nodes[i].append(i+1)
    nodes[i+1].append(i)
nodes[x].append(y)
nodes[y].append(x)

distx = bfs(nodes, x)
disty = bfs(nodes, y)

G = list2d(N, N, 0)
for i in range(N):
    for j in range(i+1, N):
        G[i][j] = min(j - i, distx[i] + disty[j] + 1, distx[j] + disty[i] + 1)
ans = [0] * N
for i in range(N):
    for j in range(i+1, N):
        ans[G[i][j]] += 1
[print(a) for a in ans[1:]]

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bfs(nodes, src):
    """ BFS(一般グラフ、重みなし) """
    from collections import deque

    N = len(nodes)
    que = deque([(src, 0)])
    dist = [INF] * N
    dist[src] = 0
    while que:
        u, c = que.popleft()
        for v in nodes[u]:
            if dist[v] != INF:
                continue
            dist[v] = c + 1
            que.append((v, c+1))
    return dist

N, x, y = MAP()
x -= 1; y -= 1

nodes = [[] for i in range(N)]
for i in range(N-1):
    nodes[i].append(i+1)
    nodes[i+1].append(i)
nodes[x].append(y)
nodes[y].append(x)

distx = bfs(nodes, x)
disty = bfs(nodes, y)

G = list2d(N, N, 0)
for i in range(N):
    for j in range(i+1, N):
        G[i][j] = min(j - i, distx[i] + disty[j] + 1, distx[j] + disty[i] + 1)
ans = [0] * N
for i in range(N):
    for j in range(i+1, N):
        ans[G[i][j]] += 1
[print(a) for a in ans[1:]]

Solution (Python):
inp = input().split()
line = list(map(int,inp))
n = line[0]
x = line[1] - 1
y = line[2] - 1

a = []
for i in range(0,n-1):
    a.append(0)

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

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

Solution (Python):
def D():
    nxy=list(map(int,input().split()))
    count_list=[0]*nxy[0]
    
    for i in range(1,nxy[0]):
        for j in range(i+1,nxy[0]+1):
            mins=min(abs(j-i),abs(nxy[1]-i)+1+abs(j-nxy[2]))
            count_list[mins]+=1
            
    for i in range(1,nxy[0]):
        print(count_list[i])
            
        
if __name__=='__main__':
    D()

Solution (Python):
from collections import defaultdict

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

a=defaultdict(int)

for i in range(1,n):
    a[i]=0


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 )

        

        a[d] +=1
b=sorted(a.items())

for i,j in b:
    print(j)

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

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


from collections import deque
def bfs_graph(G, start):
    
    dist = [-1] * N
    que = deque([start])
    dist[start] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    return dist

ans = [0] * (N - 1)
for s in range(N - 1):
    res = bfs_graph(graph, s)
    
    for val in res[s+1:]:
        if val >= 1:
            ans[val-1] += 1
print(*ans, sep="\n")

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

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

    link = np.array([[N if i!=j else 0 for j in range(N)] for i in range(N)])
    link[X-1, Y-1] = 1
    link[Y-1, X-1] = 1

    for i in range(1, N):
        link[i] = np.minimum(link[i], link[i-1] + 1)
    for i in range(N-2, -1, -1):
        link[i] = np.minimum(link[i], link[i+1] + 1)
    for i in range(1, N):
        link[:,i] = np.minimum(link[:,i], link[:,i-1] + 1)
    for i in range(N-2, -1, -1):
        link[:,i] = np.minimum(link[:,i], link[:,i+1] + 1)
    
    ans = [0] * N
    for i in range(N-1):
        for j in range(i+1, N):
            ans[link[i, j]] += 1
    
    for i in range(1, N):
        print(ans[i])

if __name__ == "__main__":
    main()

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

Solution (Python):
from collections import deque
def solve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    ans = [0] * N

    for start_vertex in range(N):
        q = deque()
        distance_list = [float('inf')] * N

        def push(vertex, distance):
            if distance_list[vertex] != float('inf'):
                return
            q.append(vertex)
            distance_list[vertex] = distance
        
        push(start_vertex, 0)

        while len(q) > 0:
            vertex = q.popleft()
            distance = distance_list[vertex]

            if vertex - 1 >= 0:
                push(vertex-1, distance+1)
            if vertex + 1 < N:
                push(vertex+1, distance+1)
            if vertex == X:
                push(Y, distance+1)
            if vertex == Y:
                push(X, distance+1)
        
        for i in distance_list:
            ans[i] += 1
    
    ans = list(map(lambda x: x // 2, ans))
    print(*ans[1:], sep='\n')

if __name__ == '__main__':
    solve()

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


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

Solution (Python):

import collections

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

    X -= 1
    Y -= 1
    distance = []
    dappend = distance.append

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

    count = collections.Counter(distance)

    for s in range(1, N):
        print(count.get(s, 0))

if __name__ == "__main__":
    cmd()

Solution (Python):


n, x, y = map(int, input().split())
ans = [0 for _ in range(n - 1)]
debug = [[] for _ in range(n-1)]
mid = (y - x) // 2 + x 

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


for i in ans:
  print(i)

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

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

k = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        min = abs(j-i)
        min1 = abs(Y-j)+abs(X-i)+1
        min2 = abs(Y-i)+abs(j-X)+1
        if min > min1:
            min = min1
        if min > min2:
            min = min2
        k[min] += 1
for i in range(1, N):
    print(k[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):
    idx = min(j - i, abs(x - i - 1) + 1 + abs(y - j - 1))
    ans[idx-1] += 1
for i in range(n - 1):
  print(ans[i])

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

if __name__ == '__main__':
    main()

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

ans = [0]*(N)
for i in range(1,N):
    for j in range(i+1,N+1):
        ans[kyori(i,j)] += 1

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

Solution (Python):
def main():
    dist = []
    import numpy as np
    from collections import deque
    n, x, y = map(int,input().split())
    g = [[] for _ in range(n)] 
    for i in range(n-1):

        g[i] += i+1,
        g[i+1] += i,
    g[x-1] += y-1,
    g[y-1] += x-1,
    a = [0]*n
    for start in range(n):
        d = [-1] * n
        d[start] = 0
        q = deque([start])
        add,pop=q.append,q.popleft
        while q:
            v = pop()
            for nv in g[v]:
                if d[nv] < 0:
                    d[nv] = d[v]+1
                    add(nv)
        
        
        dist.extend(d)
    for i in dist:
        a[i] += 1
    
    
    
    for i in range(1,n):
        print(int(a[i]/2))
main()

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

Solution (Python):
def main():
    dist = []
    import numpy as np
    from collections import deque
    n, x, y = map(int,input().split())
    g = [[] for _ in range(n)] 
    for i in range(n-1):

        g[i] += i+1,
        g[i+1] += i,
    g[x-1] += y-1,
    g[y-1] += x-1,
    a = [0]*n
    for start in range(n):
        d = [-1] * n
        d[start] = 0
        q = deque([start])
        add,pop=q.append,q.popleft
        while q:
            v = pop()
            for nv in g[v]:
                if d[nv] < 0:
                    d[nv] = d[v]+1
                    add(nv)
        for i in d:
            a[i] += 1
    
    
    
    
    
    
    print(' '.join(str(i//2) for i in a[1:]))
main()

Solution (Python):
def main():
    dist = []
    import numpy as np
    from collections import deque
    n, x, y = map(int,input().split())
    g = [[] for _ in range(n)] 
    for i in range(n-1):

        g[i] += i+1,
        g[i+1] += i,
    g[x-1] += y-1,
    g[y-1] += x-1,
    a = [0]*n
    for start in range(n):
        d = [-1] * n
        d[start] = 0
        q = deque([start])
        add,pop=q.append,q.popleft
        while q:
            v = pop()
            for nv in g[v]:
                if d[nv] < 0:
                    d[nv] = d[v]+1
                    add(nv)
        for i in d:
            a[i] += 1
    
    
    
    
    
    
    print(' '.join(str(i//2) for i in a[1:]))
main()