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

import numpy as np
n,x,y = map(int, input().split())
s = np.zeros((n,n))
t = np.zeros(n)
for i in range(0,n):
  for j in range(i,n):
    s[i][j] = abs(i-j)
x = x-1
y = y-1
s[x][y] = 1
for i in range(0,n):
  for j in range(i,n):
    a = abs(i-x)+abs(j-y)+1
    if a < s[i][j];
    s[i][j] = a

for i in range(0,n):
  for j in range(i,n):
    for k in range(0.n):
      if k+1 == s[i][j]:
        t[k+1] += 1

for k in range(0.n):
  print t[k]

n,x,y = map(int, input().split())
t = [0 for i in range(n)]
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]))

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

X -= 1
Y -= 1
k = [0]*n

for i in range(N-1):
    for j in range(i+1, N):
        a = j-i
        b = abs(i-x)+1+abs(y-j)
        c = abs(j-x)+1+abs(y-i)
        m =  min(a, b, c)
        k[m] += 1

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

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

X -= 1
Y -= 1
k = [0]*N

for i in range(N-1):
    for j in range(i+1, N):
        a = j-i
        b = abs(i-x)+1+abs(y-j)
        c = abs(j-x)+1+abs(y-i)
        m =  min(a, b, c)
        k[m] += 1

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

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

X -= 1
Y -= 1
k = [0]*N

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

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

Verdicts: Runtime Error

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):
# -*- 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])


# -*- 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)]
c=[0]*N
for i in range(N):
    for j in range(i+1,N):
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<j-i:
            Dist[i][j]=MyDist
            c[MyDist-1]+=1
        else:
            Dist[i][j] = j-i
            c[j-i-1]+=1
for i in range(N-1):
    print(c[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())

ans = [0] * n

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

for e in ans:
    print(e)


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):
        ans[min(abs(j - i), abs(x - i) + 1 + abs(y - j), abs(x - j) + 1 + abs(y - i))] += 1

for e in ans[1:]:
    print(e)


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

for i in range(1, N):
  for j in range(i+1, N+1):
    diff = min(j-i, abs(i-X)+abs(j-Y)+1)
    print("i={0}, j={1}".format(i, j))
    print("j-i={0}, abs(i-X)+abs(j-Y)+1={1}".format(j-i, abs(i-X)+abs(j-Y)+1))
    print("-----")
    ans[diff] += 1

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


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

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

