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:
from collections import Counter

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

lst = list(range(1,N+1))
d_lst = []
for left in range(0,N-1):
    for right in range(left+1,N):
        dis = min(right - left, abs(X-left) + abs(right-Y) +1)
        d_lst.append(dis)
c = Counter(d_lst)
            
for i in range(1,N):
    if i in c:
        print(c[i])
    else:
        print(0)

Submission status: Accepted

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

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


for i in count:
  print(i)

Submission status: Accepted

Solution code:
n,x,y = list(map(int, input().split()))
lst = [0 for i in range(n)]

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n,x,y=map(int,input().split())
d=defaultdict(lambda:0)
for i in range(1,n):
      for j in range(i+1,n+1):
            l=min(j-i,abs(j-x)+abs(i-y)+1,abs(i-x)+abs(j-y)+1)
            d[l]+=1
for i in range(1,n):
      print(d[i])

Submission status: Accepted

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

cnt = [0] * (n+1)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    answer = [0 for i in range(N+1)]

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    answer = [0 for i in range(N+1)]

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    answer = [0 for i in range(N+1)]

    for i in range(0, N):
        for j in range(i+1, N):
            # A-A, E-E, A-B, D-Eは近道を使えない
            if j <= X or Y <= i:
                answer[j-i] += 1
                continue
            # B-Dは近道使うだけ
            if i == X and j == Y:
                answer [1] += 1
                continue
            # A-Cは近道or直接
            if i < X and j < Y:
                answer[min(j-i, (X-i)+(Y-j)+1)] += 1
                continue
            # C-Eも同様
            if i > X and j > Y:
                answer[min(j-i, (j-Y)+(i-X)+1)] += 1
                continue
            # A-D
            if i < X and j == Y:
                answer[(X-i)+1] += 1
                continue
            # B-E
            if i == X and j > Y:
                answer[(j-Y)+1] += 1
                continue
            # B-C
            if i == X and j < Y:
                answer[min(j-i, 1+(Y-j))] += 1
                continue
            # C-D
            if i > X and j == Y:
                answer[min(j-i, 1+(i-X))] += 1
                continue
            # A-E
            if i < X and j > Y:
                answer[(X-i)+(j-Y)+1] += 1
                continue
            if i > X and j < Y:
                answer[min(j-i, (i-X)+(Y-j)+1)] += 1
                continue
            raise ValueError("error")

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, x, y = map(int, input().split())
k = [0]*n
for i in range(1, n):
    for j in range(i+1, n+1):
        if j <= x or i >= y:
            l = j - i
        elif i <= x and j >= y:
            l = (j-y) + (x-i) + 1
        elif i <= x and j >= x and j <= y:
            l = min(j-i, (x-i)+(y-j)+1)
        elif i >= x and i <= y and j >= y:
            l = min(j-i, (i-x)+(j-y)+1)
        elif i <= y and j >= x:
            l = min(j-i, (i-x)+(y-j)+1)
        k[l] += 1
for i in range(1, n):
    print(k[i])

Submission status: Accepted

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

ans = [0]*N

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in count:
    print(i)

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n, x, y = MI()

    def dist(a, b):
        return b - a

    ans = [0 for _ in range(n-1)]
    for i in range(1, n):
        for j in range(i+1, n+1):
            if i <= x and y <= j:
                d = dist(i, x) + 1 + dist(y, j)
            elif x < i < y:
                if x < j < y:
                    d = min(dist(i, j), dist(x, i) + 1 + dist(j, y))
                else:
                    d = min(dist(x, i)+1, dist(i, y)) + dist(y, j)
            elif x < j < y:
                d = min(dist(i, j), dist(i, x) + 1 + dist(j, y))
            else:
                d = dist(i, j)
            # print(i, j, d)
            ans[d-1] += 1
    print("\n".join(map(str, ans)))



if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

import collections
u2 = collections.Counter(u)
u2 = list(u2.items())
for k in range(n):
    u2.append((0,0))

for i in range(n-1):
    if u2[i][0] == i+1:
        print(u2[i][1])
    else:
        print(0)

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
b=[0 for i in range(N+1)]
#print(b)
for i in range(1,N):
    for j in range(i+1,N+1):
        #print('{},{}'.format(i,j))
        minmin=min([abs(j-i),abs(X-i)+1+abs(Y-j)])
        #print(minmin)
        b[minmin]=1+b[minmin]

for i in range(1,N):

    print(b[i])

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

Submission status: Accepted

Solution code:
N,X,Y=map(int, input().split())
dislist = [0]*N
midXY = (X+Y)//2
def caldis(i,l):
    return min((l-i),(abs(X-i)+1+abs(Y-l)))
for i in range(1,N):
    for l in range(i+1,N+1):
        dislist[caldis(i,l)] += 1
for i in dislist[1:]:
    print(i)

Submission status: Accepted

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

k = defaultdict(lambda: 0)

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

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

Submission status: Accepted

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

count = [0]*n

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

# print(count)

[print(k) for k in count[1:]]

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc160/tasks/abc160_d

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

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

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

from heapq import heappop, heappush
def dijkstra_with_heap(graph, start, v):
    # graphは隣接リスト形式（有向・無向は問わない）
    # graphは、(cost, vertex)の順で格納すること
    # startは出発点。有向グラフの場合は到達しない点はinf
    # vは全部の頂点数
    distance = [float('infinity')] * v
    distance[start] = 0
    stack = [[0, start]] # cost, vertex
    while stack:
        _, vertex = heappop(stack)
        edges = graph[vertex]
        for d, t in edges:
            if d + distance[vertex] < distance[t]:
                distance[t] = d + distance[vertex]
                heappush(stack, (d, t))
    return distance

ans = [0] * n
for i in range(n):
    d = dijkstra_with_heap(graph, i, n)
    for j in range(i, n):
        ans[d[j]] += 1
for a in ans[1:]: # 先頭はk=0なので、除外する
    print(a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 27 21:23:16 2020
"""

import sys
from collections import deque
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

X -= 1
Y -= 1
ans = [0 for i in range(N)]

for i in range(N):
    q = deque([i])
    counta = 0
    visited = [False for i in range(N)]
    visited[i] = True
    while len(q) > 0:
        buf = []
        for j in range(len(q)):
            a = q.popleft()
            b1, b2 = a+1, a-1
            if b1 >= 0 and b1 < N and not visited[b1]:
                q.append(b1)
                ans[counta] += 1
                visited[b1] = True
            if b2 >= 0 and b2 < N and not visited[b2]:
                q.append(b2)
                ans[counta] += 1
                visited[b2] = True
            if a == X:
                b3 = Y
            elif a == Y:
                b3 = X
            else:
                b3 = i
            if b3 >= 0 and b3 < N and not visited[b3]:
                q.append(b3)
                ans[counta] += 1
                visited[b3] = True
        counta += 1
#        print(i,q,a,b1,b2)
#    print(ans)

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

Submission status: Accepted

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

ans = [0]*(N+1)

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

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

Submission status: Accepted

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

from collections import deque

N,X,Y=MI()
l = []
for i in range(N):
    if i!=0 and i!=N-1:
        n = [i-1,i+1]
    elif i==0:
        n = [1]
    else:
        n = [N-2]
    if i==X-1:
        n += [Y-1]
    if i==Y-1:
        n += [X-1]
    l.append(n)
ans = [0]*(N-1)
for i in range(N):
    dist = [-1]*N
    q=deque()
    q.append(i)
    dist[i]=0
    while q:
        u = q.popleft()
        for next in l[u]:
            if dist[next]==-1:
                dist[next]=dist[u]+1
                ans[dist[u]] += 1
                q.append(next)

[print(x//2) for x in ans]

Submission status: Accepted

Solution code:
from collections import deque

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

to = [[] * N for i in range(N)]

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

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

ans = [0] * N

for i in range(N):
    dis = [0] * N
    dis[i] = 0
    visited = [False] * N
    q = deque([])
    q.append(i)
    visited[i] = True

    while len(q) != 0:
        tmp_v = q.popleft()
        for j in to[tmp_v]:
            if not visited[j]:
                dis[j] = dis[tmp_v] + 1
                visited[j] = True
                q.append(j)

    for j in range(N):
        ans[dis[j]] += 1

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

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

Submission status: Accepted

Solution code:
n,x,y=map(int,input().split())
dis=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    d=j-i
    if d>abs(j-x)+1+abs(i-y):
      d=abs(j-x)+1+abs(i-y)
    if d>abs(j-y)+1+abs(i-x):
      d=abs(j-y)+1+abs(i-x)
    dis[d-1]+=1
for i in dis:
  print(i)

Submission status: Accepted

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

ans=[0]*(n+1)



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

Submission status: Accepted

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

ans=[0]*(n+1)



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

Submission status: Accepted

Solution code:

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

  ans = [0] * (n - 1)

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

  for a in ans:
    print(a)


main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for i in range(1, N):
    for j in range(i + 1, N + 1):
        cand = []
        cand.append(j - i)
        cand.append(abs(i - X) + 1 + abs(j - Y))
        ans[min(cand) - 1] += 1
        
[print(a) for a in ans]

Submission status: Accepted

Solution code:
import math
n,x,y=map(int,input().split())
pairs=[]
for i in range(0,n-1):
    pairs.append(0)
for i in range(1,n):
    for j in range(i+1,n+1):
        if j<=x or i>=y:
            pairs[j-i-1]+=1
        elif i<=x and j>=y:
            pairs[j-i-y+x]+=1
        else:
            if j-i>(abs(y-j)+abs(x-i)+1):
                pairs[abs(y-j)+abs(x-i)]+=1
            else:
                pairs[j-i-1]+=1
for pair in pairs:
    print(pair)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import sys
# import numpy as np

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


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

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

            ans = min(dist1, dist2)
            ans_list[ans] += 1

    for n in ans_list[1:]:
        print(n)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n,x,y = map(int,input().split())
    dst = {}
    for i in range(1,n):
        dst[i]=0
    for i in range(1,n):
        for j in range(i+1,n+1):
            d = min(j-i,abs(x-i)+1+abs(y-j))
            dst[d]+=1
    for i in range(1,n):
        print(dst[i])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,X,Y = inputIL()



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

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

Submission status: Accepted

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

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

ans = list(map(str, ans))

print("\n".join(ans))

Submission status: Accepted

Solution code:
def main():
    N, X, Y = map(int, input().split())
    tree = [[float('inf')] * N for _ in range(N)]
    ans = [0] * (N + 1)
    X -= 1
    Y -= 1
    for i in range(N):
        for j in range(i,N):
            dist = min(j - i, abs(X - i) + 1 + abs(Y - j))
            ans[dist] += 1

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
ls=[0 for i in range(N-1)]
for i in range(0,N-1):
  for j in range(i+1,N):
    a=min([j-i,abs(i-(X-1))+1+abs(j-(Y-1))])
    ls[a-1]+=1
for i in range(len(ls)):
  print(ls[i])

Submission status: Accepted

Solution code:
N, X, Y = map(int,input().split())
a = [0 for _ in range(N - 1)]

for lt in range(1, N+1):
    for rt in range(lt+1, N+1):
        a[min(rt-lt-1, abs(X-lt) + abs(Y-rt))] += 1

print(*a, sep="\n")

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

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

Submission status: Accepted

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

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

iX = X - 1
iY = Y - 1
G[iX].append([iY, 1])
G[iY].append([iX, 1])

d = {}
for i in range(N):
  d[i] = 0

for i in range(N):
  to_see_queue = deque()
  to_see_queue.append(i)
  costs = [-1] * N
  costs[i] = 0

  while to_see_queue:
    cur = to_see_queue.popleft()
    for node_next, cost_nn in G[cur]:
      if costs[node_next] == -1:
        costs[node_next] = costs[cur] + cost_nn
        to_see_queue.append(node_next)
  
  for nn in range(i + 1, N): 
    d[costs[nn]] += 1

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

Submission status: Accepted

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

d = {}
for i in range(1, N):
    for j in range(i+1, N+1):
        mi_n = min(abs(j-i), abs(X-i)+1+abs(j-Y))
        if mi_n not in d:
            d[mi_n] = 1
        else:
            d[mi_n] += 1

for idx in range(1, N):
    if idx not in d:
        print('0')
    else:
        print(d[idx])

Submission status: Accepted

Solution code:

N,X,Y=map(int,input().split())
b=[0]*(N)
for i in range(N):
  for j in range(i+1,N):
    p=max(X-1-i,1+i-X)
    q=max(Y-1-j,1+j-Y)
    b[min(j-i,p+1+q)]+=1
for i in range(1,N):
  print(b[i])

Submission status: Accepted

Solution code:
N,X,Y = map(int,input().split())
Alist = [[0 for i in range(N)] for j in range(N)]
p = [0 for i in range(N)]
for i in range(N):
    for j in range(i,N):
        k = min(j-i,abs(X-1-i)+abs(Y-1-j)+1)
        p[k] = p[k] + 1        
for s in range(1,N):
    print(p[s])

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

Submission status: Accepted

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

res_dict = {}
for i in range(1, n+1):
    for j in range(i+1, n+1):
        tmp = min(j-i, abs(x-i)+abs(y-j)+1)
        if not tmp in res_dict.keys():
            res_dict[tmp] = 1
        else:
            res_dict[tmp] += 1

for i in range(1, n):
    if i in res_dict.keys():
        print(res_dict[i])
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,X,Y = map(int,input().split())
A = [0 for i in range(N)]
for i in range(N-1):
    a = i+1
    for j in range(i+1,N):
        b = j+1
        A[min([b-a,abs(X-a)+abs(Y-b)+1])] += 1
for i in range(1,N):
    print(A[i])

Submission status: Accepted

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

a = [0]*N 

for i in range(1,N+1):
    for j in range(i+1,N+1):
        if (i <= X) and (j >= Y):
                a[(j - i) - (Y - X) + 1 ] += 1
        else:
            if (j - i ) > (abs(X - i) + abs(Y - j) + 1):
                a[abs(X - i) + abs(Y - j) + 1] +=  1
            else:
                a[j - i] += 1
for i in range(1,len(a)):
    print(a[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

lenList = [0 for x in range(N)]
for start in range(1,N):
    for end in range(start+1,N+1):
        len = end - start
        if start <= X:
            if end <= X:
                lenList[len] += 1
            elif end < Y:
                len = min(len,((X-start) + 1 + (Y-end)))
                lenList[len] += 1
            else:
                len = (X-start) + 1 + (end-Y)
                lenList[len] += 1
        elif start < Y:
            if end < Y:
                len = min(len,(start-X) + 1 + (Y-end))
                lenList[len] += 1
            else:
                len = min(len,(start-X) + 1 + (end-Y))
                lenList[len] += 1
        else:
            lenList[len] += 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,x,y = na()
ans = [0]*(n-1)

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

print(*ans, sep='\n')

Submission status: Accepted

Solution code:
N,X,Y = map(int,input().split(sep=" "))
root = []
X = X-1
Y = Y-1
sumRoot = [0 for i in range(0,N-1,1)]
for i in range(0,N,1):
    for j in range(i+1,N,1):
        if j - i < abs(i-X)+abs(j-Y)+1:
            sumRoot[j-i-1] += 1
        else:
            sumRoot[abs(i-X)+abs(j-Y)] += 1
for k in range(0,N-1,1):
    print(sumRoot[k])

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
A=[0]*(N+1)
for i in range(1,N):
  for j in range(i+1,N+1):
    m=min(j-i,abs(Y-j)+abs(X-i)+1)
    A[m]+=1
for k in range(1,N):
  print(A[k])

Submission status: Accepted

Solution code:
def solve(n, x, y):
    ans = [0] * n
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            d = min(j-i, abs(y-j) + abs(x-i) + 1)
            ans[d] += 1
    return "\n".join(map(str, ans[1:]))

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

Submission status: Accepted

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

ans = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i + 1, n):
        k = min(abs(x - i - 1) + abs(y - j - 1) + 1, j - i)
        ans[k - 1] += 1
print(*ans,sep= '\n')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17

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

Submission status: Accepted

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

dis = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i + 1, n):
        d = min(abs(x - i - 1) + abs(y - j - 1) + 1, j - i)
        dis[d - 1] += 1
print(*dis, sep = '\n')