TnT/Multi_CodeNet4Repair huggingface dataset:
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):
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))



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

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



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[k+1])



Verdicts: Wrong Answer

Runtime Error

Accepted
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 scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())
F = [[0 for i in range(N)] for j in range(N)]

for i in range(N - 1):
    F[i][i + 1] = 1
    F[i + 1][i] = 1
F[X - 1][Y - 1] = 1
F[Y - 1][X - 1] = 1

G = csgraph_from_dense(F, null_value=0)
d = dijkstra(G)

# print(F)
# print(d)


s = Counter(d.flatten().astype(np.int64))
print(s)
for i in range(1, N):
    if i in s:
        print(s[i] // 2)
    else:
        print(0)

from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())
F = [[0 for i in range(N)] for j in range(N)]

for i in range(N - 1):
    F[i][i + 1] = 1
    F[i + 1][i] = 1
F[X - 1][Y - 1] = 1
F[Y - 1][X - 1] = 1

G = csgraph_from_dense(F, null_value=0)
d = dijkstra(G)

# print(F)
# print(d)


s = Counter(d.flatten().astype(np.int64))
# print(s)
for i in range(1, N):
    if i in s:
        print(s[i] // 2)
    else:
        print(0)

Verdicts: Wrong Answer

Accepted
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 bisect
X,Y,A,B,C=map(int,input().split())

AList=list(map(int,input().split()))
BList=list(map(int,input().split()))
CList=list(map(int,input().split()))

AList.sort(reverse=True)
BList.sort(reverse=True)
CList.sort(reverse=True)

alist = AList[0:X] + BList[0:Y] + CList
alist.sort(reverse=True)

print(int(sum(alist[:X+Y])))


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

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

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if i < X :
      if j < X:
        a = j - i
        ans[a] += 1
      elif j >= X and j < Y:
        a = j - i
        b = (X-i) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a =  (X-i)+ 1 + (j - Y)
        ans[a] += 1
        
    elif i >= X and i < Y:
      if j < Y:
        a = j - i
        b = (i-X) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a = j -i
        b =  (i-X) + 1 + (j - Y)
        c = min(a,b)
        ans[c] += 1
        
    else:
      a = j - i
      ans[a] += 1
        
for i in range(1,N):
  print(int(ans[i]))

Verdicts: Runtime Error

Accepted
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):
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)

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(i-(X-1))+1+abs(j-(Y-1)))
        li[dis-1] += 1
for ans in li:
    print(ans)

Verdicts: Wrong Answer

Accepted
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):
N,X,Y=map(int,input().split())
x=X-1
y=Y-1

d=[[0]*N for i in range(N)]

for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    if i == x:
      if j < y:
        d[i][j] = min(abs(i-j),y-j+1)
      elif j == y:
        d[i][j] = 1
      else:
        d[i][j] = abs(j-i)-(y-x)+1
    elif i < x:
      if j < y:
        d[i][j] = min(abs(i-j),x-i+y-j+1)
      elif j >= Y:
        d[i][j] = abs(j-i)-(y-x)+1

    elif x < i < y:
      d[i][j] = min(abs(i-j),i-x+1+abs(y-j))

    else:
      d[i][j] = abs(j-i)


for k in range(1,N):
  count=0
  for l in range(N-1):
    count += d[l].count(k)
  print(count)


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

Verdicts: Wrong Answer

Accepted
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):
N, X, Y = map(int, input().split())

t = [0] * (N - 1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        t[min(j - i, abs(X - i) + 1 + abs(Y - j)) - 1] += 1
#print('\n'.join(map(str, t)))
print(*result, sep='\n')


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

result = [0] * (N - 1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        result[min(j - i, abs(X - i) + 1 + abs(Y - j)) - 1] += 1
print(*result, sep='\n')


Verdicts: Runtime Error

Accepted
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 collections import deque

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

g = [[] for _ in range(n)]

for i in range(n - 1):
    g[i].append(i + 1)
    g[i + 1].append(i)
g[x - 1].append(y - 1)
g[y - 1].append(x - 1)


def bfs(g, n_node, start_node):         
    dist = [-1] * n_node                
    dist[start_node] = 0                
    que = deque([start_node])           

    while que:                          
        node = que.popleft()            
        for gn in g[node]:              
            if dist[gn] != -1:          
                continue                
            dist[gn] = dist[node] + 1   
            que.append(gn)              
    return dist                         


ans = [0] * n

for i in range(n):
    dist = bfs(g, n, i)
    for d in dist:
        ans[d] += 1
[print(i) for i in ans]

from collections import deque

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

g = [[] for _ in range(n)]

for i in range(n - 1):
    g[i].append(i + 1)
    g[i + 1].append(i)
g[x - 1].append(y - 1)
g[y - 1].append(x - 1)


def bfs(g, n_node, start_node):
    dist = [-1] * n_node
    dist[start_node] = 0
    que = deque([start_node])

    while que:
        node = que.popleft()
        for j in g[node]:
            if dist[j] != -1:
                continue
            dist[j] = dist[node] + 1
            que.append(j)
    return dist


ans = [0] * n

for i in range(n):
    dist = bfs(g, n, i)
    for d in dist:
        ans[d] += 1

for a in ans[1:]:
    print(a//2)

Verdicts: Wrong Answer

Accepted
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):
N,X,Y = map(int, input().split())
D = [0] * N
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1)] += 1 
print (D[1:], sep="\n")

