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:

node_num, l_connected_node, g_connected_node = [int(n) for n in input().rstrip().split()]

l_connected_node-=1
g_connected_node-=1

count=[0]*node_num

for i in range(node_num-1):
    for j in range(i+1, node_num):
        count[min(j-i, abs(i-l_connected_node)+abs(j-g_connected_node)+1)]+=1

for x in range(1, node_num):
    print(x,'jump :',count[x])

Submission status: Wrong Answer

Solution code:
import numpy as np


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

N = first_input[0]
X= first_input[1]
Y= first_input[2]

for i in range(1,N):
    all_num = N-i
    if (N-(Y-X-1))>=0:
        cut_num = N-(Y-X-1)-i
    else:
        cut_num = 0
    if (X-i)>=0:
        pre_num = X-i
    else:
        pre_num = 0
    if (N-Y+1-i)>=0:
        after_num = N-Y+1-i
    else:
        after_num = 0

    if Y-X<i:
        amari = all_num
    elif Y-X==i:
        amari = 1
    else:
        amari = 0

    num = all_num+cut_num-pre_num-after_num-amari

    print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

N = first_input[0]
X= first_input[1]
Y= first_input[2]

for i in range(1,N):
    all_num = N-i
    if (N-(Y-X-1))>=0:
        cut_num = N-(Y-X-1)-i
    else:
        cut_num = 0
    if (X-i)>=0:
        pre_num = X-i
    else:
        pre_num = 0
    if (N-Y+1-i)>=0:
        after_num = N-Y+1-i
    else:
        after_num = 0

    if Y-X<=i:
        amari = Y-X-i+1
    else:
        amari = 0

    num = all_num+cut_num-pre_num-after_num-amari

    print(num)

Submission status: Wrong Answer

Solution code:
array = list(map(int, input().split()))
miniDis = []
for i in range(1,array[0]):
  for j in range(i+1,array[0]+1):
    miniDis.append(min(j-i,abs(array[1]-i)+1+abs(array[2]-j)))
                     
