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 numpy as np





def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	n,x,y=getIntList(inputs[0])
	
	count=np.zeros(n-1, np.int32)
	
	between=y-x-1
	if between%2==0:
		middleL=between//2
		middleR=between//2
	else:
		middleL=between//2+1
		middleR=between//2
	left=x-1
	right=n-y
	
	depth0=x+middleL
	depth1=x+middleR+1
	depth2=x+right+1
	length=max(depth0,depth1,depth2)
	numDepth=np.zeros(length)
	numDepth[:x]=1
	numDepth[x:depth0]+=1
	numDepth[x:depth1]+=1
	numDepth[x+1:depth2]+=1
	
	for d in range(1, length):
		count[d-1]=numDepth[d:d+x-1].sum()


	
	x0=x
	y0=y
	
	x=n-(y0-1)
	y=n-(x0-1)
	
	between=y-x-1
	if between%2==0:
		middleL=between//2
		middleR=between//2
	else:
		middleL=between//2+1
		middleR=between//2
	left=x-1
	right=n-y
	
	depth0=x+middleL
	depth1=x+middleR+1
	length=max(depth0,depth1)
	numDepth=np.zeros(length)
	numDepth[:x]=1
	numDepth[x:depth0]+=1
	numDepth[x:depth1]+=1

	
	for d in range(1, length):
		count[d-1]+=numDepth[d:d+x-1].sum()


	
	middle=middleL+middleR+2
	if middle%2==1:
		count[:middle//2]+=middle
	else:
		count[:middle//2-1]+=middle
		count[middle//2-1]+=middle//2

	
	for c in count: print(c)
	



if __name__=="__main__":
	inputs=getInputs()

	main(inputs)

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

Solution (Python):
import sys
from collections import deque

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	n, x, y = IN()
	al=[]
	for i in range(n):
		ll=[0]*n
		for j in range(n-i):
			ll[i+j]=j
		for j in range(i+1):
			ll[i-j]=j
		
		df = x-1
		dt = y-1
		if ll[y-1] < ll[x-1]:
			df, dt = dt, df
		if ll[dt] < ll[df]+1:
			al.append(ll)
			continue
		ll[dt] = ll[df]+1
		for i in range(dt+1,n):
			if ll[i] < ll[i-1]+1:
				break
			ll[i]=ll[i-1]+1
		for i in range(dt-1,0,-1):
			if ll[i] < ll[i+1]+1:
				break
			ll[i]=ll[i+1]+1
		al.append(ll)
		
	
	
			
	rr=[0]*n
	for i in range(n):
		for j in range(i+1,n):
			rr[ al[i][j] ]+=1
	
	for v in rr[1:]:
		print(v)

def main2():
	n, x, y = IN()
	al=[[-1]*n for _ in range(n)]
	ol=queue.Queue()
	for i in range(n):
		al[i][i]=0
	
	for i in range(n-1):
		al[i][i+1]=1
		ol.put((i,i+1))
		al[i+1][i]=1
	al[x-1][y-1]=1
	ol.put((x-1, y-1))
	al[y-1][x-1]=1
	while not ol.empty():
		
		fp, tp = ol.get()
		for i, dist in enumerate(al[tp]):
			nd = al[fp][tp] + dist
			if dist > 0 and (al[fp][i] == -1 or al[fp][i] > nd) and fp < i:
				al[fp][i]=nd
				al[i][fp]=nd
				ol.put((fp,i))
			
		fp,tp=tp,fp
		for i, dist in enumerate(al[tp]):
			nd = al[fp][tp] + dist
			if dist > 0 and (al[fp][i] == -1 or al[fp][i] > nd) and fp < i:
				al[fp][i]=nd
				al[i][fp]=nd
				ol.put((fp,i))
			
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

Solution (Python):
N, X, Y = map(int, input().split())
count = [0] * (N-1)
for i in range(N):
    i += 1
    for j in range(N-i):
        j += i + 1
        if i < j:
            normal = j-i
            xtoy = abs(X-i) + 1 + abs(Y-j)
            ytox = abs(Y-i) + 1 + abs(X-j)
            minRoute = min([normal, xtoy, ytox])
            count[minRoute-1] += 1
for c in count:
    print(c)

Solution (Python):

import sys
import collections 


def solve(N: int, X: int, Y: int):
    seen = [[False] * N] * N
    X -= 1
    Y -= 1
    cnt = []
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            if seen[i][j]:
                continue
            seen[j][i] = True
            cnt.append(min(abs(j - i), abs(X - i) + 1 + abs(j - Y)))
    counter = collections.Counter(cnt)
    keys = counter.keys()
    for i in range(N):
        if i == 0:
            continue
        if i not in keys:
            print(0)
            continue
        print(counter[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 sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


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

Solution (Python):
import collections
from collections import deque

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


n = N
l_hen = [[i,i+1] for i in range(1,n)]+[[X,Y]]


l_chouten =list( set(sum(l_hen, [])) )


G = dict( [ (key,[]) for key in l_chouten]  )
for i in range(n):
   G[l_hen[i][0]].append(l_hen[i][1])


for i in range(n):
   G[l_hen[i][1]].append(l_hen[i][0])

'''
以上グラフの準備
'''

l_seen = {i:False for i in l_chouten}
l_todo = []
dist = {i:-1 for i in l_chouten}

l_d =deque([])  

for point in range(1,N+1):
  
  for key in l_seen:
    l_seen[key] = 0
  l_todo = []  
  for key in dist:
    dist[key] = 0

  
  p = point
  l_seen[p] = True 
  for i in G[p]:
    l_seen[i] = True 
  l_todo = l_todo + G[p] 
  l_todo = deque(l_todo)
  dist[p] = 0
  for i in G[p]:
    dist[i] = 1 
    l_d.append(dist[i])
  

  
  while len(l_todo) != 0:
    
    v = l_todo.popleft() 
    for i in G[v]:
      
      if l_seen[i] == True:
        continue
      else:
        l_seen[i] = True
        l_todo.append(i)
        dist[i]=dist[v]+1
        l_d.append(dist[i])

c = collections.Counter(l_d)
for i in range(1,N):
  print(c[i]//2)

Solution (Python):



def solve(*args: str) -> str:
    n, x, y = map(int, args[0].split())

    ret = [0]*n
    for i in range(1, n):
        for j in range(i+1, n+1):
            ret[min(j-i, 1+abs(x-i)+abs(y-j))] += 1
    return '\n'.join(map(str, ret[1:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):
N, X, Y = list(map(int, input().split(" ")))
min_list = [0 for i in range(0, N)]

for i in range(1, N+1):
    for j in range(i+1, N+1):
        dis_a = j-i
        dis_1 = abs(X-i)
        dis_2 = abs(j-Y)
        dis_b = dis_1+dis_2+1
        if dis_a > dis_b:
            min_list[dis_b] += 1
        else:
            min_list[dis_a] += 1

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

Solution (Python):
import sys
n, x, y = map(int, sys.stdin.readline().split())

x -= 1
y -= 1
    
final = [0]*(n-1)


for i in range(n-1):
    for j in range(i+2, n):
        if j < x or i > y:
            dist = j-i
        else:
            dist = min([j - i, abs(x-i) + 1 + abs(y-j), abs(y-i) + 1 + abs(x-j)])
        final[dist-1] += 1 
final[0] = n
res = [str(one) for one in final]
print ("\n".join(res))

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

def shortest_path(i, j):
    if i <= x <= y <= j:
        return min(j-i, x-i+j-y+1)
    elif x <= i <= y <= j:
        return min(j-i, i-x+j-y+1)
    elif x <= i <= j <= y:
        return min(j-i, i-x+y-j+1)
    elif i <= x <= j <= y:
        return min(j-i, x-i+y-j+1)
    else:
        return j-i


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

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

X -= 1
Y -= 1
distances = [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))
        distances[d] += 1

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

Solution (Python):
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  for j in range(i+1, n):
    l = j+1
    a = l - k
    b = abs(k - x) + abs(l - y) + 1
    if b < a:
      ans[b-1] += 1
    else:
      ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Solution (Python):












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

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

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

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

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

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

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

def min_dis(i,j):
    return min(abs(j-i),min(abs(j-x)+abs(y-i)+1,abs(x-i)+abs(j-y)+1))
discount = [0]*n 

for i in range(1,n+1):
    for j in range(1,n+1):
        if i<j:
            discount[min_dis(i,j)]+=1

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

Solution (Python):
N,X,Y=map(int,input().split())
ans=0
right=X-1
cycle=Y-X+1
left=N-Y
import copy
ring=copy.copy(cycle)
branchr=copy.copy(right)
if right>0:
    branchr+=1
branchl=copy.copy(left)
if left>0:
    branchl+=1
ring_branchr=0
ring_branchl=0
branchrl=0
count=0
if cycle%2==0:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k==cycle//2:
            ring = cycle//2
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2:
                ring_branchr-=2*(k-cycle//2)-1
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2:
                ring_branchl-=2*(k-cycle//2)-1
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
if cycle%2==1:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2+1:
                ring_branchr-=2*(k-cycle//2-1)
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2+1:
                ring_branchl-=2*(k-cycle//2-1)
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

Solution (Python):
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  b_1 = k - x
  for j in range(i+1, n):
    l = j + 1
    a = l - k
    b = abs(k - x) + abs(l - y) + 1
    if b < a:
      ans[b-1] += 1
    else:
      ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

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

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

Solution (Python):

def inputlist(): return [int(j) for j in input().split()]


N,X,Y = inputlist()
graph = [[] for _ in range(N+1)]
for i in range(1,N):
    graph[i].append(i+1)
    graph[i+1].append(i)
graph[X].append(Y)
graph[Y].append(X)
seen = [False]*(N+1)
ans = [0]*(N+1)
def bfs(i):
    from collections import deque
    que = deque()
    que.append([i,0])
    seen[i] = True
    while len(que)!=0:
        li = que.popleft()
        x = li[0]
        count = li[1]
        for j in graph[x]:
            if seen[j]:
                continue
            seen[j] = True
            counta= count + 1
            que.append([j,counta])
            ans[counta]+=1
for i in range(1,N+1):
    seen = [False]*(N+1)
    bfs(i)
for i in range(1,N):
    print(ans[i]//2)

Solution (Python):


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

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

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

Solution (Python):
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  b_1 = k - x
  for j in range(i+1, n):
    l = j + 1
    a = l - k
    b = abs(k - x) + abs(l - y) + 1
    if b < a:
      a = b
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Solution (Python):
import sys

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

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

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

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

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

n, x, y = na()
x -= 1
y -= 1

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

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

Solution (Python):

from collections import Counter
n, x, y = map(int, input().split())
ans=[]
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        k = min(abs(j - i), abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1)
        
        ans.append(k)

ans=Counter(ans)

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

Solution (Python):
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  b_1 = k - x
  if b_1 < 0:
      b_1 = - b_1
  for j in range(i+1, n):
    l = j + 1
    a = l - k
    b_2 = l - y
    if b_2 < 0:
      b_2 = - b_2
    b = b_1 + b_2 + 1
    if b < a:
      a = b
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Solution (Python):
N,X,Y=map(int,input().split())
ans=0
right=X-1
cycle=Y-X+1
left=N-Y
import copy
ring=copy.copy(cycle)
branchr=copy.copy(right)
if right>0:
    branchr+=1
branchl=copy.copy(left)
if left>0:
    branchl+=1
ring_branchr=0
ring_branchl=0
branchrl=0
count=0
if cycle%2==0:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k==cycle//2:
            ring = cycle//2
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2:
                ring_branchr-=2*(k-cycle//2)-1
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2:
                ring_branchl-=2*(k-cycle//2)-1
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
if cycle%2==1:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2+1:
                ring_branchr-=2*(k-cycle//2-1)
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2+1:
                ring_branchl-=2*(k-cycle//2-1)
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

Solution (Python):
from collections import Counter

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

x-=1
y-=1

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

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

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

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

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

ans=defaultdict(int)

for i in range(N):
    dist = [None]*N
    s=i+1
    q=deque()
    q.append(s)
    dist[i]=0

    while len(q)!=0:
        From = q.popleft()
        for To in d[From]:
            if dist[To-1] == None:
                q.append(To)
                dist[To-1] = dist[From-1]+1
    c=Counter(dist)
    for i,m in c.items():
        ans[i]+=m


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

Solution (Python):
from itertools import combinations
N,X,Y = map(int, input().split())
ans = [0]*(N-1)
for a,b in combinations(range(N),2):
  c = min([abs(a-b), abs(X-1-a)+abs(Y-1-b)+1, abs(Y-1-a)+abs(X-1-b)+1])
  ans[c-1] += 1
for i in ans: print(i)

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict, deque

n, x, y = na()
x -= 1
y -= 1
d = defaultdict(int)
g = [[] for _ in range(n)]
for i in range(n - 1):
    g[i].append(i + 1)
    g[i + 1].append(i)
g[x].append(y)
g[y].append(x)

def bfs(i):
    q = deque()
    q.append(i)
    dist = [-1] * n
    dist[i] = 0
    while len(q):
        p = q.popleft()
        for j in g[p]:
            if dist[j] != -1:
                continue
            dist[j] = dist[p] + 1
            q.append(j)

    return dist

dic = defaultdict(int)
for i in range(n):
    d = bfs(i)
    for j in range(n):
        dic[d[j]] += 1

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

Solution (Python):
def main():
    import collections

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

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

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


if __name__ == '__main__':
    main()

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

for i in ans:
    print(i)

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

Solution (Python):
from collections import deque
n,x,y = map(int,input().split())
to = [[] for _ in range(n)]
for i in range(n-1):
    to[i].append(i+1)
    to[i+1].append(i)
x -= 1
y -= 1
to[x].append(y)
to[y].append(x)
ans = [0]*(n-1)
dist = [-1]*n
Q = deque()
for i in range(n):
    Q.clear()
    for j in range(n): dist[j] = -1
    Q.append((i,-1))
    dist[i] = 0
    while Q:
        cur,prev = Q.popleft()
        for nxt in to[cur]:
            if nxt == prev: continue
            if dist[nxt] != -1: continue
            Q.append((nxt,cur))
            dist[nxt] = dist[cur]+1
            ans[dist[cur]] += 1

print("\n".join(map(str,(map(lambda x:x//2,ans)))))

Solution (Python):
from collections import Counter, deque


def bfs(d, s, N):
    dist = [-1]*N
    q = deque()
    q.append(s)
    dist[i] = 0
    while len(q) != 0:
        From = q.popleft()
        for To in d[From]:
            if dist[To-1] == -1:
                q.append(To)
                dist[To-1] = dist[From-1]+1
    return dist


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

ans = [0]*(N+1)

for i in range(N):
    s = i+1
    c = Counter(bfs(d, i+1, N))
    for i, m in c.items():
        ans[i] += m

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

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

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

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

Solution (Python):




import sys
input = sys.stdin.readline



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

    cost = [0 for i in range(N)]

    for i in range(1,N):
        for j in range(i,N+1):
            temp1 = abs(j-i)
            temp2 = abs(X-i) + 1 + abs(j-Y)
            temp3 = abs(Y-i) + 1 + abs(j-X)
            temp = min(temp1,temp2,temp3)
            cost[temp] += 1

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



main()

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

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

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

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

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

Solution (Python):
from heapq import heappop, heappush

def dijkstra(s):
    used = [1] * n
    dp = [INF] * n
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

INF = 10 ** 18
n, x, y = map(int, input().split())
cost = [[] for _ in range(n)]

for i in range(n - 1):
    a = i
    b = i + 1
    cost[a].append([1, b])
    cost[b].append([1, a])
cost[x - 1].append([1, y - 1])
cost[y - 1].append([1, x - 1])
ans = [0] * n
for i in range(n - 1):
    dp1 = dijkstra(i)
    for j in dp1[i:]:
        ans[j] += 1

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

Solution (Python):
import sys

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

d = [[sys.maxsize for _ in range(N)] for _ in range(N)]

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

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

for h in range(N):
  for i in range(h+1, N):
    if h != i:
      answer[d[h][i]-1] += 1

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

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

ans = [0] * N

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

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

for i in ans:
    print(i)

Solution (Python):
n,x,y=map(int, input().split())
es=[[] for _ in range(n)]
for i in range(n):
    if i<n-1:
        es[i].append([1,i+1])
    if i>0:
        es[i].append([1,i-1])
    es[x-1].append([1,y-1])
    es[y-1].append([1,x-1])

import heapq

def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in es[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in es[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

from collections import defaultdict, Counter
from copy import deepcopy
dist=dijkstra_heap(0)
distx=dijkstra_heap(x-1)
disty=dijkstra_heap(y-1)
counts=[]
for i in range(n-1):
    if i<x-1:
        tmp=[d-i for d in dist[i:]]
        counts.append(Counter(tmp))
    elif x-1<=i<y-1:
        tmp=[min(distx[i]+distx[d], disty[i]+disty[d], abs(d-i)) for d in range(i,n)]
        counts.append(Counter(tmp))
    else:
        tmp=[disty[d]-disty[i] for d in range(i,n)]
        counts.append(Counter(tmp))
ans=defaultdict(int)

for i in range(n-1):
    keys=counts[i].keys()
    for kk in keys:
        ans[kk]+=counts[i][kk]

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

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

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

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

Solution (Python):
import numpy as np
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)+1+abs(y-j),abs(y-i)+1+abs(x-j))] += 1

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

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


def main():
    N,x,y = map(int, readline().split())

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

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


if __name__ == "__main__":
    main()

Solution (Python):
import collections
n, x, y = map(int, input().split())
d = [[0]*(i+1) for i in range(n)]
x -= 1
y -= 1
for i in range(n):
    for j in range(i+1):
        d[i][j] = min(i-j, abs(x-j)+abs(y-i)+1)
L = []
for i in range(n):
    for dd in d[i]:
        L.append(dd)
C = collections.Counter(L)
for i in range(1, n):
    print(C[i])