N,X,Y = map(int, input().split())
D = [0] * N
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1)] += 1 
print (*D[1:], sep="\n")

Verdicts: Wrong Answer

Accepted
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):
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] - 1):
        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[num_data[0] - result] += 1
print(cost)


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


def main():
    n,x,y = map(int,input().split(' '))
    cost = [0 for i in range(n - 1)]
    for i in range(n - 1):
        for l in range(i + 1, n):
            result = min(abs(i - l),abs(i - x + 1) + 1 + abs(l - y + 1),abs(i - y + 1) + 1 + abs(l - x + 1))
            cost[result - 1] += 1
    for per in cost:
        print(per)

if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Wrong Answer

Accepted
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):
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)
        

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

lists = [0] * (N - 1)

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

Verdicts: Wrong Answer

Accepted
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):
a = b

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

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

print(*ans[1:])


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

def dist(fr, to):
    return min(
        to - fr,
        abs(to - Y) + 1 + abs(fr - X),
        abs(fr - Y) + 1 + abs(to - X)
    )

cnt = [0] * N

ans = 0
for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cnt[dist(fr, to)] += 1

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


Verdicts: Runtime Error

Wrong Answer

Accepted
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):
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, n, 1):
        if i == j:
            continue
        minij = min([(j - i - 1), ((x - i + 1) + (y - j) - 1)])
        result[minij] += 1
for i in range(n-1):
    print(result[i])



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

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



Verdicts: Runtime Error

Accepted
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):
n, x, y = map(int, input().split())

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

for a in ans:
    print(a)
 

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

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

for a in ans:
    print(a)
 


Verdicts: Wrong Answer

Accepted
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):
N, X, Y = map(int, input().split())
X,Y = X-1, Y-1

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

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

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

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

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

Verdicts: Runtime Error

Accepted
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):

def ruiwa(n):
  c=0
  ans=[]
  for i in range(n):
    c+=i
    ans.append(c)
  return ans

n,x,y=map(int,input().split())
dp=[j for i in range(n)for j in range(1,n)]
r=ruiwa(n)
for i in range(1,n):
  for j in range(i+1,n+1):
    if j<x:continue
    p=(n-1)*i-(n-j)-r[x]
    dp[p]=min(dp[p],x-i-~abs(j-y))
for i in range(n):
  print(dp.count(i))

n,x,y=map(int,open(0).read().split())
c=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    l=min(j-i, abs(x-i)+1+abs(y-j))
    c[l-1]+=1
for c in c:
  print(c)

Verdicts: Wrong Answer

Accepted
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):
N,X,Y = map(int,(input().split()))
lList = [ 0 for i in range(N) ]
for i in range(N):
  for j in range(i + 1,N):
    l1 = j - i
    l2 = abs(X - 1 - i) + abs(Y - 1 - j)  + 1
    l = min(l1,l2)
    lList[l] += 1
    print(l,i+1,j+1)
    
for i in lList[1:]:
  print(i)

N,X,Y = map(int,(input().split()))
lList = [ 0 for i in range(N) ]
for i in range(N):
  for j in range(i + 1,N):
    l1 = j - i
    l2 = abs(X - 1 - i) + abs(Y - 1 - j)  + 1
    l = min(l1,l2)
    lList[l] += 1
    
for i in lList[1:]:
  print(i)

Verdicts: Wrong Answer

Accepted
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):
n, x, y = map(int, input().split())
cnt = [0] * n


for i in range(n - 1):
    for j in range(n):
        if j <= x - 1:  # 1 idx
            cnt[j - i] += 1
        elif x <= j <= y - 1:
            cnt[min(j - i, x + y - i - j - 1)] += 1
        else:
            cnt[x - y - i + j + 1] += 1
for i in range(1, n):
    print(cnt[i])


n, x, y = map(int, input().split())
cnt = [0] * n


for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x - 1:
            if j <= x - 1:  # 1 idx
                cnt[j - i] += 1
            elif j <= y - 1:
                cnt[min(j - i, x + y - i - j - 1)] += 1
            else:
                cnt[x - y - i + j + 1] += 1
        elif x - 1 < x <= y - 1:
            if j <= y - 1:
                cnt[min(j - i, 1 + (i - x + 1) + (y - 1 - j))] += 1
            else:
                cnt[min(j - i), 1 + (i - x + 1) + (j - y + 1)] += 1
        else:
            cnt[j - i] += 1

for i in range(1, n):
    print(cnt[i])


n, x, y = map(int, input().split())
cnt = [0] * n


for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x - 1:
            if j <= x - 1:  # 1 idx
                cnt[j - i] += 1
            elif j <= y - 1:
                cnt[min(j - i, x + y - i - j - 1)] += 1
            else:
                cnt[x - y - i + j + 1] += 1
        elif x - 1 < x <= y - 1:
            if j <= y - 1:
                cnt[min(j - i, 1 + (i - x + 1) + (y - 1 - j))] += 1
            else:
                cnt[min((j - i), 1 + (i - x + 1) + (j - y + 1))] += 1
        else:
            cnt[j - i] += 1

for i in range(1, n):
    print(cnt[i])


Verdicts: Wrong Answer

Runtime Error

Accepted
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):
N, X, Y = map(int, input().split())
K = [0]*N
for i in range(1,N+1):
	for j in range(i+1,N+1):
		K[min(min(abs(X-i)+1,abs(Y-i))+abs(j-Y),abs(i-j))-1]+=1
for i in range(N):
	print(K[i])

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

Verdicts: Wrong Answer

Accepted
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 numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline



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

    d = [ [ 0 for j in range(N) ] for i in range(N) ]
    d = np.array(d)

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

    for k in range(1,N):
        res = np.count_nonzero(d == k)
        print(res)



main()


# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline



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

    cost = [0 for i in range(N)]

    for i in range(1,N):
        for j in range(i,N+1):
            temp1 = abs(j-i)
            temp2 = abs(X-i) + 1 + abs(j-Y)
            temp3 = abs(Y-i) + 1 + abs(j-X)
            temp = min(temp1,temp2,temp3)
            cost[temp] += 1

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



main()


Verdicts: Runtime Error

Accepted
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):
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
p.reverse()
q.reverse()
p=p[:X]
q=q[:Y]
r=r[:max(X,Y)]
 
a=p[:]
a.extend(q)
a.extend(r)
a.sort()
a.reverse()
b=q[:]
b.extend(r)
b.sort()
b.reverse()
c=p[:]
c.extend(r)
c.sort()
c.reverse()
red=0
green=0
sum=0
sum1=0
sum2=0
d=0
for i in range(X+Y):
  if(a[i] in p):
    red+=1
  elif(a[i] in q):
    green+=1
  d+=a[i]
 
  if(i<X):
      sum1+=p[i]
      sum2+=c[i]
  if(i<Y):
      sum1+=b[i]
      sum2+=q[i]
    
if(red<=X and green<=Y):
  print(d)
elif(red>X):
  print(sum1)
elif(green>Y):
  print(sum2)

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

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

Verdicts: Runtime Error

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



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

# N = 2000
# X = 100
# Y = 1900


X -= 1
Y -= 1

