Problem:


Score : 400 points

Problem Statement

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

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

There is an edge between Vertex X and Vertex Y.

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

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

Constraints

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

1 \leq X,Y \leq N

X+1 < Y

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X Y

Output

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

Sample Input 1

5 2 4

Sample Output 1

5
4
1
0

The graph in this input is as follows:

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

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

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

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

Sample Input 2

3 1 3

Sample Output 2

3
0

The graph in this input is as follows:

Sample Input 3

7 3 7

Sample Output 3

7
8
4
2
0
0

Sample Input 4

10 4 8

Sample Output 4

10
12
10
8
4
1
0
0
0



Sample input:
5 2 4


Sample output:
5
4
1
0

Submission status: Accepted

Solution code:
from collections import Counter

n,x,y = map(int,input().split())
x -= 1
y -= 1
r = y - x + 1
ans = []

for i in range(n):
    for j in range(i+1,n):
        if (x<i and i<y) and (x<j and j<y):
            ans.append(min(j-i , r - (j-i)))
        elif (i <= x) and (x<j and j<y):
            ans.append(min(j-x , r - (j-x)) + (x-i))
        elif (i <= x) and (j <= x):
            ans.append(j-i)
        elif (i <= x) and (y <= j):
            ans.append(j-i- (y-x) + 1)
        elif (y <= j) and (x<i and i<y):
            ans.append(min(y-i , r - (y-i)) + (j-y))
        elif (x <= j) and (y <= i):
            ans.append(j-i)
            
aa = Counter(ans)

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
readline = sys.stdin.readline

N, X, Y = map(int, readline().split())
X -= 1
Y -= 1

a = [[1e9] * N for i in range(N)]

def test(n):
    b = [1e9] * N
    q = deque()

    q.append((n, 0))
    while len(q) > 0:
        n, d = q.popleft()
        if b[n] == 1e9:
            b[n] = d
            if n - 1 >= 0:
                q.append((n - 1, d + 1))
            
            if n + 1 < N:
                q.append((n + 1, d + 1))
            
            if n == X:
                q.append((Y, d + 1))
            elif n == Y:
                q.append((X, d + 1))
    
    return b

for n in range(N):
    a[n] = test(n)

ans = [0] * (N - 1)
for i in range(N):
    for j in range(i + 1, N):
        ans[int(a[i][j] - 1)] += 1

for x in ans:
    print(x)

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

Submission status: Accepted

Solution code:
n, l, r = map(int, input().split())

l -= 1
r -= 1

dist = [0] * 10000000

for a in range(n):
    for b in range(a+1, n):
        #print("from", a, "to", b)
        c = 9999999999
        c = min(c, b - a)
        #print(" dire", c)
        c = min(c, abs( abs(l - a) + abs(r - b) ) + 1 )
        dist[c] += 1
for k in range(1, n):
    print(dist[k])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

ans=[]
for i in range(N-1):
    ans.append(N-1-i)

#G=[[0 for _ in range(N)] for i in range(N)]
K=[0]*(N)
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        b=abs(i-X)+1+abs(j-Y)
        c=abs(i-Y)+1+abs(j-X)
        val=min(a,b,c)
        K[val]+=1
for i in range(len(K)):
    if i==0:
        continue
    print(K[i])

Submission status: Accepted

Solution code:
N,X,Y = map(int,input().split())
X,Y = X-1,Y-1
for k in range(1,N):
    res = 0
    for n in range(N):
        r = k-abs(Y-n)-1
        for x in {n-k, X-r, X+r}:
            if 0 <= x < n and min(n-x, abs(Y-n)+1+abs(X-x)) == k:
                res += 1
    print(res)

Submission status: Accepted

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

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

def dist(i,j):
  # Use Path
  r1 = abs(i-j)
  # Move i -> X -> Y -> j
  r2 = abs(i-X) + 1 + abs(j-Y)
  # Move i -> Y -> X -> j
  r3 = abs(i-Y) + 1 + abs(j-X)
  return(min(r1,r2,r3))

for i in range(1, N+1):
  for j in range(i+1, N+1):
    ans[ dist(i,j) ] += 1

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

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
# X,Yが接続されていないとすると，距離kの頂点の数は(i,i+k)(0<=i<=N-k-1)となる．
# そこにX,Yを接続すると，(i,x+k-1) or (i,x-k+1)(0<=i<=N-k-1)を追加する
# 最短距離かぁ．．．
dis_list = [0 for k in range(N-1)]
for i in range(N-1):
    for j in range(i+1,N):
        simple_dis = j-i
        shortcut_dis = abs(X-i-1)+1+abs(Y-1-j)
        dis = min(simple_dis,shortcut_dis)
        dis_list[dis-1]+=1
for d in dis_list:
    print(d)

Submission status: Accepted

Solution code:
import heapq

def djsktra(node,edges,dist):
    heap = []
    heapq.heappush(heap,(0,node))
    visited = set()
    while heap:
        curr = heapq.heappop(heap)
        d,node = curr[0],curr[1]
        if node not in visited:
            visited.add(node)
            dist[d] += 1
            for kid in edges[node]:
                heapq.heappush(heap,(d+1,kid))

def main():
    n,x,y = map(int,input().split())
    edges = {}
    for i in range(1,n):
        if i not in edges.keys():
            edges[i] = []

        if i+1 not in edges.keys():
            edges[i+1] = []
            
        edges[i].append(i+1)
        edges[i+1].append(i)
        
    edges[x].append(y)
    edges[y].append(x)
    dist = [0]*n
    for i in range(1,n+1):
        djsktra(i,edges,dist)

    dist.pop(0)
    for i in dist:
        print(i//2)

main()

Submission status: Accepted

Solution code:
def main():
    n,x,y=map(int,input().split())
    cnt=[0]*(n-1)
    for i in range(n-1):
        for j in range(i+1,n):
            res=min(j-i,abs(x-1-i)+abs(y-1-j)+1)
            if res>0 and res<n:
                cnt[res-1]+=1
    for i in range(n-1):
        print(cnt[i])
if __name__=="__main__":
    main()

Submission status: Accepted

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

d_dict = [0] * N

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    d = j - i
    if X < j  and i < Y:
      d = min(d, abs(i-X) + abs(j-Y) + 1)
    # print(i, j, d)
    d_dict[d] += 1

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

Submission status: Accepted

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

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

mid = (X + Y + 1) * 0.5

# GUCHOKU

ans = [0] * N

for i in range(1, N):
    for j in range(i, N + 1):
        # (i, j)について距離を調べる
        # if j >= mid:
        #    dis = X - i + 1 + abs(j - Y)
        # else:
        #    j - i
        dis = min(abs(i - X) + abs(j - Y) + 1, j - i)
        ans[dis] += 1

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

Submission status: Accepted

Solution code:
from collections import deque, Counter


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

edge = [[] for _ in range(N)]
for i in range(1, N - 1):
    edge[i].append(i + 1)
    edge[i].append(i - 1)
edge[0].append(1)
edge[N - 1].append(N - 2)
edge[X - 1].append(Y - 1)
edge[Y - 1].append(X - 1)


C = Counter()
for i in range(N):
    path = [float('inf')] * N
    path[i] = 0
    q = deque()
    q.append((i, 0))
    while q:
        p, step = q.popleft()
        for np in edge[p]:
            if path[np] > step + 1:
                q.append((np, step + 1))
                path[np] = step + 1
    for j in range(i + 1, N):
        C[path[j]] += 1

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

Submission status: Accepted

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

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

for i in range(N - 1):
    for j in range(i + 1, N):
        res = j - i
        if i <= X <= j <= Y:
            res = min(res, Y - j + X - i + 1)
        if X <= i <= Y <= j:
            res = min(res, i - X + j - Y + 1)
        if i <= X and Y <= j:
            res = min(res, j - Y + X - i + 1)
        if X <= i <= j <= Y:
            res = min(res, i - X + Y - j + 1)
        R[res - 1] += 1
for r in R:
    print(r)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from scipy.sparse.csgraph import dijkstra
import numpy as np
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

g = np.zeros((N, N), dtype=int)
a = np.arange(N - 1)
np.add.at(g, (a, a + 1), 1)
np.add.at(g, (a + 1, a), 1)
np.add.at(g, (X, Y), 1)
np.add.at(g, (Y, X), 1)
fw = dijkstra(g, directed=False)
fw = (fw + 0.5).astype(int)
fw = np.tril(fw).ravel()
fw = fw[fw > 0]

cnt = np.bincount(fw).tolist()
ans = [0] * (N - 1)
for i, c in enumerate(cnt[1:]):
    ans[i] = c

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

Submission status: Accepted

Solution code:
import itertools
N,X,Y = map(int, input().strip().split())
ans_dict = {k:0 for k in range(1, N)}
for i,j in itertools.combinations(range(1, N+1), 2):
  if i > j: i, j = j, i
  # i < j
  if i < X and j <= X:  # LL
    ans_dict[j-i] += 1
  elif Y <= i and Y < j:  # RR
    ans_dict[j-i] += 1
  elif i <= X and Y <= j:  # LR
    ans_dict[(X-i)+(j-Y)+1] += 1
  elif X <= i <= Y and X <= j <= Y:  # CC
    # これはウソ　一回遠回りした方が良い可能性がある
    d = min(j-i, (i-X)+(Y-j)+1)
    ans_dict[d] += 1
  elif i <= X and X <= j <= Y:  # LC
    d = min(j-i, (X-i)+(Y-j)+1)
    ans_dict[d] += 1
  elif X <= i <= Y and Y <= j:  # CR
    d = min(j-i, (i-X)+(j-Y)+1)
    ans_dict[d] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,x,y=map(int,input().split())
x-=1
y-=1
Ans=[0]*(n-1)
for i in range(n):
  for j in range(i+1,n):
    d=j-i
    if i<=x<=j<=y:
      d=min(d,x-i+y-j+1)
    if i<=x<=y<=j:
      d=min(d,x-i+j-y+1)
    if x<=i<=j<=y:
      d=min(d,i-x+y-j+1)
    if x<=i<=y<=j:
      d=min(d,i-x+j-y+1)
    Ans[d-1]+=1
for a in Ans:
  print(a)

Submission status: Accepted

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

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

for i in l:
    print(i)

Submission status: Accepted

Solution code:
from itertools import combinations
N,X,Y=(int(x) for x in input().split())
result={x:0 for x in range(1,N)}
for i in combinations(range(1,N+1),2):
	result[min(abs(i[0]-X)+abs(i[1]-Y)+1,i[1]-i[0])] += 1
for i in range(1,N):
  print(result[i])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations

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

C = Counter(min(j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j)) for i, j in combinations(range(N), 2))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

n, x, y = map(int, input().split())
adj = [[] for _ in range(n + 1)]

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

adj[x].append(y)
adj[y].append(x)

def bfs(root):
    visited = [0] * (n + 1)
    q = deque([root])

    while q:
        x = q.popleft()
        for y in adj[x]:
            if visited[y] == 0:
                visited[y] = visited[x] + 1
                q.append(y)
    
    return visited

result = [0] * (n + 1)

for i in range(1, n + 1):
    data = bfs(i)
    for j in range(i + 1, n + 1):
        result[data[j]] += 1

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

# print(graf)
k = [0 for _ in range(n)]
for i in graf:
    for j in i:
        k[j] += 1
# print(k)
for i in k[1::]:
    print(i)

Submission status: Accepted

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

d = {i : 0 for i in range(1,n)}
for i in range(1,n+1):
    for i2 in range(i+1, n+1):
        dist = min(i2 - i, abs(x-i) + 1 + abs(y-i2))
        d[dist] += 1
for v in d.values():
    print(v)

Submission status: Accepted

Solution code:
from collections import Counter
N, X, Y = map(int, input().split())
ans = Counter()
for i in range(1, N):
    for j in range(i+1, N+1):
        cost = min([j-i, abs(X-i)+abs(Y-j)+1, abs(Y-i)+abs(X-j)+1])
        ans[cost] += 1
for k in range(1, N):
    # base = N - k
    print(ans[k])

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
dist= [0] * N # dist[i] = (距離がiなる(i, j)の組の個数)
check = [[] for _ in range(N)]
for i in range(N - 1):
    for j in range(i + 1, N):
        if j <= X or Y <= i:
            dist[j - i] += 1
            check[j - i].append((i, j))
        elif i <= X and Y <= j:
            d = (X - i) + 1 + (j - Y)
            dist[d] += 1
            check[d].append((i, j))
        elif X <= i and j <= Y:
            d = min(j - i, (i - X) + 1 + (Y - j))
            dist[d] += 1
            check[d].append((i, j))
        elif i <= X and X <= j and j <= Y:
            d = min(j - i, (X - i) + 1 + (Y - j))
            dist[d] += 1
            check[d].append((i, j))
        elif X <= i and i <= Y and Y <= j:
            d = min(j - i, (i - X) + 1 + (j - Y))
            dist[d] += 1
            check[d].append((i, j))

#print(check)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
import heapq
n,x,y = map(int,input().split())
G = [[]*n for i 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))
# print(G)
def bfs(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    q = collections.deque()
    q.append(s)
    while q:
        u = q.popleft()
        for v in g[u]:
            if dist[v] != inf:continue
            dist[v] = dist[u] + 1
            q.append(v)
    return dist
D = [0]*n
for i in range(n-1):
  dist = bfs(G,i)
  for j in range(i+1,n):
    D[dist[j]] += 1
for i in range(1,n):
  print(D[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):
        if i <= x and j >= y:
            ans[x-i+j-y] += 1
        else:
            if i < x and j < y:
                temp = min(j-i, x-i+1+y-j)
                ans[temp-1] += 1
            elif i > x and j > y:
                temp = min(j-i, i-x+1+j-y)
                ans[temp-1] += 1
            else:
                temp = min(j-i, i-x+1+y-j)
                ans[temp-1] += 1
for i in range(n-1):
    print(ans[i])

Submission status: Accepted

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

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

from collections import Counter
c = Counter(temp)

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

Submission status: Accepted

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
from collections import deque


def main():

    N, X, Y = map(int, input().split())
    G = [set() for _ in range(N)]
    for i in range(N - 1):
        G[i].add(i + 1)
        G[i + 1].add(i)
    G[X - 1].add(Y - 1)
    G[Y - 1].add(X - 1)

    ans = [0] * (N - 1)
    for i in range(N - 1):
        # bfs
        dist = [-1] * N
        dist[i] = 0
        q = deque([i])
        while len(q):
            v = q.pop()
            for nv in G[v]:
                if dist[nv] != -1:
                    continue
                q.appendleft(nv)
                dist[nv] = dist[v] + 1

        for j in range(i + 1, N):
            ans[dist[j] - 1] += 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

# 点aと点b(b>a)の最短距離は、min((b-a), (abs(x-a) + abs(y-b) + 1))
for k in range(1, n):
    count = 0
    for a in range(1, (n-k) + 1):
        # b-aパターンの確認
        b = k+a
        if((abs(x-a) + abs(y-b) + 1) >= k):
            count += 1
        # abs(x-a) + abs(y-b)パターンの確認.
        to_y = k - abs(x-a) - 1
        if(to_y >= 0):
            b1 = y + to_y
            b2 = y - to_y
            if(b1 <= n and b1 - a >= k and b != b1):
                count += 1
            if(b2 - a >= k and b != b2 and b1 != b2):
                count += 1
    print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

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

c = [0] * (n-1)
for a, b in combinations(range(1, n+1), 2):
    p = b - a
    q = abs(x-a)+1+abs(y-b)
    r = min(p, q)
    c[r-1] += 1

print('\n'.join([str(num) for num in c]))

Submission status: Accepted

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

Submission status: Accepted

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

D = [0 for _ in range(n+1)]
    
for i in range(n-1):
    for j in range(i+1,n):
        dist1 = j-i
        dist2 = abs(i-x) +1 + abs(j-y)
        dist = min(dist1,dist2)
        D[dist] = D[dist]+1


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

Submission status: Accepted

Solution code:
#
import sys
import math
import numpy as np
import itertools
# いくつか入力
n,x,y = (int(i) for i in input().split())  

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

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

Submission status: Accepted

Solution code:
from collections import deque
N, X, Y = [int(i) for i in input().split()]
X -= 1
Y -= 1
G = [[] for _ in range(N)]
for i in range(N):
    if i!=0: G[i].append(i-1)
    if i!=N-1: G[i].append(i+1)
G[X].append(Y)
G[Y].append(X)


def bfs(G, N, s):
    dist = [-1]*N
    que = deque([s])
    dist[s] = 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

res = [0]*(N+1)
for i in range(N):
    d = bfs(G, N, i)
    for j in range(i+1, N):
        res[d[j]] += 1

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

Submission status: Accepted

Solution code:
#n=int(input())
#n,m=map(int,input().split())
#a=list(map(int,input().split()))
#q:グラフ探索済み格納キュー n:キューの次探索インデックス l:キュー内の次格納インデックス
def bfs_len_max(ind,graph,q_num):
    distance_arr=[0 if i==ind  else -1 for i in range(len(graph))]
    q=[-1 for _ in range(q_num)]
    q[0]=ind
    l=1
    n=0
    while len(q)>l:
        for i in graph[ind]:
            if distance_arr[i]==-1:
                distance_arr[i]=distance_arr[ind]+1
                q[l]=i
                l+=1
        #print(n)
        #print("elapsed q:",q)
        #print("elapsed distance:",distance_arr)
        #print()
        n+=1
        ind=q[n]


    return distance_arr
    

n,x,y=list(map(int,input().split()))
#n,x,y=[2*(10**3),1,3]


q_num=n
graph=[[1]]
for i in range(1,n-1):
    graph.append([i-1,i+1])
graph.append([n-2])
graph[x-1].append(y-1)
graph[y-1].append(x-1)
ans=[0 for _ in range(n)]

for s in range(n):
    if len(graph[s])==0:
        continue
    #print("ind:",s)
    tmp=bfs_len_max(s,graph,q_num)
    for each in tmp:
        ans[each]+=1
    #print("\n\n\n\n")

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

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
input = sys.stdin.buffer.readline

def main():
    N,A,B = map(int,input().split())
    A -= 1
    B -= 1
    
    ans = [0 for _ in range(N-1)]
    
    for i in range(N):
        for j in range(i+1,N):
            if i < A:
                if j <= A:
                    ans[j-i-1] += 1
                elif A < j <= B:
                    l = min(j-i,(A-i)+1+(B-j))
                    ans[l-1] += 1
                else:
                    ans[(A-i)+(j-B)] += 1
            elif A <= i < B:
                l = min(j-i,(i-A)+1+abs(B-j))
                ans[l-1] += 1
            else:
                ans[j-i-1] += 1
                
    print(*ans,sep="\n")
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

def dist(fr, to):
    return min(
        to - fr,
        abs(to - Y) + 1 + abs(fr - X),
        abs(fr - Y) + 1 + abs(to - X)
    )

cnt = [0] * N

ans = 0
for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cnt[dist(fr, to)] += 1

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

Submission status: Accepted

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

X = X-1
Y = Y-1

dis = Y-X
dis = dis/2
ans_list = [0]*(N-1)

for i in range(N-1):
  for j in range(i+1,N):
    normal = j-i
    a = abs(i-X)
    b = abs(j-Y)
    cut = a+b+1
    ans = min(normal, cut)
    ans_list[ans-1] += 1
for i in ans_list:
  print(i)

Submission status: Accepted

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

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

ans = [0 for _ in range(N)]
for i in range(N) :
    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(N-1) :
    print(ans[i+1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ret = [0] * n

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

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

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

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

Submission status: Accepted

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


def solve(N: int, X: int, Y: int):
    matrix = [[float('inf')]*(N+1) for _ in range(N+1)]

    answer = [0]*N

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

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

x_to_mid = [0] * n
x_to_mid[0] = 1
for i in range(1, mid//2):
    x_to_mid[i] = 2
x_to_mid[mid//2] = 1 + mid%2

ans = [0] * n
#LL,RR
for i in [left,right]:
    for j in range(1,i):
        ans[j] += i-j

#mid-mid
for i in range(1, 1 + mid//2):
    ans[i] += mid * x_to_mid[i] // 2

#LR
for i in range(left):
    for j in range(right):
        ans[i+j+3] += 1

#L-mid,R-mid
for i in [left,right]:
    for j in range(n):
        tmp = x_to_mid[j]
        if(tmp==0):
            break
        for k in range(1,i+1):
            ans[ j+k ] += tmp

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

Submission status: Accepted

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

ans = [0] * N

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

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

Submission status: Accepted

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

table = [0]*N

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

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

Submission status: Accepted

Solution code:
import collections
def main():

    N, X, Y = map(int, input().split())
    count = collections.defaultdict(int)
    for i in range(1, N+1):
        for j in range(1, i):
            v = i-j
            v = min(v, abs(i-Y)+1+abs(X-j))

            count[v] += 1

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


if __name__ == '__main__':
    main()
    # print(main())

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,X,Y=map(int,input().split())
ans=[0 for i in range(N+1)]
L=[[]for i in range(N+1)]
for i in range(2,N+1):
    L[i].append(i-1)
    L[i-1].append(i)
L[X].append(Y)
L[Y].append(X)
import heapq
for i in range(1,N+1):
    C=[10**5 for i in range(N+1)]
    C[i]=0
    Q=[]
    for a in L[i]:
        Q.append((1,a))
    heapq.heapify(Q)
    for b in range(10**4):
        if len(Q)==0:
            break
        d,p=Q[0]
        heapq.heappop(Q)
        if C[p]==10**5:
            C[p]=d
            ans[d]+=1
            for c in L[p]:
                if C[c]==10**5:
                    heapq.heappush(Q,(d+1,c))
for i in range(1,N):
    print(ans[i]//2)