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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a1, a2 = map(int, input().split(" "))
print(n)
wa = a2 - a1 + 1
l1 = a1 - 1
l2 = n - a2
hwa = wa // 2
pari = wa % 2
# print(wa,l1,l2,hwa,pari)

tmp = 0
for i in range(2, n):
    if l1 + l2 + 1 >= i:
        tmp += l1 + l2 - i + 2
    if i - 1 <= l1:
        tmp -= 1
    if i - 1 <= l2:
        tmp -= 1
    # print("himonokazu",tmp)
    if hwa > i:
        tmp += wa
    elif hwa == i:
        tmp += hwa
    # print("wamoirete",tmp)
    # print((i-1),(hwa-1),(l1-1),l2-1)
    if i <= hwa + l1:
        # print(min(hwa,l1,hwa+l1-i+1,i-1))
        tmp += min(hwa, l1, hwa + l1 - i + 1, i - 1) * 2
        if pari == 0 and hwa < i:
            tmp -= 1
            # print("l1gen")
        # print("l1",tmp)
    if i <= hwa + l2:
        # print(min(hwa,l2,hwa+l2-i+1,i-1))
        tmp += min(hwa, l2, hwa + l2 - i + 1, i - 1) * 2
        if pari == 0 and hwa < i:
            tmp -= 1
            # print("l2gen")
        # print("l2", tmp)
    print(tmp)
    tmp = 0

Submission status: Wrong Answer

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

import collections
c=collections.Counter(List)
Newlist=list(c.values())
for p in Newlist:
  print(p)

Submission status: Wrong Answer

Solution code:
n,a1,a2=map(int,input().split(" "))
print(n)
wa=a2-a1+1
l1=a1-1
l2=n-a2
hwa=wa//2
pari=wa%2
#print(wa,l1,l2,hwa,pari)

tmp=0
for i in range(2,n):
    if l1+l2+1>=i:
        tmp+=l1+l2-i+2
    if i-1<=l1:
        tmp-=1
    if i-1<=l2:
        tmp-=1
    #print("himonokazu",tmp)
    if hwa>=i:
        tmp+=wa
    #print("wamoirete",tmp)
    #print((i-1),(hwa-1),(l1-1),l2-1)
    if i<=hwa+l1:
        #print(min(hwa,l1,hwa+l1-i+1,i-1))
        tmp+=min(hwa,l1,hwa+l1-i+1,i-1)*2
        if pari == 0 and hwa < i:
            tmp -= 1
            #print("l1gen")
        #print("l1",tmp)
    if i<=hwa+l2:
        #print(min(hwa,l2,hwa+l2-i+1,i-1))
        tmp+=min(hwa,l2,hwa+l2-i+1,i-1)*2
        if pari == 0 and hwa < i:
            tmp -= 1
            #print("l2gen")
        #print("l2", tmp)
    print(tmp)
    tmp=0

Submission status: Wrong Answer

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):
        if i<=X and j>=Y:
            A[j-i-Y+X+1] += 1
        else:
            A[j-i] += 1
for i in range(1, N):
    print(A[i])

Submission status: Wrong Answer

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

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

import collections
u2 = collections.Counter(u)
u2 = list(u2.items())
for k in range(n):
    u2.append((0,0))

for i in range(n):
    if u2[i][0] == i+1:
        print(u2[i][1])
    else:
        print(0)

Submission status: Wrong Answer

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



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

Submission status: Wrong Answer

Solution code:
# import sys
# import numpy as np

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


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

    ans_list = [0 for _ in range(N)]
    for i in range(N-1):
        for j in range(i+1, N):
            dist1 = j-i
            dist2 = abs(X-i-1) + 1 + abs(Y-j-1)

            ans = min(dist1, dist2)
            ans_list[ans] += 1

    for n in ans_list:
        print(n)

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
# input処理を高速化する
input = sys.stdin.readline

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

# dp =[[0]*(N) for _ in range(N)]
# for j in range(N-1):
#     dp[j][j+1]=1
#     dp[j+1][j]=1

# # 線がついているところ
# dp[X-1][Y-1] = 1
# dp[Y-1][X-1] = 1

# print(*dp,sep="\n")

def dist(s,g):
    if s==X and g==Y:
        return 1
    else:
        return min(g-s,abs(s-X)+1+abs(g-Y))

for k in range(1,N):
    cnt =0
    if k==1:
        print(N)
    else:
        for i in range(1,N+1):
            for j in range(i+1,N+1):
                if abs(j-i)>k:
                    continue
                if dist(i,j) == k:
                    cnt+=1
    print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
# input処理を高速化する
input = sys.stdin.readline

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

# dp =[[0]*(N) for _ in range(N)]
# for j in range(N-1):
#     dp[j][j+1]=1
#     dp[j+1][j]=1

# # 線がついているところ
# dp[X-1][Y-1] = 1
# dp[Y-1][X-1] = 1

# print(*dp,sep="\n")

def dist(s,g):
    if s==X and g==Y:
        return 1
    else:
        return min(g-s,abs(s-X)+1+abs(g-Y))

for k in range(1,N):
    cnt =0
    if k==1:
        print(N)
    else:
        for i in range(1,N+1):
            for j in range(i+1,N+1):
                if abs(j-i)>k:
                    continue
                if dist(i,j) == k:
                    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
# input処理を高速化する
input = sys.stdin.readline

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

dp =[[0]*(N) for _ in range(N)]
for j in range(N-1):
    dp[j][j+1]=1
    dp[j+1][j]=1

# 線がついているところ
dp[X-1][Y-1] = 1
dp[Y-1][X-1] = 1

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

def dist(s,g):
    if s<=X and Y<=g:
        return X-s + 1 + g-Y
    elif s==X and g==Y:
        return 1
    else:
        return min(g-s,abs(s-X)+1+abs(g-Y))

for k in range(1,N):
    cnt =0
    if k==1:
        print(N)
    else:
        for i in range(1,N+1):
            for j in range(i+1,N+1):
                if dist(i,j) == k:
                    cnt+=1
        print(cnt)

Submission status: Wrong Answer

Solution code:
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
from collections import Counter

n, x, y = list(map(int, input().split()))
graph = [[0]*n for _ in range(n)]

# 辺を張る
for i in range(n-1):
    print(i)
    graph[i][i+1] = 1
    graph[i+1][i] = 0
graph[x-1][y-1] = 1
graph[y-1][x-1] = 1

graph = csr_matrix(graph)

# 各点からの最短距離を求める
counter = Counter()
for i in range(n):
    dist = dijkstra(csgraph=graph, directed=False, indices=i)
    counter += Counter(dist)
    print(counter)

# 答えを出力
for i in range(1, n):
    print(counter[i] // 2)

Submission status: Wrong Answer

Solution code:
N,X,Y=map(int,input().split())
A=[0]*(N+1)
for i in range(1,N):
  for j in range(i+1,N+1):
    if i<=X and Y<=j:
      A[X-i+j-Y+1]+=1
    elif (i<=X and j<=X) or (Y<=i and Y<=j):
      A[j-i]+=1
    elif i<=X and X<j<Y:
      A[X-i+min(j-X,Y-j+1)]+=1
    elif X<i<Y and Y<=j:
      A[j-Y+min(Y-i,i-X+1)]+=1
    else:
      A[min(j-i,X-i+1+Y-j)]+=1
for k in range(1,N):
  print(A[k])

Submission status: Wrong Answer

Solution code:
import queue


n,x,y = map(int, input().split())
INF = 10**4
road = {i:[i+1] if i!=n-1 else [] for i in range(0,n)}
road[x-1].append(y-1)
res = [[INF if t!=i else 0 for t in range(n)] for i in range(n)]
ans = [0 for i in range(n-1)]
for i in range(0,n):
    s = queue.Queue()
    s.put(i)
    check = set()
    while not s.empty():
        a = s.get()
        for j in road[a]:
            res[i][j] = res[j][i] = min(res[i][a]+1,res[i][j])
            if not j in check:
                s.put(j)
                check.add(j)
    t = set(res[i])
    t.remove(0)
    for j in t:
        ans[j-1] += res[i].count(j)

[print(i//2) for i in ans]

Submission status: Wrong Answer

Solution code:
tmp = list(map(int, input().split()))
n, x, y = tmp
cnt = [0 for k in range(n-1)]

for i in range(n-1):
    for j in range(i+1, n):
        if i+1 > x or j+1 < y:
            cnt[j-i-1] += 1
        else:
            c = j+x+1-i-y
            cnt[c-1] += 1

for c in cnt:
    print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def count(k, n):
  counter = 0
  for i in range(1, n):
    for j in range(i+1, n+1):
      if i <= x and y <= j:
        if k == ((j - i) - (y - x) + 1):
          counter += 1
      else:
        if k == (j - i):
          counter += 1
  return counter

def main():
  for k in range(1, n):
    print(count(k, n))
    
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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):
        # 使わない場合
        a = abs(j - i)
        # 使う場合
        b = abs(i - X) + abs(j - Y) + 1
        ans[(min(a, b))] += 1
for i in ans:
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
    if i <= X and X < j < Y and (j - i) > (X - i + 1 + (Y - j)):
        t = (X - i + 1 + (Y - j))
    elif j >= Y and X <= i < Y and j - i > (i - X + 1 + (j - Y)):
        t = (i - X + 1 + (j - Y))
    elif i <= X and Y <= j:
      t = j - i - (Y - X - 1)
    else:
      t = j - i
    A[t] += 1
A.pop(0)
[print(i) for i in A]

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
n, x, y = [int(i) for i in input().split()]
# 0 index is 1 distance
result = [0] * (n-1)

for i in range(n-1):
	for j in range(i+1, n):
		if ((x-1) < i or j < (x-1)) and ((y-1) < i or j < (y-1)):
			dist = j - i
			result[dist-1] += 1 
		else:
			dist = min(j-i, abs(x-1-i) + 1 + abs(j-y+1))
			result[dist-1] += 1

for ans in result:
	print(ans)


# TLE

# import queue
	
# q = queue.Queue()
# n, x, y = [int(i) for i in input().split()]
# result = [0] * (n-1)

# for p in range(n):
# 	dist_list = [111111] * n
# 	dist = 0
# 	q.put(p)
# 	dist_list[p] = dist 
# 	while not q.empty():
# 		p = q.get()
# 		dist = dist_list[p]
# 		if p+1 < n: 
# 			if dist_list[p+1] > dist:
# 				dist_list[p+1] = dist
# 				q.put(p+1)
# 		if p-1 < n: 
# 			if dist_list[p-1] > dist:
# 				dist_list[p-1] = dist
# 				q.put(p-1)
# 		if p == (x-1): 
# 			if dist_list[y-1] > dist:
# 				dist_list[y-1] = dist
# 				q.put(y-1)
# 		if p == (y-1): 
# 			if dist_list[x-1] > dist:
# 				dist_list[x-1] = dist
# 				q.put(x-1)

# 	for i in dist_list:
# 		if i != 0:
# 			result[i-1] += 1

# for ans in result:
# 	print(ans//2)

Submission status: Wrong Answer

Solution code:
n, x, y = [int(i) for i in input().split()]
# 0 index is 1 distance
result = [0] * (n-1)

for i in range(n-1):
	for j in range(i+1, n):
		if ((x-1) < i or j < (x-1)) and ((y-1) < i or j < (y-1)):
			dist = j - i
			result[dist-1] += 1 
		else:
			dist = min(j-i, abs(x-1-i) + 1 + abs(j-y+1), abs(i-x+1) + 1 + abs(y-1-j))
			result[dist-1] += 1

for ans in result:
	print(ans)


# TLE

# import queue
	
# q = queue.Queue()
# n, x, y = [int(i) for i in input().split()]
# result = [0] * (n-1)

# for p in range(n):
# 	dist_list = [111111] * n
# 	dist = 0
# 	q.put(p)
# 	dist_list[p] = dist 
# 	while not q.empty():
# 		p = q.get()
# 		dist = dist_list[p]
# 		if p+1 < n: 
# 			if dist_list[p+1] > dist:
# 				dist_list[p+1] = dist
# 				q.put(p+1)
# 		if p-1 < n: 
# 			if dist_list[p-1] > dist:
# 				dist_list[p-1] = dist
# 				q.put(p-1)
# 		if p == (x-1): 
# 			if dist_list[y-1] > dist:
# 				dist_list[y-1] = dist
# 				q.put(y-1)
# 		if p == (y-1): 
# 			if dist_list[x-1] > dist:
# 				dist_list[x-1] = dist
# 				q.put(x-1)

# 	for i in dist_list:
# 		if i != 0:
# 			result[i-1] += 1

# for ans in result:
# 	print(ans//2)

Submission status: Wrong Answer

Solution code:
n, x, y = [int(i) for i in input().split()]
# 0 index is 1 distance
result = [0] * (n-1)

for i in range(n-1):
	for j in range(i+1, n):
		if ((x-1) < i or j < (x-1)) and ((y-1) < i or j < (y-1)):
			dist = j - i
			result[dist-1] += 1 
		else:
			dist = min(j-i, abs(x-1-i) + 1 + abs(j-y+1), abs(i-x+1) + 1 + abs(y-1-j))
			result[dist-1] += 1
		print("a", i, j, result)

for ans in result:
	print(ans)


# TLE

# import queue
	
# q = queue.Queue()
# n, x, y = [int(i) for i in input().split()]
# result = [0] * (n-1)

# for p in range(n):
# 	dist_list = [111111] * n
# 	dist = 0
# 	q.put(p)
# 	dist_list[p] = dist 
# 	while not q.empty():
# 		p = q.get()
# 		dist = dist_list[p]
# 		if p+1 < n: 
# 			if dist_list[p+1] > dist:
# 				dist_list[p+1] = dist
# 				q.put(p+1)
# 		if p-1 < n: 
# 			if dist_list[p-1] > dist:
# 				dist_list[p-1] = dist
# 				q.put(p-1)
# 		if p == (x-1): 
# 			if dist_list[y-1] > dist:
# 				dist_list[y-1] = dist
# 				q.put(y-1)
# 		if p == (y-1): 
# 			if dist_list[x-1] > dist:
# 				dist_list[x-1] = dist
# 				q.put(x-1)

# 	for i in dist_list:
# 		if i != 0:
# 			result[i-1] += 1

# for ans in result:
# 	print(ans//2)

Submission status: Wrong Answer

Solution code:
def bfs(linkL, chckL, nextNL, breath):
    pasNL = []
    for item in nextNL:
        chckL[item] = breath

    for item in nextNL:
        for lnkItem in linkL[item]:
            linkL[lnkItem].remove(item)
            if (chckL[lnkItem] != -1) and (lnkItem not in pasNL):
                pasNL.append(lnkItem)
        linkL[item] = []
    
    if len(pasNL) == 0:
        return chckL
    else:
        chckL = bfs(linkL, chckL, pasNL, breath+1)
        return chckL

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

lList = []

for indx in range(N):
    tmpList = []
    if indx != 0:   tmpList.append(indx-1)
    if indx != N-1: tmpList.append(indx+1)
    if indx == X-1: tmpList.append(Y-1)
    if indx == Y-1: tmpList.append(X-1)
    lList.append(tmpList)

mySum = [0] * (N-1)

for baseIndx in range(N):
    chckList = [-1] * N

    chckList = bfs(lList, chckList, [baseIndx], 0)
    chckList = chckList[baseIndx+1:N]

    for sumIndx in range(N-1):
        mySum[sumIndx] += chckList.count(sumIndx+1)

for printIndx in range(N-1):
    print(mySum[printIndx])

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
ans=[0]*n #個数を数えるのにバケットを用意する
for i in range(1,n+1): #i<jなるすべての頂点の組について最短距離を求める
    for j in range(i+1,n+1):
        dist1=j-i
        dist2=abs(x-i)+abs(y-j)+1
        dist3=abs(y-i)+abs(x-j)+1
        print(dist1,dist2,dist3)
        d=min(dist1,dist2,dist3) #最短距離は上式により求められる
        ans[d]+=1 #最短距離がdとなる組の個数を1増やす
for i in range(1,n):
    print(ans[i])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X, Y = MAP()
graph = [[] for i in range(N)]

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

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

dic = defaultdict(int)

for i in range(N):
    q = deque()
    q.append(i)
    dist = [INF] * N
    dist[i] = 0
    while q:
        n = q.popleft()
        for node in graph[n]:
            if dist[node] == INF:
                dist[node] = dist[n] + 1
                q.append(node)
        
        for d in dist:
            dic[d] += 1

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

Submission status: Wrong Answer

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

    x -= 1
    y -= 1

    res = [0]*(n)

    for i in range(n-1):
        for j in range(i+1, n):
            if (i <=x and j >= y):
                act = j - i
                now = act - (y - x - 1)
                res[now] += 1
            else:
                res[j-i] += 1
    for i in range(1,n):
        print(res[i])

main()

Submission status: Wrong Answer

Solution code:
n, x, y = map(int,input().split())
dist = [0] * n
x -= 1
y -= 1
for i in range(n):
  for j in range(i+1, n):
    if (i <= x and j <= x) or (x < i < y and x < j < y) or (y <= i and y <= j):
      dist[j-i] += 1
    elif i <= x and y <= j:
      dist[j-i-(y-x)+1] += 1
    elif i <= x <= j <= y:
      dist[x-i + min(j-x, y-j+1)] += 1
    else:
      dist[j-y + min(y-i, i-x+1)] += 1
for d in dist[1:]:
  print(d)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

x -= 1
y -= 1

storage = defaultdict(int)

def find_distance(a, b):
    if (a == x and b == y) or (a == y and b == x):
        return 1
    elif (a <= x and b >= y) or (b <= x and a >= y):
        return abs(b - a) - (y - x - 1)
    else:
        return abs(a - b)

for i in range(n - 1):
    for j in range(i + 1, n):
        # print('i,j', i, j)
        # print(j-i, find_distance(x, i) + find_distance(x, j), find_distance(y, i) + find_distance(y, j))
        distance = min(j-i, find_distance(x, i) + find_distance(x, j), find_distance(y, i) + find_distance(y, j))
        # print('res', distance)
        storage[distance] += 1

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

l = [0] * n


for i in range(1,n):
    for j in range(i+1,n+1):
        if i <= x and j >= y:
            a = j-i-y+x+1
            l[a] += 1
        else:
            a = j-i
            l[a] += 1

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

Submission status: Wrong Answer

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

l = [0] * n


for i in range(1,n):
    for j in range(i+1,n):
        if i <= x and j >= y:
            a = j-i-y+x+1
            l[a] += 1
        else:
            a = j-i
            l[a] += 1

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

Submission status: Wrong Answer

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

l = [0] * n


for i in range(n):
    for j in range(i+1,n):
        if i <= x and j >= y:
            a = j-i-y+x+1
            l[a] += 1
        else:
            a = j-i
            l[a] += 1

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

Submission status: Wrong Answer

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

l = [0] * n


for i in range(n):
    for j in range(i+1,n):
        if i <= x and j >= y:
            a = j-i-y+x+1
            l[a-1] += 1
        else:
            a = j-i
            l[a-1] += 1

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

Submission status: Wrong Answer

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

l = [0] * n


for i in range(n):
    for j in range(i+1,n):
        if i <= x and j >= y:
            a = j-i-y+x+1
            l[a-1] += 1
        else:
            a = j-i
            l[a-1] += 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for e in ans:
    print(e)

Submission status: Wrong Answer

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


def count(k):
    ans=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if min(abs(j-i),abs(X-i)+abs(Y-j)+1)==k:
                ans+=1
                if ans >=4:
                    break
    return ans

for k in range(1,N):
    print(count(k))

Submission status: Wrong Answer

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


def count(k):
    count=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if min(abs(j-i),abs(X-i)+abs(Y-j)+1)==k:
                count+=1
                if count >= 4:
                    break
    return count

for k in range(1,N):
    print(count(k))

Submission status: Wrong Answer

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


def count(k):
    count=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if min(abs(j-i),abs(X-i)+abs(Y-j)+1)==k:
                count+=1
                if count >= 3:
                    break
    return count

for k in range(1,N):
    print(count(k))

Submission status: Wrong Answer

Solution code:
import queue

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

G = [[i-1, i+1] for i in range(N)]
G[0].remove(-1)
G[N-1].remove(N)
G[X-1].append(Y-1)
G[Y-1].append(X-1)

print(G)

def BFS(s, G, D):
    D[s] = 0
    already = []
    already.append(s)
    q = queue.Queue()
    q.put(s)
    while not q.empty():
        tmp = q.get()
        for i in range(len(G[tmp])):
            tmp1 = G[tmp][i]
            if not tmp1 in already:
                D[tmp1] = D[tmp] + 1
                q.put(tmp1)
                already.append(tmp1)

ans = [0] * (N)
for i in range(N):
    D = [-1] * N
    BFS(i, G, D)
    for j in range(N):
        ans[D[j]] += 1

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

Submission status: Wrong Answer

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

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

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if j < Y:
      distance[j-i-1] += 1
    else:
      if i > X:
        distance[j-i-1] += 1
      else:
        distance[j-i-1-(Y-X-1)] += 1
        
for i in distance:
  print(i)

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
obj = [number for number in range(N)]

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

Submission status: Wrong Answer

Solution code:
n,x,y = map(int,input().split())
from itertools import combinations
shortcut = (y-x)-1
result = []
for a in combinations([x for x in range(1,n+1)],2):
    length = a[1]-a[0]
    
    if (a[0]<=x) and (a[1]>=y):
        length-=shortcut
    elif (a[0]<=x) and (a[1]<y) and ((a[1]-x) > (1+y-a[1])):
        shortcut2 = a[1]-x  - (1+y-a[1])
        length-=shortcut2
    elif (a[0]>x) and (min(y,a[1])-a[0]>a[0]-x+1):
        shortcut3 = min(y,a[1])-a[0] - (a[0]-x+1)
        length-=shortcut3
        

    result.append(length)
    
from collections import Counter
c = Counter(result)
for i in range(1,n):
    print(c[i])

Submission status: Wrong Answer

Solution code:
n,x,y = map(int,input().split())
from itertools import combinations
shortcut = (y-x)-1
result = []
for a in combinations([x for x in range(1,n+1)],2):
    length = a[1]-a[0]
    
    if (a[0]<=x) and (a[1]>=y):
        length-=shortcut
    elif (a[0]<=x) and ((a[1]-x) > (1+y-a[1])):
        shortcut2 = a[1]-x  - (1+y-a[1])
        length-=shortcut2
    elif (a[0]>x) and (min(y,a[1])-a[0]>a[0]-x+1):
        shortcut3 = y-a[0] - (a[0]-x+1)
        length-=shortcut3

    result.append(length)
    
from collections import Counter
c = Counter(result)
for i in range(1,n):
    print(c[i])

Submission status: Wrong Answer

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

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



for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
import numpy as np

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x, y = map(int,input().split())
dist = [0] * n
x -= 1
y -= 1
for i in range(n):
  for j in range(i+1, n):
    if (i <= x and j <= x) or (x <= i <= y and x <= j <= y) or (y <= i and y <= j):
      dist[j-i] += 1
    elif i <= x and y <= j:
      dist[j-i-(y-x)+1] += 1
    elif i <= x and x <= j <= y:
      dist[x-i + min(j-x, y-j+1)] += 1
    else:
      dist[j-y + min(y-j, j-x+1)] += 1
for d in dist[1:]:
  print(d)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n, x, y = 5, 2, 4
inf = 10**9
#tmp = [[inf]*n]*n の様な配列の初期化では各行のidが同じになってしまう
tmp = [[inf for i in range(n)] for j in range(n-1)]
c = Counter()

def dfs(start, now, cnt):
    global tmp
    if now > n:
        return
    #print(f"{start=},{now=},{cnt=}")
    tmp[start-1][now-1] = min(cnt, tmp[start-1][now-1])
    dfs(start, now+1, cnt+1)
    if now == x:
        dfs(start, y, cnt+1)

for i in range(1, n):
    dfs(i, i, 0)
    #dfs(i, i+1, 1) これは誤り、初期値がxのときにショートカットを見逃す
    c += Counter(tmp[i-1])

ans = sorted(c.items())
for i in range(1, len(ans)-1):
    print(ans[i][1])
print(0)

Submission status: Wrong Answer

Solution code:
def resolve():
    n, x, y = map(int, input().split())
    a=y-x-1
    r=x-1
    l=n-y
    ans=0
    for i in range(1,n):
        ans+=r+1+l-n+1
        if i < a+r:
            ans+=a+r-i+1
        if i < a+l:
            ans+=a+l-i+1
        print(ans)
        ans=0
resolve()

Submission status: Wrong Answer

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

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

for i in range(n):
    print(sub_degree[i])

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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):
        if i <= X and Y <= j:
            road = min(j-i,(X-i)+(j-Y)+1)
            ans[road] += 1
        else:
            road = j-i
            ans[road] += 1

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