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



Sample input:
5 2 4


Sample output:
5
4
1
0

Submission status: Accepted

Solution code:
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)
		
	#for l in al:
	#	print(l)
			
	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():
		#print(ol.qsize())
		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
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        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])

Submission status: Accepted

Solution code:
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={頂点:[頂点に繋がっている点たち],... } を取得する
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])

'''
以上グラフの準備
'''
#seenとtodoの初期設定
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):
  #seenとtodoの初期設定
  for key in l_seen:
    l_seen[key] = 0
  l_todo = []  
  for key in dist:
    dist[key] = 0

  #seenに出発地点pを決めてやる、出発点の隣接リストもtodoに入れる
  p = point
  l_seen[p] = True #pはチェック済み
  for i in G[p]:
    l_seen[i] = True #pに隣接する頂点もチェック済み
  l_todo = l_todo + G[p] #pに隣接する頂点をtodoリストに追加
  l_todo = deque(l_todo)
  dist[p] = 0
  for i in G[p]:
    dist[i] = 1 #pに隣接する頂点とpとの距離を1とする
    l_d.append(dist[i])
  

  #探索
  while len(l_todo) != 0:
    #幅優先探索
    v = l_todo.popleft() #todoの左端つまりindex0から処理しているので
    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)

Submission status: Accepted

Solution code:
# coding: utf-8


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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# strlist = "abcdefghijklmnopqrstuvwxyz"
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")
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# D
# -*- coding: utf-8 -*-
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Sat Mar 28 11:53:27 UTC 2020
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])

Submission status: Accepted

Solution code:
#D
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)
        # print(i,j,k)
        ans.append(k)
# print(ans)
ans=Counter(ans)
# print(ans)
for i in range(1, n):
    print(ans[i])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Sat Mar 28 11:53:27 UTC 2020
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

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

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

cnt = [0]*N

def bfs(num):
    dq = deque()
    dq.append((num,0))
    visited = [-1]*N
    visited[num] = 0
    while dq:
        a, b = dq.popleft()
        for i in graph[a]:
            if visited[i] == -1:
                visited[i] = b+1
                dq.append((i, b+1))
    return visited

vx = bfs(X-1)
vy = bfs(Y-1)

for i in range(0,N-1):
    for j in range(i+1, N):
        if abs(X-1-i) <= abs(Y-1-i):
            idx = min(j-i, abs(X-1-i) + vx[j])
        else:
            idx = min(j-i, abs(Y-1-i) + vy[j])
        cnt[idx] += 1
    
for i in cnt[1:]:print(i)

Submission status: Accepted

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

ans=[0]*n

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


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

Submission status: Accepted

Solution code:
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):
        d1 = j-i
        d2 = abs(X-i) + 1 + abs(Y-j)
        d = d1 if d1 <= d2 else d2
        ans[d] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, X, Y = map(int, input().split())
dis_comb = [0]*N

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc160/submissions/11310424

def main():
    from itertools import combinations

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

    def dist(a, b, X=X, Y=Y):
        return min(
            abs(a - b),
            abs(a - X) + abs(b - Y) + 1,
            abs(a - Y) + abs(b - X) + 1
        )

    ctr = [0] * N
    for combi in combinations(range(N), r=2):
        ctr[dist(*combi)] += 1

    it = iter(ctr)
    next(it)
    print(*it, sep='\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
N,X,Y = map(int,input().split())

ret = [0]*N
for s,e in list(itertools.combinations(range(1,N+1), 2)):
  d = min(e-s, abs(X-s)+1+abs(Y-e), abs(X-e)+1+abs(Y-s))
  ret[d] += 1

for r in ret[1:]:
  print(r)

Submission status: Accepted

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

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

for _ in range(1, n):
  print(klist[_])

Submission status: Accepted

Solution code:
import numpy as np
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):
    root1 = j-i
    root2 = abs(X-i) + 1 + abs(Y-j)
    min_k = min(root1, root2)
    ans[min_k-1] = ans[min_k-1] + 1

for a in ans:
  print(int(a))

Submission status: Accepted

Solution code:
N, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0] * (N)

for i in range(N-1):
  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)])
    dist[d] += 1

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc160/submissions/11310424

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

    def dist(a, b, X=X, Y=Y):
        return min(
            abs(a - b),
            abs(a - X) + abs(b - Y) + 1,
            abs(a - Y) + abs(b - X) + 1
        )

    ctr = [0] * N
    for b in range(N):
        for a in range(b):
            ctr[dist(a, b)] += 1

    it = iter(ctr)
    next(it)
    print(*it, sep='\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def dist(a, b):
    return min(abs(b-a), abs(X-a) + 1 + abs(b-Y))

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

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

Submission status: Accepted

Solution code:
def resolve():
    n,x,y = map(int, input().split())
    ans = {}
    for i in range(1, n):
        for j in range(i+1, n+1):
            dist1 = j-i
            dist2 = abs(x-i)+1+abs(y-j)
            dist =min (dist1, dist2)
            if dist in ans:
                ans[dist] += 1
            else:
                ans[dist] = 1
    for i in range(1,n):
        if i not in ans:
            ans[i] =0
        print(ans[i])
resolve()

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc160/submissions/11310424

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

    def dist(a, b):
        return min(
            abs(a - b),
            abs(a - X) + abs(b - Y) + 1,
            abs(a - Y) + abs(b - X) + 1
        )

    ctr = [0] * N
    for b in range(N):
        for a in range(b):
            ctr[dist(a, b)] += 1

    it = iter(ctr)
    next(it)
    print(*it, sep='\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

g = [[] for _ in range(n)]

for i in range(n - 1):
    g[i].append(i + 1)
    g[i + 1].append(i)

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

from collections import deque

def bfs(u):
    d = [-1]*n
    d[u] = 0
    queue = deque([u])
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] < 0:
                d[i] = d[v] + 1
                queue.append(i)
    return d

ans = [0] * n

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

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

Submission status: Accepted

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

answer=[0]*(N-1)
#i, j from 1 to N
for i in range(1, N):
    for j in range(i+1, N+1):
        temp=min(abs(j-i), abs(j-Y)+1+abs(X-i)) #, abs(j-X)+1+abs(Y-i)
        #print(i, j, temp)
        answer[temp-1]+=1
for val in answer:
    print(val)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc160/submissions/11310424

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

    def dist(a, b):
        return min(
            abs(a - b),
            abs(a - X) + abs(b - Y) + 1,
            abs(a - Y) + abs(b - X) + 1
        )

    ctr = [0] * N
    for b in range(N):
        for a in range(b):
            d = dist(a, b)
            ctr[d] += 1

    it = iter(ctr)
    next(it)
    print(*it, sep='\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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), abs(Y-i) + 1 + abs(j-X))

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

Submission status: Accepted

Solution code:
import numpy as np
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):
    root1 = j-i
    root2 = abs(X-i) + 1 + abs(Y-j)
    min_k = min(root1, root2)
    ans[min_k-1] = ans[min_k-1] + 1

for a in ans:
  print(a)