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

Solution (Python):


















from sys import stdin
from collections import deque




def get_adj_list(num_nodes, data, undirected=True):
    graph = [[] for _ in range(num_nodes)]
    for val in data:
        x, y = val
        graph[x-1] = graph[x-1] + [y-1]
        if undirected:
            graph[y-1] = graph[y-1] + [x-1]
    return graph



def breadth_first_search(adj_list, start_node):
    N = len(adj_list)
    order = [-1] * N 
    parent = [-1] * N 
    depth = [-1] * N 
    q = deque([(start_node, -1, 0)]) 
    num = 0 
    while q:
        v, p, d = q.popleft()
        if order[v] < 0: 
            order[v] = num
            parent[v] = p
            depth[v] = d
            num += 1
            for u in adj_list[v]:
                if order[u] >= 0: continue
                q.append((u, v, d+1))
    return order, parent, depth


def get_result(data):
    N, X, Y = data
    _data = [[i, i+1] for i in range(1, N)]
    _data += [[X, Y]]
    adj_list = get_adj_list(N, _data)
    dist_cnt = [0 for i in range(N)]
    for i in range(N):
        _, _, depth = breadth_first_search(adj_list, i)
        for j in range(i, N):
            dist_cnt[depth[j]] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)

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

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

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

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

for i in range(N):
    if i > 0:
        print(cnt[i])

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

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

for i in range(N):
    if i > 0:
        print(cnt[i])

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

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

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

Solution (Python):
def solve(string):
    n, x, y = map(int, string.split())
    ans = [0] * (n - 1)
    for s in range(1, n + 1):
        d = [abs(i - s) for i in range(1, n + 1)]
        if d[x - 1] < d[y - 1]:
            p = y - 1
            d[p] = min(d[p], d[x - 1] + 1)
        else:
            p = x - 1
            d[p] = min(d[p], d[y - 1] + 1)
        for i in range(p + 1, n):
            d[i] = min(d[i], d[i - 1] + 1)
        for i in range(p - 1, -1, -1):
            d[i] = min(d[i], d[i + 1] + 1)
        for _d in d[s:]:
            ans[_d - 1] += 1
    return "\n".join(map(str, ans))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
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):
        if (i <= x and j <= x) or (y <= i and y <= j):
            ans[j - i] += 1
        elif i <= x and y <= j:
            ans[x-i+1+j-y] += 1
        else:
            dist = min((j-i),(abs(i-x)+1 + abs(y-j)))
            ans[dist] += 1
            
print('\n'.join([str(s) for s in ans[1:]]))

Solution (Python):
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):
    if (i <= X and j <= X) or (Y <= i and Y <= j):
      
      ans[j - i] += 1
    elif i <= X and Y <= j:
      
      ans[X - i + 1 + j - Y] += 1
    else:
      
      dist = min((j - i), (abs(i - X) + 1 + abs(Y - j)))
      ans[dist] += 1

print('\n'.join([str(s) for s in ans[1:]]))

Solution (Python):
from itertools import *

def loop(n):
  yield from repeat(n, (n-1)>>1)
  if n & 1 == 0:
    yield n >> 1
  yield from repeat(0)

def branch(n, l):
  if n:
    yield 0
    a, b = divmod(l-3, 2)
    s = 1
    for i in range(n+a+b):
      yield s
      if i < a:
        s += 2
      elif b and i==a:
        s += 1
      if n <= i:
        s -= 2
      elif i==n-1:
        s -= 1
  yield from repeat(0)

def b_to_b(n):
  yield n
  yield from range(n, 0, -1)
  yield from repeat(0)

N, X, Y = map(int, input().split())
L = Y - X + 1
for p in islice(zip(loop(L), branch(X-1, L), branch(N-Y, L), b_to_b(N-L)), N-1):
  print(sum(p))

Solution (Python):
from itertools import *

