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

Solution code:
import heapq

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

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

edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    if i == 0:
        edge[i].append([1,i+1])
    elif i == w-1:
        edge[i].append([1,i-1])
    else:
        edge[i].append([1,i+1])
        edge[i].append([1,i-1])
edge[X-1].append([1,Y-1])
edge[Y-1].append([1,X-1])

ans = [0]*(N+1)
tmp = []
for i in range(N):
    tmp.append(dijkstra_heap(i,edge)[i+1:])

for i in range(N):
    for j in tmp[i]:
        ans[j] += 1

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

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[min(j - i, abs(X - i) + abs(j - Y) + 1)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(Y - y) + 1)  # assume x < y
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[min(j - i, abs(X - i) + abs(Y - j) + 1)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    calc_min_dist = lambda x, y: min(y - x, abs(X - x) + abs(y - Y) + 1)  # assume x < y
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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


dic = {}

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        if v in dic:
            dic[v] += 1
        else:
            dic[v] = 1


for i in range(1, N):
    if i in dic:
        print(dic[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
from collections import deque

def bfs(u):
    dist = [-1 for _ in range(n)]
    dist[u] = 0
    que = deque([])
    que.append(u)
    
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)

    for d in dist:
        if d == 0:
            continue
        ans[d-1] += 1
    return ans


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)

ans = [0]*(n-1)
for i in range(n):
    bfs(i)

for i in ans:
    print(i//2)

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist = [0] * N
    calc_min_dist = lambda x, y: min(
        y - x, abs(X - x) + abs(y - Y) + 1, abs(Y - x) + abs(y - X) + 1
    )  # assume x < y
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist = [0] * N
    calc_min_dist = lambda x, y: min(
        y - x, abs(X - x) + abs(y - Y) + 1, abs(Y - x) + abs(y - X) + 1
    )
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist = [0] * N
    calc_min_dist = lambda x, y: min(
        abs(x - y), abs(X - x) + abs(y - Y) + 1, abs(Y - x) + abs(y - X) + 1
    )
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist[1:])))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque
import sys
sys.setrecursionlimit(10**6)

def bfs(u):
    dist = [-1 for _ in range(n)]
    dist[u] = 0
    que = deque([])
    que.append(u)
    
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)

    for d in dist:
        if d == 0:
            continue
        ans[d-1] += 1
    return ans


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)

ans = [0]*(n-1)
for i in range(n):
    bfs(i)

for i in ans:
    print(i//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,X,Y = map(int,(input().split()))
cn = [[] for _ in range(N+1)]
for i in range(1,N+1):
    if i-1 >= 1:
        cn[i].append(i-1)
    if i+1 <= N:
        cn[i].append(i+1)
    if i == X:
        cn[X].append(Y)
    if i == Y:
        cn[Y].append(X)

result = {}

for i in range(1,N+1):

    dis = [0]*(N+1)

    not_visit = [True]*(N+1) 
    stack = [i]
    not_visit[i] = False

    while stack:
        now = stack.pop(0)
        for j in cn[now]:
            if not_visit[j]:
                not_visit[j] = False
                stack.append(j)
                dis[j] = dis[now] + 1

    for i in range (0,len(dis)):
        item = dis[i]
        if item in result:
            result[item] = result[item]+1
        else:
            result[item] = 1

for i in range(1,N):
    if i in result:
        print(result[i]//2)
    else:
        print(0)

Submission status: Accepted

Solution code:
n, x, y = map(int, input().split())
freq = [0 for i in range(n+1)]
for i in range(1, n+1):
  for j in range(i+1, n+1):
    dist = min(j-i, abs(i-x) + 1 + abs(y-j))
    freq[dist] += 1
for i in range(1,n):
  print(freq[i])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(N)

X -= 1
Y -= 1

def disdance(i, j):
    if i <= X and j >= Y:
        return X - i + j - Y + 1
    elif i >= X and j <= Y:
        return min(j - i, i - X + Y - j + 1)
    elif i >= X and j >= Y:
        return min(j - i, i - X + j - Y + 1)
    elif i <= X and j <= Y:
        return min(j - i, X - i + Y - j + 1)

d = [0] * N

for i in range(N - 1):
    for j in range(i + 1, N):
        d[disdance(i, j)] += 1

for k in range(2, N):
    print(d[k])

Submission status: Accepted

Solution code:
from collections import deque
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
K = [0 for _ in range(N)]
INF = 10 ** 9
def bfs(n):
    d = deque()
    d.append(n)
    reached = [INF for _ in range(N)]
    reached[n] = 0
    dx = [-1, 1]
    while d:
        x = d.popleft()
        for i in range(2):
            nx = x + dx[i]
            if nx < 0 or nx > N - 1 or reached[nx] != INF:
                continue
            d.append(nx)
            reached[nx] =reached[x] + 1
        if x == X and reached[Y] == INF:
            reached[Y] = reached[x] + 1
            d.append(Y)
        if x == Y and reached[X] == INF:
            reached[X] = reached[x] + 1
            d.append(X)
    for i in range(N):
        K[reached[i]] += 1            

for i in range(N):
    bfs(i)

for i in range(1, N):
    print(K[i]//2)

Submission status: Accepted

Solution code:
s=input().split()
n=int(s[0])
x=int(s[1])
y=int(s[2])
current=0
list=[0]*(n-1)
for i in range(n) :
  for j in range(i+1,n) :
    k=min(j-i,abs(x-i-1)+1+abs(y-j-1))
    
    list[k-1]+=1
for youso in list :
  print(youso)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]



def main():
    a=LI()
    n=a[0]
    x=a[1]-1
    y=a[2]-1
    dist={}
    ans={}
    for i in range(n):
        dist[i]={}
        ans[i]=0
    for i in range(n):
        for j in range(i+1, n):
            dist[i][j]=min(j-i, 1+abs(j-y)+abs(i-x))
            ans[dist[i][j]]+=1
    for i in range(1,n):
        print(ans[i])
main()

Submission status: Accepted

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

ans_list = [0]*(N-1)

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

for i in ans_list:
    print(i)

Submission status: Accepted

Solution code:
from collections import deque
N, X, Y = map(int, input().split())
INF = N+1
q = deque()

def node_search(i):
    nodes = []
    if i < N and check[i+1] == 0:
        nodes.append(i+1)
    if i > 1 and check[i-1] == 0:
        nodes.append(i-1)
    if i == X and check[Y] == 0:
        nodes.append(Y)
    return nodes


cnt = [0]*N
for i in range(1, N):
    check = [0]*(N+1)
    dist = [INF] * (N + 1)
    dist[i] = 0
    q.append(i)
    d = 1
    while q:
        now_node = q.pop()
        check[now_node] = 1
        for next_node in node_search(now_node):
            dist[next_node] = min(dist[now_node]+1, dist[next_node])
            q.appendleft(next_node)


    for j in range(i+1, N+1):
        cnt[dist[j]] += 1

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


a = 0

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


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

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

Submission status: Accepted

Solution code:
from sys import stdin
N, X, Y = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]

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)+1+abs(Y-j))
        ans[d] += 1
        #ans.append(j-i)
        #print(min(j-i, abs(i-X)+1+abs(Y-j)), i, j)

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

Submission status: Accepted

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

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

def bfs(i):
    dist = [-1]*N
    dist[i] = 0
    que = collections.deque([])
    que.append(i)
    
    while len(que) != 0:
        v = que.popleft()
        for nv in graph[v]:
            if dist[nv] != -1:continue
            dist[nv] = dist[v]+1
            que.append(nv)
    return dist[i+1:]

graph = {}
for i in range(N):
    graph[i] = set()

for i in range(N-1):
    graph[i].add(i+1)
    graph[i+1].add(i)
graph[X-1].add(Y-1)
graph[Y-1].add(X-1)

d = collections.Counter([])
for i in range(N):
    d += collections.Counter(bfs(i))
for i in range(1,N):
    if i == N-1:
        print(0)
    else:
        print(d[i])

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

answer = [0 for _ in range(0, N)]
for i in range(1, N+1):
    for j in range(i, N+1):
        distance1 = abs(i-j)
        distance2 = abs(X-i) + abs(Y-j) + 1
        distance3 = abs(X-j) + abs(Y-i) + 1
        min_distance = min(distance1, distance2, distance3)
        answer[min_distance] += 1
for a in answer[1:]:
    print(a)

Submission status: Accepted

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

    x -= 1
    y -= 1

    ans_list = [0]*n

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

answer = [0 for _ in range(0, N)]
for i in range(1, N+1):
    for j in range(i, N+1):
        distance1 = abs(i-j)
        distance2 = abs(X-i) + abs(Y-j) + 1
        distance3 = abs(X-j) + abs(Y-i) + 1
        min_distance = min(distance1, distance2, distance3)
        answer[min_distance] += 1
for i, a in enumerate(answer):
    if i != 0:
        print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from heapq import heappush, heappop
from collections import deque
n, x, y = list(map(int, input().split()))
G = [[]*n 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)

N = n
# G[v]: 頂点vに隣接する頂点list
# N: 頂点数
dd = []
for i in range(n):
    dist = [-1]*N
    que = deque([i])
    dist[i] = 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)
    dd.append(dist)
ans = defaultdict(lambda: 0)
for dist in dd:
    for t in dist:
        ans[t] += 1
for i in range(n-1):
    print(ans[i+1]//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,X,Y=map(int,input().split())
    X-=1
    Y-=1
    
    def dijkstra(start,n,edges):
        d=[INF]*n
        used=[False]*n
        d[start]=0
        used[start]=True
        edgelist=[]
        for edge in edges[start]:
            heappush(edgelist,edge)
        while edgelist:
            minedge=heappop(edgelist)
            if used[minedge[1]]:
                continue
            v=minedge[1]
            d[v]=minedge[0]
            used[v]=True
            for edge in edges[v]:
                if not used[edge[1]]:
                    heappush(edgelist,(edge[0]+d[v],edge[1]))
        return d
    
    edges=[[] for _ in range(N)]
    for i in range(N-1):
        edges[i].append((1,i+1))
        edges[i+1].append((1,i))
    edges[X].append((1,Y))
    edges[Y].append((1,X))

    ans=[0]*N
    for i in range(N):
        d=dijkstra(i,N,edges)
        for x in d:
            ans[x]+=1
    for row in ans[1:]:
        print(row//2)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

#edge = [[] for _ in range(n)]
cnt = [0] * n
#dist = [0] * n
#for i in range(1,n):
#    edge[i].append(i - 1)
#    edge[i - 1].append(i)

#edge[x].append(y)
#edge[y].append(x)

#def dfs(x, last = -1):
#    cnt[dist[x]] += 1
#    for nxt in edge[x]:
#        if nxt == last:continue
#        dist[nxt] = dist[i] + 1
#        dfs(nxt, x)

for i in range(n):
    for j in range(i + 1, n):
        dist = min(j - i,abs(j - x) + 1 + abs(i - y), abs(j - y) + 1 + abs(i - x))
        cnt[dist] += 1
#    dist[i] = 0
#    dfs(i)

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

Submission status: Accepted

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

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

graph = [[] for _ in range(N + 1)]
for i in range(1, N):
    graph[i].append(i + 1)
    graph[i + 1].append(i)
graph[X].append(Y)
graph[Y].append(X)

def dfs(st, graph):
    INF = 10 ** 18
    dist = [INF] * len(graph)
    dist[st] = 0
    stack = [st]
    while stack:
        s = stack.pop()
        for t in graph[s]:
            if dist[t] > dist[s] + 1:
                dist[t] = dist[s] + 1
                stack.append(t)
    return dist

answer = [0] * (N + 1)
for i in range(1, N + 1):
    dist = dfs(i, graph)
    for j in range(1, N + 1):
        answer[dist[j]] += 1

for i in range(1, N):
    print(answer[i] // 2)

Submission status: Accepted

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

Submission status: Accepted

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

k = [0]*N
for p1 in range(1,N):
  for p2 in range(p1+1,N+1):
    d = [0]*3
    d[0] = p2-p1
    d[1] = abs(X-p1)+1+abs(Y-p2)
    d[2] = abs(X-p2)+1+abs(Y-p1)
    k[min(d)] += 1
k = list(map(str, k))
print('\n'.join(k[1:N]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import numpy as np
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
N, X, Y = list(map(int, input().split()))
x=min([X,Y])
y=max([X,Y])
dists = [0] * (N-1)
 
for i in range(0,N-1):
  for j in range(i+1,N):
    dists[min([abs(j-i), abs(x-i-1)+1+abs(j+1-y)])-1] += 1

for s in dists:
  print(s)

Submission status: Accepted

Solution code:
from itertools import combinations

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


def length(i, j):
  return min(j - i, abs(X - i) + abs(Y - j) + 1, abs(X - j) + abs(Y - i) + 1)


counter = [0] * (N - 1)

for i, j in combinations(range(1, N + 1), 2):
  l = length(i, j)
  counter[l - 1] += 1

for c in counter:
  print(c)

Submission status: Accepted

Solution code:
from sys import stdin


def get_result(data):
    N, X, Y = data
    dist_cnt = [0 for i in range(N)]
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            min_dist = min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)])
            dist_cnt[min_dist] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)

Submission status: Accepted

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

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

[print(i) for i in dis]

Submission status: Accepted

Solution code:
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):
    tmp = min(j - i, abs(i - X) + abs(j - Y) + 1)
    ans[tmp] += 1
