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:
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 == Y - 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 == Y - 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
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, x, y = MI()

    d = y - x - 1
    for i in range(1, n):
        c = 0
        for j in range(1, n + 1):
            if j <= x:
                if j + i <= x:
                    c += 1
                elif x < j + i < y:
                    c += 1
                else:
                    if j + i <= n - d:
                        c += 1
            elif x < j < y:
                if j + i <= y:
                    c += 1
                else:
                    if j + i <= n:
                        c += 1
            elif j >= y:
                if j + i <= n:
                    c += 1
            print(c)

    pass


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
ans = {}
for i in range(N):
    # print(i+1)
    # print()
    for j in range(i+1, N):
        diff = (j+1)-(i+1)
        if i+1 <= X and j+1 >= Y:
            diff = diff - (Y-X)+1

        elif X+1 == i+1 and j+1 == Y and X+1 != j+1:
            # print("Yes")
            diff -= 1
        elif j+1 == Y-1 and X >= i+1 and X+1 != j+1:
        # print("Yes")
            diff -= 1

        if diff == 0:
            diff += 1
        # print(i+1, j+1, diff)



        tmp = ans.get(diff)

        if tmp == None:
            ans[diff] = 1
        else:
            ans[diff] = tmp + 1

# print(ans)
for i in range(N-1):
    tmp = ans.get(i+1)
    if tmp == None:
        tmp = 0
    print(tmp)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5)
n, x, y = map(int, input().split())
G = {i: [] for i in range(1, n+1)}
G[x].append(y)
G[y].append(x)
for i in range(1, n):
    G[i].append(i+1)
    G[i + 1].append(i)
tf = [[False] * (n+1) for i in range(n+1)]
ans = [0] * (n+1)
def dfs(now, before, depth):
    v[now] = True
    next_G = G[now]
    if tf[now][before] == False and depth != 0:
        ans[depth] += 1
        tf[now][before] = True
        tf[before][now] = True
    for next in next_G:
        if v[next]:
            continue
        if next == before:
            continue
        dfs(next, now, depth + 1)
    return
for i in range(1, n+1):
    v = [False] * (n+1)
    dfs(i, 0, 0)
print(ans)

Submission status: Wrong Answer

Solution code:
n, x, y = [int(i) for i in input().split()]

def distance(n, x, y):
    k_list = []
    for m in range(1,n):
        if m <= x:
            for n in range(m+1,n+1):
                if n < x:
                    k = n - m
                    k_list.append(k)
                else:
                    k1 = n - m
                    k2 = (x-m)+1+abs(n-y)
                    k = min([k1,k2])
                    k_list.append(k)
        else:
            for n in range(m+1,n+1):
                k = n - m
                k_list.append(k)

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

    return

distance(n, x, y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
for k in range(1, n):
    ans = max(0, x + n - y + 1 - k)
    print(ans)
    if k == 1:
        ans += y - x
    elif y - x + 1 > 2 * k:
        ans += y - x + 1
    elif y - x + 1 == 2 * k:
        ans += k
    print(ans)
    if k <= x - 1:
        if y - x + 1 > 2 * (k - 1):
            ans += 2 * (k - 1)
        else:
            ans += y - x
    else:
        if y - x + 1 > 2 * (k - 1):
            ans += 2 * (x - 1) - 1
        else:
            ans += max(0, y - x - (k - x) * 2 + (-1 if k==x else 0))
    print(ans)
    if k <= n - y:
        if y - x + 1 > 2 * (k - 1):
            ans += 2 * (k - 1)
        else:
            ans += y - x 
    else:
        if y - x + 1 > 2 * (k - 1):
            ans += 2 * (n - y) - 1
        else:
            ans += max(0, y - x - (k - (n - y)) * 2 + (-1 if k==x else 0))
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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


l = np.full((n,n),10**7)

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

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

data = np.copy(l)

#print(l)
for i in range(n):
    for j in range(n):
        if l[i][j] == 1:
            for k in range(n):
                data[j][k] = min(data[i][k]+1,data[j][k])

data = np.tril(data)
for i in range(n):
    data[i][i] = 0

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

Submission status: Wrong Answer

Solution code:
import collections
N,X,Y = list(map(int,input().split()))
ans = 0
A = []
B = []
for j in range(X+1,Y):
  A.append(j-1)
  A.append(N-j)
for f in range(len(A)):
  for h in range(1,A[f]+1):
    B.append(h)
B = str(B)
c = collections.Counter(B)
for i in range(1,N-Y+X+2):
  F = N-Y+X-i+1
  D = str(i)
  C = c[D]
  print(F+C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,X,Y = map(int, input().split())
l = []
ll=[]
s =1
t = 2

for i in range(N-1):
	if s <= X:
		while t < Y:
			ll.append(t-s)
			t+=1
		while t<=N:
			if s==Y-1 or s==N-1 or Y==N:
				ll.append(t-s)
			else:
				ll.append(X-s+1+t-Y)
			t +=1
		l.append(ll)
		ll=[]
		s +=1
		t = s+1
	else:
		while t<=N:
			ll.append(t-s)
			t +=1
		l.append(ll)
		ll=[]
		s +=1
		t = s+1

print(l)

Submission status: Wrong Answer

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

d=[[0]*N for i in range(N)]

for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    if i == x:
      if j < y:
        d[i][j] = min(abs(i-j),y-j+1)
      elif j == y:
        d[i][j] = 1
      else:
        d[i][j] = abs(j-i)-(y-x)+1
    elif i < x:
      if j < y:
        d[i][j] = min(abs(i-j),x-i+y-j+1)
      elif j >= Y:
        d[i][j] = abs(j-i)-(y-x)+1

    elif x < i < y:
      d[i][j] = min(abs(i-j),i-x+1+abs(y-j))

    else:
      d[i][j] = abs(j-i)


for k in range(1,N):
  count=0
  for l in range(N-1):
    count += d[l].count(k)
  print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math
import numpy

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

k = [0] * (n-1)
dp = []
for i in range(n):
    tmp= []
    for j in range(n):
        tmp.append(n)
    dp.append(tmp)

for i in range(n-1):
    dp[i][i+1] = 1

for i in range(n):
    dp[i][i] = 0

dp[x-1][y-1] = 1

for i in range(n-1):
    for j in range(i+1,n):
        tmp = dp[i][j-1] + dp[j-1][j]
        tmp2 = n
        if (x - 1) <= j and (y-1) <= j:
            tmp2 = dp[i][x-1] + dp[x-1][y-1] + (j - y + 1)
            # print(tmp2,"tmp2",i ,":" ,j)
        dp[i][j] = min(tmp , tmp2 , dp[i][j] )

for i in range(n-1):
    for j in range(i+1,n):
        ind = dp[i][j]
        if ind != n:
            k[ind-1] += 1

# print(dp)
for i in k:
    print(i)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

l = []
for i in range(N - 1):
    for j in range(i, N - 1):
        if not (i <= X and j >= Y):
            l.append(abs(i - j))

m = Y - X
for i in range(X):
    for j in range(Y - 1, N - 1):
        l.append(abs(i - j) - m)

c = Counter(l)
print(c)
for k in range(N - 1):
    ans = c[k]
    print(ans)

Submission status: Wrong Answer

Solution code:
n, x, y = [int(i) for i in input().split()]

def distance(n, x, y):
    k_list = []
    for m in range(1,n):
        if m < x:
            for n in range(m+1,n+1):
                if n < x:
                    k = n - m
                    k_list.append(k)
                else:
                    k1 = n - m
                    k2 = (x-m)+1+abs(n-y)
                    k = min([k1,k2])
                    k_list.append(k)
        else:
            for n in range(m+1,n+1):
                k = n - m
                k_list.append(k)

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

    return

distance(n, x, y)

Submission status: Wrong Answer

Solution code:
def posonly(n):
    if n < 0:
        return 0
    else:
        return n
# k = K + 1
def calc(k):
    # sec1 and sec3
    s13 = posonly(sec1 + sec3 - k + 1)
    # 個別
    k2 = posonly( sec2 - k + 1)

    # n
    not12 = calcd(sec1, sec2, k)
    not23 = calcd(sec2, sec3, k)

    kan = sec2 + 2
    b213 = 0
    b231 = 0
    if kan >= (k-1) * 2:
        # 2-1-3
        b213 = calcd3s(sec2, sec3, k)
        # 2-3-1
        b231 = calcd3s(sec2, sec1, k)

    # print('k=', k , 's13=', s13,'k2=', k2, 'not12=', not12 ,'2-3=', not23)
    return s13 + k2 + not12 + not23 + b213 + b231
    

def calcd(f, s, k):
    i = k - f
    st = i if i > 0 else 1
    i = k - s
    end = i if i > 0 else 1
    return posonly(k - (st + end) + 1)

def calcd3s(f, s, k):
    i = k - (f+1)
    st = i if i > 0 else 1
    i = k - (s+1)
    end = i if i > 0 else 1
    return posonly(k - (st + end))

n, x, y = [int(s) for s in input().split()]
sec1 = x
sec2 = y-x-1
sec3 = n - y + 1

print("sec1", sec1, "sec2", sec2, "sec3", sec3)

for k in range(2, n+1):
    print(calc(k))

Submission status: Wrong Answer

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

ans=[0]*n

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

for i in range(n):
    print(ans[i])

Submission status: Wrong Answer

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

    dis = [0] * (N - 1)
    for i in range(N):
        for j in range(i+1, N):
            if ((i+1) <= X) and ((j+1) >= Y):
                tmp_x = X - (i+1)
                tmp_y = (j+1) - Y
                dis[tmp_x + tmp_y] += 1
            elif((i+1) <= X) and (Y-(j+1)) < ((j+1)-X):
                tmp_x = X - (i+1)
                tmp_y = Y - (j+1)
                dis[tmp_x + tmp_y] += 1
            else:
                dis[j-i-1] += 1
    for d in dis:
        print(d)



    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import numpy as np
D = np.zeros((N, N), int)
for i in range(N):
  D[i, :]  = [max(0, j-i) for j in range(N)]

for i in range(X):
  for j in range(Y-1, N):
    D[i, j] = D[i, j] - Y + X + 1
  for j in range(Y-2, X-1+(Y-X)//2, -1):
    D[i, j] = D[i, Y-1] + (Y - 1 - j)

for i in range(X-1, X-1+(Y-X)//2):
  D[i, Y-1] = i + 1 - X + 1
  for j in range(Y, N):
    D[i, j] = D[i, j-1] + 1

for k in range(1, N):
  ans = np.count_nonzero(D == k)
  print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    N, X, Y = map(int, input().split())
    X, Y = X-1, Y-1
    S = [0]*(N-1)
    for i in range(N):
        for j in range(i+1, N):
            if i <= X and Y <= j:
                diff = X-i+j-Y+1
            elif i > X and j >= Y:
                diff = min(j-i, i-X+j-Y+1)
            elif i <= X and j < Y:
                diff = min(j-i, X-i+Y-j+1)
            else:
                diff = j-i
            S[diff-1] += 1

    for dc in S:
        print(dc)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
r = X - 1
l = N - Y
m = Y - X + 1
print(r, l, m)
for i in range(1, N):
    ans = 0
    # mid ok 
    if i * 2 == m:
        ans += i
    elif i * 2 < m:
        ans += m
    # right
    ans += max(0, r + 1 - i)
    for j in range(1, r+1):
        if j >= i:
            continue
        diff = i - j
        # circle
        if diff * 2 == m:
            ans += 1
        elif diff * 2 < m:
            ans += 2
        # outer
        if diff - 1  >= 1 and diff - 1 <= l:
            ans += 1
    # left
    ans += max(0, l + 1 - i)
    for j in range(1, l+1):
        if j >= i:
            continue
        diff = i - j
        # circle
        if diff * 2 == m:
            ans += 1
        elif diff * 2 < m:
            ans += 2
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

INF = int(1e9+7)

def dijkstra(s,n,w,cost, k):
    d = [INF] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(k, 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(k, n):
            d[j] = min(d[j],d[v]+cost[v][j])
    return d

def main():
    n, x, y = na()

    cost = [[INF for i in range(n)] for i in range(n)] 
    for i in range(n-1):
        cost[i][i+1] = 1
        cost[i+1][i] = 1
    cost[x-1][y-1] = 1
    cost[y-1][x-1] = 1

    ans = dict()
    kyo = 1
    for i in range(n):
        for s in dijkstra(i, n, n-1, cost, kyo):
            if s in ans:
                ans[s] += 1
            else:
                ans[s] = 1
        kyo += 1
    
    for i in range(n-1):
        if i+1 in ans:
            print(ans[i+1])
        else:
            print(0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

d = {}

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

ans = [0] * (N - 1)

for k, v in d.items():
    ans[v - 1] += 1

for v in ans:
    print(v)

Submission status: Wrong Answer

Solution code:
n,x,y=map(int,input().split())
#a<b
def dis(a,b):
  if a<=x and b<=y:
    return min(b-a,(x-a)+1+(y-b))
  elif a<=x and b>=y:
    return min(b-a,(x-a)+1+(b-y))
  if x+1<= a <=y-1:
    return min (b-a,(a-x)+1+abs(b-y))

for k in range(1,n):
  count=0
  #i<j
  for i in range(1,n+1):
    for j in range(i+1,n+1):
      if dis(i,j)==k:
        count+=1
  print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input().split()
n=int(s[0])
x=int(s[1])
y=int(s[2])
current=0
for i in range(n-1) :
  if i!=0 :
    value=n-i-1-current

    current=0
    if (y-(x+i) >i+1) :
      

      current+=1
    if (y-(x-i)>i+1) and x-i>0 :
      
      current+=1
    if (y-i)-x>i+1  :
      
      current+=1
    if (y+i)-x>i+1 and y+i<=n :
      
      current+=1
    if (x-1)+(n-y)+1>=i+1 and y-x<i+1 :
      
      current+=x-1
    value+=current
    print (value)
  else :
    print(n-i)
    current=1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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):
        num = j-i
        if i <= x and j >= y:
            num = (x-i)+(j-y) +1

        if i <= x and x < j < y:
            num = min(num, y-j+1+x-i)

        if x < i < y and j >= y:
            num = min(num, i-x + 1 + j-y )

        if x<i and j<y:
            num = min(num, x-i + 1 + y-j)

        ans[num] += 1


print(*ans[1:], sep='\n')

Submission status: Wrong Answer

Solution code:
import numpy as np

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


l = np.full((n,n),10**7)

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

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

data = np.copy(l)

#print(l)
for i in range(n):
    for j in range(n):
        if l[i][j] == 1:
            for k in range(n):
                data[j][k] = min(data[i][k]+1,data[j][k])

data = np.tril(data)
#print(data)

for i in range(1,n):
    ans = np.count_nonzero(data == i)
    if i == 2:
        ans -= n
    print(ans)

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
p = X - 1
q = Y - X + 1
r = N - Y

n = p // 2
m = p % 2

for i in range(N-1):
    ans = 0
    k = i + 1
    if p > k:
        ans = ans + p - k
    if n >= k:
        ans = ans + q
    if r > k:
        ans = ans + r - k
        
    if n >= k and p > 0:
        if k <= p:
            ans = ans + (2 * k) - 1
        else:
            ans = ans + (2 * p)
    elif p + n >= k and p > 0:
        if m == 0:
            if k <= p:
                ans = ans + q
            else:
                ans = ans + 2 * (p + n - k + 1) - 1
        if m == 1:
            if k <= p:
                ans = ans + q
            else:
                ans = ans + 2 * (p + n - k + 1)

    if n >= k and r > 0:
        if k <= r:
            ans = ans + (2 * k) - 1
        else:
            ans = ans + (2 * r)
    elif r + n >= k and r > 0:
        if m == 0:
            if k <= r:
                ans = ans + q
            else:
                ans = ans + 2 * (r + n - k + 1) - 1
        if m == 1:
            if k <= r:
                ans = ans + q
            else:
                ans = ans + 2 * (r + n - k + 1)
    if p > 0 and r > 0 and n + 2 <= k :
        t = p + n + r - k
        ans = ans + min(p, r)
    print(k, ans)

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
            elif g_1 <= x and g_2 < y and y - g_2 < g_2 - x:
                if x - g_1 + y - g_2 + 1 == i:
                    cnt += 1
            elif g_1 > x and g_2 >= y and y - g_1 > g_1 - x:
                if g_1 - x + g_2 - y + 1 == i:
                    cnt += 1
            else:
                if g_2 - g_1 == i:
                    cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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):
        num = j-i
        if i <= x and j >= y:
            num = (x-i)+(j-y) +1

        if i <= x and x < j < y:
            num = min(num, y-j+1+x-i)

        if x < i < y and j >= y:
            num = min(num, i-x + 1 + j-y )

        ans[num] += 1


print(*ans[1:], sep='\n')

Submission status: Wrong Answer

Solution code:
# Problem D - Line++

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

# initialization
INF = 10*18
graph = [[0]*N for i in range(N)]
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)
for i in range(N):
    for j in range(i, N):
        if i==j:
            continue
        if j==i+1:
            graph[i][j] = 1
            kyori_graph[i][j] = 1
        else:
            kyori_graph[i][j] = INF
graph[X-1][Y-1] = 1
kyori_graph[X-1][Y-1] = 1

# graph search
for i in range(N):
    for j in range(i, N):
        if i==j and j==i+1:
            continue
        if j==Y-1 and graph[i][X-1]==1:
            # 遷移先からの距離をもとめる
            kyori_graph[i][j] = min(kyori_graph[i][j] ,kyori_graph[i][X-1] + 1, kyori_graph[i][j-1]+1)
        else:
            kyori_graph[i][j] = min(kyori_graph[i][j] , kyori_graph[i][j-1] + 1)

# 個数の数え上げ
for i in range(N):
    for j in range(i, N):
        if i==j:
            continue
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1

# output
for k in kosu_list:
    print(k)

Submission status: Wrong Answer

Solution code:
N, X, Y = [int(n) for n in input().split()]
C = (X + Y + 1) / 2

ans = [0] * (N - 1)
for i in range(1,N):
    for j in range(i+1,N+1):
        if i <= X:
            if j <= C:
                k = j - i
            elif j < Y:
                k = X - i + 1 + Y - j
            else:
                k = X - i + 1 + j - Y
        elif i <= Y:
            if j < Y:
                if j <= i + C:
                    k = j - i
                else:
                    k = i - X + 1 + Y - j
            else:
                if i <= (X + Y - 1) / 2:
                    k = i - X + 1 + j - Y
                else:
                    k = j - i
        else:
            k = j - i
        ans[k-1] += 1

print("\n".join([str(n) for n in ans]))

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, x, y = MAP()
yx = y - x + 1
lnf = x
lne = n - y + 1
#print(lnf, lne)
for k in range(1, n):
    ans1 = max(0, lnf - k) + max(0, lne - k)
    ans2 = yx if (yx - k) >= k else 0
    ans3 = 0
    if lnf > 1 and k > 1:
        for i in range(1, min(lnf, k)): #どれだけ外に出すか
            ans3 += 2 if (yx - k + i) >= k - i else 0
    #print(k, k - lnf + 1, k - lne + 1, ans3, end=' ')
    if lne > 1 and k > 1:
        for i in range(1, min(lne, k)):
            ans3 += 2 if (yx - k + i) >= k - i else 0
    #print(ans3)
    ans4 = 0
    if k >= 3:
        for i in range(1, k - 1):
            ans4 += 1 if i <= lnf - 1 and k - i - 1 <= lne - 1 else 0
    #print('aaaaaaaaaa', lnf + lne - k)
    #print(ans1, ans2, ans3, ans4)
    print(ans1 + ans2 + ans3 + ans4)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

INF = int(1e9+7)

def dijkstra(s,n,w,cost,k):
    d = [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(k, n):
            d[j] = min(d[j],d[v]+cost[v][j])
    return d

def main():
    n, x, y = na()

    cost = [[INF for i in range(n)] for i in range(n)] 
    for i in range(n-1):
        cost[i][i+1] = 1
        cost[i+1][i] = 1
    cost[x-1][y-1] = 1
    cost[y-1][x-1] = 1

    ans = dict()
    kyo = 1
    for i in range(n):
        for s in dijkstra(i, n, n-1, cost, kyo):
            if s in ans:
                ans[s] += 1
            else:
                ans[s] = 1
        kyo += 1
    
    for i in range(n-1):
        if i+1 in ans:
            print(ans[i+1])
        else:
            print(0)

if __name__ == '__main__':
    main()

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)+(y-i)+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):
    print(len([l for l in L if l==k]))

Submission status: Wrong Answer

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

m = [[0 for i in range(n)] for j in range(n)]

def check(i, j):
    if -1 < i and i < n and -1 < j and j < n and i < j:
        if m[i][j] == 0:
            return True
    return False

def mark(i, j, c):
    if check(i-1, j):
        m[i-1][j] = c
    if check(i+1, j):
        m[i+1][j] = c
    if check(i, j-1):
        m[i][j-1] = c
    if check(i, j+1):
        m[i][j+1] = c

for i in range(n-1):
    m[i][i+1] = 1

m[x-1][y-1] = 1

for c in range(n):
    for i in range(n):
        for j in range(n):
            if 1 < c and m[i][j] == c-1:
                mark(i, j, c)

import itertools
l = list(itertools.chain.from_iterable(m))

for i in range(n):
    print(l.count(i+1))

Submission status: Wrong Answer

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



def warshall_floyd(n , x, y):
    d = [0] * n

    for i in range(n):
        d[i] = [0] * n
        for j in range(n):
            if abs(i - j) == 1 or (i == x and j == y ) or (j == x and i == y):
                d[i][j] = 1
            else:
                d[i][j] = 100000
    
    for k in range(n):
        for i in range(n):
            for j in range(i+1, n):
                next_distance = d[i][k]+d[k][j]
                if next_distance < d[i][j]:
                    d[i][j] = next_distance
    
    distance_map = {i: 0 for i in range(1, n)}
    for i in range(n):
        for j in range(i + 1,n):
            if d[i][j] != 100000:
                distance_map[d[i][j]] += 1  

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

warshall_floyd(n, x-1, y-1)

Submission status: Wrong Answer

Solution code:
from collections import deque

def main():
    n,x,y=map(int,input().split())
    g=[[] for _ in range(n+1)]
    for i in range(1,n):
        g[i].append(i+1)
        g[i+1].append(i)
    g[x].append(y)
    g[y].append(x)
    
    def chk(s):
        d=[-1]*(n+1)
        a=deque()
        a.append((0,s))
        while a:
            i,j=a.popleft()
            d[j]=i
            for k in g[j]:
                if d[k]==-1 or d[k]>i+1:
                    a.append((i+1,k))
        return d

    dist=[0]*n                    
    for i in range(1,n):
        di=chk(i)
        for j in range(1,n+1):
            dist[di[j]]+=1
    for i in range(1,n):
        print(dist[i])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

G = [[n for i in range(n+1)] for j in range(n+1)]

for i in range(1,n):
    G[i][i] = 1
G[x][y-1]=1

for s in range(1,n-1):
    for i in range(1,n-1):
        for j in range(i,n-1):
            if G[i][j]==s:
                G[i+1][j]=min([G[i+1][j], G[i][j]+1])
                G[i][j+1]=min([G[i][j+1], G[i][j]+1])
                G[i-1][j]=min([G[i-1][j], G[i][j]+1])
                G[i][j-1]=min([G[i][j-1], G[i][j]+1])

ans = [0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i,n):
        ans[G[i][j]-1] += 1
for i in ans:
    print(i)

Submission status: Wrong Answer

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

d = {}

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

ans = [0] * (N - 1)

for k, v in d.items():
    ans[v - 1] += 1

for v in ans:
    print(v)

Submission status: Wrong Answer

Solution code:
def min_distance(a,b,x,y):
  if a <= x and y <= b:
    # ショートカットをはさむ場合
    return (b-a - (y-x)+1)
  else:
    if x <= a and y <= b:
      # 左端がショートカットの中の場合
      s1 = b - a
      s2 = (a-x) + 1 + (b-y)
      if s1 < s2:
        # 順周り
        return s1
      else:
        # 戻って
        return s2
    elif a <= x and b <= y:
    # ショートカットの中の場合
      s1 = (b-a)
      s2 = (x-a) + 1 + (y-b)
      if s1 < s2:
        return s1
      else:
        return s2
    else:
      return (b-a)
nxy = input('').split(' ')
n = int(nxy[0])
x = int(nxy[1])
y = int(nxy[2])

for k in range(1,n):
  cnt = 0
  for i in range(1,n+1):
    for j in range(i+1,n+1):
      s = min_distance(i,j,x,y)
      if s == k:
        cnt+=1
  print(cnt)