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
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, x, y = map(int, input().split())
    d = [0]*n

    for i in range(1, n):
        for j in range(i+1, n+1):
            # if i <= x and j >= y:
            #     tree[i - 1][j - 1] = j-i-(y - x - 1)
            # elif i <= x and j < y:
            
            # elif i > x and j >= y:
            
            # else:
            #     tree[i - 1][j - 1] = j-i
            d[min(j-i, abs(x-i) +
                  1+abs(j-y), abs(y-i)+1+abs(j-x))] += 1

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


# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, x, y = map(int, input().split())
    d = [0]*n

    for i in range(1, n):
        for j in range(i+1, n):
            # if i <= x and j >= y:
            #     tree[i - 1][j - 1] = j-i-(y - x - 1)
            # elif i <= x and j < y:
            
            # elif i > x and j >= y:
            
            # else:
            #     tree[i - 1][j - 1] = j-i
            d[min(j-i, abs(x-i) +
                  1+abs(j-y), abs(y-i)+1+abs(j-x))] += 1

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


# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, x, y = map(int, input().split())
    d = [0]*n

    for i in range(1, n):
        for j in range(i+1, n):
            # if i <= x and j >= y:
            #     tree[i - 1][j - 1] = j-i-(y - x - 1)
            # elif i <= x and j < y:
            
            # elif i > x and j >= y:
            
            # else:
            #     tree[i - 1][j - 1] = j-i
            d[min(j-i, abs(x-i) +
                  1+abs(j-y), abs(y-i)+1+abs(j-x))] += 1

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


if __name__ == '__main__':
    main()


# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, x, y = map(int, input().split())
    tree = [None]*n

    for i in range(1, n):
        for j in range(i+1, n+1):
            # if i <= x and j >= y:
            #     tree[i - 1][j - 1] = j-i-(y - x - 1)
            # elif i <= x and j < y:
            
            # elif i > x and j >= y:
            
            # else:
            #     tree[i - 1][j - 1] = j-i
            tree[i - 1].append(min(j-i, abs(x-i) +
                                     1+abs(j-y), abs(y-i)+1+abs(j-x)))

    for k in range(1, n):
        ans = 0
        for i in range(n):
            ans += tree[i].count(k)
        print(ans)


# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, x, y = map(int, input().split())
    d = [0]*n

    for i in range(1, n):
        for j in range(i+1, n+1):
            # if i <= x and j >= y:
            #     tree[i - 1][j - 1] = j-i-(y - x - 1)
            # elif i <= x and j < y:
            
            # elif i > x and j >= y:
            
            # else:
            #     tree[i - 1][j - 1] = j-i
            d[min(j-i, abs(x-i) +
                  1+abs(j-y), abs(y-i)+1+abs(j-x))] += 1

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


if __name__ == '__main__':
    main()


from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())


# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc




def SR(n): return [S() for i in range(n)]

# 2





def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n, x, y = LI()
    d = [0]*n
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d[min(j - i, abs(x - i) + 1 + abs(j - y)) - 1] += 1
    for k in range(n-1):
        print(d[k])


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted