Problem:


Score : 400 points

Problem Statement

We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:

For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.

There is an edge between Vertex X and Vertex Y.

For each k=1,2,...,N-1, solve the problem below:

Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Constraints

3 \leq N \leq 2 \times 10^3

1 \leq X,Y \leq N

X+1 < Y

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X Y

Output

For each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.

Sample Input 1

5 2 4

Sample Output 1

5
4
1
0

The graph in this input is as follows:

There are five pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\,,(2,3)\,,(2,4)\,,(3,4)\,,(4,5).

There are four pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\,,(1,4)\,,(2,5)\,,(3,5).

There is one pair (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).

There are no pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 4.

Sample Input 2

3 1 3

Sample Output 2

3
0

The graph in this input is as follows:

Sample Input 3

7 3 7

Sample Output 3

7
8
4
2
0
0

Sample Input 4

10 4 8

Sample Output 4

10
12
10
8
4
1
0
0
0



Sample input:
5 2 4


Sample output:
5
4
1
0

Submission status: Accepted

Solution code:
import itertools
from collections import defaultdict

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

def dis(x, y):
  d1 = abs(x - y)
  d2 = abs(X - x) + 1 + abs(Y - y)
  return min(d1, d2)

for p in itertools.combinations(range(1, N+1), 2):
  d = dis(p[0], p[1])
  ans[d] += 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())

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

Submission status: Accepted

Solution code:
n,x,y=map(int,input().split())
le=x-1
ri=n-y
rnd=y-x+1
L=[0]*(n-1)
lim=rnd//2
for i in range(1,n):
    if i <= lim:
        if rnd%2==0 and i==lim:
            L[i-1] += lim
        else:
            L[i-1] += rnd

for i in range(1,le+1):
    for j in range(1,lim+1):
        if rnd%2==0 and j==lim:
            L[i-1+j] += 1
        else:
            L[i-1+j] += 2

for i in range(1,ri+1):
    for j in range(1,lim+1):
        if rnd%2==0 and j==lim:
            L[i-1+j] += 1
        else:
            L[i-1+j] += 2

for i in range(le):
    for j in range(ri):
        L[i+j+2] += 1

for i in range(le):
    L[i] += le-i
for j in range(ri):
    L[j] += ri-j

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X, Y = lr()
dis = [[0] * (N+1) for _ in range(N+1)]
for i in range(1, N):
    for j in range(i+1, N+1):
        dis[i][j] = j - i
        dis[j][i] = j - i

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

answer = [0] * (N)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = dis[i][j]
        answer[d] += 1

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

Submission status: Accepted

Solution code:
# abc160_d.py
import sys
import time
import unittest
from io import StringIO
from collections import defaultdict


def resolve():
    N, X, Y = [int(i) for i in input().split()]
    dd = defaultdict(int)
    X -= 1
    Y -= 1
    for i in range(N):
        for j in range(i + 1, N):
            dd[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(dd[i])


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def checkTLE(self, input):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin

    def debugIO(self, input):
        stdin = sys.stdin
        sys.stdin = StringIO(input)
        resolve()
        sys.stdin = stdin

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """5 2 4"""
        output = """5
4
1
0"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 1 3"""
        output = """3
0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """7 3 7"""
        output = """7
8
4
2
0
0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """10 4 8"""
        output = """10
12
10
8
4
1
0
0
0"""
        self.assertIO(input, output)

    def test_入力例_TLE(self):  # TODO:
        input = """2000 2 4"""
        self.checkTLE(input)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()

Submission status: Accepted

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


ans = [0] * (n-1)

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

Submission status: Accepted

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

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

for v in val:
    print(v)

Submission status: Accepted

Solution code:
n,x,y = map(int,input().split())
k = [0 for i in range(n)]
for i in range(n):
    for j in range(i,n):
        #print(i,j,j-i,abs(x-1-i)+abs(y-1-j)+1,abs(x-1-j)+abs(y-1-i)+1)
        dist = min(j-i,abs(x-1-i)+abs(y-1-j)+1,abs(x-1-j)+abs(y-1-i)+1)
        k[dist]+=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,n):
    for j in range(i+1, n+1):
        r1 = j-i
        r2 = abs(x-i) + 1 + abs(j-y)
        r3 = abs(y-i) + 1 + abs(j-x)
        ans[min(r1,r2,r3)] += 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import os

def file_input():
    f = open('ABC160/input.txt', 'r')
    sys.stdin = f

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

    out=[0]*(N-1)

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

    [print(x) for x in out]

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
N, X, Y = map(int, input().split())
G = defaultdict(list)
for i in range(1, N):
    G[i].append(i+1)
    G[i+1].append(i)
#print(G)

G[X].append(Y)
G[Y].append(X)

#print(G)

d = [0] * N

for i in range(1, N+1):
    q = deque()
    q.append(i)
    visit = [-1]*N
    visit[i-1] = 0
    while q:
        p = q.popleft()
        for next_p in G[p]:
            if visit[next_p-1] == -1:
                visit[next_p-1] = visit[p-1] + 1
                q.append(next_p)

    for l in range(N):
        d[visit[l]] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
