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):
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = shortest_path(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = shortest_path(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph._shortest_path import dijkstra, floyd_warshall, bellman_ford, johnson, shortest_path
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = dijkstra(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph._shortest_path import dijkstra, floyd_warshall, bellman_ford, johnson, shortest_path
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = dijkstra(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph._shortest_path import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = shortest_path(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph._shortest_path import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = shortest_path(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph._shortest_path import dijkstra, floyd_warshall, bellman_ford, johnson, shortest_path
from scipy.sparse import csr_matrix


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

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x-1]
j = list(range(1,n)) + [y-1]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) 
# print(type(csr),csr,sep="\n")


dist = dijkstra(graph, directed=False).astype(int)

# print(type(dist),dist,sep="\n")

dist = dist.ravel() 
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted