Problem:


Score : 400 points

Problem Statement

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.

Constraints

3 \leq N \leq 2 \times 10^3

1 \leq X,Y \leq N

X+1 < Y

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X Y

Output

For each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.

Sample Input 1

5 2 4

Sample Output 1

5
4
1
0

The graph in this input is as follows:

There are five pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\,,(2,3)\,,(2,4)\,,(3,4)\,,(4,5).

There are four pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\,,(1,4)\,,(2,5)\,,(3,5).

There is one pair (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).

There are no pairs (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j is 4.

Sample Input 2

3 1 3

Sample Output 2

3
0

The graph in this input is as follows:

Sample Input 3

7 3 7

Sample Output 3

7
8
4
2
0
0

Sample Input 4

10 4 8

Sample Output 4

10
12
10
8
4
1
0
0
0



Sample input:
5 2 4


Sample output:
5
4
1
0

Submission status: Wrong Answer

Solution code:
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    #return d
a , b , c = map(int,input().split())

n = a
w = a #n:頂点数　w:辺の数

d = [[float("inf")]*n for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(n-1):
    x = i
    y = i+1
    d[x][y] = 1
    d[y][x] = 1
d[b-1][c-1] = 1
d[c-1][b-1] = 1

for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
    
warshall_floyd(d)

ert =[]
for i in range(n):
    ert.append(d[i][i+1:])

for i in range(1,n):
    ans = 0
    if i >= b + a - c + 1:
        print(ans)
        continue
    for j in range(n):
        ans += ert[j].count(i)
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict

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

ans = {num: 0 for num in range(1, N)}
for i in range(1, N + 1):
    # i = 3
    for j in range(i + 1, N + 1):
        # j = 7
        dist = j - i
        if i <= X and j >= Y:
            dist -= Y - X - 1

        if i <= X and j < Y:
            sub_dist = (X - i) + (Y - j) + 1
            if dist > sub_dist:
                dist = sub_dist
        elif i > X and j >= Y:
            sub_dist = (i - X) + (j - Y) + 1
            if dist > sub_dist:
                dist = sub_dist

        ans[dist] += 1

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
d = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        d[(i, j)] = j-i
for i in range(X+1):
    for j in range(Y, N):
        d[(i, j)] = X-i+1+j-Y
for i in range(X+1, X+Y//2):
    for j in range(Y, N):
        d[(i, j)] = min(d[(i, j)], i-X+1+j-Y)
for i in range(X+1):
    for j in range(X+Y//2, Y):
        d[(i, j)] = min(d[(i, j)], X-i+1+Y-j)
cnt = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        cnt[d[(i, j)]] += 1
for i in range(1, N):
    print(cnt[i])

Submission status: Wrong Answer

Solution code:
from pprint import pprint
from collections import Counter
N, X, Y = map(int, input().split())

d = [[float("inf")]*N for i in range(N)] 
for i in range(N-1):
    d[i][i+1] = 1
    d[i+1][i] = 1

d[X-1][Y-1] = 1
d[Y-1][X-1] = 1

def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(i):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

wf = warshall_floyd(d)
for i in range(N):
    wf[i][i] = 0

c = Counter()
for i in range(N):
    c.update(wf[i][:i])

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

Submission status: Wrong Answer

Solution code:
import collections
from collections import deque

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

#辺のリスト
n = N
l_hen = [[i,i+1] for i in range(1,n)]+[[X,Y]]

#頂点のラベルリスト
l_chouten =list( set(sum(l_hen, [])) )

#G={頂点:[頂点に繋がっている点たち],... } を取得する
G = dict( [ (key,[]) for key in l_chouten]  )
for i in range(n):
   G[l_hen[i][0]].append(l_hen[i][1])

#無効グラフの場合両方から見ているので以下のコードも実行する
for i in range(n):
   G[l_hen[i][1]].append(l_hen[i][0])

'''
以上グラフの準備
'''


#距離の羅列用  
l_d =deque([])  
for point in range(1,N+1):
  #seenとtodoの初期設定
  l_seen = {i:False for i in l_chouten}
  l_todo = []
  dist = {i:-1 for i in l_chouten}


  #seenに出発地点pを決めてやる、出発点の隣接リストもtodoに入れる
  p = point
  l_seen[p] = True #pはチェック済み
  for i in G[p]:
    l_seen[i] = True #pに隣接する頂点もチェック済み
  l_todo = l_todo + G[p] #pに隣接する頂点をtodoリストに追加
  l_todo = deque(l_todo)
  dist[p] = 0
  for i in G[p]:
    dist[i] = 1 #pに隣接する頂点とpとの距離を1とする
    l_d.append(dist[i])
  

  #探索
  while len(l_todo) != 0:
    #幅優先探索
    v = l_todo.popleft() #todoの左端つまりindex0から処理しているので
    for i in G[v]:
      #回り込まれて先越された時
      if l_seen[i] == True and dist[i]==dist[v]+1:
        l_d.append(dist[i])
      elif l_seen[i] == True:
        continue
      else:
        l_seen[i] = True
        l_todo.append(i)
        dist[i]=dist[v]+1
        l_d.append(dist[i])
###
c = collections.Counter(l_d)
for i in range(1,N):
  print(c[i]//2)

Submission status: Wrong Answer

Solution code:
n,x,y = (int(x) for x in input().split())
x-=1
y-=1
middle=(y+x)/2
list=[[0 for i in range(n)]for j in range(n)]
dic={}
for i in range(n-1):
    for j in range(i+1,n):
        if i<=x and j<=x:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif j==middle:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i==middle:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i<=x and j>=x and j<=middle:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i<=x and j>=middle and j<=y:
            k = (x-i) + 1 + (y-j)
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i<=x and j>=middle and j>=y:
            k = (x-i) + 1 + (j-y)
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i>=x and i<=middle and j<=middle:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i>=x and i<=middle and j>=middle and j<=y:
            k = min(j-i, i-x+y-j+1)
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i>=x and i<=middle and j>=y:
            k = i-x + j-y + 1
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i>=middle and j<=y:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i>=middle and j>=y:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
        elif i>=y and j>=y:
            k = j-i
            if k not in dic:
            	dic[k]=1
            else:
            	dic[k]+=1
dic={}
for i in range(n-1):
    for j in range(i+1,n):
        if list[i][j] not in dic:
            dic[list[i][j]]=1
        else:
            dic[list[i][j]]+=1
for i in range(1,n):
    if i not in dic:
        print(0)
    else:
        print(dic[i])

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5 2 4
'''

def solve(n,x,y):
	adj = [[] for i in range(n+1)]
	adj[x].append(y)
	adj[y].append(x)
	for i in range(1,n):
		adj[i].append(i+1)
		adj[i+1].append(i)
	# print(adj)
	ans = []
	d = {}
	for i in range(1,n):
		d[i] = 0
	for k in range(1,n+1):
		q = [k]
		dis = [maxsize]*(n+1)
		dis[k] = 0
		while(q):
			src = q.pop()
			for nn in adj[src]:
				if(dis[nn] > dis[src]+1 and (nn > k or (k-1 == X or k-1 == Y))):
					dis[nn] = dis[src] + 1
					q.append(nn)
			# if(k == 3):
			# 	print('src:',src)
			# 	print('dis:',dis)
		curr = 0
		# if(k == 3):
		# print('k:',k,dis)
		for ii in range(k+1,n+1):
			d[dis[ii]] += 1
	return d

N,X,Y = list(map(int, stdin.readline().rstrip().split()))
ans = solve(N,X,Y)
for i in range(1,N):
	print(ans[i])

Submission status: Wrong Answer

Solution code:
N, X, Y = (int(x) for x in input().split())
line = [(i,i+1) for i in range(1,N)]
line.insert(X-1, (X,Y))

dis = [[N*2]*(N+2) for _ in range(N+2)]
for i in range(1, N):
    for j in range(i+1, N+1):
        if i <= X and Y <= j:
            dis[i][j] = (X-i) + (j-Y) + 1
        else:
            dis[i][j] = j-i

fdis = sum(dis, [])
fdis = [x for x in fdis if x != N*2]
for k in range(1,N):
    print(fdis.count(k))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n, X, Y = [int(x) for x in input().split()]

ans = [0] * (n) # 1 ~ n - 1

g = [x for x in range(1, n + 1)]
g_2 = [x for x in range(1, n + 1)]
g_2[Y - 1] = X + 1
for i in range(Y, n):
    if i < n:
        g_2[i] -= (Y - X - 1)
# print(g)
# print(g_2)

for i in range(X):
    for j in range(i + 1, n):
        # print(g_2[j], g[i])
        b = min(g_2[j] - g[i], g[X - 1] - g[i] + g_2[Y - 1] - g[X - 1] + abs(g[Y - 1] - g[j]))
        ans[b] += 1

for i in range(X, Y):
    for j in range(i + 1, n):
        # print(g[j], g[i])
        a = min(g[j] - g[i], g[i] - 2 * g[X - 1] + g_2[j])
        ans[a] += 1
if Y != n:
    for i in range(Y, n):
        for j in range(i + 1, n):
            # print(g[j], g[i])
            ans[g[j] - g[i]] += 1

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,X,Y = inputMap()
	g2 = Graph()

	for i in range(N):
		if i == 0:
			continue
		#g2.add_edge(i, i-1, 1)
		g2.add_edge(i-1, i, 1)

	#g2.add_edge(X-1, Y-1, 1)
	g2.add_edge(Y-1, X-1, 1)

	for i in range(1,N):
		if i == 1:
			print(N)
			continue
		if i == N-1:
			print(0)
			continue

		ans2 = 0
		ans = []
		for ii in range(N):
			d2 = Dijkstra(g2, ii)
			for jj in range(N):
				if ii >= jj:
					continue
				tmp2 = d2.shortest_distance(jj)
				
				if tmp2 == i:
					if (jj,ii) in ans:
						continue
					#print("{} {}".format(ii+1,jj+1))
					ans2 += 1
					ans.append((ii,jj))
		print(ans2)
		#print("{} {}".format(ans,ans2))





#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# special thanks :
#  https://nagiss.hateblo.jp/entry/2019/07/01/185421
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]

def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(math.sqrt(n) * (1 + 1e-10)))

# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

dis = []

for i in range(n):
    for j in range(i+1, n):
        # またぐべきでない
        if (i+1 <= x and j+1 <= x) or (i+1 > x and i+1 < y and j+1 > x and j+1 < y) or i+1 >= y:
            kyori = j - i
            dis.append(kyori)
        # またぐべき
        elif i+1 <= x and j+1 >= y :
            kyori = (x - (i+1)) + 1 + abs((j+1) - y)
            dis.append(kyori)
        # 分からない
        else:
            kyori = min(j-i, abs(x - (i+1)) + 1 + abs(y - (j+1)))
            dis.append(kyori)

for k in range(1, n):
    print(dis.count(k))

Submission status: Wrong Answer

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

print(N)


for k in range(2, N):
    cnt = 0
    for i in range(1, N + 1):
        if X < i and i + k <= N:
            cnt += 1
        if i <= X and X - i + 1 == k:
            cnt += 2
        if i <= X and X - i + 2 <= k:
            if Y - (k - (X-i+1)) > i + k:
                cnt += 2
            if Y - (k - (X-i+1)) == i + k:
                cnt += 1
            if Y + (k - (X-i+1)) <= N:
                cnt += 1
        if i + k <= X:
            cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
d = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        d[(i, j)] = j-i
for i in range(X+1):
    for j in range(Y, N):
        d[(i, j)] = min(d[(i, j)], d[(i, j)]-Y+X+1)
for i in range(X+1, X+Y//2+1):
    for j in range(Y, N):
        d[(i, j)] = min(d[(i, j)], i-X+1+j-Y)
for i in range(X+1):
    for j in range(X+Y//2, Y):
        d[(i, j)] = min(d[(i,j)], X-i+1+Y-j)
cnt = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        cnt[d[(i, j)]] += 1
for i in range(1, N):
    print(cnt[i])

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict

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

ans = {num: 0 for num in range(1, N)}
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        dist = j - i
        if i <= X and j >= Y:
            dist -= Y - X - 1
        elif i <= X and j < Y:
            sub_dist = (X - i) + (Y - j) + 1
            if dist > sub_dist:
                dist = sub_dist
        elif i > X and j >= Y:
            sub_dist = (i - X) + (j - Y) + 1
            if dist > sub_dist:
                dist = sub_dist
        ans[dist] += 1

for num in ans.values():
    print(num)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
d = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        d[(i, j)] = j-i
for i in range(X+1):
    for j in range(Y, N):
        d[(i, j)] = min(d[(i, j)], d[(i, j)]-Y+X+1)
for i in range(X+1, X+Y//2+1):
    for j in range(Y, N):
        d[(i, j)] = min(d[(i, j)], i-X+1+j-Y)
for i in range(X+1):
    for j in range(X+Y//2, Y):
        d[(i, j)] = min(d[(i,j)], X-i+1+Y-j)
cnt = defaultdict(int)
for i in range(N-1):
    for j in range(i+1, N):
        cnt[d[(i, j)]] += 1
print(d)
for i in range(1, N):
    print(cnt[i])

Submission status: Wrong Answer

Solution code:
import queue
import numpy as np
n, x, y = map(int,input().split())
g = [[] for _ in range(n)] 
for i in range(n-1):
    g[i] = [i+1]
g[x-1].append(y-1)
# if n%2==0:
#     ma = int(n/2)
# else:
#     ma = int((n+1)/2)
# print(ma)
d = []
for i in range(n-1):
    start = i
    dist = [-1] * n
    dist[start] = 0
    que = queue.Queue()
    que.put(start)
    while not que.empty():
        v = que.get()
        for nv in g[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v]+1
            que.put(nv)
    d.append(dist)
d = np.array(d).flatten()
for i in range(1,n):
    print(int(np.count_nonzero(d==i)))

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
a = [[0 for i in range(n)] for j in range(n)]
for i in range(n-1):
  for j in range(i+1, n):
    a[i][j] = j - i
for i in range(x):
  for j in range(y-1, n):
    a[i][j] = j - i - 3
for i in range(x):
  for j in range(y-2, x-1, -1):
    z = (x + y - 1 - j) - i
    if z < a[i][j]:
      a[i][j] = z
for i in range(y-2, x-1, -1):
  for j in range(y-1, n):
    z = j - (x + y - 3 - i)
    if z < a[i][j]:
      a[i][j] = z
ans = [0 for i in range(n-1)]
for i in range(n-1):
  l = i + 1
  for j in range(n):
    for k in range(n):
      if a[j][k] == l:
        ans[i] += 1
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
#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)

Submission status: Wrong Answer

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

ans = []

for i in range(n):
  for j in range(i+1,n):
    if i <= x-i and j <= x-1:
      t=j-i
      ans.append(t)
    elif i <= x-1 and j > x-1 and j <= y-1:
      t = min(j-i, (x-1)-i + 1 + (y-1) -j)
      ans.append(t)
    elif i <= x-1 and j > y-1:
      t = (x-1)-i + 1 + j -(y-1)
      ans.append(t)
    elif i > x-1 and i < y-1 and j < y-1:
      t=j-i
      ans.append(t)
    elif i > x-1 and i < y-1 and j >= y-1:
      t = min(j-i, i-(x-1) + 1 + j - (y-1))
      ans.append(t)
    elif i >= y-1:
      t=j-i
      ans.append(t)
    else:
      print("error")

for i in range(1,n):
  print(ans.count(i))

Submission status: Wrong Answer

Solution code:
import collections
N,X,Y = map(int,input().split())

#辺のリスト
n = N
l_hen = [[i,i+1] for i in range(1,n)]+[[X,Y]]

#頂点のラベルリスト
l_chouten =list( set(sum(l_hen, [])) )

#G={頂点:[頂点に繋がっている点たち],... } を取得する
G = dict( [ (key,[]) for key in l_chouten]  )
for i in range(n):
   G[l_hen[i][0]].append(l_hen[i][1])

#無効グラフの場合両方から見ているので以下のコードも実行する
for i in range(n):
   G[l_hen[i][1]].append(l_hen[i][0])

'''
以上グラフの準備
'''


#距離の羅列用  
l_d =[]  
for point in range(1,N+1):
  #seenとtodoの初期設定
  l_seen = {i:False for i in l_chouten}
  l_todo = []
  dist = {i:-1 for i in l_chouten}


  #seenに出発地点pを決めてやる、出発点の隣接リストもtodoに入れる
  p = point
  l_seen[p] = True #pはチェック済み
  for i in G[p]:
    l_seen[i] = True #pに隣接する頂点もチェック済み
  l_todo = l_todo + G[p] #pに隣接する頂点をtodoリストに追加
  dist[p] = 0
  for i in G[p]:
    dist[i] = 1 #pに隣接する頂点とpとの距離を1とする
    l_d.append(dist[i])
  

  #探索
  while len(l_todo) != 0:
    #幅優先探索
    v = l_todo.pop(0) #todoの左端つまりindex0から処理しているので
    for i in G[v]:
      #回り込まれて先越された時
      if l_seen[i] == True and dist[i]==dist[v]+1:
        l_d.append(dist[i])
      elif l_seen[i] == True:
        continue
      else:
        l_seen[i] = True
        l_todo = l_todo + [i]
        dist[i]=dist[v]+1
        l_d.append(dist[i])
###
c = collections.Counter(l_d)
for i in range(1,N):
  print(c[i]//2)

Submission status: Wrong Answer

Solution code:
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))



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

cir = y-x+1
p = x-1
q = n-y

print(n)

ans = 0
if(cir>=5): ans =+ cir
elif(cir==4): ans =+ 2 
if(p>=1): ans+=2
if(p>=2): ans+= p-1
if(q>=1): ans+=2
if(q>=2): ans+= q-1
print(ans)
    
for ii in range(n-3):
    i = ii+3
    ans = 0
    
    if(i==cir//2 and cir%2==0):
        ans += cir//2
    elif(i<=cir//2):
        ans+=cir
    #print("a",ans)
    if(i<=cir//2+p):
        ans+=min(cir//2+p-i+1, p, i-1)*2
        if(cir%2==0 and i>cir//2):
            ans -= 1
    if(i<=cir//2+q):
        ans+=min(cir//2+q-i+1, q, i-1)*2
        if(cir%2==0 and i>cir//2):
            ans -= 1
    #print("b",ans)
    if(i<=p+q+1 and i>=3):
        ans += min(p+q+1-i+1,i-2,p,q)
    if(i<=p):
        ans+= p-i+1
    if(i<=q):
        ans+= q-i+1
    print(ans)

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
distance = []
N += 1
XYdist = Y - X - 1

for i in range(2, N) :
  for j in range(1, i) :
    if i >= Y and j <= X :
      distance.append(i - j - XYdist)
    else :
      distance.append(i - j)
      
for i in range(1, N - 1) :
  print(distance.count(i))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n, X, Y = [int(x) for x in input().split()]

ans = [0] * (n) # 1 ~ n - 1

g = [x for x in range(1, n + 1)]
g_2 = [x for x in range(1, n + 1)]
g_2[Y - 1] = X + 1
for i in range(Y, n):
    if i < n:
        g_2[i] -= (Y - X - 1)
# print(g)
# print(g_2)

for i in range(X):
    for j in range(i + 1, n):
        # print(g_2[j], g[i])
        b = min(g_2[j] - g[i], g[X - 1] - g[i] + g_2[Y - 1] - g[X - 1] + abs(g[Y - 1] - g[j]))
        ans[b] += 1

for i in range(X, Y):
    for j in range(i + 1, n):
        # print(g[j], g[i])
        a = min(g[j] - g[i], g[i] - 2 * g[X - 1] + g_2[j])
        ans[a] += 1
if Y != n:
    for i in range(Y, n):
        for j in range(i + 1, n):
            ans[g[j] - g[i]] += 1

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

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
L = []
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            length = j-i-(y-x-1)
        elif x < i < y and x < j < y:
            a = j-i
            b = (j-x)+(i-y)+1
            if a < b:
                length=a
            else:
                length=b
        elif x < i < y and j >= y:
            length = j-y
            a = y-i
            b = (i-x)+1
            if a < b:
                length+=a
            else:
                length+=b
        elif x < j < y and i <= x:
            length = x-i
            a = j-x
            b = (y-j)+1
            if a < b:
                length+=a
            else:
                length+=b
        else:
            length = j-i
        if length==0:
            length=2
        L.append(length)
for k in range(1, n):
    print(len([l for l in L if l==k]))

Submission status: Wrong Answer

Solution code:
n,x,y = map(int,input().split())
l = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        '''
        1 2,1 3,1 4
        2 3,2 4
        3 4
        '''
        if i<=x and j>=y:
            dis = x-i +1+ j-y
            l[dis-1] += 1
            #print(i,j,dis-1)
        elif i<=x and x<=j<=y:
            dis = min(j-i,x-i+y-j+1)
            l[dis-1] += 1
        elif x<=i<=y and j>=y:
            dis = min(j-i,i-x+j-y+1)
            l[dis-1] += 1
        else:
            dis = min(j-i,i-x+y-j+1)
            l[dis-1] += 1
for kkk in l:
    print(kkk)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
n, x, y = map(int, input().split())
for k in range(1, n):
    if k == 1:
        print(n)
    # elif y - x > k:
    #     if (n - y) + (x - 1) + 1 < k:
    #         print(n)
    #     else:
    #         ans = 0
    #         right = n - y
    #         left = x - 1
    #         if right + left + 1 >= k:
    #             for i in range(min(right, left)):
    #                 if k - i - 1 <= max(right, left):
    #                     ans += 1
    #         print(ans)
    else:
        ans = 0
        for i in range(1, n - k + 1):
            if i + k < y:
                ans += 1
            elif x < i:
                ans += 1
        right = n - y
        left = x - 1
        if right + left + 1 >= k:
            for i in range(min(right, left) + 1):
                if k - i - 1 <= max(right, left):
                    ans += 1
        print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, x, y = [int(i) for i in input().split()]
    adj = {i: [i+1, i-1] for i in range(1, n-1)}
    adj[0] = [1]
    adj[n-1] = [n-2]
    adj[x-1].append(y-1)
    adj[y-1].append(x-1)
    res = [0] * n
    print(adj)
    for i in range(n):
        memo = [-1] * n
        pos = i
        cand = [pos]
        memo[pos] = 0
        while len(cand) > 0:
            pos = cand.pop(0)
            for nx in adj[pos]:
                if memo[nx] != -1:
                    continue
                memo[nx] = memo[pos] + 1
                res[memo[nx]] += 1
                cand.append(nx)
    for r in res[1:]:
        print(int(r/2))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A, B = N-(Y-X-1), Y-X-1
for i in range(1, A):
    ans[i] += A - i
ans[1] -= 1

if B % 2 == 0:
    for i in range(1, (B+2)//2):
        ans[i] += (B+2)
    ans[B//2] += (B+2)//2

    C = [x for x in range(1, B//2 + 1)]
    C = C[1:] + C + [B//2 + 1]

else:
    for i in range(1, (B+2)//2 + 1):
        ans[i] += (B+2)
    C = [x for x in range(1, B//2 + 2)]
    C = C[1:] + C

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

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