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

Submission status: Accepted

Solution code:
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  b_1 = k - x
  c_1 = k - y
  if b_1 < 0:
      b_1 = - b_1
  if c_1 < 0:
      c_1 = - c_1
  for j in range(i+1, n):
    l = j + 1
    a = l - k
    b_2 = l - y
    c_2 = l - x
    if b_2 < 0:
      b_2 = - b_2
    if c_2 < 0:
      c_2 = - c_2
    b = b_1 + b_2 + 1
    c = c_1 + c_2 + 1
    if b < a:
      a = b
    if c < a:
      a = c
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    n, x, y = [int(s) for s in sys.stdin.readline().strip().split()]
    x1 = x-1
    y1 = y-1

    score = {i:0 for i in range(n)}

    for i in range(n-1):
        for j in range(i+1, n):
            diff = j - i
            cand = abs(x1 - i) + 1 + abs(y1 - j)
            cand2 = abs(y1 - i) + 1 + abs(x1 - j)
            result = min(diff, cand, cand2)
            score[result] += 1

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

main()

Submission status: Accepted

Solution code:
def distance(i, j, x, y):
    return min([abs(j - i), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x)])


if __name__ == '__main__':
    n, x, y = tuple([int(i) for i in input().split()])
    x, y = min(x, y), max(x, y)

    dists = [0 for k in range(n)]
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d = distance(i, j, x, y)
            dists[d] += 1

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

Submission status: Accepted

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

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

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

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

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


if __name__ == '__main__':
    main()

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 k in a[1:]:
	print(k)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

# import bisect
from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    ans = [0] * n

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

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


if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
# D
N,X,Y = map(int,input().split())
lst = [[0]*N for i in range(N)]
dct = {i+1: 0 for i in range(N-1)}
for i in range(N):
    for j in range(i+1, N):
        if (i+1 <= X and j+1 >= Y):
            num = X - (i + 1) + 1 + j + 1 - Y
        elif (i+1 < X and j + 1 > X and  j+1 < Y):
            num = min(j-i, X - (i+1) + 1 + Y - (j+1))
        elif (i+1 >= X and j+1 < Y):
            num = min(j-i, i+1 - X + 1 + Y - (j+1))
        elif (i+1 > X and i + 1 < Y and  j+1 >= Y):
            num = min(j-i, i+1 - X + 1 + j+1 - Y)
        else:
            num = j - i
        dct[num] += 1
for i in dct.values():
    print(i)

Submission status: Accepted

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