for i in range(1, N):
  print(ans[i])

Submission status: Accepted

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

k=[0]*n

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

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

Submission status: Accepted

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

x-=1
y-=1

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

Submission status: Accepted

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

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

for i in range(1, len(ans_list)):
    print(ans_list[i])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = [ 0 for _ in range(N-1)]

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

Submission status: Accepted

Solution code:
import collections
N,X,Y=map(int,input().split())
xdex=X-1            #配列に落とし込んで考える時は
ydex=Y-1            #素の値-1にして考えると混乱がない
"""
#ans1…愚直な場合分け
l=[0]*(N)
#print(l)
le=0
#print(xdex,ydex)
for i in range(N):
    for j in range(i+1,N):
        le=(j-i)
        if (i<=xdex)and(ydex<=j):
            le = min(j - i, (j - i) - (Y - X - 1))
        elif ((i<=xdex)and(j<=ydex)and(xdex<=j)):
            le=min(j - i, (xdex-i)+(ydex- j)+1)
        elif ((xdex<i)and(j<=ydex)and(xdex<=j)):
            le=min(j-i,(i-xdex)+(ydex-j)+1)
        elif ((xdex<i)and(ydex<j)):
            le=min(j-i,(i-xdex)+(j-ydex)+1)
        #print(i+1,j+1,le)
        l[le]=l[le]+1
#print(l)
for i in range(N-1):
    print(l[i+1])
"""
#ans2…bfsチックなやつ
inf=1001001
def pus(v,d,dist,q):    #vは頂点,dは距離、distは(1頂点固定時の)距離配列、 qは作業用deque
    if dist[v]==inf:    #ある点から頂点vまでの距離が定義されてないならば
        dist[v]=d       #vまでの距離はdである
        q.append(v)     #次はvを起点にして考えるつもり
    return 0


