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())

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = min(j-i,abs(x-i)+abs(j-y)+1)
            print(ans,i,j)
            dict[ans] +=1
            
for i in range(n-1):
     print(dict[i+1])

Submission status: Wrong Answer

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

ans = [0] * (N - 1)

for i in range(1, N + 1, 1):
    for j in range(i + 1, N + 1, 1):
        tmp = min(
            abs(j - i),
            abs(X - i) + 1 + abs(j - Y),
            abs(X - j) + 1 + abs(i - Y) # このパターンは
        )
        ans[tmp - 1] += 1


print(ans)

Submission status: Wrong Answer

Solution code:
N, R1, R2 = map(int, input().split())
count={}
for m in range(N-1):
    count[m+1] = 0 
for i in range(N):
    for j in range(i+1, N):
        if i <= R1-1 and j >= R2-1:
            count[j-i-(R2-R1-1)] +=1
        else:
            count[j-i] += 1
for k in count.values():
    print(k)

Submission status: Wrong Answer

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    n,x,y = map(int, input().split())
    costList = [0]*n

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


    for i in range(n):
        if i >0:
            print(costList[i])

Submission status: Wrong Answer

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    n,x,y = map(int, input().split())
    costList = [0]*n

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


    for i in range(n):
        if i >0:
            print(costList[i]//2)

Submission status: Wrong Answer

Solution code:
from collections import deque
n,x,y=map(int,input().split())
x-=1
y-=1
g=[[] for i in range(n)]
g[x].append(y)
g[y].append(x)
for i in range(n-1):
    g[i].append(i+1)
    g[i+1].append(i)
ans=[0]*n
for i in range(n):
    s=i
    q=deque([s])
    v=[-1]*n
    v[s]=0
    while q:
        p=q.popleft()
        for j in g[p]:
            if v[j]==-1:
                ans[v[p]]+=1
                v[j]=v[p]+1
                q.append(j)
for i in ans:
    print(i//2)

Submission status: Wrong Answer

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

for k in range(0,n-1):
  print(int(t[k]))

Submission status: Wrong Answer

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, X, Y = iim()
    ans = [N-i-1 for i in range(N-1)]
    X1, Y1 = X-1, Y -1

    xy2 = (X+Y)  // 2
    for i in range(max(0, X-xy2), xy2):
        x1 = X1 - i
        if x1 < 0: x1 = -x1
        for j in range(xy2, min(Y+xy2, N)):
            d1 = j - i - 1
            y1 = Y1-j
            if y1 < 0: y1 = -y1
            d2 = x1 + y1
            if d1 > d2:
                #print((i+1, j+1), d1+1, d2+1, x1, y1)
                ans[d1] -= 1
                ans[d2] += 1

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    n,x,y = map(int, input().split())
    costList = [0]*n

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


    for i in range(n):
        if i >0:
            print(costList[i]//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,x,y = [int(i) for i in input().split()]
ans = []
for i in range(1,n):
  for j in range(i+1,n+1):
    chk = j-i
    if i<=x<y<=j:
      chk = min(chk,1+x-i+j-y)
    elif i<=x<j<y:
      chk = min(chk,x-i+1+y-j)
    elif x<i<y<=j:
      chk = min(chk,i-x+j-y+1)
    ans.append(chk)
    
import collections
c = collections.Counter(ans)
for i in range(1,n):
  print(c[i])

Submission status: Wrong Answer

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

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = min(j-i,abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
            print(ans,i,j)
            dict[ans] +=1
            
print(dict)

Submission status: Wrong Answer

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

g = [[1000000000 if i != j else 0 for j in range(n)] for i in range(n)]
for i in range(n-1):
    g[i][i+1] = 1
    g[i+1][i] = 1

x -= 1
y -= 1
g[y][x] = 1
g[x][y] = 1


for i in range(n):
    for j in range(n):
        for k in range(n):
            if g[i][j] > g[i][k] + g[k][j]:
                g[i][j] = g[i][k] + g[k][j]

ds = [0] * n

for xs in g:
    for x in xs:
        ds[x] += 1

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

Submission status: Wrong Answer

Solution code:

#####

import numpy as np
# from collections import Counter
# import itertools

#####

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	n,x,y=getIntList(inputs[0])
	
	count=np.zeros(n-1, np.int32)
	
	between=y-x-1
	if between%2==0:
		middleL=between//2
		middleR=between//2
	else:
		middleL=between//2+1
		middleR=between//2
	left=x-1
	right=n-y
	
	depth0=x+middleL
	depth1=x+middleR+1
	depth2=x+right+1
	length=max(depth0,depth1,depth2)
	numDepth=np.zeros(length)
	numDepth[:x]=1
	numDepth[x:depth0]+=1
	numDepth[x:depth1]+=1
	numDepth[x+1:depth2]+=1
	
	for d in range(1, length):
		count[d-1]=numDepth[d:d+x-1].sum()
# 	print("a",count)
# 	count[...]=0 ###
	
	x0=x
	y0=y
	
	x=n-(y0-1)
	y=n-(x0-1)
	
	between=y-x-1
	if between%2==0:
		middleL=between//2
		middleR=between//2
	else:
		middleL=between//2+1
		middleR=between//2
	left=x-1
	right=n-y
	
	depth0=x+middleL
	depth1=x+middleR+1
	length=max(depth0,depth1)
	numDepth=np.zeros(length)
	numDepth[:x]=1
	numDepth[x:depth0]+=1
	numDepth[x:depth1]+=1
# 	print(numDepth)
	
	for d in range(1, length):
		count[d-1]+=numDepth[d:d+x-1].sum()
# 	print("b",count)
# 	count[...]=0 ###
	
	middle=middleL+middleR+2
	count[:middle//2]+=middle
# 	print("c", count)
	
	for c in count: print(c)

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)

Submission status: Wrong Answer

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

distances = [0]*N
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))
        distances[d] += 1

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
N = a[0]
X = a[1]
Y = a[2]
ans = list(range(N+1))
for k in range(1,N+1):
  ans[k] = 0
 
for i in range(1,N):
  for j in range(i+1,N+1):
    k = min(j-i,abs(X-i)+1+abs(j-Y))
    ans[k] = ans[k]+1
 
for dist in ans:
  print(dist)

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,x,y = mi()
dist = y-x
import numpy as np
d = np.array([[0]*n for i in range(n)])
br = [[] for i in range(n)]
for i in range(1,n-1):
    br[i].append(i-1)
    br[i].append(i+1)
br[0].append(1)
br[n-1].append(n-2)
br[x-1].append(y-1)
br[y-1].append(x-1)
from collections import deque
l=deque()
for i in range(n):
    l.append(i)
    b = [-1]*n
    b[i]=1
    d[i][i]=0
    while len(l)>0:
        nn = l.popleft()
        for j in br[nn]:
            if b[j] ==-1:
                l.append(j)
                b[j] = 1
                d[i][j] = d[i][nn]+1


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

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
ans=[0 for i in range(n)]
gone=[0 for i in range(n)]
for start in range(n):
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]!=i:
        go.add(s-1)
        gone[s-1]=i
        ans[i]+=1
      if s!=n-1 and gone[s+1]!=i:
        go.add(s+1)
        gone[s+1]=i
        ans[i]+=1
      if s==x-1 and gone[y-1]!=i:
        go.add(y-1)
        gone[y-1]=i
        ans[i]+=1
      if s==y-1 and gone[x-1]!=i:
        go.add(x-1)
        gone[x-1]=i
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
ans=[0 for i in range(n)]
gone=[0 for i in range(n)]
for start in range(n):
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]==i:
        go.add(s-1)
        gone[s-1]=i
        ans[i]+=1
      if s!=n-1 and gone[s+1]==i:
        go.add(s+1)
        gone[s+1]=i
        ans[i]+=1
      if s==x-1 and gone[y-1]==i:
        go.add(y-1)
        gone[y-1]=i
        ans[i]+=1
      if s==y-1 and gone[x-1]==i:
        go.add(x-1)
        gone[x-1]=i
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)