def loop(n):
  yield from repeat(n, (n-1)//2)
  if n & 1 == 0:
    yield n >> 1
  yield from repeat(0)

def branch(n, l):
  if n:
    yield 0
    l -= 3
    a, b = divmod(l, 2)
    s = 1
    for i in range(n+a+b):
      yield s
      if i < a:
        s += 2
      elif b and i==a:
        s += 1
      if n <= i:
        s -= 2
      elif i==n-1:
        s -= 1
  yield from repeat(0)

def b_to_b(n):
  n -= 1
  yield n
  yield from range(n, 0, -1)
  yield from repeat(0)

N, X, Y = map(int, input().split())
L = Y - X + 1
for p in islice(zip(loop(L), branch(X-1,L), branch(N-Y,L), b_to_b(N-L+1)), N-1):
  print(sum(p))

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

lists = [0] * (N - 1)

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

for k in lists:
  print(k)

Solution (Python):
n, x, y = list(map(int,input().split()))
d = [0 for i in range(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)])-1] += 1

for i in d:
  print(i)

Solution (Python):
from collections import deque, defaultdict
n, x, y = map(int, input().split())
 
edges = defaultdict(lambda: [])
for i in range(1, n):
    edges[i].append(i+1)
    edges[i+1].append(i)
edges[x].append(y)
edges[y].append(x)
 

counter = [0 for i in range(n)]
for i in range(1, n+1):
    d = deque()
    dist = [-1 for _ in range(n+1)]
    d.append((i, -1))
    while len(d) > 0:
        e, pre_dist = d.popleft()
        if dist[e] > -1:
            continue
        else:
            dist[e] = pre_dist + 1
            for next_e in edges[e]:
                if dist[next_e] == -1:
                    d.append((next_e, pre_dist+1))
    for j in range(i+1, n+1):
        counter[dist[j]] += 1
print("\n".join(list(map(str, counter[1:]))))

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

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

Solution (Python):
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

    
    
    
    
    
    
    
    

    ans = [0] * N

    for i in range(N - 1):
        for j in range(i + 1, N):
            ij = abs(j - i)
            ixyj = abs(X - i) + 1 + abs(j - Y)
            iyxj = abs(Y - i) + 1 + abs(j - X)

            dist = min(ij, ixyj, iyxj)

            ans[dist] += 1

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
input = sys.stdin.readline

from collections import deque


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

    for start_vertex in range(N):
        q = deque()
        distance_list = [float('inf')] * N

        def push(vertex, distance):
            if distance_list[vertex] != float('inf'):
                return
            q.append(vertex)
            distance_list[vertex] = distance

        push(start_vertex, 0)

        while len(q) != 0:
            vertex = q.popleft()
            distance = distance_list[vertex]

            if vertex - 1 >= 0:
                push(vertex - 1, distance + 1)
            if vertex + 1 < N:
                push(vertex + 1, distance + 1)
            if vertex == X:
                push(Y, distance + 1)
            if vertex == Y:
                push(X, distance + 1)

        for i in distance_list:
            ans[i] += 1

    print('\n'.join([str(i // 2) for i in ans[1:]]))


if __name__ == '__main__':
    main()

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


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

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

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

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

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

for i in ans :
    print(i)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
from collections import deque
n,x,y = map(int,input().split())
g = [[]for i in range(n)]
g[0].append(1)
g[n-1].append(n-2)
g[x-1].append(y-1)
g[y-1].append(x-1)
for i in range(1,n-1):
  g[i].append(i-1)
  g[i].append(i+1)
ans = [0]*(n-1)
def dfs(b,c):
  for i in g[b]:
    if a[i] > c+1:
      a[i] = c+1
      que.append([i,c+1])
    
for i in range(n):
  a = [999999999]*n
  a[i] = 0
  que = deque()
  que.append([i,0])
  while que:
    x,y = que.popleft()
    dfs(x,y)
  for j in a:
    if j == 0:
      continue
    ans[j-1] += 1
for i in ans:
  print(i//2)

Solution (Python):

import collections


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

    inf = 10 ** 9
    ans = [0]*N

    def push(v, d, dist, q):
        if dist[v] == inf:
            dist[v] = d
            q.append(v)

    for i in range(N):
        q = collections.deque()
        dist = [inf]*N
        push(i, 0, dist, q)

        while(len(q)):
            v = q.popleft()
            d = dist[v]
            if v < N-1:
                push(v+1, d+1, dist, q)
            if 0 < v:
                push(v-1, d+1, dist, q)
            if v == X-1:
                push(Y-1, d+1, dist, q)
            if v == Y-1:
                push(X-1, d+1, dist, q)

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

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


if __name__ == "__main__":
    solve()

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

li = [0]*n
x,y = x-1,y-1

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

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

t = [0] * (N - 1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        t[min(j - i, abs(X - i) + 1 + abs(Y - j)) - 1] += 1
print('\n'.join(map(str, t)))

Solution (Python):
N, X, Y = list(map(int, input().split()))
result = [0] * N


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

for e in result[1:]: print(e)

Solution (Python):
from collections import deque

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

ans = [0] * (n+1)
INF = 10 ** 10

for i in range(n):
    d = [INF] * n
    q = deque([])
    d[i] = 0
    q.append(i)
    while len(q) > 0:
        v = q.popleft()
        if v - 1 >= 0:
            if d[v-1] == INF:
                q.append(v-1) 
                d[v-1] = d[v] + 1
        if v + 1 < n:
            if d[v+1] == INF:
                q.append(v+1)
                d[v+1] = d[v] + 1
        if v == x:
            if d[y] == INF:
                q.append(y)
                d[y] = d[v] + 1
        if v == y:
            if d[x] == INF:
                q.append(x)
                d[x] = d[v] + 1
    for i in range(n):
        ans[d[i]] += 1

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

Solution (Python):
from collections import deque

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

ans = [0] * (n+1)
INF = 10 ** 10

for i in range(n):
    distance = [INF] * n
    q = deque([])
    distance[i] = 0
    q.append(i)
    while len(q) > 0:
        v = q.popleft()
        if v - 1 >= 0:
            if distance[v-1] == INF:
                q.append(v-1) 
                distance[v-1] = distance[v] + 1
        if v + 1 < n:
            if distance[v+1] == INF:
                q.append(v+1)
                d = distance[v] + 1
                distance[v+1] = distance[v] + 1
        if v == x:
            if distance[y] == INF:
                q.append(y)
                distance[y] = distance[v] + 1
        if v == y:
            if distance[x] == INF:
                q.append(x)
                distance[x] = distance[v] + 1
    for i in range(n):
        ans[distance[i]] += 1

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

Solution (Python):
mod = 10**9 + 7

def iip(listed = False):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod



def main():
    N, X, Y = iip()
    X, Y = sorted((X-1, Y-1))
    

    result = [0 for i in range(1, N)]
    for a in range(0, N):
        for b in range(a+1, N):
            d1 = b-a
            d2 = abs(X-a)+abs(Y-b)+1
            d = min(d1, d2)-1
            

            result[d] += 1

    print("\n".join([str(i) for i in result]))


if __name__ == "__main__":
    main()

Solution (Python):
n, x, y = input().split()
n, x, y = int(n), int(x)-1, int(y)-1
d = [[abs(i-j) for i in range(n)] for j in range(n)]
for i in range(x+1):
    for j in range(y, n):
        d[i][j] -= y-x-1
    for j in range(y-1, x+(y-x)//2, -1):
        d[i][j] = d[i][j+1]+1
for i in range(x+1, x+(y-x)//2):
    d[i][y] = d[i][x] + 1
    for j in range(y+1, n):
        d[i][j] = d[i][j-1]+1
    for j in range(y-1, x+(y-x)//2+(i-x), -1):
        d[i][j] = d[i][j+1]+1
apar = [0 for i in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        apar[d[i][j]] += 1
for i in range(1, n):
    print(apar[i])

Solution (Python):
from itertools import combinations

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

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

print("\n".join(map(str, A[1:])))

Solution (Python):
from itertools import combinations
from collections import Counter

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

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

print("\n".join(str(C[k]) for k in range(1, N)))

Solution (Python):
from itertools import combinations

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

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

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

Solution (Python):

"""
Created on Tue Mar 31 01:29:10 2020

@author: liang
"""

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

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

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

t = [0] * (N - 1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        t[min(j - i, abs(X - i) + 1 + abs(Y - j)) - 1] += 1
print('\n'.join(map(str, t)))

Solution (Python):

"""
Created on Tue Mar 31 01:29:10 2020

@author: liang
"""

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

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

Solution (Python):
n,x,y = map(int, input().split())
x,y = x-1,y-1
dis = []

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

ans = [0]*(n-1)
for d in dis:
  ans[d-1] += 1

for a in ans:
  print(a)

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

Solution (Python):
N, X, Y= map(int, input().split(' '))
 
array=[None]*N
for i in range(N):
    array[i]=0
    
for k in range(1, N+1):
    for v in range(k, N+1):
       array[min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1])] += 1 

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

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

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

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

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

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

Solution (Python):
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
from collections import Counter

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

fr,to,w=[],[],[]

for i in range(n-1):
  fr.append(i)
  to.append(i+1)
  w.append(1)

fr.append(x-1)
to.append(y-1)
w.append(1)

g=csr_matrix((w, (fr, to)), shape=(n, n))
d=dijkstra(g,directed=False).astype(int)



ans_l=list(d.ravel())
c=Counter(ans_l)
for i in range(1,n):
  print(c[i]//2)

Solution (Python):
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

fr,to,w=[],[],[]

for i in range(n-1):
  fr.append(i)
  to.append(i+1)
  w.append(1)

fr.append(x-1)
to.append(y-1)
w.append(1)

g=csr_matrix((w, (fr, to)), shape=(n, n))
d=dijkstra(g,directed=False).astype(int)

ans_l=np.bincount(d.ravel(), minlength=n)//2

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

Solution (Python):
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

fr,to,w=[],[],[]

for i in range(n-1):
  fr.append(i)
  to.append(i+1)
  w.append(1)

fr.append(x-1)
to.append(y-1)
w.append(1)

g=csr_matrix((w, (fr, to)), shape=(n, n))

ans_l=[]

'''for i in range(n):
  d=dijkstra(g,indices=i,directed=False)
  ans_l+=list(d)'''

d=dijkstra(g,directed=False).astype(int)
ans_l=np.bincount(d.ravel(), minlength=n)//2

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

'''
for i in ans_l[1:]:
  print(i)
'''

Solution (Python):
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

fr,to,w=[],[],[]

for i in range(n-1):
  fr.append(i)
  to.append(i+1)
  w.append(1)

fr.append(x-1)
to.append(y-1)
w.append(1)

g=csr_matrix((w, (fr, to)), shape=(n, n))

ans_l=[]

'''for i in range(n):
  d=dijkstra(g,indices=i,directed=False)
  ans_l+=list(d)'''

d=dijkstra(g,directed=False).astype(int)

ans_l=np.bincount(d.ravel(), minlength=n)//2



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

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

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

ans = {i+1:0 for i in range(N-1)}

d = lambda i,j: min(abs(i-j), abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(X-j))

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

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

Solution (Python):
N,x,y=map(int,input().split())

ln=[0]*(N-1)

for i in range(1,N+1):
    for j in range(i+1,N+1):
        d2=N
        d=j-i
        if j <= x:
            pass
        elif i<=x and j <=y:
            d2=y-j+1+x-i
        elif j<=y:
            d2=y-j+1+i-x
        elif i<=x and j>=y:
            d2=x-i+j-y+1
        elif j>=y:
            d2=j-y+1+i-x

        if d2 < d:
            d=d2
        
        ln[d-1]+=1

for i in ln:
    print(i)

Solution (Python):
from sys import stdin
from collections import deque


def get_adj_list(num_nodes, data, undirected=True):
    
    graph = {}
    for i in range(num_nodes):
        graph[i+1] = []
    for val in data:
        x, y = val
        graph[x] = graph[x] + [y]
        if undirected:
            graph[y] = graph[y] + [x]
    return graph


def breadth_first_search(adj_list, start_node):
    dist = {}
    queue = deque([(start_node, 0)])
    while len(queue) > 0:
        v, d = queue.popleft()
        if v in dist: continue
        dist[v] = d
        for u in adj_list[v]:
            if u not in dist:
                queue.append((u, d+1))
    return dist


def get_result(data):
    N, X, Y = data
    _data = [[i, i+1] for i in range(1, N)]
    _data += [[X, Y]]
    adj_list = get_adj_list(N, _data)
    dist_cnt = [0 for i in range(N)]
    for i in range(N):
        dist = breadth_first_search(adj_list, i+1)
        for j in range(i, N):
            dist_cnt[dist[j+1]] += 1
    for i in range(1, N):
        print(dist_cnt[i])













if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, X, Y = map(int, rl().split())
    X -= 1
    Y -= 1
    
    ans = [0] * N
    for i in range(N - 1):
        for j in range(i + 1, N):
            ans[min(j - i, abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X))] += 1
    print('\n'.join(map(str, ans[1:])))


if __name__ == '__main__':
    solve()

Solution (Python):

"""
Created on Mon Mar 30 20:27:30 2020

@author: black
"""

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

def sp_root(i, j, X, Y): 
    root = abs(X-i) + abs(Y-j) + 1
    return root

k_lis = [0]*(N-1)

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

for i in k_lis:
    print(i)

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


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

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

Solution (Python):
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])

Solution (Python):
import heapq

def dijkstra(edges, s):
    hq = []
    d = [-1] * n
    d[s] = 0
    heapq.heappush(hq, (0, s))
    while hq:
        d1, p = heapq.heappop(hq)
        for i in edges[p]:
            if d[i] == -1 or d[i] > d1 + 1:
                d[i] = d1 + 1
                heapq.heappush(hq, (d1+1, i))
    return d

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

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

ans = [0] * (n-1)

for i in range(n):
    d = dijkstra(edges, i)
    for j in d:
        if j != 0:
            ans[j-1] += 1

for i in ans:
    print(i//2)

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N,X,Y=MI()
    X-=1
    Y-=1
    
    
    import heapq
    class Dijkstra():
        """
        ・有向 / 無向は問わない(無向の場合は，逆向きの辺もたす)
        ・負のコストがない場合のみ
        ・計算量はO(E log|V|)　
        ・heapを使うことで頂点を走査する必要がなくなる（代わりに，距離更新したものは確定でなくともqueに入れておく）
        """
        
        
        
        
        class Edge():
            
            
            def __init__(self, _to, _cost):
                self.to =_to
                self.cost = _cost
        
        def __init__(self, V):
            
            self.G = [[] for _ in range(V)] 
            self. _E = 0 
            self._V = V 
        
        
        def E(self):
            return self._E
        
        
        def V(self):
            return self._V
        
        def add(self, _from, _to, _cost):
            
            self.G[_from].append(self.Edge(_to,_cost))
            self._E +=1
            
        def add2(self, _from, _to, _cost):
            
            self.G[_from].append(self.Edge(_to, _cost))
            self.G[_to].append(self.Edge(_from, _cost))
            self._E +=1
            
        def shortest_path(self,s):
            
            
            que = [] 
            d = [float("inf")] * self.V()
            prev = [None]*self.V() 
            d[s] = 0
            heapq.heappush(que,(0,s)) 
            
            while len(que)!=0:
                
                cost,v = heapq.heappop(que)
                
                
                if d[v] < cost:
                    continue
                    
                
                for i in range(len(self.G[v])):
                    e = self.G[v][i] 
                    if d[e.to] > d[v] + e.cost:
                        d[e.to] = d[v] + e.cost 
                        prev[e.to] = v
                        heapq.heappush(que,(d[e.to],e.to)) 
            
                        
            return d
    
        
    djk = Dijkstra(N)        
    for i in range(N-1):
        djk.add2(i,i+1,1)
    djk.add2(X,Y,1)
    
    ans=[0]*(N+1)
    
    for i in range(N):
        d=djk.shortest_path(i)
        for j in range(N):
            ans[d[j]]+=1
            
    for i in range(N-1):
        print(ans[i+1]//2)
        
    

main()

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

for i in ans:
    print(i)

Solution (Python):
import numpy as np
N, X, Y = map(int, input().split())
 
dist = []
for i in range(1, N):
    x = np.arange(i + 1, N + 1)
    
    d1 = np.abs(x - i)
    
    d2 = np.abs(i - X) + np.abs(Y - x) + 1
    
    d3 = np.abs(i - Y) + np.abs(X - x) + 1
    d = np.minimum(np.minimum(d1, d2), d3)
    dist.append(d)
 
dist = np.concatenate(dist)
count = np.bincount(dist, minlength=N)
print('\n'.join(count[1:].astype(str)))

Solution (Python):
N, ex, ey = list(map(int, input().split()))
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
count = [0 for _ in range(N)]
for start_edge in range(1, N+1):
    for end_edge in range(start_edge, N+1):
        dist = min(abs(start_edge-ex)+abs(end_edge-ey)+1,abs(end_edge-start_edge))
        count[dist] += 1

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