# @profile


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

    for a in ans[1:]:
        print(a//2)


main(N, X, Y)



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

# N = 2000
# X = 100
# Y = 1900


X -= 1
Y -= 1

# @profile


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


main(N, X, Y)


N, X, Y = list(map(int, input()))

import numpy as np
# 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, Y] = 1
# dist[Y, X] = 1
for i in range(N):
    for j in range(i+1, N):
        for k in range(0, N):
            print(i, k, j, dist[i, k]+dist[k, j])
            dist[i, j] = min(dist[i, j], dist[i, k]+dist[k, j])
for i in range(1, N):
    count = np.count_nonzero(dist == i)
    print(count)


import numpy as np
from scipy.sparse.csgraph import dijkstra

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

# N = 2000
# X = 100
# Y = 1900


X -= 1
Y -= 1

# @profile


def main(N, X, Y):
    graph = np.zeros((N, N))
    # np.fill_diagonal(graph[1:, :], 1)
    np.fill_diagonal(graph[:, 1:], 1)
    graph[X, Y] = 1
    # graph[Y, X] = 1
    dist = dijkstra(graph, directed=False).astype(int).ravel()
    # print(dist_matrix)

    ans = np.bincount(dist, minlength=N)//2
    print(*ans[1:], sep="\n")


main(N, X, Y)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
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

input = sys.stdin.readline

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

dp =[[0]*(N) for _ in range(N)]
for j in range(N-1):
    dp[j][j+1]=1
    dp[j+1][j]=1


dp[X-1][Y-1] = 1
dp[Y-1][X-1] = 1

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

def dist(s,g):
    if s<=X and Y<=g:
        return X-s + 1 + g-Y
    elif s==X and g==Y:
        return 1
    else:
        return min(g-s,abs(s-X)+1+abs(g-Y))

for k in range(1,N):
    cnt =0
    if k==1:
        print(N)
    else:
        for i in range(1,N+1):
            for j in range(i+1,N+1):
                if dist(i,j) == k:
                    cnt+=1
        print(cnt)
         



import sys

input = sys.stdin.readline

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

from collections import deque

class BFS():
    def __init__(self):
        self.matrix=[]
        print("BFS class is imported!")

    def add(self,start,end,cost):
        self.matrix.append([start,end,cost])
    
    def CreateRoot(self):
        
        V = max([ max(i[:2]) for i in self.matrix])


        
        self.root = [[float('inf')]*(V+1) for _ in range(V+1)]

        
        for j in range(V+1):
            self.root[j][j] = 0

        for e in self.matrix:
            self.root[e[0]][e[1]] = e[2]
            self.root[e[1]][e[0]] = e[2]

        # print(*self.root,sep="\n")

    def shortest_path(self,start,end):
        
        V = len(self.root)

        
        distance=[float('inf')] * V
        distance[start] =0

        
        
        visited=[0]*V
        visited[start] = 1
        size = 1

        
        d =deque()
        d.append(start)

        while size<V:
            for v in range(V):
                if self.root[d[0]][v]!=float('inf') and visited[v]==0:
                    d.append(v)

            for w in d:
                if distance[w] > distance[d[0]] + self.root[d[0]][w]:
                    distance[w] = distance[d[0]] + self.root[d[0]][w]
                    visited[w] =1
                    size+=1

            d.popleft()       

        return distance

i=BFS()

for j in range(N-1):
    i.add(j,j+1,1)

i.add(X-1,Y-1,1)

i.CreateRoot()

matrix=[]
for j in range(N):
    matrix.append(i.shortest_path(j,j+1))


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

Distances=[0]*(N+1)

for i in range(N):
    for j in range(i+1,N):
        Distances[matrix[i][j]]+=1 

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


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

x,y = x-1,y-1

d={}
for k in range(1,n):
    d[k]=0


for i in range(n):
    for j in range(i+1,n):
     
        dist=min(abs(i-j) , abs( i - x ) + 1 + abs(y - j) ,abs( i - y ) + 1 + abs(x - j))

        d[dist]+=1

for k in range(1,n):
    print(d[k])

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
de main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline
    
    
    def bfs(v):
        dist = [f_inf for _ in range(n)]
        dist[v] = 0
        q = deque()
        q.append(v)
        while q:
            u = q.popleft()
            for nv in tree[u]:
                if dist[nv] == f_inf:
                    dist[nv] = dist[u] + 1
                    q.append(nv)
        for d in dist:
            res[d] += 1
    
    
    n, x, y = map(int, input().split())
    
    tree = [[] for _ in range(n)]
    for i in range(n - 1):
        tree[i].append(i + 1)
        tree[i + 1].append(i)
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)
    
    f_inf = float("inf")
    res = [0 for _ in range(n)]
    for i in range(n):
        bfs(i)
    
    for i in range(1, n):
        print(res[i] // 2)

if __name__ == '__main__':
    main()


import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, x, y = map(int, input().split())
    tree = [[] for _ in range(n)]
    for i in range(1, n):
        tree[i - 1].append(i)
        tree[i].append(i - 1)

    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

    def bfs(v):
        dist = [f_inf for _ in range(n)]
        dist[v] = 0
        q = deque()
        q.append(v)
        while q:
            u = q.popleft()
            for nv in tree[u]:
                if dist[nv] == f_inf:
                    dist[nv] = dist[u] + 1
                    q.append(nv)

        for d in dist:
            res[d] += 1

    res = [0 for _ in range(n)]
    for i in range(n):
        bfs(i)

    for j in range(1, n):
        print(res[j] // 2)


if __name__ == '__main__':
    resolve()


Verdicts: Runtime Error

Accepted
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):
n,x,y=map(int,input().split())
x-=1
y-=1
cnt=[0]*n
for i in range(n):
  for j in range(i+1,n):
    dist=min(j-i,abs(j-x)+1+abs(i-y))
    cnt[dist]+=1
for i in range(1,n):
  print(cnt[i])

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

Verdicts: Wrong Answer

Accepted
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):
N, X, Y = map(int, input().split())
r = X - 1
l = N - Y
m = Y - X + 1
print(r, l, m)
for i in range(1, N):
    ans = 0
    # mid ok 
    if i * 2 == m:
        ans += i
    elif i * 2 < m:
        ans += m
    # right
    ans += max(0, r + 1 - i)
    for j in range(1, r+1):
        if j >= i:
            continue
        diff = i - j
        # circle
        if diff * 2 == m:
            ans += 1
        elif diff * 2 < m:
            ans += 2
        # outer
        if diff - 1  >= 1 and diff - 1 <= l:
            ans += 1
    # left
    ans += max(0, l + 1 - i)
    for j in range(1, l+1):
        if j >= i:
            continue
        diff = i - j
        # circle
        if diff * 2 == m:
            ans += 1
        elif diff * 2 < m:
            ans += 2
    print(ans)


N, X, Y = map(int, input().split())
r = X - 1
l = N - Y
m = Y - X + 1
for i in range(1, N):
    ans = 0
    # mid ok 
    if i * 2 == m:
        ans += i
    elif i * 2 < m:
        ans += m
    # right
    ans += max(0, r + 1 - i)
    for j in range(1, r+1):
        if j >= i:
            continue
        diff = i - j
        # circle
        if diff * 2 == m:
            ans += 1
        elif diff * 2 < m:
            ans += 2
        # outer
        if diff - 1  >= 1 and diff - 1 <= l:
            ans += 1
    # left
    ans += max(0, l + 1 - i)
    for j in range(1, l+1):
        if j >= i:
            continue
        diff = i - j
        # circle
        if diff * 2 == m:
            ans += 1
        elif diff * 2 < m:
            ans += 2
    print(ans)


Verdicts: Wrong Answer

Accepted
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):
N,X,Y=map(int,input().split())
Z=Y-X

for k in range(1,N):
    ans=0
    if k<Z:
        ans+=N-k
        if 2*k+2<=Z:
            ans+=max(min(k-1,Z-k-3),0)+min(k-1,N-Y+1)
        if 2*k<Z+2:
            ans+=max(k-2,0)
    elif Z<=k<=N-Z:
        ans+=min(X,X-k+N-Y+1)

    print(ans)

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

for k in range(1,N):
    ans=0
    if k<Z:
        ans+=N-k+min(k,N-Y+1)
        if 2*k+2<=Z:
            ans+=max(min(k-1,Z-k-3),0)+min(k-1,N-Y+1)
        if 2*k<Z+2:
            ans+=max(k-2,0)
    elif Z<=k<=N-Z:
        ans+=min(X,X-k+N-Y+1)

    print(ans)

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

A=[]
for _ in range(N-1):
    A.append(0)  

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

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




Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
n, x, y = map(int, input().split())
x -= 1
y -= 1

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

for k in range(1, n):
    print(ans[k])


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

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

for k in range(1, n):
    print(ans[k])


Verdicts: Runtime Error

Accepted
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):
N,X,Y=map(int,input().split())
l=[0]*N
for i in range(1,N):
    for j in range(i):
        l[min(abs(i-j-1),abs(X-j-1)+abs(Y-i-1))]+=1
print(*l,sep="\n")

N,X,Y=map(int,input().split())
l=[0]*~-N
for i in range(1,N):
    for j in range(i):
        l[min(abs(i-j-1),abs(X-j-1)+abs(Y-i-1))]+=1
print(*l,sep="\n")

Verdicts: Wrong Answer

Accepted
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):
n ,x, y = map(int, input().split())

sub_degree = [0]*n
for i in range(1,n):
    for j in range(i+1, n+1):
        a = min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        sub_degree[a]+=1