Submission status: Wrong Answer

Solution code:
def main():
  X, Y, A, B, C  = map(int, input().split())
  aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
  midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
  mu_list = sorted([int(t) for t in input().split()],reverse=True)
  
  sum_list = sorted(aka_list + midori_list + mu_list ,reverse=True)[:X+Y]
  print(sum(sum_list))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
from collections import Counter
def key(x, y):
    return str(x)+str(y)
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    M = {}
    for i in range(N):
        for j in range(i, N):
            M[key(i, j)] = j - i
    
    def helper(x, y, from_cost):
        if 0 <= x <= N-1 and 0 <= y <= N-1:
            if M[key(x,y)] > from_cost+1:
                M[key(x,y)] = from_cost + 1
                cost = from_cost + 1

                helper(x-1,y, cost)
                helper(x+1,y, cost)
                helper(x,y-1, cost)
                helper(x,y+1, cost)
        
    helper(X, Y, 0)

    cost_list = Counter(list(M.values()))
    for k in range(N-1):
        print(cost_list[k+1])


main()

Submission status: Wrong Answer

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

lNum = Y-X+1
hr = round(lNum/2)

leftNode = X - 1
rightNode = N - Y

for i in range(1,N):
    if i<hr:
        count = lNum
    elif i==lNum/2:
        count = hr
    else:
        count = 0
    count += max(0,leftNode+1-i)
    count += max(0,rightNode+1-i)

    if leftNode > 0:
        line = leftNode + hr
        c = line - i
        if c>0:
            c -= max(leftNode + 1 - i,0)
            c -= max(hr - i, 0)
            count += 2*max(c,0)
    if rightNode > 0:
        line = rightNode + hr
        c = line - i
        if c>0:
            c -= max(rightNode + 1 - i,0)
            c -= max(hr - i,0)
            count += 2*max(c,0)

    if i > 2:
        line = leftNode+rightNode+2
        c = line - i
        if c>0:
            c -= max(leftNode + 2 - i,0)
            c -= max(rightNode + 2 - i,0)
            count += max(c,0)
    print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]
A=[]
for i in range(1,N+1):
    A.append([0]*N)

        
res1={}
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        A[x][y]=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        if(x>=y):
            A[x][y]=0

for row in A:
    for y in row:
        if(y in res1):
                res1[y]=res1[y]+1
        else:
            res1[y]=1              
for ress in res1.keys():
    if(ress>0):
        print(res1[ress])

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=min(k-2,right,left)
            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
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=min(k-2,right,left)
            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:
def output(k_list, N):
    for k in range(1, N):
        print(k_list[k])


def print_check(check, N):
    for i in range(1, N+1):
        print(check[i][1:])

N, X, Y = map(int,input().split())
k_list = [0]*N

check = [[0 for i in range(N+1)] for j in range(N+1)]

#A and A　(a and b)
# for k in range(1, X): #1<= a < b <= X の点について距離kのものがいくつあるかを記録
#     k_list[k] += X - k
for p in range(1, X):
    for q in range(p+1, X+1):
        check[p][q] += 1
        k_list[q-p] += 1


#a and c
if (X + Y) % 2 == 1:
    # A and B
    for q in range(X+1, (X+Y+1)//2):
        for p in range(1, X+1):
            check[p][q] += 1
            k_list[q-p] += 1

    # A and C
    for q in range((X+Y+1)//2, Y):
        for p in range(1, X+1):
            check[p][q] += 1
            k_list[X-p+1+Y-q] += 1

else:
    for q in range(X+1, (X+Y)//2):
        for p in range(1, X+1):
            check[p][q] += 1
            k_list[q-p] += 1
    
    for q in range((X+Y)//2+1, Y):
        for p in range(1, X+1):
            check[p][q] += 1
            k_list[X-p+1+Y-q] += 1



#A and D (a and d)
for q in range(Y, N+1):
    for p in range(1, X+1):
        check[p][q] += 1
        k_list[X-p+1+q-Y] += 1


# c and d
if (X + Y) % 2 == 1:
    # B and D
    for p in range(X+1, (X+Y+1)//2):
        for q in range(Y, N+1):
            check[p][q] += 1
            k_list[p - X  + 1 + q - Y] += 1
    # C and D
    for p in range((X+Y+1)//2, Y):
        for q in range(Y, N+1):
            check[p][q] += 1
            k_list[q-p] += 1

else:
    for p in range(X+1, (X+Y)//2):
        for q in range(Y, N+1):
            check[p][q] += 1
            k_list[p - X + 1 +q - Y] += 1

    for p in range((X+Y)//2+1, Y):
        for q in range(Y, N+1):
            check[p][q] += 1
            k_list[q-p] += 1


#D and D　(d and e)
for p in range(Y, N):
    for q in range(p+1, N+1):
        mid = (X+Y)//2
        if p != mid and q != mid:
            check[p][q] += 1
            k_list[q-p] += 1



#c and c
for p in range(X+1, Y-1):
    for q in range(p+1, Y):
        mid = (X+Y)//2
        if p != mid and q != mid:
            check[p][q] += 1
            k_list[q-p] += 1

if (X+Y) % 2 == 0: #XとYのまん中について無視してきたので
    for i in range(1, N+1):
        q = max((X+Y)//2, i)
        p = min((X+Y)//2, i)
        if p != q:
            check[p][q] += 1
        k_list[q-p] += 1



#output
#print_check(check, N)
output(k_list, N)

Submission status: Wrong Answer

Solution code:
n,x,y=[int(i) for i in input().split()]
a=list(range(1,x+1))+list(range(y,n+1))
b=list(range(1,y))
c=list(range(x+1,n+1))
ans=[set() for i in range(n-1)]
for i in range(1,n):
    for j in range(0,len(a)):
        if j+i<len(a):
            ans[i-1].add((a[j],a[j+i]))
        else: break
for i in range(1,n):
    for j in range(0,len(b)):
        if j+i<len(b):
            ans[i-1].add((b[j],b[j+i]))
        else: break   
for i in range(1,n):
    for j in range(0,len(c)):
        if j+i<len(c):
            ans[i-1].add((c[j],c[j+i]))
        else: break   
for i in ans:
    print(len(i))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n,x,y=[int(i) for i in input().split()]
a=list(range(1,x+1))+list(range(y,n+1))
b=list(range(1,y))
c=list(range(x+1,n+1))
ans=[set() for i in range(n-1)]
for i in range(1,n-1):
    for j in range(0,len(a)):
        if j+i<len(a):
            ans[i-1].add((a[j],a[j+i]))
        else: break
for i in range(1,n-1):
    for j in range(0,len(b)):
        if j+i<len(b):
            ans[i-1].add((b[j],b[j+i]))
        else: break   
for i in range(1,n-1):
    for j in range(0,len(c)):
        if j+i<len(c):
            ans[i-1].add((c[j],c[j+i]))
        else: break   
for i in ans:
    print(len(i))

Submission status: Wrong Answer

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

def dist(a, b):
    return min(abs(b-a), abs(X-a) + 1 + abs(b-Y))

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

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

Submission status: Wrong Answer

Solution code:
def distance(i, j, x, y):
    if x == y:
        return j - i
    if i <= x and j >= y:
        return x - i + j - y + 1
    elif i > x and j < y:
        return j - i
    elif i <= x and j < y:
        return min(y - j + x - i + 1, j - i)
    elif i > x and j >= y:
        return min(i - x + j - y + 1, j - i)


if __name__ == '__main__':
    # n = 5
    # x, y = 1, 1
    # for i in range(1, n):
    #     for j in range(i + 1, n + 1):
    #         print("{} to {}: {}".format(i, j, distance(i, j, x, y)))
    n, x, y = tuple([int(i) for i in input().split()])
    x, y = min(x, y), max(x, y)

    dists = [0 for k in range(n)]
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d = distance(i, j, x, y)
            dists[d] += 1

    for k in dists[1:]:
        print(k)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, X, Y = map(int, input().split())

min_dist_list = []
ans_list = [N]
for k in range(2, N):
    temp_ans = max(0, X - k)
    for i in range(max(1, X - k), N):
        if i > X - k and i < X + k and i + k <= N:
            if i >= X + (Y - X) // 2:
                temp_ans += 1
            elif i + k < Y - (k - abs(i - X)) - 1:
                temp_ans += 2
            elif i + k == Y - (k - abs(i - X)) - 1:
                temp_ans += 1
            
            if Y + (k - abs(i - X)) - 1 <= N:
                temp_ans += 1
#             print(2, k, i, temp_ans, Y + (k - abs(i - X)) - 1)
        elif i >= X + k:
            if i + k <= N:
                temp_ans += 1
#             print(3, k, i, temp_ans)
    ans_list.append(temp_ans)
                
print("\n".join(map(str, ans_list)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python


n, x, y = (int(v) for v in input().split())
x -= 1
y -= 1
c = [0] * (n - 1)
for i in range(n):
    c.append(n - i)
for i in range(n):
    for j in range(n):
        idx = min(
            abs(i - j),
            abs(i - x) + 1 + abs(j - y),
            abs(i - y) + 1 + abs(j - x)
        )
        c[idx - 1]
for v in c:
    print(str(int(v)))

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 / 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:
import sys
input = lambda: sys.stdin.readline().rstrip()
n,x,y=[int(i) for i in input().split()]
a=list(range(1,x+1))+list(range(y,n+1))
b=list(range(1,n+1))
ans=[set() for i in range(n-1)]
for i in range(1,n-1):
    for j in range(0,len(a)):
        if j+i<len(a):
            ans[i-1].add((a[j],a[j+i]))
        else: break
for i in range(1,n-1):
    for j in range(0,len(b)):
        if j+i<len(b):
            ans[i-1].add((b[j],b[j+i]))
        else: break   
ans.reverse()
for i in range(len(ans)):
    for j in range(i+1,len(ans)):
        ans[i]-=ans[i+1]
ans.reverse()
for i in ans:
    print(len(i))

Submission status: Wrong Answer

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

lNum = Y-X+1

leftNode = X - 1
rightNode = N - Y

for i in range(1,N):
    if i<lNum/2:
        count = lNum
    elif i==lNum/2:
        count = lNum//2
    else:
        count = 0
    count += max(0,leftNode+1-i)
    count += max(0,rightNode+1-i)

    if leftNode > 0:
        line = leftNode + lNum//2 + 1
        c = line - i
        if c>0:
            c -= max(leftNode + 1 - i,0)
            c -= max(lNum // 2 + 1 - i, 0)
            count += 2*c
    if rightNode > 0:
        line = rightNode + lNum//2 + 1
        c = line - i
        if c>0:
            c -= max(rightNode + 1 - i,0)
            c -= max(lNum//2 + 1 - i,0)
            count += 2*c

    if i > 2:
        line = leftNode+rightNode+2
        c = line - i
        if c>0:
            c -= max(leftNode + 2 - i,0)
            c -= max(rightNode + 2 -i,0)
            count += c
    print(count)

Submission status: Wrong Answer

Solution code:
def distance(i, j, x, y):
    if i <= x and j >= y:
        return x - i + j - y + 1
    elif i > x and j < y:
        return j - i
    elif i <= x and j < y:
        return min(y - j + x - i + 1, j - i)
    elif i > x and j >= y:
        return min(i - x + j - y + 1, j - i)


if __name__ == '__main__':
    n, x, y = tuple([int(i) for i in input().split()])
    x, y = min(x, y), max(x, y)

    dists = [0 for k in range(n)]
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d = distance(i, j, x, y)
            dists[d] += 1

    for k in dists[1:]:
        print(k)

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
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

for e in k:
    print(e)

Submission status: Wrong Answer

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

D = Y-X
L = list(itertools.combinations(range(1,N+1), 2))

ans = [0] * N
for l in L:
    x, y = l[0], l[1]
    index = 0
    if x > Y or y < X:
        index = y-x
    elif x > X or y < Y:
        org = y-x
        oth = abs(X-x) + abs(Y-y) + 1
        if org > oth:
            index = oth
        else:
            index = org
    else:
        index = y-x - D+1
    
    ans[index] += 1
    print(l, index)