v=0
d=0
ans=[0]*N
for i in range(N):                  #N頂点全てにてやる
    dist=[inf]*N                    #まず頂点iからの距離配列を組む(まずは距離を無限大に定義mugendainiteigi)
    q = collections.deque()         #qは距離計算時の基準点を格納する。それにより、始点から基準点までの距離を計算できていれば、基準点から新しい点までの距離も計算でき、再帰的に視点から新しい点までの距離が格納される流れだ
    pus(i,0,dist,q)                 #まず始点iは距離が0であることを格納する
    while len(q)!=0:                #以後基準点をpopしていくので、もう基準点ができないこと=全て探索できたということである
        #print(dist,q)
        v=q.popleft()               #qの中にvは距離が小さい順に右へ右へappendしていくため、最短路探査の際にはqの最左頂点vを基準に探索する(探索できたら不要なのでq.popleftで対応)
        d=dist[v]                   #取りまず基準点からvまでの距離をdとする
        if (v-1>=0):                #左に行けるなら
            pus(v-1,d+1,dist,q)     #頂点v-1へはvまでの距離dに1加えた距離でも行ける。distにこれを格納し、q.append(v-1)とすれば良い
        if (v+1<N):                 #右に行けるなら
            pus(v+1,d+1,dist,q)     #頂点v+1へはvまでの距離dに1加えた距離でも行ける。distにこれを格納し、q.append(v-1)とすれば良い
        if v==xdex:                 #ここがxdex(分岐の最左部)ならば
            pus(ydex,d+1,dist,q)    #頂点ydex(分岐の最右側)まではvまでの距離dに1加えた距離でも行ける。distにこれを格納し、q.append(xdex)とすれば良い
        if v==ydex:                 #ここがydex(分岐の最右部)ならば
            pus(xdex,d+1,dist,q)    #頂点xdex(分岐の最左側)まではvまでの距離dに1加えた距離でも行ける。distにこれを格納し、q.append(ydex)とすれば良い
        #print(dist,q)
        #input()
    for i in range(N):              #全ての点にて
        ans[dist[i]]=ans[dist[i]]+1 #基準点からの距離dist[i]をincrementすれば、ある点から全ての点までの距離を格納できる(これをN頂点にやれば全て探査できる)
for i in range(1,N):                #距離1の時の数値から出力することに注意
    print(ans[i]//2)                #距離の個数は重複しているので/2した値を出力する

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

    x -= 1
    y -= 1

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

    for ret in result:
        print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

def dist(i,j):
    return min(abs(j-i), abs(X-i)+1+abs(j-Y))

ans = [0]*N
for i in range(N):
    for j in range(i+1, N):
        d = dist(i+1,j+1)
        ans[d] += 1
for i in range(N):
    if i == 0:
        continue
    print(ans[i])

Submission status: Accepted

Solution code:
def MI():return map(int,input().split())
def LI():return list(MI())

from collections import deque
INF=float("inf")
n,x,y=MI()
x-=1
y-=1
ans=[0]*n

for sv in range(n):
  dist=[INF]*n
  q=deque()
  def push(v,d):
    if dist[v]!=INF:
      return
    dist[v]=d
    q.append(v)
  push(sv,0)
  while q:
    v=q.popleft()
    d=dist[v]
    if v-1>=0:
      push(v-1,d+1)
    if v+1<n:
      push(v+1,d+1)  
    if v==x:
      push(y,d+1)
    if v==y:
      push(x,d+1)
        
  for i in range(n):
    ans[dist[i]]+=1
for i in range(n):
  ans[i]//=2
for i in range(1,n):
  print(ans[i])

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

    for r in ret:
        print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

dists = Counter([min(j - i, abs(x - i) + abs(y - j) + 1) for i in range(n - 1) for j in range(i + 1, n)])
[print(dists.get(i, 0)) for i in range(1, n)]