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,X,Y=map(int,input().split())
ans=0
right=X-1
cycle=Y-X+1
left=N-Y
import copy
ring=copy.copy(cycle)
branchr=copy.copy(right)
if right>0:
    branchr+=1
branchl=copy.copy(left)
if left>0:
    branchl+=1
ring_branchr=0
ring_branchl=0
branchrl=0
count=0
if cycle%2==0:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k==cycle//2:
            ring = cycle//2
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2:
                ring_branchr-=2*(k-cycle//2)-1
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2:
                ring_branchl-=2*(k-cycle//2)-1
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if k ==3:
                branchrl=1
            if 3<k<right+left+1:
                branchrl=2
            if k==right+left+1:
                branchrl=1
            if k>right+left+1:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
    for k in range(count+1,N):
        print(0)
if cycle%2==1:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2+1:
                ring_branchr-=2*(k-cycle//2-1)
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2+1:
                ring_branchl-=2*(k-cycle//2-1)
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if k ==3:
                branchrl=1
            if 3<k<right+left+1:
                branchrl=2
            if k==right+left+1:
                branchrl=1
            if k>right+left+1:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

Submission status: Wrong Answer

Solution code:
inputs = list(map(int, (input().split())))

n = inputs[0]
x = inputs[1] - 1  # 3
y = inputs[2] - 1  # 7
z = y - x - 1  # 3
c = y - x + 1
k = [0 for i in range(n-1)]

for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x and j >= y:
            d = j - i - z
        elif i <= x and not j >= y:
            d = min(j - i, c - j + x + x - i)
        elif not i <= x and j >= y:
            d = min(j - i, c - y + i + j - y)
        else:
            d = j - i
        # print(str(i+1) + " "+str(j+1)+" "+str(d))
        k[d - 1] += 1

print(k)

Submission status: Wrong Answer

Solution code:
import copy
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1

A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        if i <= x:
            if abs(i +j -x) <= abs(y - i -j):
                A[i][i+j] = j
            elif abs(i + j -x) > abs(y - i -j):
                A[i][i + j] = x-i + 1 + abs(y - (i+j))
        elif i>x:
            if abs(x-i)<= abs(y-i):
                A[i][i + j] = min(abs(x- i) +1 +abs(y-i - j),j)
            else:
                A[i][i+j] = j
A[X-1][Y-1] = 1
print(A)
for t in range(N):
    if t == 0:
        continue
    sum = 0
    for u in range(N):
        sum = sum + A[u].count(t)

    print(sum)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
inputs = list(map(int, (input().split())))

n = inputs[0]
x = inputs[1] - 1  # 3
y = inputs[2] - 1  # 7
z = y - x - 1  # 3
c = y - x + 1
k = [0 for i in range(n-1)]

for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x and j >= y:
            d = j - i - z
        elif i <= x and not j >= y:
            d = min(j - i, c - j + x + x - i)
        elif not i <= x and j >= y:
            d = min(j - i, c - y + i + j - y)
        else:
            d = j - i
        print(str(i+1) + " "+str(j+1)+" "+str(d))
        k[d - 1] += 1

print(k)

Submission status: Wrong Answer

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

sakaime = X + (Y - X)//2
kosuu = (Y - X)//2

def sen1(n):
    if N - (Y-X-1) > n:
        return (N - (Y-X-1) - n)
    else:
        return 0

def sen2(n):
    if kosuu + 1 > n:
        return 0
    elif X + kosuu - 1 < n:
        return 0
    else:
        return (X + kosuu - n)

def sen3(n):
    if Y - sakaime + 1 > n:
        return 0
    elif X + Y - sakaime - 1 < n:
        return 0
    else:
        return (X + Y - sakaime - n)

def sen4(n):
    if Y - sakaime + 1 > n:
        return 0
    elif N - sakaime < n:
        return 0
    else:
        return (N - sakaime + 1 - n)

def sen5(n):
    if sakaime - X + 2 > n:
        return 0
    elif N - Y + sakaime - X < n:
        return 0
    else:
        return (N - Y + sakaime - X + 1 - n)
        
def en(n):
    if (Y - X + 1)//2 + 1 > n:
        if n != 1:
            return (Y - X + 1)
        else:
            return (Y-X)
    else:
        return 0

for i in range(1,N):
    print(sen1(i) + sen2(i) + sen3(i) + sen4(i) + sen5(i) + en(i))

Submission status: Wrong Answer

Solution code:
# 各条件の入力
n, x, y = map(int, input().split())

# 判定

nodes = list(range(1, n+1))
diff = y - x - 1

def cnt_pairs(distance):
    pairs_cnt = 0
    for i in range(len(nodes)):
        for j in range(i+1, len(nodes)):
            if nodes[i] <= x and nodes[j] >= y:
                if abs(nodes[i] - nodes[j]) - diff == distance:
                    pairs_cnt += 1
            elif abs(nodes[i] - nodes[j]) == distance:
                pairs_cnt += 1
    return pairs_cnt


# 答えの出力
for i in range(len(nodes)-1):
    print(cnt_pairs(nodes[i]))

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
loop = y-x+1
line = n-y+x
l1 = x-1
l2 = n-y
print(n)
for k in range(2, n):
    ans = max(line-k+1, 0)
    if k<=loop//2:
        ans += loop
    if k-l1<=1:
        ans += (min(loop//2, k-1))*2-1
    else:
        ans += max((min(loop//2, k-1)-(k-l1)+1), 0)*2
    if k-l2<=1:
        ans += (min(loop//2, k-1))*2-1
    else:
        ans += max((min(loop//2, k-1)-(k-l2)+1), 0)*2
    print(ans)

Submission status: Wrong Answer

Solution code:
def get_pattern_count(a, b, section_len):
    m1 = max(0, section_len - 1 - a)
    m2 = max(0, section_len - 1 - b)
    return max(0, section_len - 1 - m1 - m2)

param_N, param_X, param_Y = list(map(lambda x: int(x), input().split()))

# 頂点1から頂点Nまでの最短距離
len_a = param_N - (param_Y - param_X)
# 頂点1から頂点Xまでの最短距離
len_b = param_X - 1
# 頂点Xから頂点Yまでの最長距離
len_c = param_Y - param_X
# 頂点Yから頂点Nまでの最短距離
len_d = param_N - param_Y

for i in range(1, param_N):
    count_a = max(0, len_a - i + 1)
    count_b_c = get_pattern_count(len_b, int(len_c / 2), i) + get_pattern_count(len_d + 1, int((len_c - 1) / 2), i)
    count_d_c = get_pattern_count(len_d, int(len_c / 2), i) + get_pattern_count(len_b + 1, int((len_c - 1) / 2), i)
    count_c = max(0, len_c - i + 1) if i < (len_c + 1) / 2 else 0
    if i == len_c:
        count_c -= 1
    print(count_a + count_b_c + count_d_c + max(0, count_c))

Submission status: Wrong Answer

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

ans=[0]*(n-1)

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

for a in ans:
    print(a)

Submission status: Wrong Answer

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

    dmin = [[n]*n for _ in [0]*n]

    nlist = list(range(n))

    for i in range(n):
        for j in range(i,n):
            dmin[i][j] = j-i
            dmin[j][i] = j-i

    for i in range(x):
        for j in range(y-1,n):
            dmin[i][j] -= y-x-1
            dmin[j][i] -= y-x-1


    for i in range(n):
        for j in range(x,(x+y)//2):
            t = dmin[j][x-1]+dmin[x-1][i]
            if dmin[i][j]>t:
                dmin[i][j] = t
                dmin[j][i] = t

        for j in range((x+y)//2,y):
            t = dmin[j][y-1]+dmin[y-1][i]
            if dmin[i][j]>t:
                dmin[i][j] = t
                dmin[j][i] = t

    res = [0]*(n+1)
    for dmin_ in dmin:
        for d in dmin_:
            res[d] += 1

    for r in res[1:n+1]:
        print(r//2)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# 各条件の入力
n, x, y = map(int, input().split())

# 判定

nodes = list(range(1, n+1))

def cnt_pairs(distance):
    pairs_cnt = 0
    for i in range(len(nodes)):
        for j in range(i+1, len(nodes)):
            if nodes[i] <= x and nodes[j] >= y:
                if abs(nodes[i] - nodes[j]) - 1 == distance:
                    pairs_cnt += 1
            elif abs(nodes[i] - nodes[j]) == distance:
                pairs_cnt += 1
    return pairs_cnt


# 答えの出力
for i in range(len(nodes)-1):
    print(cnt_pairs(nodes[i]))

Submission status: Wrong Answer

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

    dmin = [[n]*n for _ in [0]*n]

    nlist = list(range(n))

    for i in range(n):
        for j in range(i,n):
            dmin[i][j] = j-i
            dmin[j][i] = j-i

    for i in range(x):
        for j in range(y-1,n):
            dmin[i][j] -= y-x-1
            dmin[j][i] -= y-x-1


    for i in range(n):
        for j in range(x,(x+y)//2):
            t = dmin[j][x-1]+dmin[x-1][i]
            if dmin[i][j]>t:
                dmin[i][j] = t
                dmin[j][i] = t

        for j in range((x+y)//2,y):
            t = dmin[j][y-1]+dmin[y-1][i]
            if dmin[i][j]>t:
                dmin[i][j] = t
                dmin[j][i] = t

    res = [0]*(n+1)
    for dmin_ in dmin:
        for d in dmin_:
            res[d] += 1

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())


n,x,y=IA()
ans=[0 for i in range(0,n)]


def out():
    for i in range(1,n):
        print(ans[i])
    print()
if x==y:
    for i in range(1,n+1):
        ans[i]=n-i
else:

    m=x+n-y+1

    for i in range(1,m+1):
        ans[i]=m-i
        
    cha=y-x-1
    for i in range(1,cha+1):
        ans[i]+=cha-i
    #out()
    tt=cha//2+1

    def f(tt,x,t=0):
        if tt==1 and x==1:
            ans[1+t]+=1
        add=0
        for i in range(1+t,max(tt,x)+t):
            
            if i<=min(x,tt)+t:
                add+=1
            #print(str(i)+" "+str(add))
            ans[i]+=add

        for i in range(max(tt,x)+t,max(tt,x)+min(x,tt)+t):
            #print(str(i)+":"+str(add))
            ans[i]+=add
            add-=1
    if cha%2==1:
        f(tt,x)
        f(tt-1,n-y+1,1)
        #out()
        f(tt,n-y+1)
        #out()
        f(tt-1,x,1)

        
    else:
        f(tt-1,x)
        f(tt-1,n-y+1,1)
        
        f(tt-1,n-y+1)
        f(tt-1,x,1)
for i in range(1,n):
    print(ans[i])

Submission status: Wrong Answer

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

a=X-1
b=N-Y
c=Y-X+1

for k in range(1,N):
    #print('--k={}--'.format(k))
    ans=0
    #A
    if a < k:
        pass
    else:
        ans+=a-k+1
        #print('a')
        #print(a-k+1)
    #B
    if b < k:
        pass
    else:
        ans+=b-k+1
        #print('b')
        #print(b-k+1)
    #c
    if c/2 < k:
        pass
    else:
        ans+=c
        #print('c')
        #print(c)
    #ABC
    if a!=0 and b!=0 and 3<=k<=a+b+1:
        suba=(k-3)-(a-1) if (k-3)-(a-1)>0 else 0 
        subb=(k-3)-(b-1) if (k-3)-(b-1)>0 else 0
        ans += k-2-suba-subb
        #print('abc')
        #print(k-2-suba-subb)
    #AC
    if a!=0 and 2<=k<=a+c//2:
        aa=a-1
        cc=c//2
        suba=(k-2)-(aa) if (k-2)-(aa)>0 else 0 
        subc=(k-1)-(cc) if (k-1)-(cc)>0 else 0
        ans += (k-1-suba-subc)*2
        #print('ac')
        #print(k-1-suba-subc)
        #print(suba)
        #print(subc)
    #BC
    if b!=0 and 2<=k<=b+c//2:
        bb=b-1
        cc=c//2
        subb=(k-2)-(bb) if (k-2)-(bb)>0 else 0 
        subc=(k-1)-(cc) if (k-1)-(cc)>0 else 0
        ans += (k-1-subb-subc)*2
        #print('bc')
        #print(k-1-subb-subc)
    print(ans)

Submission status: Wrong Answer

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

ans = [0] * (N - 1)
ans[0] = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
from scipy.sparse.csgraph import dijkstra

def main():
    n,x,y=map(int,input().split())
    cost = [[0 for i in range(n)] for i in range(n)]
    #cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
    for i in range(1,n):
        cost[i-1][i] = 1
#        cost[i][i-1]=1
    cost[x-1][y-1]=1
    cost[y-1][x-1]=1
    res=tuple(dijkstra(tuple(cost), directed=False))
    print(res)
    ans = [0 for i in range(n)]
    for i in range(n):
        for j in range(i,n):
            ans[int(res[i][j])] += 1
 
    for i in range(1,n):
        print(ans[i])
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
a = [[0 for i in range(n)] for j in range(n)]
for i in range(n-1):
  for j in range(i+1, n):
    if i < x:
      if j >= y-1:
        a[i][j] = j - i - (y - x - 1)
      elif j > ((y - x + 1) / 2) + (x - 1):
        a[i][j] = (x + y - 1 - j) - i
      else:
        a[i][j] = j - i
    elif i < ((y - x + 1) / 2) + (x - 1) - 1 and j >= y-1:
      a[i][j] = j - (x + y - 3 - i)
    else:
      a[i][j] = j - i
ans = [0 for i in range(n-1)]
for i in range(n-1):
  l = i + 1
  for j in range(0, n-1):
    for k in range(j+1, n):
      if a[j][k] == l:
        ans[i] += 1
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
def chookusen(n, k):
    return n - k

def wa(n, k):
    if (n%2 == 0) and(n//2 == k):
        return n//2
    elif (n + 1) //2 > k:
        return n
    else:
        return 0
def wa_(n, k):
    if (n%2 == 0) and(n//2 == k):
        return 1
    elif k == 1:
        return 1
    elif (n + 1) //2 > k:
        return 2
    else:
        return 0

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

for k in range(1, N):
    ans = chookusen((X + N - Y + 1), k) + wa(Y - X + 1, k)

    if k == 1:
        ans -= 1

    for i in range(1, X):
        if (k - i) <= 0:
            break
        else:
            ans += wa_(Y - X + 1, k - i)

    for o in range(1, N - Y + 1):
        if (k - o) <= 0:
            break
        else:
            ans += wa_(Y - X + 1, k - o)

    print(max(ans, 0))

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N, X, Y = list(map(int, input().split()))

# N = 5
# X = 2
# Y = 4

dist = np.full(N*N, float("inf")).reshape((N, N))
np.fill_diagonal(dist, 0)
np.fill_diagonal(dist[1:], 1)
np.fill_diagonal(dist[:, 1:], 1)
dist[X-1, Y-1] = 1
dist[Y-1, X-1] = 1
changed = True
while changed:
    changed = False
    for i in range(N):
        for j in range(N):
            for k in range(N):
                dist[i, j] = min(dist[i, j], dist[i, k]+dist[k, j])
                if dist[i, j] != dist[j, i]:
                    changed = True
                dist[j, i] = dist[i, j]


print(dist)
for i in range(1, N):
    count = np.count_nonzero(dist == i)//2
    print(count)

Submission status: Wrong Answer

Solution code:
import sys
n, x, y = [int(x) for x in input().split()]
ks = [0] * n
m = (x + y) // 2
for i in range(1, x + 1):
    for j in range(i + 1, n + 1):
        if j <= x:
            ks[j - i] += 1
        elif x < j < y:
            ks[min(j - i, y - j + 1 + x - i)] += 1
        else:
            ks[j - y + 1 + x - i] += 1
for i in range(x + 1, y + 1):
    for j in range(i + 1, n + 1):
        if j <= y:
            ks[min(j - i, i - x + y - j + 1)] += 1
        else:
            ks[min(j - i, i - x + 1 + j - y)] += 1
for c in ks[1:]:
    print(c)

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x,y=INTM()
    z=y-x
    sc=y-x-1
    loop=y-x+1
    maxl=max((n-(y-x)),x+loop//2+1,(n-y)+loop//2+1)
    for i in range(1,n):
        ct=0
        if i<maxl:
            for j in range(1,n):
                if j+i<=x or j>=y:
                    if j+i<=n:
                        ct+=1
                else:
                    if j<=x:
                        if j+i+sc<=n:
                            ct+=1
                        temp=i-(x-j)
                        if temp>=2:
                            if loop>temp*2:
                                ct+=2
                            elif loop==temp*2:
                                ct+=1
                        else:
                            ct+=1
                        
                    else:
                        lpmin=min(y-j,+(j-x+1))
                        if lpmin==j-x+1:
                            if lpmin==y-j:
                                if lpmin+(n-y)>=i:
                                    ct+=1
                            else:
                                if lpmin>i:
                                    ct+=1
                                elif lpmin==i:
                                    ct+=2
                                else:
                                    if lpmin+(n-y)>=i:
                                        ct+=1
                                    
                                    if loop>i*2:
                                        ct+=2
                                    elif loop==i*2:
                                        ct+=1
                        else:
                            if lpmin+(n-y)>=i:
                                ct+=1
                #print(ct)
            print(ct)        
        else:
            print(ct)
                
        
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x,y=INTM()
    z=y-x
    sc=y-x-1
    loop=y-x+1
    maxl=max((n-(y-x)),x+loop//2+1)
    for i in range(1,n):
        ct=0
        if i<maxl:
            for j in range(1,n):
                if j+i<=x or j>=y:
                    if j+i<=n:
                        ct+=1
                else:
                    if j<=x:
                        if j+i+sc<=n:
                            ct+=1
                        temp=i-(x-j)
                        if temp>=2:
                            if loop>temp*2:
                                ct+=2
                            elif loop==temp*2:
                                ct+=1
                        else:
                            ct+=1
                        
                    else:
                        lpmin=min(y-j,+(j-x+1))
                        if lpmin==j-x+1:
                            if lpmin==y-j:
                                if lpmin+(n-y)>=i:
                                    ct+=1
                            else:
                                if lpmin>i:
                                    ct+=1
                                elif lpmin==i:
                                    ct+=2
                                else:
                                    if lpmin+(n-y)>=i:
                                        ct+=1
                                    
                                    if loop>i*2:
                                        ct+=2
                                    elif loop==i*2:
                                        ct+=1
                        else:
                            if lpmin+(n-y)>=i:
                                ct+=1
                #print(ct)
            print(ct)        
        else:
            print(ct)
                
        
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

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

result = [0] * n
for i in range(n):
    for j in range(i+1, n, 1):
        if j <= x or y <= i:
            result[(j - i - 1)] += 1  # 普通に+1
        elif x < i and j < y:
            result[(j - i - 1)] += 1 # 普通に+1
        else:
            minij = min([(j - i - 1), (abs(i - x) + 1 + abs(j - y) - 1)])
            result[minij] += 1

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

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x,y=INTM()
    z=y-x
    sc=y-x-1
    loop=y-x+1
    maxl=max((n-(y-x)),x+loop//2+1)
    for i in range(1,n):
        ct=0
        if i<=maxl:
            for j in range(1,n):
                if j+i<=x or j>=y:
                    if j+i<=n:
                        ct+=1
                else:
                    if j<=x:
                        if j+i+sc<=n:
                            ct+=1
                        temp=i-(x-j)
                        if temp>=2:
                            if loop>temp*2:
                                ct+=2
                            elif loop==temp*2:
                                ct+=1
                        else:
                            ct+=1
                        
                    else:
                        lpmin=min(y-j,+(j-x+1))
                        if lpmin==j-x+1:
                            if lpmin==y-j:
                                if lpmin+(n-y)>=i:
                                    ct+=1
                            else:
                                if lpmin>i:
                                    ct+=1
                                elif lpmin==i:
                                    ct+=2
                                else:
                                    if lpmin+(n-y)>=i:
                                        ct+=1
                                    
                                    if loop>i*2:
                                        ct+=2
                                    elif loop==i*2:
                                        ct+=1
                        else:
                            if lpmin+(n-y)>=i:
                                ct+=1
                #print(ct)
            print(ct)        
        else:
            print(ct)
                
        
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

def main():
    n, x, y = 7, 3, 7
    # n, x, y = [int(s) for s in sys.stdin.readline().strip().split()]
    score = {i: 0 for i in range(1, n)}
    total_pair = set()

    def bfs(start):
        seen = set()
        q = deque()
        q.append((0, start))
        while q:
            dist, cur = q.popleft()
            pair = (min(start, cur), max(start, cur))
            if pair in seen:
                continue
            seen.add(pair)
            if dist > 0:
                if pair not in total_pair:
                    score[dist] += 1
                    total_pair.add(pair)
            if cur < n-1:
                q.append((dist+1, cur+1))
            if cur > 0:
                q.append((dist+1, cur-1))
            if cur == x-1:
                q.append((dist+1, y-1))
            if cur == y-1:
                q.append((dist+1, x-1))

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

main()

Submission status: Wrong Answer

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


def not_cross(b, a, k):
    if k > b + a or k == 1:
        return 0
    b_max = min(k-1, b)
    a_max = min(k-1, a)

    return a_max + b_max - (k-1)


def cross(b, a, k):
    if k > b + a + 1 or k == 2:
        return 0
    return not_cross(b, a+1, k)


def straight(l, k):
    if k > l:
        return 0
    return l - (k-1)


def circle(l, k):
    if k > l // 2:
        return 0
    return l


u = X - 1
d = N - Y
m = Y - X

for i in range(N-1):
    k = i+1

    ans = 0

    ans += straight(u+1+d, k)
    ans += circle(m+1, k)
    if k == 1:
        ans -= 1
    ans += not_cross(m//2 + m % 2, u, k)
    ans += not_cross(m//2 + m % 2, d, k)
    ans += cross(m//2 - 1 + m % 2, u, k)
    ans += cross(m//2 - 1 + m % 2, d, k)

    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, X, Y = map(int, input().split())
ans = []

for i in range(N):
    for j in range(i+1, N):
        ans.append(min(j-i, 1+abs(i-X)+abs(j-Y)))

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

Submission status: Wrong Answer

Solution code:
import numpy

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import collections
N,X,Y = map(int,input().split())
ToltN=N*(N-1)/2
Dist=[[0 for i in range(N)] for i in range(N)]
for i in range(N):
    for j in range(i,N):
        Dist[i][j] = j-i
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<Dist[i][j]:
            Dist[i][j]=MyDist
for j in range(N-1):
    ans=[0]
    for i in range(N):
        ans+=Dist[i]
c = collections.Counter(ans)
for i in range(N):
    print(c[i])

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
l = [i for i in range(N)]
g = []
for i in range(N):
    g_n = []
    for j in range(N):
        g_n.append(abs(l[j] - i))
    g.append(g_n)

distance = Y - X - 1
# for i in range(Y-1, N):
#     for j in range(X):
#         g[i][j] -= distance
#     for j in range(X, X+distance//2, 1):
#         g[i][j] -= 1
for i in range(X):
    for j in range(Y-1, N):
        g[i][j] -= distance
        g[j][i] -= distance
    for j in range(Y-2, X+distance//2, -1):
        g[i][j] -= 1
        g[j][i] -= 1
for i in range(X, X+(distance//2)):
    for j in range(Y-1, N):
        g[i][j]-=1
        g[j][i]-=1


for i in range(1, N):
    ans = 0
    for j in range(N):
        ans += g[j].count(i)
    print(int(ans/2))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

ans=[0]*(n-1)

def func2(np, nd, state):
    #print(np, nd, state)
    nxp=[]
    for p in np:
        if p > 0 and not state[p-1]:
            nxp.append(p-1)
            ans[nd]+=1
        if p < n-1 and not state[p+1]:
            nxp.append(p+1)
            ans[nd]+=1
        if p == x-1 and not state[y-1]:
            nxp.append(y-1)
            ans[nd]+=1
        if p == y-1 and not state[x-1]:
            nxp.append(x-1)
            ans[nd]+=1
#    if nd == 1:
#        print(nd, nxp)

    nxp=list(set(nxp))
    for i in nxp:
        state[i]=True
    if len(nxp) == 0:
        return
    else:
        func2(nxp, nd+1, state)

for i in range(n):
    st=[False]*n
    st[i]=True
    func2([i], 0, st)

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