for i in range(1, N):
  print(ans[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())
x-=1
y-=1
ans=[0 for i in range(n)]
for ni in range(n):
    d=[100000 for i in range(n)]
    q=[]
    q.append(ni)
    d[ni]=0
    while q:
        p=q.pop()
        if(p>0 and d[p-1]>d[p]+1):
            q.append(p-1)
            d[p-1]=d[p]+1
        if(p<n-1 and d[p+1]>d[p]+1):
            q.append(p+1)
            d[p+1]=d[p]+1

        if(p==x and d[y]>d[x]+1):
            q.append(y)
            d[y]=d[x]+1
        if(p==y and d[x]>d[y]+1):
            q.append(x)
            d[x]=d[y]+1
        break

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

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

for i in range(1,n):
    print(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):
#import numpy

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

L=[[i+1 for i in range(j+1)][::-1]+[0]*(N-1-j) for j in range(N-1)]
#print(L)

for i in range(len(L)):
    L[i]=[0]+L[i]+[0]
L.append([0]*(N+2))
L.insert(0,[0]*(N+2))
L.insert(0,[0]*(N+2))

#print(L)

H=[i+1 for i in range(N-1)][::-1]
#print(L)
#print(H)

L[Y][X]=1
task=[(Y,X,1)]
while len(task)>0:
    P=task.pop()
    y,x,c=P[0],P[1],P[2]
    if y<0 or x<0 or y>N or x>N:
        continue
    if L[y+1][x]>=c+1:
        L[y+1][x]=c+1
        task.append((y+1,x,c+1))
    if L[y-1][x]>=c+1:
        L[y-1][x]=c+1
        task.append((y-1,x,c+1))
    if L[y][x+1]>=c+1:
        L[y][x+1]=c+1
        task.append((y,x+1,c+1))
    if L[y][x-1]>=c+1:
        L[y][x-1]=c+1
        task.append((y,x-1,c+1))
    #print(y,x,c)
    #print(numpy.array(L))

LL=[]
for i in range(len(L)):
    LL+=L[i]
#LL.sort()
#print(LL)

import collections
D=collections.Counter(LL)
d=list(D.values())
d.pop(0)

for i in d:
    print(i)


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

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

ans.pop(0)
for i in ans:
    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 = [int(i.strip()) for i in input().split(' ')]
X = X-1
Y = Y - 1
diff = (Y-X-1)//2
print(diff)
result = [0]*N
for i in range(N):
    for j in range(i+1,N):
        if i <= X and j >= Y:
            dist = X-i + j - Y +1
        elif i <=X + diff  and j >= Y: 
            # print('A')
            dist = diff + 1 + j - Y
        elif i <= X and j >= Y - diff:
            # print('B')
            # print(X,i,diff,1)
            dist = X - i + Y - j + 1
        elif i <= X + diff and j >= Y - diff:
            if 2*diff + 1 > j - i:
                dist = j - i
            else:
                dist = 2*diff + 1
        else:
            dist = j - i
        # print(i,j,dist)
        result[dist-1] += 1

L = len(result) - 1
for i,j in enumerate(result):
    if not i == L:
        print(j)

N,X,Y = [int(i.strip()) for i in input().split(' ')]
X = X-1
Y = Y - 1
diff = (Y-X-1)//2
result = [0]*N
for i in range(N):
    for j in range(i+1,N):
        dist = min(j-i,abs(X-i)+abs(Y-j)+1)
        result[dist-1] += 1

L = len(result) - 1
for i,j in enumerate(result):
    if not i == L:
        print(j)

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())
 
def dist(i,j):
  return min(j - i, abs(x - i) + abs(y - j) + 1)
 
listlist = [0]*(n-1)
 
for i in range(1,n):
    for j in range(i + 1, n + 1):
        print(j-i,abs(x - i) + abs(y - j) + 1)
        distance = dist(i,j)
        listlist[distance-1] = listlist[distance-1] + 1
    
for k in listlist:
  print(k)

n,x,y = map(int,input().split())
 
def dist(i,j):
  return min(j - i, abs(x - i) + abs(y - j) + 1)
 
listlist = [0]*(n-1)
 
for i in range(1,n):
    for j in range(i + 1, n + 1):
        distance = dist(i,j)
        listlist[distance-1] = listlist[distance-1] + 1
    
for k in listlist:
  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):
N, X, Y = list(map(int,input().split()))

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


N, X, Y = list(map(int,input().split()))
 
Num = [0] * N
for j in range(1, N + 1):
  for i in range(1, j):
    D = min(j - i, abs(j - Y) + 1 + abs(i - X))
    Num[D] += 1
for k in range(1, N):
  print(Num[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):
N, X, Y = map(int, input().split())
c = [0 for i in range(N)]
print(c)
for i in range(1,N):
  for j in range(i+1,N+1):
    x = abs(X-i)
    y = abs(Y-j)
    a = min(x+y+1,j-i)
    c[a]+=1

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


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

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


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

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


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):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
from collections import Counter

n, x, y = list(map(int, input().split()))
graph = [[0]*n for _ in range(n)]


for i in range(n-1):
    print(i)
    graph[i][i+1] = 1
    graph[i+1][i] = 0
graph[x-1][y-1] = 1
graph[y-1][x-1] = 1

graph = csr_matrix(graph)


counter = Counter()
for i in range(n):
    dist = dijkstra(csgraph=graph, directed=False, indices=i)
    counter += Counter(dist)
    print(counter)


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


from collections import Counter

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

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

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


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):
# -*- coding: utf-8 -*-
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):
        dist1 = j - i
        dist2 = abs(X - i) + abs(Y - j) + 1
        ans[min(dis1, dist2)] += 1