memo = [0] *(N)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from collections import deque
    n,x,y=map(int,input().split())
    e=[[]for _ in range(n)]
    for i in range(n-1):
        e[i]+=i+1,
        e[i+1]+=i,
    e[x-1]+=y-1,
    e[y-1]+=x-1,
    a=[0]*n
    for s in range(n):
        d=[-1]*n
        d[s]=0
        q=deque([s])
        add,pop=q.append,q.popleft
        while q:
            v=pop()
            for w in e[v]:
                if d[w]<0:
                    d[w]=d[v]+1
                    add(w)
        for i in d:a[i]+=1
    print(' '.join(str(i//2)for i in a[1:]))
main()

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

Submission status: Accepted

Solution code:
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N, X, Y = read_values()
    X -= 1
    Y -= 1
    res = [0] * N

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

            res[d] += 1

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, x, y = map(int,input().split())
cnt = [0 for _ in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            cnt[(x-i)+1+(j-y)] += 1
        else:
            c = min(j-i, abs(x-i)+1+abs(y-j))
            cnt[c] += 1
for i in cnt[1:]:
    print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
dist_to_cnt = defaultdict(int)
for i in range(N):
    for j in range(i, N):
        dist = min(j - i, abs(i - X) + 1 + abs(Y - j))
        dist_to_cnt[dist] += 1
for i in range(1, N):
    print(dist_to_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):
    d = min(j - i, abs(i - x) + abs(j - y) + 1)
    ans[d] += 1
    
for i in range(1, n):
    print(ans[i])

Submission status: Accepted

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

counter = [0] * n

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

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

nodes = list(range(1, N + 1))
ans = [0] * N
for i in range(1, N):
    for j in range(i + 2, N + 1):
        distance = min(abs(X - i) + abs(Y - j) + 1, j - i)
        ans[distance] += 1

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

Submission status: Accepted

Solution code:
# coding: utf-8
from collections import deque
def main(N, X, Y):
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            D[i][j] = abs(j-i)
            D[j][i] = abs(j-i)
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(D[nx][ny], D[x][y]+1)
                queue.append([nx, ny])
    ans = [0 for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    main(N, X, Y)

Submission status: Accepted

Solution code:
N, X, Y = map(int, input().split())
counter = {i: 0 for i in range(1, N)}

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

N, X, Y = map(int, input().split())
count = [0] * N
for i, j in combinations(range(1, N+1), 2):
    k = min(j - i, abs(X - i) + 1 + abs(Y - j))
    count[k] += 1
print(*count[1:], sep='\n')

Submission status: Accepted

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

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1, k):
    if  i<=l and k-i >1:
      M += g(m,k-i)*2/m
    elif i<=l:
      M +=1 
  return M
    
A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(int(c))

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

Submission status: Accepted

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

# G[v]: 頂点vに隣接する頂点list
# N: 頂点数
G = [[] for i in range(N)]
G[X - 1].append(Y - 1)
for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)
# print(G)


def bfs_graph(start):
    # 隣接リストを食わせる
    dist = [-1] * N
    que = deque([start])
    dist[start] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    return dist


ans = [0] * N

for i in range(N - 1):
    # print(bfs(i))
    for ele in bfs_graph(i)[i + 1:]:
        ans[ele] += 1
for a in ans[1:]:
    print(a)

Submission status: Accepted

Solution code:
# coding: utf-8
from collections import deque
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            D[i][j] = abs(j-i)
            D[j][i] = abs(j-i)
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(D[nx][ny], D[x][y]+1)
                queue.append([nx, ny])
    ans = [0 for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
main()

Submission status: Accepted

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

Submission status: Accepted

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

import numpy as np
# import scipy as scp

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,x,y = map(int,input().split())

ans = [0 for _ in range(n)]

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

print(*ans[1:],sep="\n")
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Accepted

Solution code:
from collections import defaultdict
import math
N, X, Y = map(int, input().split(' '))
d = defaultdict(int)
for i in range(1, N):
    for k in range(i+1, N+1):
        if(k < X):
            ans = k-i
            d[ans] += 1
        else:
            ans = min(k-i, abs(Y-k)+1+abs(i-X))
            d[ans] += 1

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

Submission status: Accepted

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

X = X-1
Y = Y-1

kDict = {}

for kIndx in range(1, N+1):
    kDict[kIndx] = 0

for jIndx in range(N):
    for iIndx in range(jIndx):
        if (jIndx <= X) or (iIndx >= Y):
            kDict[jIndx - iIndx] += 1
        elif (iIndx <= X) and (jIndx >= Y):
            kDict[(jIndx - iIndx) - (Y - X - 1)] += 1
        elif (iIndx <= X) and ((jIndx > X) and (jIndx < Y)):
            if 2 * jIndx - (X + Y) - 1 > 0:
                kDict[(jIndx - iIndx) - (2 * jIndx - (X + Y) - 1)] += 1
            else:
                kDict[jIndx - iIndx] += 1
        elif ((iIndx > X) and (iIndx < Y)) and (jIndx >= Y):
            if (X + Y) - 2 * iIndx - 1 > 0:
                kDict[(jIndx - iIndx) - ((X + Y) - 2 * iIndx - 1)] += 1
            else:
                kDict[jIndx - iIndx] += 1
        else:
            if (2 * (jIndx - iIndx) - (Y - X) - 1) > 0:
                kDict[(jIndx - iIndx) - (2 * (jIndx - iIndx) - (Y - X) - 1)] += 1
            else:
                kDict[jIndx - iIndx] += 1

for kIndx in range(1, N):
    print(kDict[kIndx])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = {}
for i in range(n-1):
  ans[i+1] = 0
  
for i in range(n):
  for j in range(i+1,n):
    if i <= x-1:
      if j <= x-1:
      	t=j-i
      	ans[t] += 1
      elif j <= y-1:
      	t = min(j-i, (x-1)-i + 1 + (y-1) -j)
      	ans[t] += 1
      else: #j > y-1
      	t = (x-1)-i + 1 + j -(y-1)
      	ans[t] += 1
    elif i < y-1:
      if j < y-1:
      	t = min(j-i, i-(x-1) + 1 + (y-1) -j)
      	ans[t] += 1
      else: #j >= y-1:
      	t = min(j-i, i-(x-1) + 1 + j - (y-1))
      	ans[t] += 1
    elif i >= y-1:
      t=j-i
      ans[t] += 1
    else:
      print("error")

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

def bfs(graph, initial):
    n = len(graph) - 1
    dist = [-1] * (n + 1)
    q = deque([initial])
    visited = [False] * (n + 1)
    visited[initial] = True
    dist[initial] = 0

    while len(q) != 0:
        edge = q.popleft()
        nxt = graph[edge]

        for i, e in enumerate(nxt):
            if visited[e] is False:
                q.append(e)
                dist[e] = dist[edge] + 1
                visited[e] = True

    return dist


def main():
    N, M = MI()

    ret = bfs(graph, 1)
    print(ret)


def main():
    N, X, Y = MI()
    graph = [[] for i in range(N+1)]

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

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

    d = defaultdict(int)
    for i in range(1, N+1):
        ret = bfs(graph, i)
        for j in range(1, len(ret)):
            if i != j:
                d[ret[j]] += 1
        # print(ret)

    # print(d)
    for i in range(1, N):
        if i in d:
            print(d[i]//2)
        else:
            print(0)
    # d = defaultdict(int)

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
import math
import numpy as np
N, X, Y = map(int, input().split(' '))
d = defaultdict(int)
for i in range(1, N):
    for k in range(i+1, N+1):
        if(k < X):
            ans = k-i
            d[ans] += 1
        else:
            ans = min(k-i, abs(Y-k)+1+abs(i-X))
            d[ans] += 1

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

N, X, Y = map(int, input().split())
ans = [0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        dist = min(j-i, min(abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j)))
        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())
result = [0]*N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        result[min([j-i,abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X)])-1]+=1
s = '\n'.join(map(str, result[:-1]))
print(s)

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
X-=1
Y-=1
E=[[] for _ in range(N)]
for i in range(N-1):
  E[i].append(i+1)
  E[i+1].append(i)
  if i==X:
    E[i].append(Y)
    E[Y].append(X)

cnt=[0]*N
for i in range(N):
  dist=[-1]*N
  dist[i]=0
  stack=[i]
  while stack:
    u=stack.pop(0)
    for v in E[u]:
      if dist[v]==-1:
        dist[v]=dist[u]+1
        cnt[dist[v]-1]+=1
        stack.append(v)
for i in range(N-1):
  print(cnt[i]//2)

Submission status: Accepted

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

D = Y-X
L = list(itertools.combinations(range(1,N+1), 2))

ans = [0] * N
for l in L:
    x, y = l[0], l[1]
    index = 0
    if x > Y or y < X:
        index = y-x
    elif x > X or y < Y:
        org = y-x
        oth = abs(X-x) + abs(Y-y) + 1
        if org > oth:
            index = oth
        else:
            index = org
    else:
        index = y-x - D+1
    
    ans[index] += 1

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

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,X,Y = imn()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    N, X, Y = map(int, input().split())
    from collections import defaultdict
    dist = defaultdict(int)
    for i in range(1, N):
        for j in range(i+1, N+1):
            _dist = min(j-i, abs(X-i) + 1 + abs(j-Y), abs(Y-i) + 1 + abs(j-X))
            dist[_dist] += 1
    for i in range(1, N):
        print(dist[i])

resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter

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

    def count():
        for i in range(1, n+1):
            for j in range(i+1, n+1):
                yield min(abs(j-i), abs(x-i)+1+abs(j-y))

    c = Counter(count())
    for i in range(1, n):
        print(c[i] if i in c else 0)


main()

Submission status: Accepted

Solution code:
def d_line():
    N, X, Y = [int(i) for i in input().split()]
    ans = [0] * N
    for i in range(1, N + 1):
        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))
            ans[dist] += 1
    return '\n'.join(map(str, ans[1:]))

print(d_line())

Submission status: Accepted

Solution code:
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

n,x,y = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

ans=[0]*(n)

for a in range(1,n):
	for b in range(a+1,n+1):
		k = min(b-a, abs(x-a)+1+abs(y-b))
		ans[k]+=1
#		p(ans,a,b,k)
#	p("---")

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

Submission status: Accepted

Solution code:
import sys
 
n, x, y = map(int, sys.stdin.readline().split())
x, y = x-1, y-1
cnt = [0] * (n - 1)
 
for i in range(n):
    for j in range(i+1, n):
        a = abs(j-i)
        b = abs(x-i) + abs(y-j) + 1
        c = abs(y-i) + abs(x-j) + 1
        cnt[min(a,b,c) - 1] += 1
 
for i in range(n-1):
    print(cnt[i])

Submission status: Accepted

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

array = [[-1 for i in range(n)] for j in range(n)]

for i in range(n):
  for j in range(n):
    array[i][j] = abs(j-i)
    
for i in range(n):
  if array[i][x] == array[i][y]:
    pass
  
  elif array[i][x] > array[i][y]:
    array[i][x] = array[i][y] + 1
    
    index = x - 1
    while True:
      if index < 0 or array[i][index] <= array[i][index+1]:
        break
        
      array[i][index] = array[i][index+1] + 1
      index -= 1
      
    index = x + 1
    while True:
      if index >= n or array[i][index] <= array[i][index-1]:
        break
        
      array[i][index] = array[i][index-1] + 1
      index += 1
      
  else:
    array[i][y] = array[i][x] + 1
    
    index = y - 1
    while True:
      if index < 0 or array[i][index] <= array[i][index+1]:
        break
        
      array[i][index] = array[i][index+1] + 1
      index -= 1
      
    index = y + 1
    while True:
      if index >= n or array[i][index] <= array[i][index-1]:
        break
        
      array[i][index] = array[i][index-1] + 1
      index += 1
      
ans = [0] * (n+1)
for i in range(n):
  for j in range(i, n):
    tmp = array[i][j]
    ans[tmp] += 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+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))
        #print(i,j,d)
        ans[d-1]+=1

for a in ans:
    print(a)

Submission status: Accepted

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

X = X - 1
Y = Y - 1
ans = [0]*N 

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

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