import math
import sys

n,x,y = list(map(int,sys.stdin.readline().split()))
x -= 1
y -= 1
table=[0]*(n-1)
#print(table)

#i,jに関して全探索
for i in range(n):
    for j in range(i+1,n):
        #print(i,j, min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)))
        table[min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)) - 1] += 1

for ans in table:
    print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
from scipy.sparse import csr_matrix, csgraph
N, X, Y = map(int, input().split())
data = [1] * N
row = list(range(N - 1)) + [X - 1]
column = list(range(1, N)) + [Y - 1]
graph = csr_matrix((data, (row, column)), dtype=np.int32, shape=(N, N))
dists = csgraph.shortest_path(graph.toarray(), directed=False).astype(np.int32)
print(*np.bincount(np.triu(dists).ravel(), minlength=N)[1:], sep="\n")

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(abs(j-i), abs(X-i)+1+abs(j-Y))
    l[d-1] += 1

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

Submission status: Accepted

Solution code:
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	N, X, Y = getlist()
	X -= 1; Y -= 1
	D = defaultdict(int)
	for i in range(N):
		for j in range(i + 1, N):
			var = min(j - i, abs(X - i) + abs(Y - j) + 1)
			D[var] += 1

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




if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

result = [0]*(N-1)
list = list(itertools.combinations(list(range(1,N+1)),2))
for i in list:
    g = i[1]-i[0]
    j = abs(Y-i[1]) + abs(X-i[0]) + 1
    result[min([g,j])-1] += 1

for i in result:
    print(i)

Submission status: Accepted

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

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

for j in ptns:
    print(j)

Submission status: Accepted

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

# 以下カンニング
ans = [ 0 ] * n
for i in range( 1, n + 1 ):
    for j in range( i + 1, n + 1 ):
        d = min( [ j - i,
                abs( x - i ) + 1 + abs( j - y ),
                abs( y - i ) + 1 + abs( j - x ) ] )
        ans[ d ] += 1

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

Submission status: Accepted

Solution code:
n,x,y = map(int,input().split())
mid = (x + y) // 2
# indと距離が同じ
num_roots = [0] * n
for start in range(1,n):
    for goal in range(start + 1,n+1):
        if start <= mid:
            if goal <= mid:
                d = goal - start
            else:
                d = min(goal - start, abs(x - start) + 1 + abs(goal - y))
        else:
            d = goal - start
        num_roots[d] += 1
for i in range(1,n):
    print(num_roots[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
from collections import deque
from collections import Counter
def main():
    # 入力
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1

    # 処理
    dis = deque()
    for i1 in range(n):
        if x < i1:
            right = i1 + 1
            while right < n:
                dis_now = min(right - i1, (i1 - x + abs(right - y) + 1))
                dis.append(dis_now)
                right += 1
        else:
            right = i1 + 1
            while right < n:
                if right < y:
                    dis_now = min(right - i1,(x - i1 + abs(y - right) + 1))
                    dis.append(dis_now)
                else:
                    dis.append(right - i1 - (y - x) + 1)
                right += 1
    dis_c = Counter(dis)
    dis_list = [0] * (n - 1)
    for i2 in range(1, n):
        dis_list[i2 - 1] = dis_c[i2]

    # 出力

    for edis in dis_list:
        print(edis)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, X, Y=map(int,input().split())
List=[]
i=1
for j in range(2,N+1):
  for i in range(1,j):
    List.append(min([abs(j-i), abs(X-i)+abs(Y-j)+1]))

List.sort()

import collections
C=collections.Counter(List)

for p in range(1,N):
  if p in C.keys():
    print(C[p])
  else:
    print(0)

Submission status: Accepted

Solution code:
import queue

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import itertools

N,X,Y = map(int,input().split())
n = list(range(1,N+1))
l = [0]*N
for v in itertools.combinations(n,2):
  l[min(abs(Y-v[1]) + abs(X-v[0]) + 1,v[1] - v[0])] += 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):
        d = min(j-i, abs(X-i)+abs(j-Y)+1)
        ans[d-1] += 1

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, x, y = map(int, read().split())
ans = [0] * n
for k in range(1, n):
    for i in range(k + 1, n + 1):
        ans[min(i - k, abs(y - i) + abs(x - k) + 1)] += 1
print('\n'.join(map(str, ans[1:])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, x, y = map(int, read().split())
ans = [0] * n
for k in range(1, n):
    for i in range(k + 1, n + 1):
        if i <= x:
            ans[i - k] += 1
        elif x < i <= y:
            ans[min(i - k, y - i + abs(x - k) + 1)] += 1
        else:
            if k <= x:
                ans[i - y + x - k + 1] += 1
            elif x <= k <= y:
                ans[min(k - x + 1 + i - y, i - k)] += 1
            else:
                ans[i - k] += 1
print('\n'.join(map(str, ans[1:])))

Submission status: Accepted

Solution code:
import itertools
from collections import deque
from collections import Counter
N,X,Y = list(map(int,input().split()))
moto = [x for x in range(1,N+1)]
d = deque([])
C = itertools.combinations(moto,2)
C = list(C)
for c in C:
    i = c[0]
    j = c[1]
    d.append(min(j-i,abs(i-X)+abs(j-Y)+1))
c = Counter(list(d))
for v in c.values():
  print(v)
for _ in range(N-1-len(list(c))):
  print(0)

Submission status: Accepted

Solution code:
from collections import defaultdict

def getdis(a, b, n, x, y):
    mini = abs(a - b)
    mini = min(mini, abs(a - x) + 1 + abs(b - y))
    mini = min(mini, abs(a - y) + 1 + abs(b - x))
    return mini

def solve(n, x, y):
    dis = [0 for i in xrange(n)]
    for i in xrange(1, n + 1):
        for j in xrange(i + 1, n + 1):
            u = getdis(i, j, n, x, y)
            # print i, j, u
            dis[u] += 1
    return dis[1:]

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

res = solve(n, x, y)
for num in res:
    print num

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):
    m=min(abs(i-j),abs(x-i)+1+abs(y-j))
    if m in d:
      d[m]+=1
    else:
      d[m]=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())

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

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

Submission status: Accepted

Solution code:
from sys import stdin


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from heapq import heappush, heappop

INF = 10 ** 18

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for b, cost in G[v]:
            if dist[b] > dist[v] + cost:
                dist[b] = dist[v] + cost
                heappush(h, (dist[b], b))
    return dist

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

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

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

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

ans = [0] * n

for i in range(n):
    for d in dijkstra(n, g, i):
        ans[d] += 1

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

Submission status: Accepted

Solution code:
import heapq

INF = float('inf')

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for b, cost in G[v]:
            if dist[b] > dist[v] + cost:
                dist[b] = dist[v] + cost
                heapq.heappush(h, (dist[b], b))
    return dist

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

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

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

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

ans = [0] * n

for i in range(n):
    for d in dijkstra(n, g, i):
        ans[d] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def function(args):
    N, X, Y = map(int, args.split())
    dests = [0] * (N)
    
    for i in range(1, N):
        for j in range(i+1, N+1):
            dist_direct = j - i
            dist_throughX = abs(X - i) + 1 + abs(Y - j)
            shortest = min(dist_direct, dist_throughX)
            dests[shortest] += 1
    dests.pop(0)
    return dests

if __name__ == '__main__':
    dests = function(input())
    for d in dests:
        print(d)

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

for x in ans:
    print(x)

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

for cnt in ans:
    print(cnt)

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

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

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

for i in d:
    print(i)

Submission status: Accepted

Solution code:

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

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

for i in d:
    print(i)

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

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

Submission status: Accepted

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

X -= 1
Y -= 1

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc160/tasks/abc160_d
N, X, Y = map(int, input().split())

visited = set()

# special case: first advance
for i in range(N - 1):
    visited.add((i, i + 1))
visited.add((X - 1, Y - 1))

print(len(visited))

next_items = visited.copy()
for _ in range(N - 2):
    candidates = []

    for point in next_items:
        x, y = point

        if (x - 1, y) not in visited and x - 1 >= 0:
            visited.add((x - 1, y))
            candidates.append((x - 1, y))

        if (x + 1, y) not in visited and x + 1 != y:
            visited.add((x + 1, y))
            candidates.append((x + 1, y))

        if (x, y - 1) not in visited and x != y - 1:
            visited.add((x, y - 1))
            candidates.append((x, y - 1))

        if (x, y + 1) not in visited and y + 1 < N:
            visited.add((x, y + 1))
            candidates.append((x, y + 1))

    print(len(candidates))
    next_items = candidates

Submission status: Accepted

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

X -= 1
Y -= 1

output = [0]*N

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,x,y = LI()
    x -= 1
    y -= 1
    c = collections.defaultdict(int)
    for i in range(n):
        xi = abs(i-x)
        for j in range(i+1,n):
            yj = abs(j-y)
            c[min(j-i, xi+yj+1)] += 1

    return JA([c[i] for i in range(1,n)], "\n")


print(main())

Submission status: Accepted

Solution code:

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

a = {i:0 for i in range(1, n)}


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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
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 LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, x, y = map(int, input().split())
a = abs
d = [0] * n
for i in range(1, n+1):
    for j in range(i + 1, n+1):
        d[min(j-i, a(x-i)+a(y-j)+1, a(x-j)+a(y-i)+1)] += 1
print(*d[1:], sep="\n")

Submission status: Accepted

Solution code:
import collections

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

ans = []
for i in range(n):
    for j in range(i + 1, n):
        min_l = min(j - i, abs(x - i) + abs(y - j) + 1)
        ans.append(min_l)
t = collections.Counter(ans)
for i in range(1, n):
    print(t[i])

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N, X, Y = LI()
X -= 1
Y -= 1
anss = [0 for i in range(N)]

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

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

Submission status: Accepted

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

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

c = collections.Counter(disList)
cList = list(c.values())
for i in range(n-1):
    if(i < len(cList)):
        print(cList[i])
    else:
        print(0)