Problem: 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.

Submission attempts (in order):
import sys
import queue
import time
import numpy as np
def main():
    #t1=time.time()
    input=sys.stdin.readline
    n,x,y=map(int,input().split())
    edge=[]
    for i in range(int(n)):
        tmp=[0 if i==j else 1 if abs(i-j)==1 else -1 for j in range(n)]
        edge.append(tmp)
    edge[x-1][y-1]=1
    edge[y-1][x-1]=1
    np.array(edge)
    #t2=time.time()
    step=[0]*n
    def bfs(start,graph,step):
        kyori={}
        que_check=[0]*n
        Tovis=queue.Queue()
        Tovis.put(start)
        que_check[start]=1
        kyori[start]=0        
        while Tovis.empty()==False:            
            nex=Tovis.get()            
            for v in range(n):                
                tmp=graph[nex][v]
                if tmp!=-1:                    
                    if que_check[v]==1:
                        continue
                    Tovis.put(v)
                    que_check[v]=1
                    res=kyori[nex]+1
                    kyori[v]=res
                    step[res]+=0.5
    
    for i in range(n):
        bfs(i,edge,step)
        if i==n-1:
     #       t3=time.time()
    for i in range(1,len(step)):
        print(int(step[i]))
    #t4=time.time()
    #t=[0,t2-t1,t3-t2,t4-t3,t4-t1]
    #print(t)
if __name__ == '__main__':
    main()       


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 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                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 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

Verdicts: Runtime Error

Accepted