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 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:
        print(int(r/2))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

_list=[]

for i in range(1,n):
    for j in range(i+1,n+1):
        if j<=x:
            tmp=j-i
        elif x<i and j<y:
            tmp=j-i
        elif y<=i:
            tmp=j-i

        elif i<=x and y<=j:
            tmp=j-i -(y-x-1)

        elif i<=x and x<j and j<y:
            tmp=min(j-i,(x-i)+1+(y-j))
        elif x<i and i<y and y<=j:
            tmp=min(j-i,(i-x)+1+(j-y))

        _list.append(tmp)

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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
#from scipy.special import comb
import itertools

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

combi = list(itertools.combinations(range(1,N+1), 2))
#print(combi)
dist = {}
for i in range(1, N):
    dist[i] = 0

for kyori in combi:
    if kyori[1] >= Y and kyori[0] <= X:
        c = (kyori[1] - Y) + 1 + (X - kyori[0])
    elif kyori[1] >= Y:
        a = kyori[1] - kyori[0]
        b = (kyori[1] - Y) + 1 + int(abs((X - kyori[0])))
        c = min([a, b])
    elif kyori[0] <= X:
        a = kyori[1] - kyori[0]
        b = int(abs(kyori[1] - Y)) + 1 + (X - kyori[0])
        c = min([a, b])
    else:
        c = kyori[1] - kyori[0]
    dist[c] += 1
    #print(c, kyori)
dist2 = sorted(dist.items())
#print(dist, dist2)
for i in range(0, N-1):
    print(dist2[i][1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import numpy as np

res = np.zeros(shape=(n, n))

for i in range(1, n):
    res[i - 1, i] = 1

res[x -1, y - 1] = 1

for i in range(0, n):
    for j in range(i + 2, n):

        jibun = res[i, j]
        hidari = res[i, j - 1]
        shita = res[i + 1, j]

        if jibun == 0:
            if shita == 0:
                res[i, j] = hidari + 1
            else:
                res[i, j] = min(hidari, shita) + 1

for i in range(1, n):
    ans = np.count_nonzero(res == i)
    print(ans)

Submission status: Wrong Answer

Solution code:
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

n,x,y=map(int,input().split())
cost = [[float("inf") for i in range(n)] for i in range(n)]
#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
for i in range(1,n):
    cost[i-1][i] = 1
    cost[i][i-1]=1
cost[x-1][y-1]=1
cost[y-1][x-1]=1
ans=[[float("0") for i in range(n)] for i in range(n)] 
for j in range(n):
    ans[j]=dijkstra(j,n,n,cost)
def flatten_2dim(array):
    return [item for sublist in array for item in sublist]
data = flatten_2dim(ans)
for k in range(1,n-1):
    print(int(data.count(k)/2))

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

Submission status: Wrong Answer

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

tb=[[0]*(n+1) for i in xrange(n+1)]
tb[x][y]=1
for i in xrange(1, n+1):
    for j in xrange(i+1,n+1):
        # if i==x:
        #     continue
        if i<=x and j==y:
            tb[i][j]=min(tb[i][j-1]+1-(y-x)+1, j-i)
        else:
            tb[i][j]=min(tb[i][j-1]+1, j-i)

res=[0]*(n+1)

for i in xrange(1 ,n+1):
    for j in xrange(i+1, n+1):
        res[tb[i][j]]+=1

s=''
for i in xrange(1, n):
    s+=str(res[i])+'\n' 

# for i in tb:
#     print i
print s

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
        L.append(length)
for k in range(1, n):
    if k == 2:
        print(len([l for l in L if l==k])+1)
    else:
        print(len([l for l in L if l==k]))

Submission status: Wrong Answer

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

def solve(k):
    global N
    global X
    global Y
    count = 0
    count = N-k
    if count<0:
        count = 0
    
    for i in range(N):
        p = i+1
        if abs(X-p)+1+N-Y>=k and abs(X-p)+1<=k:
            count += 1
        if abs(X-p)+1+(Y-p)>k and  abs(X-p)+1<=k:
            count += 1
    
        
    print(count)
    
for i in range(N-1):
    solve(i+1)

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, n):
    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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import numpy as np


arr = [0] * (n - 1)
b = n - (y - x - 1)

for k in range(b):
    arr[k] = b - k - 1

r = (y - x - 1)
left = x
right = n - y + 1


for k in range(r):
    arr[k] += r - k - 1

if r % 2 == 1:
    arr_r = [1] + [2] * (r // 2)
else:
    arr_r = [1] + [2] * (r // 2 - 1) + [1]

arr_r = np.array(arr_r)
arr = np.array(arr)

for k in range(right):
    arr[k:len(arr_r) + k] += arr_r

for k in range(left):
    arr[k:len(arr_r) + k] += arr_r

for a in arr:
    print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
from scipy.sparse.csgraph import shortest_path

list_in = list(map(int, input().split()))
N = list_in[0]
X = list_in[1]
Y = list_in[2]

graph_arr = np.zeros((N,N), dtype=np.int)

for i in range(N-1):
    graph_arr[i, i + 1] = 1

graph_arr[X-1, Y-1] = 1

result = shortest_path(graph_arr)
for i in range(1, N):
    num_path = np.count_nonzero(result == i)
    print(num_path)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

D = [0] * (N - 1)

for i in range(1, N+1):
    for j in range(i + 1, N+1):
        K = j - i
        M = abs(X - i) + 1 + abs(Y - j)
        J = abs(Y - i) + 1 + abs(X - i)
        R = min(K, M, J)
        D[R - 1] += 1

for d in D:
    print(d)

Submission status: Wrong Answer

Solution code:
def shortest_path(s, n, es):
    d = [float('inf')] * n

    d[s] = 0
    while True:
        update = False
        for p, q in es:
            if d[p] != float('inf') and d[q] > d[p] + 1:
                d[q] = d[p] + 1
                update = True
        if not update:
            break
    return d

n, x, y = map(int, input().split())
es = [(x - 1, y - 1), (y - 1, x - 1)]
for i in range(n - 1):
    es.append((i, i + 1))
    es.append((i + 1, i))
length = [0] * (n - 1)
for i in range(n - 1):
    a = shortest_path(i, n, es)
    for l in range(i + 1, n):
        if a[l] != float('inf') and l != 0:
            length[a[l] - 1] += 1
print(length)

Submission status: Wrong Answer

Solution code:
n, x, y = (int(x) for x in input().split())
g = []
for i in range(1, n + 1):
    g.append(i)
for i in range(1, n):
    cnt = 0
    for g_1 in g:
        for g_2 in g:
            if g_1 <= x and g_2 >= y:
                if g_2 - g_1 - (y - x) + 1 == i:
                    cnt += 1
            else:
                if g_2 - g_1 == i:
                    cnt += 1
    print(cnt)

Submission status: Wrong Answer

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


def how_many(k,n,x,y):
    res = 0
    for i in range(n):
        for j in range(n):
            nom = abs(i - j)
            x_y = abs(i-x)+1+abs(y-j)
            y_x = abs(i-y)+1+abs(x-j)
            tmp = min(nom,x_y,y_x)
            tmp_a = [nom,x_y,y_x]
            if(tmp == k):
                #print(i,j)
                res += tmp_a.count(tmp)
    
    return res//2
    

#print(how_many(2,n,x-1,y-1))

for k in range(1,n):
    print(how_many(k,n,x-1,y-1))

Submission status: Wrong Answer

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

_list=[]

for i in range(1,n):
    for j in range(i+1,n+1):
        if j<=x:
            tmp=j-i
        elif x<i and j<y:
            tmp=j-i
        elif y<=i:
            tmp=j-i

        elif i<=x and y<=j:
            tmp=j-i -(y-x-1)

        elif i<=x and x<j and j<y:
            tmp=min(j-i,(x-i)+1+(y-j))
        elif x<i and i<y and y<=j:
            tmp=min(j-i,(i-x)+1+(j-y))
        else:
            print('error')

        _list.append(tmp)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
a,b,c=map(int,input().split())
half_a=a//2
if a==c and b==1:
    if a%2:

        for n in range(1,a):
            if n<=half_a:
                print(a)
            else:
                print(0)
    else:

        for n in range(1,a):
            if n<=half_a:
                print(a)
            else:
                print(0)

Submission status: Wrong Answer

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

N, X, Y = map(int, input().split())
dp = [[N] * N for _ in range(N)]
for i in range(N):
  dp[i][i] = 0
  for j in range(i, N - 1):
    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)

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

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

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

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

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

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

  for j in range(N - 1, 0, -1):
    dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)
table = [0] * N
for i in range(N):
  for j in range(i, N):
    if dp[i][j] < N: table[dp[i][j]] += 1

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

Submission status: Wrong Answer

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

N, X, Y = map(int, input().split())
dp = [[N] * N for _ in range(N)]
for i in range(N):
  dp[i][i] = 0
  for j in range(i, N - 1):
    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)

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

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

  for j in range(N - 1, 0, -1):
    dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)
table = [0] * N
for i in range(N):
  for j in range(i, N):
    if dp[i][j] < N: table[dp[i][j]] += 1

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

Submission status: Wrong Answer

Solution code:
from collections import deque

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


def bfs(x):
    q = deque([])
    q.append(x)

    while q:
        x = q.popleft()

        if x == X - 1:
            dist[Y - 1] = dist[x] + 1
            q.append(Y - 1)

        if x == N - 1:
            continue

        if dist[x + 1] != 0:
            continue
        else:
            dist[x + 1] = dist[x] + 1
            q.append(x + 1)


dist_lis = [0] * N

for i in range(N):
    for j in range(N):
        dist = [0] * N
        bfs(i)
        dist_lis[dist[j]] += 1

# print(dist)
# print(dist_lis)

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

Submission status: Wrong Answer

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

N, X, Y = map(int, input().split())
dp = [[N] * N for _ in range(N)]
for i in range(N):
  dp[i][i] = 0
  for j in range(i, N - 1):
    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)
  for j in range(N - 1, 0, -1):
    dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)
  for j in range(i, N - 1):
    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1)
    if j == X - 1:
      dp[i][Y - 1] = min(dp[i][Y - 1], dp[i][j] + 1)
table = [0] * N
for i in range(N):
  for j in range(i, N):
    if dp[i][j] < N: table[dp[i][j]] += 1

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

Submission status: Wrong Answer

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

tb=[[0]*(n+1) for i in xrange(n+1)]
tb[x][y]=1
for i in xrange(1, n+1):
    for j in xrange(i+1,n+1):
        # if i==x:
        #     continue
        if i<=x and j==y:
            tb[i][j]=tb[i][j-1]+1-(y-x)+1
        else:
            tb[i][j]=tb[i][j-1]+1

res=[0]*(n+1)

for i in xrange(1 ,n+1):
    for j in xrange(i+1, n+1):
        res[tb[i][j]]+=1

s=''
for i in xrange(1, n):
    s+=str(res[i])+'\n'
print s

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, x, y = map(int, sys.stdin.readline().split())
	x -= 1
	y -= 1
	ans = [0]*(n-1)
	for i in range(n):
		for j in range(i+1, n):
			log.print(i, j, ans, x, y, j-y, x-i)
			if i == j:
				continue
			if (i <= x and j <= x) or (y <= i and y <= j):
				ans[abs(i-j)-1] += 1
			elif (i <= x and y <= j):
				ans[x-i + j-y + 1 - 1] += 1
			elif (x < i < y and x < j < y):
				ans[abs(i-j)-1] += 1
			elif (i <= x and x < j < y):
				ans[min(abs(i-j), x-i + 1 + y-j)-1] += 1
			elif (x < i < y and y <= j):
				ans[min(abs(i-j), j-y + 1 + i-x)-1] += 1
	for i in range(len(ans)):
		print(ans[i])







main()

Submission status: Wrong Answer

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

for i in range(1, n):
  s = 0
  for a in range(1, n):
    for b in range(a, n+1):
      if n < b:
        break
      #print(a,b)
      if a <= x and y <= b:
        if b-a-1 == i:
          s += 1  
      elif b-a == i:
        s += 1
  print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,x,y = map(int,input().split())
a = y - x
for i in range(n-1):
    b = np.maximum(n-a-i,0)
    count = np.maximum(0,a-1-i-1)
    for j in range(a-1):
        x1 = min(j+1,a-j)
        y1 = min(j+2,a-j-1)
        if i+1 == x1:
            count+=1
            #print('a')
        elif i+1 >= x1 and x1 + x-1 >= i+1:
            count+=1
            #print('b')
        if i+1 == y1:
            count+=1
            #print('c')
        elif i+1 >= y1 and n-y+y1 >= i+1:
            count+=1
            #print('d')
    print(b+count)

# 1 2 3     7
#     4 5 6 




# x + j + 1 より
# j+1 y-(x+j+1)+1
# j+2 y-(x+j+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, X, Y = [int(i) for i in input().split()]
gp = [[float('inf')]*N for _ in range(N)]

def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(i+1,n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



for i in range(N-1):
    gp[i][i+1] = 1
    gp[i+1][i] = 1
    if(i==X-1):
        gp[i][Y-1] = 1
        gp[Y-1][i] = 1

d = warshall_floyd(gp, N)
li = [0]*(N-1)
for i in range(N):
    for j in range(i+1, N):
        li[d[i][j]-1] += 1

for i in li:
    print(i)

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
k=[0]*(n-1)
num = (n*(n-1))//2
for i in range(1,n):
	for j in range(i+1,n+1):
		if i<=x and y<=j:
			k[j-i-y+x] += 1
		elif x<j and j<y and i<=x:
			unta = min(j-i-1, y-j-i+x)
			k[unta] += 1
		elif x<i and i<y and y<=j:
			unta = min(j-i-1, i+j-x-y)
			k[unta] += 1
		else:
			k[j-i-1] += 1
for i in range(n-1):
	print(k[i])

Submission status: Wrong Answer

Solution code:
def main():
    n,x,y=map(int,input().split())
    Ans=[0]*n
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i<=x and y<=j:
                d=x-i+j-y+1
            elif i<=x and x<=j<=y:
                d=min(j-i,x-i+1+y-j)
            elif x<=i<=y and j>=y:
                d=min(j-i,i-x+1+j-y)
            else:
                d=j-i
            #print(i,j,d)
            Ans[d]+=1
    for ans in Ans[1:]:
        print(ans)
    
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,X,Y=map(int,input().split())
s=[]
for i in range(1,N):
  for j in range (i+1,N+1):
    if j<=X or Y<=i or (X<i and j<Y):
      s.append(j-i)
    elif i<=X and Y<=j:
      s.append(j-Y+X-i+1)
    else:
      s.append(min((j-i),(abs(i-X)+abs(j-Y)+1)))
for p in range(1,N):
  print(s.count(p))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

from itertools import combinations

n,x,y=map(int,readline().split())
dis=[0]*n
lst=list(range(1,n+1))
for a,b in combinations(lst,2):
  if b<=x or a>=y:
    dist=b-a
    continue
  else:
    dist=min(b-a, abs(x-a)+abs(y-b)+1,abs(y-a)+abs(x-b)+1)
  dis[dist]+=1
print(*dis[1:],sep='\n')

Submission status: Wrong Answer

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

for i in range(n-1):
  for j in range(i+1,n):
    a=j-i
    b=n    
    if i<=x and y<=j:
      b=j-y+1+x-i
    elif i<=x and x<=j<=y:
      b=y-j+1+x-i
    elif y<=j and x<=i<=y:
      b=j-y+1+i-x


    mn=min(a,b)
    #print(i+1,j+1,a,b,mn)
    ans[mn-1]+=1
    



for x in ans:
  print(x)

#print(ans)

Submission status: Wrong Answer

Solution code:
[n,x,y]=list(map(int,input().split()))
anslist=[0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        if i<=x-1 and y-1<=j:
            kyori=j-y+x-i+1
        else:
            kyori=j-i
        anslist[kyori-1]+=1
for i in range(len(anslist)):
    print(anslist[i])

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
A=[]
for i in range(1,n):
    for j in range(i+1,n+1):
        k=0
        if x>=i and j<=y:
            k=x-i+1+y-j
        elif x>=i and j>y:
            k=x-i+1+j-y
        elif x<i and j>y:
            k=i-x+1+j-y
        else:
            k=j-i
        A.append(min(j-i,k))
for i in range(1,n):
    print(A.count(i))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

from itertools import combinations

n,x,y=map(int,readline().split())
dis=[0]*n
lst=list(range(1,n+1))
for a,b in combinations(lst,2):
  dist=min(b-a, abs(x-a)+abs(y-b)+1,abs(y-a)+abs(x-b)+1)
  dis[dist]+=1
print(*dis,sep='\n')

Submission status: Wrong Answer

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

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

a=[[abs(i-j) for i in range(n)]for j in range(n)]

for i in range(x+1):#1-x
  for j in range(y,n):#y-n-1
    a[i][j]=min(a[i][j],x-i+1+j-y)
    
l=y-x+1
l//=2
l-=1

for i in range(x+1):
  for j in range(y-l,y):
    a[i][j]=min(a[i][j],x-i+1+y-j)
    
for i in range(x,x+1+l):
  for j in range(y,n):
    a[i][j]=min(a[i][j],i-x+1+j-y)
    
for i in range(n-1):
  for j in range(i+1,n):
    ans[a[i][j]-1]+=1
    
#for i in range(n):
#  for j in range(n):
#    print(a[i][j],end=" ")
#  print()
    
for k in range(n-1):
  print(ans[k])

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

from itertools import combinations

n,x,y=map(int,readline().split())
dis=[0]*n
lst=list(range(1,n+1))
for a,b in combinations(lst,2):
  dist=min(b-a, abs(x-a)+abs(y-b)+1,abs(y-a)+abs(x-b)+1)
  dis[dist]+=1
print(dis)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

g = {}
for i in range(n - 1):
    g.setdefault(i, [])
    g.setdefault(i + 1, [])
    g[i].append(i + 1)
    g[i + 1].append(i)


g[x - 1].append(y - 1)

global_stat = [0] * n

def bfs(i, g):
    q = deque([(i, 0)])
    vis = [0] * len(g)
    vis[i] = 1
    stat = [0] * len(g)
    while q:
        cur_v, cur_dist = q.popleft()
        # print("%s->%s: %s" % (i + 1, cur_v + 1, cur_dist))
        if cur_v > i:
            stat[cur_dist] += 1
        for adj_v in g[cur_v]:
            if not vis[adj_v]:
                vis[adj_v] = 1
                q.append((adj_v, cur_dist + 1))
    # print(stat)
    return stat

for i in range(n):
    local_stat = bfs(i, g)
    for i, v in enumerate(local_stat):
        global_stat[i] += v

# global_stat = [v // 2 for v in global_stat]
print(global_stat)

for v in global_stat[1:]:
    print(v)

Submission status: Wrong Answer

Solution code:
# li = [[0] * 4 for i in range(3)]

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

import heapq

INF = 99999999999999999


class edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost

    def __str__(self):
        return str(self.to) + " " + str(self.cost)


def dijkstra(start, nodes):
    distance = [INF] * N
    distance[start] = 0
    used = [False] * N

    q = []
    heapq.heapify(q)
    heapq.heappush(q, [0, start])

    while len(q) > 0:
        nowNode = heapq.heappop(q)[1]

        if used[nowNode] != False:
            continue

        used[nowNode] = True

        for nowEdge in nodes[nowNode]:
            if distance[nowEdge.to] > distance[nowNode] + nowEdge.cost:
                distance[nowEdge.to] = distance[nowNode] + nowEdge.cost
                heapq.heappush(q, [distance[nowEdge.to], nowEdge.to])

    return distance


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

node[X - 1].append(edge(Y - 1, 1))
node[Y - 1].append(edge(X - 1, 1))
ans = [0] * N
for i in range(N):
    dis = dijkstra(i, node)
    print(dis)
    for j in range(N):
        ans[dis[j]] += 1

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

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):
        length = j - i
        if i <= x and j >= y:
            length -= y-x-1
        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())
count = [0 for i in range(2001)]
diff = y - x - 1
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and y <= j:
            count[j - i - diff] += 1
            #print(i, j, j - i - diff, "!")
        else:
            count[j - i] += 1
            #print(i, j, j - i)
for k in range(1, n):
    print(count[k])

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
Z = Y - X + 1
print(N)
for k in range(2, N):
    ans = max(0, X + N - Y + 1 - k)
    if k <= Z // 2:
        ans += Z
    if X > k - 1:
        ans += 1
    if N - Y + 1 > k - 1:
        ans += 1
    for i in range(2, min(k, Z//2+1)):
        if X > k - i:
            ans += 2
        if N - Y + 1 > k - i:
            ans += 2
    if Z % 2 == 0:
        if X > k - Z // 2:
            ans += 1
        if N - Y + 1 > k - Z // 2:
            ans += 1
    print(ans)

Submission status: Wrong Answer

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