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

A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        if i <= x:
            if abs(i +j -x) <= abs(y - i -j):
                A[i][i+j] = j
            elif abs(i + j -x) > abs(y - i -j):
                A[i][i + j] = x-i + 1 + abs(y - (i+j))
        elif i>x:
            if abs(x-i)<= abs(y-i):
                A[i][i + j] = min(abs(x- i) +1 +abs(y-i - j),j)
            else:
                A[i][i+j] = j
A[X-1][Y-1] = 1
print(A)
for t in range(N):
    if t == 0:
        continue
    sum = 0
    for u in range(N):
        sum = sum + A[u].count(t)

    print(sum)




import copy
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1

A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        A[i][i + j] = min(abs(x- i) +1 +abs(y-i-j),j)
A[X-1][Y-1] = 1
for t in range(N):
    if t == 0:
        continue
    sum = 0
    sum =  A.count(t)
    print(sum)





N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
print(*ans, sep='\n')


N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = []
A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
print(*ans, sep="\n")




import copy
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1

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

for p in range(N):
    ans.append(sum(A, []))
    print(ans)
for t in range(N):
    if t == 0:
        continue
    sum =  A.count(t)
    print(ans[0].count(t))





N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in range(len(ans)):
    if _ == 0:
        continue
    print(ans[_])




import copy
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1

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

for p in range(N):
    ans.append(sum(A, []))
    print(ans)
for t in range(N):
    if t == 0:
        continue
    sum =  A.count(t)
    print(ans[0].count(t))




N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in ans:
    if _ ==0:
        continue
    print(_)


N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
ans.pop(0)
print('\n'.join(map(str,ans)))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted