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:
N, X, Y = map(int,input().split())

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

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

from scipy.sparse.csgraph import shortest_path

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

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

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

Submission status: Accepted

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


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

#print(count)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    n, x, y = map(int, input().split())
    cnt = [0]*n
    q = deque()
    
    for i in range(n):
        q.appendleft(i)
        dist = [None]*n
        dist[i] = 0
        while q:
            j = q.pop()
            d = dist[j]
            cnt[d] += 1
            if j > 0 and dist[j-1] is None:
                dist[j-1] = d+1
                q.appendleft(j-1)
            if j < n-1 and dist[j+1] is None:
                dist[j+1] = d+1
                q.appendleft(j+1)
            if j == x-1 and dist[y-1] is None:
                dist[y-1] = d+1
                q.appendleft(y-1)
            elif j == y-1 and dist[x-1] is None:
                dist[x-1] = d+1
                q.appendleft(x-1)
    for i in range(1, n):
        print(cnt[i]//2)
                

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = [0] * (n-1)

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

Submission status: Accepted

Solution code:
N,X,Y = map(int, input().split())
count = [0]*(N-1)
c=0
for i in range(0,N):
    for j in range(i+1,N):
        if abs(i-j) >= abs(X-i-1)+1+abs(Y-j-1):
            count[abs(X-i-1)+1+abs(Y-j-1)-1] +=1
        else:
            count[abs(i-j)-1] += 1
for i in range(N-1):
    print(count[i])

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, x, y = list(map(int, readline().split()))
    tmd = collections.defaultdict(list)
    tmd[x-1] += [y-1]
    tmd[y-1] += [x-1]
    for i in range(n):
        if i == 0:
            tmd[i] += [i + 1]
        elif i == n - 1:
            tmd[i] += [i - 1]
        else:
            tmd[i] += [i + 1]
            tmd[i] += [i - 1]

    res = [0] * (n - 1)
    for i in range(n):
        ql = [[0, i]]
        ql = collections.deque(ql)
        fq = collections.defaultdict(list)
        fq[i]
        while len(ql):
            cost, tmp = ql.popleft()
            for tmv in tmd[tmp]:
                if tmv not in fq:
                    ql.append([cost + 1, tmv])
                    fq[tmv]
                    res[cost] += 1
    for i in range(len(res)):
        res[i] //= 2
    print(*res, sep="\n")


if __name__ == '__main__':
    solve()

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):
        if j <= x or y <= i:
            dist = j - i
        else:
            dist = j - i
            short = abs(x - i) + 1 + abs(y - j)
            dist = min(dist, short)
        ans[dist-1] += 1

for k in ans:
    print(k)

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
Ans=[0 for i in range(1,N)]
X-=1;Y-=1
for i in range(N-1):
  for j in range(i+1,N):
    if i<=X:
      if j<=X:
        d=j-i
      elif X<j<Y:
        d=min(j-i,X-i+1+Y-j)
      else:
        d=X-i+1+j-Y
    elif X<i<Y:
      if X<j<Y:
        d=min(j-i,i-X+1+Y-j)
      else:
        d=min(j-i,i-X+1+j-Y)
    else:
      d=j-i
    #print(i,j,d)
    Ans[d-1]+=1
for a in Ans:
  print(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = [0]*(n)
tmp = 10000000000000000
for i in range(n-1):
    for j in range(i+1,n):
        if i == j:continue
        tmp = min((j-i),abs(j-y)+abs(i-x)+1)
 #       print(tmp)
        ans[tmp] +=1



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

Submission status: Accepted

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

Submission status: Accepted

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

from collections import defaultdict, deque

d = defaultdict(int)
INF = 10 ** 9
def bfs(n):
    reached = [INF for _ in range(N)]
    reached[n] = 0
    q = deque()
    q.append(n)
    while q:
        x = q.popleft()
        for i in [-1, 1]:
            nx = x + i
            if nx < 0 or nx > N-1 or reached[nx] != INF:
                continue
            reached[nx] = reached[x] + 1
            q.append(nx)
        if x == X and reached[Y] == INF:
            reached[Y] = reached[x] + 1
            q.append(Y)
        if x == Y and reached[X] == INF:
            reached[X] = reached[x] + 1
            q.append(X)
    for i in range(N):
        k = reached[i]
        d[k] += 1

for i in range(N):
    bfs(i)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A=[]
for _ in range(N-1):
    A.append(0)  

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

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
N,X,Y = a[0],a[1],a[2]
dic={}
for i in range(1,N):
  for j in range(i+1,N+1):
    dis = min (abs(j-i),abs(X-i)+abs(Y-j)+1)
    if dis not in dic:
      dic[dis]=1
    else:
      dic[dis]+=1

for i in range(1,N):
  if i in dic:
    print(dic[i])
  else:
    print(0)

Submission status: Accepted

Solution code:
import itertools as iters

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

A = [0 for i in range(N)]
for i,j in iters.combinations(range(1,N+1),2):
    D = ( j-i , abs(i-X) + 1 + abs (j-Y))
    #print(i,j,min(D))
    A[min(D)] += 1

print(*A[1:], sep='\n')

Submission status: Accepted

Solution code:
#D

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

  cnt = {i:0 for i in range(1,N)}

  for s in range(1, N+1):
    for e in range(s+1, N+1):
      if s<X and e<X:
        d = e-s
      elif s<X and X<=e<Y:
        d = min(e-s, (X-s)+1+(Y-e))
      elif s<X and Y<=e:
        d = (X-s)+1+(e-Y)
      elif X<=s<Y and X<=e<Y:
        d = min(e-s, (s-X)+1+(Y-e))
      elif X<=s<Y and Y<=e:
        d = min(e-s, (s-X)+1+(e-Y))
      else:
        d = e-s

      cnt[d]+=1

  for c in cnt.values():
    print(c)
main()

Submission status: Accepted

Solution code:
n,x,y=map(int,input().split())
x-=1
y-=1
cnt=[0]*n
for i in range(n):
  for j in range(i+1,n):
    dist=min(j-i,abs(j-x)+1+abs(i-y),abs(j-y)+1+abs(i-x))
    cnt[dist]+=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
Ans={}
for i in range(n-1):
      for j in range(i+1,n):
            d=j-i
            dd=abs(x-i)+abs(y-j)+1
            dist=min(d,dd)
            if dist in Ans:
                  Ans[dist]+=1
            else:
                  Ans[dist]=1

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

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    n,x,y=map(int,input().split())
    Dist=[]
    for i in range(1,n+1):
        A=np.arange(1,n+1)
        D1=np.abs(A-i)
        D2=np.abs(i-x)+np.abs(y-A)+1
        D3=np.abs(i-y)+np.abs(x-A)+1
        D=np.minimum(np.minimum(D1,D2),D3)
        Dist.append(D)
    Dist=np.concatenate(Dist)
    Cnt=np.bincount(Dist,minlength=n)
    print('\n'.join((Cnt[1:]//2).astype(str)))

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, x, y = map(int,input().split())
    res_l = [0 for _ in range(n - 1)]
    for j in range(1, n + 1):
        for i in range(1, j):
            route_1 = j - i
            if i < y:
                route_2 = abs(i - x) + 1 + abs(j - y)
                route = min(route_1,route_2)
            else:
                route = route_1
            res_l[route - 1] += 1
    for res in res_l:
        print(res)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,x,y=n1()

a=[0]*n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if i<=x and j<=x:
            a[j-i]+=1
        elif i<=x and x<j<y:
            a[min(j-i,y-j+1+x-i)]+=1
        elif i<=x:
            a[j-y+1+x-i]+=1
        elif i<=y and j<=y:
            a[min(j-i,y-j+1+i-x)]+=1
        elif i<=y:
            a[min(j-i,j-y+1+i-x)]+=1
        else:
            a[j-i]+=1
for k in range(1,n):
    print(a[k])

Submission status: Accepted

Solution code:
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
D = {}
for i in range(N - 1):
    for j in range(i + 1, N):
        dist = min(j - i, abs(i - X) + 1 + abs(j - Y))
        if dist not in D:
            D[dist] = 1
        else:
            D[dist] += 1
for i in range(1, N):
    if i in D:
        print(D[i])
    else:
        print(0)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for i in count:
    print(i)

Submission status: Accepted

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

# L[距離]　組の数を格納する
L = [0 for _ in range(N)]

# i,j の間の最短距離 d 
for i in range(1,N):
    for j in range(i+1,N+1):
        d = min( abs(j-i), abs(X-j) + 1 + abs(Y-i), abs(Y-j) + 1 + abs(X-i))
        L[d] += 1

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

[print(v) for v in ans]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
node_num, l_connected_node, g_connected_node = [int(n) for n in input().rstrip().split()]

l_connected_node-=1
g_connected_node-=1

count=[0]*node_num

for i in range(node_num-1):
    for j in range(i+1, node_num):
        count[min(j-i, abs(i-l_connected_node)+abs(j-g_connected_node)+1)]+=1

for x in range(1, node_num):
    print(count[x])

Submission status: Accepted

Solution code:
node_num, l_connected_node, g_connected_node = [int(n) for n in input().rstrip().split()]

l_connected_node-=1
g_connected_node-=1

count=[0]*node_num

for i in range(node_num-1):
    for j in range(i+1, node_num):
        count[min(j-i, abs(i-l_connected_node)+abs(j-g_connected_node)+1)]+=1

for x in range(1, node_num):
    print(count[x])

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

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

Submission status: Accepted

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

Submission status: Accepted

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

from collections import deque
for i in range(1, n+1):
    dist = [10**5] * (n+1)
    q = deque([i])
    dist[i] = 0
    while q:
        now = q.popleft()
        for next in g[now]:
            if dist[next] == 10**5:
                dist[next] = dist[now] + 1
                q.append(next)
    for j in range(i+1, n+1):
        ans[dist[j]] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, X, Y = map(int, input().split())
d = {k: 0 for k in range(1, N)}
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        m = min(abs(j - i),
                abs(X - i) + 1 + abs(j - Y),
                abs(Y - i) + 1 + abs(j - X),)
        d[m] += 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+1):
	q = [i]
	flg = [-1] * (N+1)
	flg[i] = 0
	while q:
		cp = q.pop(0)
		for d in [-1,1]:
			if 1 <= cp+d <= N:
				if flg[cp+d] == -1:
					flg[cp+d] = flg[cp]+1
					ans[flg[cp+d]] += 1
					q.append(cp+d)
		if cp == X:
			if flg[Y] == -1:
				flg[Y] = flg[cp]+1
				ans[flg[Y]] += 1
				q.append(Y)
		if cp == Y:
			if flg[X] == -1:
				flg[X] = flg[cp]+1
				ans[flg[X]] += 1
				q.append(X)

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

Submission status: Accepted

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

dist = [N-i-1 for i in range(N-1)]

for a in range(X+int((Y-X)/2)+2) :
  temp = [0 for i in range(a)]
  for b in range(a+1, N) :
    d = abs(a+1-X)+abs(b+1-Y)+1
    if((b-a) > d) :
      dist[b-a-1] -= 1
      dist[d-1] += 1
  
for k in range(len(dist)) :
  print(dist[k])

Submission status: Accepted

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

s = [0]*(n)

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

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
array = list(map(int, input().split()))
miniDis = [0]*(array[0] -1)
for i in range(1,array[0]):
  for j in range(i+1,array[0]+1):
    miniDis[min(j-i,abs(array[1]-i)+1+abs(array[2]-j))-1] += 1
    
                   
                   
                   
                   
for i in range(array[0] -1):
  print(miniDis[i])

Submission status: Accepted

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

ans = [0] * (n - 1)

dist = 0

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

N, X, Y = list(map(int, input().split()))
dists = [
        min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))
        for i in range(N-1) for j in range(i+1, N)
    ]
c = collections.Counter(dists)
ans = [c[K] for K in range(1,N)]
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
from collections import deque

def bfs(queue, visited):
    while len(queue) > 0:
        dest = queue.popleft()
        for i in G[dest]:
            if visited[i] == -1:
                visited[i] = visited[dest] + 1
                queue.append(i)
    return visited


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

G = {}
G[0]=[1]

for i in range(n-1):
    G[i+1] = [i]
    if i==0:
        continue
    G[i].append(i+1)
G[x-1].append(y-1)
G[y-1].append(x-1)

dis_table=[]
for i in range(n):
    visited = [-1]*n
    queue = deque()
    visited[i]=0
    queue.appendleft(i)
    dis_table.append(bfs(queue, visited))

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

for i in ans :
    print(i)

Submission status: Accepted

Solution code:
import collections

N, X, Y = list(map(int, input().split()))
dists = [
        min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))
        for i in range(N-1) for j in range(i+1, N)
    ]
c = collections.Counter(dists)
for K in range(1,N):
    print(c[K])

Submission status: Accepted

Solution code:
import collections

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
c = collections.Counter(dists)
for K in range(1,N):
    print(c[K])

Submission status: Accepted

Solution code:
import collections

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
c = collections.Counter(dists)
keys = c.keys()
for K in range(1,N):
    if K in keys:
        print(c[K])
    else:
        print(0)

Submission status: Accepted

Solution code:
def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
dist_dic = { i: 0 for i in range(1,N)}
for dist in dists:
    dist_dic[dist] += 1
for K in range(1,N):
    print(dist_dic[K])

Submission status: Accepted

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

ans = [0] * (n - 1)

dist = 0

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def f(i, j):
    a = abs(j - i)
    b = abs(Y - j) + 1 + abs(X - i)
    c = abs(j - X) + 1 + abs(Y - i)

    d = min(a, b, c)
    return d

D = [0] * N
for j in range(2, N + 1):
    for i in range(1, j):
        d = f(i, j)
        D[d - 1] += 1

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

Submission status: Accepted

Solution code:
N,X,Y = map(int, input().split())
answer= [0]*(N-1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i==j:
            break
        ans=i-j
        if j<=X and i<=Y and i>=X and Y-i+1+X-j<ans:
            ans=Y-i+1+X-j
        if j<=X and i>=Y and i-Y+1+X-j<ans:
            ans=i-Y+1+X-j
        if j>=X and j<=Y and i>=Y and i-Y+1+j-X<ans:
            ans=i-Y+1+j-X
        if j>=X and j<=Y and i>=X and i<=Y and Y-i+1+j-X<ans:
            ans=Y-i+1+j-X
        answer[ans-1]=answer[ans-1]+1
for k in range (1,N):
    print(answer[k-1])

Submission status: Accepted

Solution code:
def dist(a, b):
    return min(
        abs(a - b),
        abs(a - x) + 1 + abs(y - b),
        abs(a - y) + 1 + abs(x - b)
    )


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

d = [0] * n

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

it = iter(d)
next(it)

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

Submission status: Accepted

Solution code:
from collections import Counter, deque, defaultdict


def main():
    n, x, y = map(int, input().split())
    v = defaultdict(list)
    for i in range(n):
        if i + 1 < n: v[i].append(i + 1)
        if i - 1 >= 0: v[i].append(i - 1)
    v[x - 1].append(y - 1)
    v[y - 1].append(x - 1)

    cnt = Counter()
    for start in range(n):
        dist = [-1] * n
        q = deque()
        q.append([start, 0])
        while q:
            c, d = q.popleft()
            for next in v[c]:
                if dist[next] == -1:
                    q.append([next, d + 1])
                    dist[next] = d + 1
        cnt += Counter(dist[start + 1:])

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
n,x,y = map(int,input().split())
G = [[] for _ in range(n+1)]
for i in range(1, n):
    G[i].append(i+1)
    G[i+1].append(i)
G[x].append(y)
G[y].append(x)

cost = [0]*(n+1)
for i in range(1, n+1):
    visited = [-1]*(n+1)
    que = deque([(i, 0)])
    while que:
        idx, cst = que.popleft()
        if visited[idx]!=-1:
            continue
        visited[idx] = cst
        for to in G[idx]:
            que.append((to, cst+1))
    for j in range(i, n+1):
        cost[visited[j]] += 1
for c in cost[1:-1]:
    print(c)

Submission status: Accepted

Solution code:
n,x,y = map(int, input().split())
cnt = [0]*n
for i in range(1,n):
    for k in range(i+1, n+1):
        if abs(i-x) + abs(k-y) < k-i:
            cnt[abs(i-x)+ abs(k-y)+1] += 1
        else:
            cnt[k-i] += 1
for l in range(1,n):
    print(cnt[l])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import collections

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

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


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

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

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

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


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

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

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

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


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

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

Submission status: Accepted

Solution code:

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

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

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

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

Submission status: Accepted

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

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