print(*ans[1:], sep='\n')


# -*- coding: utf-8 -*-
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):
        dist1 = j - i
        dist2 = abs(x - i) + abs(y - j) + 1
        ans[min(dist1, dist2)] += 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):
from collections import deque
def solve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    ans = [0] * N
    
    for start_vertex in range(N):
        q = deque()
        distance_list = [float('inf')] * N
        def push(vertex, distance):
            if distance_list[vertex] != float('inf'):
                return
            distance_list[vertex] = distance
            q.append(vertex)
        
        push(start_vertex, 0)
        while len(q) > 0:
            vertex = q.popleft()
            distance = distance_list[vertex]

            if vertex - 1 >= 0:
                push(vertex-1,distance+1)
            if vertex + 1 < N:
                push(vertex+1,distance+1)
            if vertex == X:
                push(Y,distance+1)
            if vertex == Y:
                push(X,distance+1)
        for d in distance_list:
            ans[d] += 1
    
    ans = list(map(lambda x: x // 2, ans))
    print(*ans, sep='\n')
        

if __name__ == '__main__':
    solve()

from collections import defaultdict, deque
def solve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    cnter = defaultdict(int)

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


if __name__ == '__main__':
    solve()

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):
# print('input >>')
N, X, Y = map(int,(input().split()))
ans = [0] * N

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

# print('-----output-----')
for ans_e in ans[1:]:
    print(ans_e) 

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

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

# print('-----output-----')
for ans_e in ans[1:]:
    print(ans_e)

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):
from itertools import combinations
N,X,Y=(int(x) for x in input().split())
result=[]
for i in combinations(range(1,N+1),2):
	result.append(min(abs(i[0]-X)+abs(i[1]-Y)+1,i[1]-i[0]))
for i in range(1,N+1):
  print(result.count(i))

from itertools import combinations
N,X,Y=(int(x) for x in input().split())
result={x:0 for x in range(1,N)}
for i in combinations(range(1,N+1),2):
	result[min(abs(i[0]-X)+abs(i[1]-Y)+1,i[1]-i[0])] += 1