for i in range(n):
    print(sub_degree[i])


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

sub_degree = [0]*n
for i in range(1,n):
    for j in range(i+1, n+1):
        a = min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        sub_degree[a]+=1

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


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

sub_degree = [0]*n
for i in range(1,n):
    for j in range(i+1, n+1):
        a = min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))+1
        sub_degree[a]+=1

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


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

ans = [0]*N

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

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
n,x,y = map(int,input().split())

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
graph = np.zeros((n,n))
for i in range(n-1):
    graph[i][i+1] = 1
graph[x-1][y-1] = 1
s = floyd_warshall(graph,directed=False)

for i in range(1,n-1):
    print(np.sum(s==i)//2)

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

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
graph = np.zeros((n,n))
for i in range(n-1):
    graph[i][i+1] = 1
graph[x-1][y-1] = 1
s = floyd_warshall(graph,directed=False)

for i in range(1,n-1):
    print(np.sum(s==i)//2)

def main():
    import itertools
    n,x,y = map(int,input().split())
    stat = [i for i in range(n)]
    ans = [0 for i in range(n-1)]
    for s in itertools.combinations(stat,2):
        d = min(s[1]-s[0],abs(x-1-s[0])+1+abs(y-1-s[1]))
        ans[d-1] += 1
    for i in range(len(ans)):
        print(ans[i])

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
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 collections 
N,X,Y = map(int,input().split())
d = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N):#i => j
    for j in range(i+1,N+1):
        if(i>=Y or j<=X):
            d[i][j] = j-i
        elif(i<=X and j>=Y):
            d[i][j] = (X-i)+1+(j-Y)
        else:
            a_path = j-i
            b_path = abs(X-i)+1+abs(Y-j)
            d[i][j] = min(a_path,b_path)

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

import collections 
N,X,Y = map(int,input().split())
d = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N):#i => j
    for j in range(i+1,N+1):
        if(i>=Y or j<=X):
            d[i][j] = j-i
        elif(i<=X and j>=Y):
            d[i][j] = (X-i)+1+(j-Y)
        else:
            a_path = j-i
            b_path = abs(X-i)+1+abs(Y-j)
            d[i][j] = min(a_path,b_path)

ans = [0]
for i in range(N+1):
    ans += d[i]
c = collections.Counter(ans)
for k in range(1,N): 
    print(c[k])

Verdicts: Runtime Error

Accepted
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 pprint
n, x, y = (int(each) for each in input().split(' '))

table1 = [[0] * n for i in range(n)]
table2 = [[0] * n for i in range(n)]
pprint.PrettyPrinter().pprint(table1)




for i in range(n):
    for j in range(n):
        if j-i > 0:
            table1[i][j] = j-i


for i in range(n):
    for j in range(n):
        # if j-i > 0:
        table2[i][j] = abs(j-y)-abs(i-x)+1

pprint.PrettyPrinter().pprint(table1)
pprint.PrettyPrinter().pprint(table2)

import pprint
from itertools import chain
import collections
n, x, y = (int(each) for each in input().split(' '))



table = [[0] * n for i in range(n)]
# cntr = {}





#     for j in range(n):
#         if j-i > 0:
#             table1[i][j] = j-i



#     for j in range(n):
#         if j-i > 0:
#             table2[i][j] = abs(j-y+1)+abs(i-x+1)+1


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


cntr = collections.Counter(list(chain.from_iterable(table)))


for each in range(1,n):
    print(cntr.get(each, 0))

Verdicts: Wrong Answer

Accepted
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):
def dijkstra(s,n,w,cost):
    
    
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

n,x,y=map(int,input().split())
cost = [[float("inf") for i in range(n)] for i in range(n)]

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
ans=[[float("0") for i in range(n)] for i in range(n)] 
for j in range(n):
    ans[j]=dijkstra(j,n,n,cost)
def flatten_2dim(array):
    return [item for sublist in array for item in sublist]
data = flatten_2dim(ans)
for k in range(1,n-1):
    print(int(data.count(k)/2))

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
N, X, Y = map(int, input().split())

counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        
        d1 = abs(j-i)
        
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2, d3)
        counts[d] += 1


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

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


counts = [0] * (N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        
        d1 = abs(j-i)
        
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2)
        print('i, j, dist', i, j, d)
        counts[d-1] += 1

for count in counts:
  print(count)

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


counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        
        d1 = abs(j-i)
        
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2)
        counts[d] += 1


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

Verdicts: Runtime Error

Wrong Answer

Accepted