for i in range(1,array[0]-1):
  print(miniDis.count(i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
l_list = []
for i in range(1, n+1):
    for j in range(i+1, n+1):
        start = i
        end = j
        l = j - i
        if start <= x and x <= end and end < y and l > x - start + y - end + 1:
            l = x - start + y - end + 1
        elif start <= x and y <= end:
            l -= y - x - 1
        elif start <= y and y <= end and x < start and l > start - x + end - y + 1:
            l = start - x + end - y + 1
        l_list.append(l)
for i in range(n-1):
    print(l_list.count(i + 1))

Submission status: Wrong Answer

Solution code:
N,X,Y = map(int, input().split())
answer= [0]*(N-1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i==j:
            break
        ans=i-j
        if j<=X and i<=Y and i>=X and Y-i+1+X-j<ans:
            ans=Y-i+1+X-j
        if j<=X and i>=Y and i-Y+1+X-j<ans:
            ans=i-Y+1+X-j
        if j>=X and j<=Y and i>=Y and i-Y+1+j-X<ans:
            ans=i-Y+1+j-X
        if j>=X and j<=Y and i>=X and i<=X and Y-i+1+j-X<ans:
            ans=Y-i+1+j-X
        answer[ans-1]=answer[ans-1]+1
for k in range (1,N):
    print(answer[k-1])

Submission status: Wrong Answer

Solution code:
N,X,Y = map(int, input().split())
answer= [0]*(N-1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i==j:
            break
        ans=N-1
        if i-j<ans:
            ans=i-j
        if j<=X and i<=Y and i>=X:
            if Y-i+1+X-j<ans:
                ans=Y-i+1+X-j
        if j<=X and i>=Y:
            if i-Y+1+X-j<ans:
                ans=i-Y+1+X-j
        if j>=X and j<=Y and i>=Y:
            if i-Y+1+j-X<ans:
                ans=i-Y+1+j-X
        if j>=X and j<=Y and i>=X and i<=X:
          if Y-i+1+j-X<ans:
            ans=Y-i+1+j-X
        answer[ans-1]=answer[ans-1]+1

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

Submission status: Wrong Answer

Solution code:
N,X,Y = map(int, input().split())
answer= [0]*(N-1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i==j:
            break
        ans=N-1
        if i-j<ans:
            ans=i-j
        if j<=X and i<=Y and i>=X:
            if Y-i+1+X-j<ans:
                ans=Y-i+1+X-j
        if j<=X and i>=Y:
            if i-Y+1+X-j<ans:
                ans=i-Y+1+X-j
        if j>=X and j<=Y and i>=Y:
            if i-Y+1+j-X<ans:
                ans=i-Y+1+j-X
        answer[ans-1]=answer[ans-1]+1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
kmax=min(n+x-y,(y-x)//2+max(x-1,n-y))
ans=[0]*(n-1)
for i in range(1,x+1):
  for j in range(n-i):
    if j<x-i:
      ans[j]+=1
    elif j==x-i:
      ans[j]+=2
    else:
      if j<n-y+x-i+1:
        ans[j]+=1
      if (y-x)%2==0:
        if j<x-i+(y-x)//2:
          ans[j]+=2
      else:
        if j<x-i+(y-x-1)//2:
          ans[j]+=2
        if j==x-i+(y-x-1)//2:
          ans[j]+=1
for i in range(x+1,n+1):
  for j in range(n-i):
    ans[j]+=1
for ii in range(len(ans)):
  print(ans[ii])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
#解答見た

n,x,y = map(int,input().split())
x,y = x-1,y-1
ans = [0 for i in range(n-1)]

for i in range(n-1):
    for j in range(i+1,n):
        dis = min(j-i, abs(x-i)+abs(y-j)+1)
        ans[dis-1] += 1
        #print(f'from{i}to{j}:{dis}')
        
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,X,Y = map(int, input().split())
cnt = np.zeros(N+1)
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if abs(X-i)+abs(j-Y)+1 < j-i:
            cnt[abs(X-i)+abs(j-Y)+1] += 1
        else:
            cnt[j-i] += 1
for i in range(1,N+1):
    print(int(cnt[i]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,X,Y = map(int, input().split())
cnt = np.zeros(N+1)
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if abs(X-i)+abs(j-Y)+1 < j-i:
            cnt[abs(X-i)+abs(j-Y)+1] += 1
        else:
            cnt[j-i] += 1
for i in range(1,N+1):
    print(cnt[i])

Submission status: Wrong Answer

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

for i in range(1, N):
  for j in range(i+1, N+1):
    diff = min(j-i, abs(i-X)+abs(j-Y)+1)
    print("i={0}, j={1}".format(i, j))
    print("j-i={0}, abs(i-X)+abs(j-Y)+1={1}".format(j-i, abs(i-X)+abs(j-Y)+1))
    print("-----")
    ans[diff] += 1

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

Submission status: Wrong Answer

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

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

for i in range(len(ls)):
    print(ls[i])

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
dist_list = [0]*N

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

for k in range(N-1):
    print(dist_list.count(k+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
count_list = [0]*n

for i in range(1,n):
  for k in range(i + 1,n + 1):
    count_list[i-1] = min(k - i,abs(a-i)+ abs(b-k) + 1)
    
for co in range(1,n +1):
  print(count_list.count(co))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
count_list = [0]*n

for i in range(1,n):
  for k in range(i + 1,n + 1):
    c = min(k - i,abs(a-i)+ abs(b-k) + 1)
    print(i,k,c)

Submission status: Wrong Answer

Solution code:
aaa = [int(i) for i in input().split()]

print(aaa)

Submission status: Wrong Answer

Solution code:
import math

str = input()
num = int(str.split()[0])
x = int(str.split()[1])
y = int(str.split()[2])

#グループ分けしてそれぞれで一列に並べてみる
#        ↓group3
#       ○○○○...○
#○○○...○        ○○○○...○
# ↑ group1       ↑group2

group_1 = x
group_3 = y-x-1
group_2 = num-y+1

for n in range(1,num):
    branch = 0
    #group_1 の枝
    if group_1 > n:
        branch += group_1-n
    #group_2 の枝
    if group_2 > n:
        branch += group_2-n
    #group_3 の枝
    if group_3 > n:
        branch += group_3-n
    #group_1,2 の枝
    if group_1 >= n and group_2 >= n:
        branch += n
    elif group_1 + group_2 >= n+1:
        if n < max(group_1,group_2):
            branch += min(group_1,group_2)
        else:
            branch += group_1 + group_2 - n
    #group_1,3 の枝
    if group_1 >= n and math.ceil(group_3/2) >= n:
        branch += n
    elif group_1 + math.ceil(group_3/2) >= n+1:
        if n < max(group_1,math.ceil(group_3/2)):
            branch += min(group_1,math.ceil(group_3/2))
        else:
            branch += group_1 + math.ceil(group_3/2) - n
    #group_2,3 の枝
    if group_2 >= n and math.ceil(group_3/2) >= n:
        branch += n
    elif group_2 + math.ceil(group_3/2) >= n+1:
        if n < max(group_2,math.ceil(group_3/2)):
            branch += min(group_2,math.ceil(group_3/2))
        else:
            branch += group_2 + math.ceil(group_3/2) - n
    #group_1,3 の枝 2を経由
    if group_1 >= n and math.floor(group_3/2) >= n-1 and n >= 2:
        branch += n-1
    elif (group_1 + math.floor(group_3/2) >= n) and n >= 2:
        if n <= max(group_1,math.floor(group_3/2)):
            branch += min(group_1,math.floor(group_3/2))
        else:
            branch += group_1 + math.floor(group_3/2) + 1 - n 
    #group_2,3 の枝 1を経由
    if group_2 >= n and math.floor(group_3/2) >= n-1 and n >= 2:
        branch += n-1
    elif (group_2 + math.floor(group_3/2) >= n) and n >= 2:
        if n <= max(group_2,math.floor(group_3/2)):
            branch += min(group_2,math.floor(group_3/2))
        else:
            branch += group_2 + math.floor(group_3/2) + 1 - n
    
    print(branch)

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    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
            distance_list[vertex] = distance
            q.append(vertex)
        
        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 d in distance_list:
            ans[d] += 1
    
    ans = list(map(lambda x: x // 2, ans))
    print(*ans, sep='\n')
        

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
print('\n'.join(map(str, [sum([[(j-i)-(Y-X)+1 if i<=X<Y<=j else (j-i) for j in range(1, N+1) if i<j] for i in range(1, N+1)], []).count(k) for k in range(1, N)])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-*-

from sys import stdin


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

    cost = []
    for i in range(N):
        for j in range(i + 1, N):
            if i <= X < Y <= j:
                cost.append((X - i) + 1 + j - Y)
            elif X < i < Y <= j:
                left = i - X + 1
                right = Y - i
                if left <= right:
                    cost.append(left + j - Y)
                else:
                    cost.append(j - i)
            elif i <= X < j < Y:
                left = j - X
                right = Y - j + 1
                if left < right:
                    cost.append(j - i)
                else:
                    cost.append(X - i + right)
            else:
                cost.append(j - i)
    for i in range(1, N):
        print(cost.count(i))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

answer = [0 for n in range(N - 1)]
for i in range(N):
  for j in range(N):
    if d[i][j] != - 1:
      answer[d[i][j] - 1] += 1
print(answer)
for i in range(len(answer)):
  print(answer[i])

Submission status: Wrong Answer

Solution code:
num = input().split(' ')
num_data = [int(num[i]) for i in range(3)]
#N X Y
cost = [0 for i in range(num_data[0] - 1)] #start position has the lowest number
for i in range(num_data[0]):
    for l in range(num_data[0]):
        if(l != i):
            result = min(abs(i - l),abs(i - num_data[1] + 1) + 1 + abs(l - num_data[2] + 1),abs(i - num_data[2] + 1) + 1 + abs(l - num_data[1] + 1))
            cost[int(result) - 1] += 1
for per in cost:
    print(int(per))

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
X = min(x,y)
Y = max(x,y)
x =X
y = Y
sum = x +y +1
dist = x+1
for i in range(2,dist):
	sum += dist//i
dist = n+1-y
for j in range(2,dist):
	sum += dist//j
dist = y+1-x
sum+= dist
for k in range(2,dist):
  sum += dist//k
sum+= y-n+2

Submission status: Wrong Answer

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

lst = [0 for _ in range(1, n-1)]
for _ in itertools.combinations([_ for _ in range(1, n+1)], 2):
    i, j = _[0], _[1] 
    ans = min(abs(i-j), abs(x-j)+1+abs(y-i),abs(x-i)+1+abs(y-j))
    lst[ans-1] += 1
    
for _ in lst:
    print(_)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, X, Y= map(int, input().split())
l = N + X - Y + 1
for k in range(1,N):
    count = 0
    i = 1
    while i+k <= N:
        if i > X or  Y > i+k: 
            count += 1
        else:
            pass
        if i <= X and i+k >= X + 1:
            count += 1
        i +=1
    print(count)

Submission status: Wrong Answer

Solution code:
N, X, Y= map(int, input().split())
for k in range(1,N):
    count = 0
    i = 1
    while i+k < N:
        if i > X or  Y > i+k: 
            count += 1
        else:
            if i+k-1 <= X:
                count += 1
        i +=1
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,x,y=map(int,input().split())

result = {}
for i in range(1,n):
  result[i]=0

# 経路を3つに分ける 1. 順番通り 2. 1つ目分岐して2つ目で戻るor2つ目の分岐点just 3. 1つ目分岐して2つ目は進む
for i in range(1,n): # 左側
  right = [0]*(n+1) # 右側候補
  for j in range(1,n-i+1): # 距離
    first = i+j # 1つ目の点
    if first<=n and right[first]==0: # 1つ目の経路 i+j
      result[j]+=1
      right[first]=1

    if j-1-abs(x-i)>=0: # 2つ目の経路の点のyからの距離
      second = y - (j-1-abs(x-i))     
      if second>first and right[second]==0: # 2つ目の経路 j-1-abs(x-i)
        result[j]+=1
        right[second]=1

    if  j-1-abs(x-i)>0: # 3つ目の経路の点のyからの距離
      third = y + j-1-abs(x-i) # 3つ目の点
      if 0<third<=n and right[third]==0: #  3つ目の経路
        result[j]+=1
        right[third]=1

for key in result:
  print(result[key])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,x,y=map(int,input().split())

result = {}
for i in range(1,n):
  result[i]=0

# 経路を3つに分ける 1. 順番通り 2. 1つ目分岐して2つ目で戻るor2つ目の分岐点just 3. 1つ目分岐して2つ目は進む
for i in range(1,n): # 左側
  right = [0]*(n+1) # 右側候補
  for j in range(1,n-i+1): # 距離
    first = i+j # 1つ目の点

    if j-1-abs(x-i)>=0: # 2つ目の経路の点のyからの距離
      second = y - (j-1-abs(x-i))

    else:
      second=0

    if  j-1-abs(x-i)>0: # 3つ目の経路の点のyからの距離
      third = y + j-1-abs(x-i) # 3つ目の点

    else:
      third=0

    if first<=n and right[first]==0: # 1つ目の経路 i+j
      result[j]+=1
      right[first]=1
     
    if second>first and right[second]==0: # 2つ目の経路 j-1-abs(x-i)
      result[j]+=1
      right[second]=1

    if 0<third<=n and right[third]==0: #  3つ目の経路
      result[j]+=1
      right[third]=1


for key in result:
  print(result[key])

Submission status: Wrong Answer

Solution code:
def dijkstra(graph, start):
	### initialize
	n_node = len(graph)
	d = [float('inf') for n in range(n_node)]
	d[start] = 0
	Q = [(_d, n) for _d, n in zip(d, range(n_node))]
	Q.sort()

	### search
	while(len(Q)!=0):
		u = Q[0][1]
		del Q[0]
		for v in range(n_node):
			if graph[u][v]==1 and d[v] > d[u]+1:
				d[v] = d[u]+1
	return d


if __name__=='__main__':
	N, X, Y = [int(i) for i in input().split()]

	### graph making
	graph = [[0 for n in range(N)] for n in range(N)]
	graph[X-1][Y-1] = 1
	graph[Y-1][X-1] = 1
	for n in range(N-1):
		graph[n][n+1] = 1
		graph[n+1][n] = 1

	### call dijkstra
	l = []
	for n in range(N-1): l.extend(dijkstra(graph, n)[n+1:])
	for n in range(1,N): print(l.count(n))

Submission status: Wrong Answer

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

count=[0]*N

def bfs(start):
    dist=[-1]*(N+1)#indexと頂点の番号を合わせる
    q=queue.Queue()
    q.put([start,0])
    dist[start]=0
    while not q.empty():
        j,kyori=q.get()

        if j-1>=1:
            if dist[j-1]==-1:
                q.put([j-1,kyori+1])
                dist[j-1]=kyori+1

        if j+1<=N:
            if dist[j+1]==-1:
                q.put([j+1,kyori+1])
                dist[j+1]=kyori+1
        
        if j == X and dist[Y]==-1:
            q.put([Y,kyori+1])
            dist[Y]=kyori+1

        if j == Y and dist[X]==-1:
            q.put([X,kyori+1])
            dist[X]=kyori+1

    return dist

def main():
    for start in range(1,N+1):
        dist=bfs(start)
        for d in dist:
            count[d]+=1

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

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	N, X, Y = map(int, input().split())

	ans = 0

	for k in range(1,N):
		ans = 0
		for i in range(1,N):
			for j in range(i+1,N+1):
				l1 = abs(j-i)
				l2 = abs(X-i) + 1 + abs(j-Y)
				l3 = abs(Y-i) + 1 + abs(j-X)

				lm = min(l1,l2,l3)

				if lm == k:
					if lm == l1:
						ans += 1
					if lm == l2:
						ans += 1
					if lm == l3:
						ans += 1

		print(ans)

Submission status: Wrong Answer

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

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

for i in range(1,n+1):
    for j in range(i+1,n+1):
        print(i,j)
        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])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

lists = [0] * (N - 1)

for i in range(N - 1):
  for j in range(i + 1, N):
    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)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,X,Y=map(int,input().split())
c=np.zeros((N+1,N+1),dtype=int)

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

print(c)
K=[0]*(N+100)
for i in range(1,N):
  for j in range(i+1,N+1):
    K[c[i][j]]+=1
for i in range(1,N):
  print(K[i])

Submission status: Wrong Answer

Solution code:
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:
        #print(f"{n}C{r} = {ret}")
        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))
    print(X, Y)

    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
            #print(a, b, d)

            result[d] += 1

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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+1, -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])

Submission status: Wrong Answer

Solution code:
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+1, -1):
        d[i][j] = d[i][j+1]+1
print(d)
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])

Submission status: Wrong Answer

Solution code:
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):
    for j in range(y, n):
        d[i][j] -= i-x
    for j in range(y-1, x+3*(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])

Submission status: Wrong Answer

Solution code:
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):
    for j in range(y, n):
        d[i][j] -= i-x
    for j in range(y-1, x+3*(y-x)//2+1, -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])

Submission status: Wrong Answer

Solution code:
N, X, Y= map(int, input().split(' '))
 
node = []
for k in range(1, N+1):
    for v in range(k, N+1):
       node.append(min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1]))

for i in range(1, N+1):
    print(node.count(i))

Submission status: Wrong Answer

Solution code:
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, sep="\n")

Submission status: Wrong Answer

Solution code:
N,X,Y=tuple(int(num) for num in input().split(" "))


A=[i for i in range(1,N+1) if i < ((X+Y)/2-0.5)]
B=[i for i in range(1,N+1) if i > ((X+Y)/2+0.5)]
Ans=[i for i in range(1,N)]
Ans.reverse()

for a,b in [(a,b) for a in A for b in B if a<=X or Y<=b]:
    inc=abs(a-X)+abs(b-Y)+1
    dec=abs(b-a)
    Ans[inc-1]+=1
    Ans[dec-1]-=1

for a in Ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N,X,Y=tuple(int(num) for num in input().split(" "))


A=[i for i in range(1,N+1) if i < (X+Y)/2-0.5]
B=[i for i in range(1,N+1) if i > (X+Y)/2+0.5]
Ans=[i for i in range(1,N)]
Ans.reverse()

for a,b in [(a,b) for a in A for b in B if a<=X or Y<=b]:
    inc=abs(a-X)+abs(b-Y)+1
    dec=abs(b-a)
    Ans[inc-1]+=1
    Ans[dec-1]-=1

for a in Ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N,X,Y=tuple(int(num) for num in input().split(" "))


A=[i for i in range(1,N+1) if i < (X+Y)/2-0.5]
B=[i for i in range(1,N+1) if i > (X+Y)/2+0.5]
Ans=[i for i in range(1,N)]
Ans.reverse()

print([(a,b) for a in A for b in B if a<=X or Y<=b])
for a,b in [(a,b) for a in A for b in B if a<=X or Y<=b]:
    inc=abs(a-X)+abs(b-Y)+1
    dec=abs(b-a)
    Ans[inc-1]+=1
    Ans[dec-1]-=1

for a in Ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N,X,Y=tuple(int(num) for num in input().split(" "))

A=[i for i in range(1,N+1) if i < (X+Y)/2]
B=[i for i in range(1,N+1) if i > (X+Y)/2]
Ans=[i for i in range(1,N)]
Ans.reverse()

for a,b in [(a,b) for a in A for b in B if a<=X or Y<=b]:
    inc=abs(a-X)+abs(b-Y)+1
    dec=abs(b-a)
    Ans[inc-1]+=1
    Ans[dec-1]-=1

for a in Ans:
    print(a)

Submission status: Wrong Answer

Solution code:
#BFS
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0] * (n)
for i in range(n):
    q = [i]
    alr = []
    d = {i:0}
    while not len(q) == 0:
        v = q.pop()
        alr.append(v)
        def count(a, b):
            q.append(a)
            if not a in d:
                d[a] = d[b] + 1
            else:
                d[a] = min(d[a], d[b]+1)
        if v-1 >= 0 and not v-1 in alr:
            count(v-1, v)
        if v+1 < n and not v+1 in alr:
            count(v+1, v)
        if v == x and not y in alr:
            count(y, v)
        if v == y and not x in alr:
            count(x, v)
    for value in d.values():
        ans[value] += 1
        
for j in range(1, n):
    print(ans[j]//2)

Submission status: Wrong Answer

Solution code:
import collections
import itertools
root = [[] for i in range(4)]
print(root)

# 解説を読んだ。
n, x, y = [int(x) for x in input().split()]

nodes = [i for i in range(1, n + 1)]
patterns = itertools.combinations(nodes, 2)

distannces = []
distannces_append = distannces.append
for p in patterns:
    routes = (
        abs(p[1] - p[0]),
        abs(x - p[0]) + 1 + abs(p[1] - y),
        abs(y - p[0]) + 1 + abs(p[1] - x)
    )
    distannces_append(min(routes))

c = collections.Counter(distannces)

# distannces_count = distannces.count
s = '\n'.join(str(c[k]) for k in range(1, n))
print(s)

# 後半 TLE したのでリストの関数をオブジェクトに格納した: だめ
# collections.Counter 導入: だめ。
# print 回数を減らすため事前に改行文字列作成: だめ