for i in range(1,N):
  print(result[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())
ans=[0 for i in range(n-1)]

def check(i, j):
    a = j-i
    short = abs(x-i) + 1 + abs(j-y)
    if a==short:
        ans[a-1] += 2
    else:
        mini = min(a, short)
        ans[mini-1] += 1
for i in range(1, n):
    for j in range(i+1, n+1):
        check(i,j)


print(' '.join(map(str, ans)))

n ,x, y = map(int, input().split())
ans=[0 for i in range(n-1)]

def check(i, j):
    a = j-i
    short = abs(x-i) + 1 + abs(j-y)
    if a==short:
        ans[a-1] += 2
    else:
        mini = min(a, short)
        ans[mini-1] += 1
for i in range(1, n):
    for j in range(i+1, n+1):
        check(i,j)


print(ans)

n, x, y = map(int, input().split())
ans = [0] * (n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        d = min(j-1, abs(x-i)+abs(j-y)+1)
        ans[d-1] += 1
print(*ans, sep='/n')

n ,x, y = map(int, input().split())
ans=[0 for i in range(n-1)]

def check(i, j):
    
    a = j-i
    
    short = abs(x-i) + 1 + abs(j-y)
    if a==short:
        ans[a-1] += 2
    else:
        mini = min(a, short)
        ans[mini-1] += 1
        
for i in range(1, n):
    for j in range(i+1, n+1):
        check(i,j)


print(' '.join(map(str, ans)))

n, x, y = map(int, input().split())
ans = [0] * (n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        d = min(j-i, abs(x-i)+abs(j-y)+1)
        ans[d-1] += 1
print(*ans, sep='\n')

Verdicts: Wrong Answer

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

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

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


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

k = [0 for _ in range(n)]
for i in range(n):
    for j in range(i + 1, n):
        dist = min(j-i, abs(x-i)+1+abs(j-y))
        if dist < n:
            k[dist] += 1
for i in range(1, len(k)):
    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):
n,x,y = [int(x) for x in input().split()]
count = [0]*(n+1)
for i in range(1,n):
    for j in range(i+1,n+1):
        if i < x and j <= x:
            nagasa = j - i
            print(i,j,1,nagasa)
        elif i < x and x < j and j < y:
            nagasa = x-i + min(j-x,y-j+1)
            print(i,j,2,nagasa)
        elif i < x and y <= j:
            nagasa = x-i + j - y + 1
            print(i,j,3,nagasa)
        elif x <= i and i < y and j <= y:
            nagasa = min(j-i,i-x+y-j+1)
            print(i,j,4,nagasa)
        elif x <= i and i < y and y < j:
            nagasa = j - y + min(y-i,i-x+1)
        elif y <= i:
            nagasa = j -i
            print(i,j,5,nagasa)
        count[nagasa] += 1
for i in range(1,n):
    print(count[i])

n,x,y = [int(x) for x in input().split()]
count = [0]*(n+1)
for i in range(1,n):
    for j in range(i+1,n+1):
        if i < x and j <= x:
            nagasa = j - i
        elif i < x and x < j and j < y:
            nagasa = x-i + min(j-x,y-j+1)
        elif i < x and y <= j:
            nagasa = x-i + j - y + 1
        elif x <= i and i < y and j <= y:
            nagasa = min(j-i,i-x+y-j+1)
        elif x <= i and i < y and y < j:
            nagasa = j - y + min(y-i,i-x+1)
        elif y <= i:
            nagasa = j -i
        count[nagasa] += 1
for i in range(1,n):
    print(count[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())

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

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



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

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

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



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

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

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



from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

#a = cmb(n, r)

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

#A = [[0 for i in range(2)] for j in range(c)]
#A[0][1] = 1
A = []
#print(A)


for i in range(N):
	for j in range(N):
		if j > i:
			A.append(j-i)

for i in range(N):
	for j in range(N):
		if range(X,Y) in range(i,j):
			A[i][j] = A[i][j] - (Y-X -1)

for i in range(N):
	for j in range(N):
		print(A[i][j])



"""
for i in range(2):
	for j in range(c):
		if j == (i+1):
			A[i][j] = 1
"""




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

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

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



Verdicts: Wrong Answer

Runtime Error

Runtime Error

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-1)
for i in range(1, n+1):
    for j in range(1, n+1):
        if i < j
            
            d = min(j-i, abs(x-i)+abs(j-y)+1, abs(y-i)+abs(x-j)+1)
            
            ans[d-1] += 1
print(*ans, sep="\n")

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

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

pos = [i for i in range(1,N+1)]
ways = list(itertools.combinations(pos,2))

dist_l = [min(abs(i-j), abs(i - X) + 1 + abs(Y - j)) for i,j in ways]

dic = collections.Counter(dist_l)
for i in range(1,N):
    print(dic[i])

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

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

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

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

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

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

Verdicts: Runtime Error

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
a = [0] * n
for i in range(n-1):
    for j in range(i+1,n):
        m = min(j-i,abs(i-x)+1+abs(j-y))
        a[m] += 1
for i in range(n):
    print(a[i])


n,x,y = map(int,input().split())
x -= 1
y -= 1
a = [0] * n
for i in range(n-1):
    for j in range(i+1,n):
        m = min(j-i,abs(i-x)+1+abs(j-y))
        a[m] += 1
for i in range(1,n):
    print(a[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
from collections import defaultdict

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

x -= 1
y -= 1

inf = 1000000000
dist = np.full((n, n), inf, dtype=np.int)

for i in range(n):
    for j in range(n):
        if i == j:
            dist[i][j] = 0
        else:
            path1 = abs(j - i)
            path2 = abs(x - i) + 1 + abs(y - j)
            dist[i][j] = min(abs(j - i), path2)

dist_counts = defaultdict(int)
for i in range(n):
    for j in range(i + 1, n):
        d = dist[i][j]
        dist_counts[d] += 1

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


from collections import defaultdict

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

x -= 1
y -= 1

dist_counts = defaultdict(int)
for i in range(n):
    for j in range(i + 1, n):
        path1 = abs(j - i)
        path2 = abs(x - i) + 1 + abs(y - j)
        dist = min(abs(j - i), path2)
        dist_counts[dist] += 1

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


Verdicts: Time Limit Exceeded

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())
a = [0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        dist = min(j-i, abs(i-x+1)+1+abs(j-y+1), abs(i-y+1)+1+abs(j-x+1))
for ans in a:
    print(ans)

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

distance_list =[]

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list.append(min(a,b)

count_list = []

for i in range(n-1):
    count_list.append(distance_list.count(i+1))

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

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

distance_list =[0]*n

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

for i in range(1,n):
    print(distance_list[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())

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1,k):
    if i<=l:
      M += g(m,k-i)*2/m
  return M

A=[n]
for i in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(c)
for i in range(n-1):
  print(A[i])
    

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

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1,k):
    if i<=l:
      M += g(m,k-i)*2/m
  return M

A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(c)
for i in range(n-1):
  print(A[i])
    


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

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1, k):
    if  i<=l and k-i >1:
      M += g(m,k-i)*2/m
    elif i<=l:
      M +=1 
  return M
    
A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(int(c))

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

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):
# = map(int, input().split())
# = list(map(int, input().split()))
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = []
for i in range(n):
    for j in range(i+1, n):
        a = min([j-i, abs(x-i)+abs(y-j)+1, abs(y-i)+abs(x-j)+1]) 
        ans.append(a)
ans = [str(l) for l in ans]
print(type(ans))

for k in range(1, n):
    finalans=ans.count(str(k))
    print(finalans)


# = map(int, input().split())
# = list(map(int, input().split()))
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = ()
for i in range(n):
    for j in range(i+1, n):
        a = min([j-i, abs(x-i)+abs(y-j)+1, abs(y-i)+abs(x-j)+1]) 
        ans.append(a)
ans = (str(l) for l in ans)

for k in range(1, n):
    finalans=ans.count(str(k))
    print(finalans)


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


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

ans = [0 for i in range(n)]

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


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

ans = [0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        p1 = j-i
        p2 = abs(i-x)+abs(j-y)+1
        ans[min(p1,p2)] += 1
for i in range(1,n):
    print(ans[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())
ans = [0] * (N - 1)
X, Y = X - 1, Y - 1
Z = Y - X - 1

for i in range(N):
  if i <= X:
    for j in range(i + 1, Y):
      p = min(j - i - 1, abs(i - X) + Y - j)
      ans[p] += 1
    for l in range(Y, N):
      ans[l - i - Z - 1] += 1
      
  elif (X < i) and (i < Y - 1):
    for j in range(i + 1, Y + 1):
      p = min(j - i - 1, abs(i - X) + abs(Y - j))
      ans[p] += 1
      
  else:#Y <= i
    for j in range(i + 1, N):
      ans[j - i - 1] += 1
  print(ans)
for i in range(N - 1):
  print(ans[i])

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

for i in range(N):
  if i <= X:
    for j in range(i + 1, Y):
      p = min(j - i - 1, abs(i - X) + Y - j)
      ans[p] += 1
    for l in range(Y, N):
      ans[l - i - Z - 1] += 1
      
  elif (X < i) and (i < Y - 1):
    for j in range(i + 1, N):
      p = min(j - i - 1, abs(i - X) + abs(Y - j))
      ans[p] += 1  
      
  else:#Y <= i
    for j in range(i + 1, N):
      ans[j - i - 1] += 1
  #print(ans)
for i in range(N - 1):
  print(ans[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())

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

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

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

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

for i in range(1,n):
    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):
n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque

def bfs(start):  
  queue = deque()
  queue.append(start)
  step_counts = [-1]*(n+1)
  step_counts[start] = 0
  while(queue):
    i = queue.popleft()
    cnt = step_counts[i]
    
    if(i==x):
      nex_l = (i-1,y,i+1)
      elif(i==y):
        nex_l = (i-1,x,i+1)
      else:
        nex_l = (i-1,i+1)

      cnt += 1
      for j in nex_l:
        
        if(j < 1 or n < j):
          continue
          
          if(step_counts[j]!=-1):
            continue
            queue.append(j)
            step_counts[j] = cnt
            cnt_l[cnt] += 1


for i in range(1,n+1):
  bfs(i)
 
for i in range(1,n):
  
  print(cnt_l[i]//2)


n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque

def bfs(start):
    queue = deque()
    queue.append(start)
    step_counts = [-1]*(n+1)
    step_counts[start] = 0
    while(queue):
        i = queue.popleft()
        cnt = step_counts[i]
        
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            
            if(j < 1 or n < j):
                continue
            
            if(step_counts[j]!=-1):
                continue
            queue.append(j)
            step_counts[j] = cnt
            cnt_l[cnt] += 1

for i in range(1,n+1):
    bfs(i)

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


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())
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
inf = float("inf")

graph = np.zeros((N, N))
for i in range(N - 1):
    graph[i][i + 1] = 1
    graph[i + 1][i] = 1
graph[X - 1][Y - 1] = 1
graph[Y - 1][X - 1] = 1

shortest_paths = shortest_path(csr_matrix(graph), directed=False, method="D", unweighted=True)
ans = [0] * (N - 1)
for i in range(N):
    for j in range(N):
        if i != j:
            ans[shortest_paths[i][j]] += 1


N, X, Y = map(int, input().split())
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
inf = float("inf")

graph = np.zeros((N, N))
for i in range(N - 1):
    graph[i][i + 1] = 1
    graph[i + 1][i] = 1
graph[X - 1][Y - 1] = 1
graph[Y - 1][X - 1] = 1

shortest_paths = shortest_path(csr_matrix(graph), directed=False, method="D", unweighted=True)
ans = [0] * (N - 1)
for i in range(N):
    for j in range(N):
        if i != j:
            ans[shortest_paths[i][j]] += 1
for a in ans:
    print(a)


N, X, Y = map(int, input().split())
graph = [[i + 1] for i in range(N - 1)]
graph.append([])
for i in range(1, N):
    graph[i].append(i-1)
graph[X-1].append(Y-1)
graph[Y-1].append(X-1)

# print(graph)
from collections import deque
def bfs_graph(G, start):
    
    dist = [-1] * N
    que = deque([start])
    dist[start] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    return dist

ans = [0] * (N - 1)
for s in range(N - 1):
    res = bfs_graph(graph, s)
    # print(res)
    for val in res[s+1:]:
        if val >= 1:
            ans[val-1] += 1
print(*ans, sep="\n")


Verdicts: Runtime Error

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
# import numpy as np

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


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

    ans_list = [0 for _ in range(N)]
    for i in range(N-1):
        for j in range(i+1, N):
            dist1 = j-i
            dist2 = abs(X-i-1) + 1 + abs(Y-j-1)

            ans = min(dist1, dist2)
            ans_list[ans] += 1

    for n in ans_list:
        print(n)

    return


if __name__ == '__main__':
    main()


# import sys
# import numpy as np

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


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

    ans_list = [0 for _ in range(N)]
    for i in range(N-1):
        for j in range(i+1, N):
            dist1 = j-i
            dist2 = abs(X-i-1) + 1 + abs(Y-j-1)

            ans = min(dist1, dist2)
            ans_list[ans] += 1

    for n in ans_list[1:]:
        print(n)

    return


if __name__ == '__main__':
    main()


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 = list(map(int, input().split()))
path = list(range(1, N+1))
for i in range(N-1):
  i += 1
  if i == 1:
    count = 1
  else:
    count = 0
  for j in path:
    if j - i > 0:
      count += 1
  if i == (Y - X):
    count -= 1
  print(count)



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


Verdicts: Wrong Answer

Accepted