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

ans = [0]*n

x = x-1
y = y-1

def search(i, j):
    if j <= x or y <= i:
        ans[j-i] += 1
    elif i <= x and x <= j and j <= y:
        d = min(j-i, x-i+y-j+1)
        ans[d] += 1
    elif x <= i and j <= y:
        d = min(j-i, i-x+y-j+1)
        ans[d] += 1
    elif x <= i and i <= y and y <= j:
        d = min(j-i, i-x+j-y+1)
        ans[d] += 1
    elif i <= x and y <= j:
        ans[x-i+j-y+1] += 1
    
    
for i in range(0, n-1, 1):
    for j in range(i+1, n, 1):
        search(i,j)
        
for i in range(1,n):
    print(ans[i])

Submission status: Accepted

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


def solve(N: int, X: int, Y: int):
    distances = [0] * (N - 1)
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            distance = min(j - i, abs(X - 1 - i) + abs(Y - 1 - j) + 1)
            distances[distance - 1] += 1

    for k in distances:
        print(k)
    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:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,x,y = [int(i) for i in readline().split()]

ans = [0] * n

for a in range(1, n+1):
    for b in range(a+1, n+1):
        d = b - a
        d2 = abs(x-a) + abs(y-b) + 1
        d = d if d < d2 else d2
        ans[d] += 1

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

Submission status: Accepted

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


def solve(N: int, X: int, Y: int):
    distances = [0] * (N - 1)
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            if j < X - 1 or Y - 1 < i:
                distance = j - i
            else:
                distance = min(j - i, abs(X - 1 - i) + abs(Y - 1 - j) + 1)
            distances[distance - 1] += 1

    for k in distances:
        print(k)

            
    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:
n, x, y = map(int, input().split())
l = [0]*(n-1)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        num = min(abs(i-j), abs(i-x) + abs(j-y) + 1)
        l[num-1] += 1
for i in l:
    print(i)

Submission status: Accepted

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

for i in range(n):
    for j in range(i + 1, n):
        if j <= (x + y - 1) // 2 or (x + y - 2) // 2 <= i or j - i <= (y - x) // 2:
            ans[j - i] += 1
        else:
            ans[abs(i - x + 1) + abs(j - y + 1) + 1] += 1

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

Submission status: Accepted

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

kdic={}
for a in range(1,n):
    kdic[a]=0
for i in range(1,n+1):
    for j in range(i+1,n+1):
        tmp=min(j-i,abs(j-x)+abs(y-i)+1,abs(j-y)+abs(i-x)+1)
        kdic[tmp]=kdic[tmp]+1

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

Submission status: Accepted

Solution code:
from collections import Counter
def min_distance(i,j):
    return min(abs(i-j),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))
               
n,x,y=list(map(int,input().split()))
x=x-1
y=y-1
dp=[]
for i in range(n-1):
    for j in range(i+1,n):
        dp.append(min_distance(i,j))
dic=Counter(dp)
for i in range(1,n):
    print(int(dic[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):
        dis = min(j-i, abs(j-x)+1+abs(y-i), abs(j-y)+1+abs(x-i))
        ans[dis-1] += 1
for i in range(n-1):
    print(ans[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):
    dis = min(j - i, abs(i - x) + abs(j - y) + 1)
    ans[dis-1] += 1
    
for i in range(n-1):
  print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N, X, Y = list(map(int, input().split(' ')))
    # d(i, j) is the minimum of ...
    # * j - i                 (not use the edge X-Y)
    # * |i - X| + 1 + |j - Y| (use the edge X-Y)
    counter = defaultdict(int)
    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)])
            counter[k] += 1
    for k in range(1, N):
        print(counter[k])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
import sys
sys.setrecursionlimit(10**9)

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

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


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

    # print(ans)

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
# D - Line++

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

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

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

Submission status: Accepted

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

def main():
    N, X, Y = map(int, input().split())
    dic = {key: 0 for key in range(1, N)}
    for i in range(1, N+1):
        for j in range(1, N+1):
            if(i < j):
                key = min(abs(j - i), abs(X - i)+1+abs(j - Y),
                      abs(Y - i) + 1 + abs(j - X))
                dic[key] += 1
    for ans in dic.values():
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

for i in k:
    print(i)

Submission status: Accepted

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

D=[0]*(N-1)

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

Submission status: Accepted

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

D=[0]*(N-1)

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

mod=10**4
def dk(edge,vis):
    q=[vis]
    visited=[False]*N
    heapify(q)
    while len(q):
        e=heappop(q)
        cd,ce=e//mod, e%mod
        
        if visited[ce]:
            continue
        #print(cd,ce)
        visited[ce]=True
        if ce>vis:
            ans[cd]+=1
        for ne in edge[ce]:
            heappush(q,(cd+1)*mod+ne)



N, X, Y = map(int,input().split()) #n:頂点数　w:辺の数
ans=[0]*(N)
edge = [[] for i in range(N)]
    #edge[i] : iから出る道の[重み,行先]の配列
for i in range(N-1):
    x,y=i,i+1
    edge[x].append(y)
    edge[y].append(x)
edge[X-1].append(Y-1)
edge[Y-1].append(X-1)

for vis in range(N-1):
    dk(edge,vis)
    #print(ans)
for a in ans[1:]:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
ans=[0 for i in range(1,N)]
 
for i in range(1,N):
    for j in range(i+1,N+1):
        k=min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(Y-i)+1+abs(X-j))
        ans[k-1]+=1
 
for i in ans:
    print(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):
        cnt[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(cnt[i])

Submission status: Accepted

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

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

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import os
import sys

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph._shortest_path import dijkstra

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, X, Y = list(map(int, sys.stdin.buffer.readline().split()))

V = [X - 1]
U = [Y - 1]
for i in range(N - 1):
    V.append(i)
    U.append(i + 1)

graph = csr_matrix(([1] * N, (V, U)), shape=(N, N))
dist = dijkstra(graph, directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=N) // 2
print(*ans[1:], sep='\n')

Submission status: Accepted

Solution code:
import sys
import numpy as np
from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import dijkstra

N, X, Y = list(map(int, sys.stdin.buffer.readline().split()))
 
V = [X - 1]
U = [Y - 1]
for i in range(N - 1):
    V.append(i)
    U.append(i + 1)

graph = csr_matrix(([1] * N, (V, U)), shape=(N, N))
dist = dijkstra(graph, directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=N) // 2
print(*ans[1:], sep='\n')

Submission status: Accepted

Solution code:
import sys
import numpy as np
from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import dijkstra

input = sys.stdin.readline

n, x, y = map(int, input().split())
# A,B: 頂点, C: コスト
A, B = [], []

for i in range(n-1):
    A.append(i)
    B.append(i+1)

A.append(x-1)
B.append(y-1)

# directed: 有効ならTrue, indices: 始点
# WF O(V^3)
# wf = floyd_warshall(csr_matrix((C, (A, B)), shape = (n, n)), directed=False)
# Dijkstra O((V+E)logV)


dist = dijkstra(csr_matrix(([1] * n, (A, B)), shape = (n, n)), directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

Submission status: Accepted

Solution code:
import sys
import numpy as np
from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import dijkstra

input = sys.stdin.readline

n, x, y = map(int, input().split())
# A,B: 頂点, C: コスト
A, B, C = [], [], []

for i in range(n-1):
    A.append(i)
    B.append(i+1)
    C.append(1)

A.append(x-1)
B.append(y-1)
C.append(1)

# directed: 有効ならTrue, indices: 始点
# WF O(V^3)
# wf = floyd_warshall(csr_matrix((C, (A, B)), shape = (n, n)), directed=False)
# Dijkstra O((V+E)logV)


dist = dijkstra(csr_matrix((C, (A, B)), shape = (n, n)), directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

Submission status: Accepted

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


counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        # i -> x 直接
        d1 = abs(j-i)
        # i -> X -> Y -> j
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2)
        counts[d] += 1


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

Submission status: Accepted

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    n, x, y = map(int, input().split())
    g = [[] for _ in range(n)]
    for i in range(n-1):
        g[i].append(i+1)
        g[i+1].append(i)
    x -= 1
    y -= 1
    g[x].append(y)
    g[y].append(x)

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

    for i in range(n):
        q = deque()
        q.append(i)
        visit = [-1]*n
        visit[i] = 0
        while q:
            x = q.popleft()
            for nx in g[x]:
                if visit[nx] == -1:
                    visit[nx] = visit[x]+1
                    q.append(nx)
        for i in range(n):
            d[visit[i]] += 1
    # print(d)
    for k in range(1, n):
        print(d[k]//2)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

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

# dp = [[float('inf')] * (N+1) for _ in range(N+1)]
# # dp[Y][X] = 1
# dp[X][Y] = 1

# for i in range(1,N+1):
#     for j in range(i,N+1):
#         if i == j:
#             dp[i][j] = 0
#         elif i == X and j == Y:
#             dp[X][Y] = 1
#         elif i <= X:
#             dp[i][j] = min(dp[i][j-1] + 1, dp[i][X] + abs(Y - j) + 1)
#         else:
#             dp[i][j] = min(dp[i][j-1]+ 1, abs(i - X)+ abs(Y - j) + 1 )

# dp = list(itertools.chain.from_iterable(dp))
# for i in range(1,N):
#     print(dp.count(i))

result = [0] * N

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

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

Submission status: Accepted

Solution code:
#160-4
n,x,y=map(int,input().split())
ans=[0]*n #個数を数えるのにバケットを用意する
for i in range(1,n+1): #i<jなるすべての頂点の組について最短距離を求める
    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 #最短距離がdとなる組の個数を1増やす
for i in range(1,n):
    print(ans[i])

Submission status: Accepted

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

# min{|j − i|, |X − i| + 1 + |j − Y |, |Y − i| + 1 + |j − X|}

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

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

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

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

Submission status: Accepted

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

cnt = [0]*(n-1)

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

for out in cnt:
  print(out)

Submission status: Accepted

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

distance_l = [0]*(n-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),abs(i-y)+1+abs(j-x))
        distance_l[distance-1] += 1

for val in distance_l:
    print(val)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, a1, a2 = map(int, input().split(" "))
print(n)
wa = a2 - a1 + 1
l1 = a1 - 1
l2 = n - a2
hwa = wa // 2
pari = wa % 2
# print(wa,l1,l2,hwa,pari)
 
tmp = 0
for i in range(2, n):
    if l1 + l2 + 1 >= i:
        tmp += l1 + l2 - i + 2
    if i - 1 <= l1:
        tmp -= 1
    if i - 1 <= l2:
        tmp -= 1
    # print("himonokazu",tmp)
    if hwa > i:
        tmp += wa
    elif hwa == i:
        if pari == 1:
        	tmp += wa
        else:
            tmp += hwa
    # print("wamoirete",tmp)
    # print((i-1),(hwa-1),(l1-1),l2-1)
    if i <= hwa + l1:
        # print(min(hwa,l1,hwa+l1-i+1,i-1))
        tmp += min(hwa, l1, hwa + l1 - i + 1, i - 1) * 2
        if pari == 0 and hwa < i:
            tmp -= 1
            # print("l1gen")
        # print("l1",tmp)
    if i <= hwa + l2:
        # print(min(hwa,l2,hwa+l2-i+1,i-1))
        tmp += min(hwa, l2, hwa + l2 - i + 1, i - 1) * 2
        if pari == 0 and hwa < i:
            tmp -= 1
            # print("l2gen")
        # print("l2", tmp)
    print(tmp)
    tmp = 0

Submission status: Accepted

Solution code:
n, a1, a2 = map(int, input().split(" "))
anscount = [0 for i in range(n + 1)]

for i in range(1, n):
    for j in range(i + 1, n + 1):
        anscount[min(abs(j - i), abs(i - a1) + abs(j - a2) + 1, abs(i - a2) + abs(j - a1) + 1)] += 1

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

Submission status: Accepted

Solution code:
from sys import stdin

n, x, y = [int(x) for x in stdin.readline().rstrip().split()]
dic = { x: 0 for x in range(1, n)}

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

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

Submission status: Accepted

Solution code:
from sys import stdin

n, x, y = [int(x) for x in stdin.readline().rstrip().split()]
li = [0 for x in range(n - 1)]

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

for x in li:
    print(x)

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):
        s = j -i
        if 0 < i < Y:
            ss = abs(j - Y) + abs(X - i) + 1 
            l[min(s, ss)-1] += 1
        elif i >= Y:
            l[s-1] += 1
for i in range(N-1):
    print(l[i])

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, X, Y = MAP()
    lis = [[0 for _ in range(N-1)]for _ in range(N-1)]
    ans = [0] * (N-1)

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

    for x in ans:
        print(x)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import collections
    n,x,y = map(int,input().split(" "))
    dp = [[0]*n for i in range(n)]

    for i in range(0,n):
        for j in range(i+1,n):
            if i < x-1:
                if j < x:
                    dp[i][j] =dp[i][j-1] +1
                if j >= x and j < y:
                    dp[i][j] = dp[i][x-1]+min(j-x+1,y-j)
                if j >=y:
                    dp[i][j] = dp[i][y-1]+j-y+1
            
            if i >= x-1 and i < y-1:
                if j < y:
                    dp[i][j] = dp[i][x-1]+min(j-i,y-x+1-(j-i))
                if j >=y:
                    dp[i][j] = dp[i][y-1]+j-y+1
            
            if i >= y-1:
                dp[i][j] = dp[i][j-1] + 1
    
    dp_fl = dp[0]
    for i in range(1,n):
        dp_fl += dp[i]

    cnts = collections.Counter(dp_fl)

    for i in range(1,n):
        print(cnts.get(i,0))
main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,x,y=map(int,input().split())
    x-=1
    y-=1
    ans=[0]*n
    for i in range(n-1):
        for j in range(i+1,n):
            ans[min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))]+=1
    for a in ans[1:]:
        print(a)


if __name__=='__main__':
    main()

Submission status: Accepted

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

#進む距離kの箱
Ans = [0 for _ in range(N)]


for i in range(1, N): #スタートする頂点
    for j in range(i+1, N+1): #到着する頂点
        
        #頂点iからjまでの最短経路
        #iからjまで普通に進むか、X-Yの道を使うか。そのどっちが最短か
        Ans[min(j-i, abs(X-i)+abs(Y-j)+1)] += 1

#答え:K=1から出力
for i in Ans[1:]:
    print(i)

Submission status: Accepted

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

import collections
h = collections.Counter()
for i in range(1, n+1):
	for j in range(i+1, n+1):
		h[min(abs(j - i), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))] +=1
for distance in range(1, n):
	print h[distance]

Submission status: Accepted

Solution code:
N, X, Y = map(int, input().split())
A = [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(Y-j))
        A[k] += 1
for i in range(1, N):
    print(A[i])

Submission status: Accepted

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