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:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,x,y = mi()
dist = y-x
hh = x
th = n-y+1
# print(hh,th,dist)
for k in range(1,n):
    # hh
    a = 0 if hh < k else hh-k
    # th
    b = 0 if th < k else th-k
    #hh-c
    c = min((k-1)*2 , dist) - min(max(0, (k-hh)*2),dist) 
    #th-c
    d = min((k-1)*2 , dist) - min(max(0, (k-th)*2),dist) 
    #hh-th
    if hh+th-1 < k:
        e = 0
    elif hh+th-1 == k:
        e = 1
    elif k>2:
        e = min(k-2,hh-1,th-1)
    else:
        e = 0
    
    #c
    if k > ((dist+1)/2):
        f = 0
    else:
        f = dist+1

    # print(k,a,b,c,d,e,f)
    print(a+b+c+d+e+f)

Submission status: Wrong Answer

Solution code:
import itertools

if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    ls = list(range(1, N+1, 1))
    N_ls = list(itertools.combinations(ls, 2))
    print(N_ls)
    ret = [0] * N
    for i in N_ls:
        if i[0] <= X  and i[1] >= Y:
            print(i)
            cnt = X - i[0] + 1 + i[1] - Y
        else:
            cnt = i[1] - i[0]
        ret[cnt] += 1
    for k in range(1, N, 1):
        print(ret[k])

Submission status: Wrong Answer

Solution code:
n,x,y = map(int, input().split())
r_sokusa = x - 1
l_sokusa = n - y
cycle = y - x + 1
print(n)
for i in range(2,n):
  if i <= cycle // 2:
    res = cycle
  else:
    res = 0
  for j in range(1,r_sokusa + 1):
    if j + i <= r_sokusa + 1:
      res += 1
    elif j + i - r_sokusa - 1 <= cycle //2:
      res += 2
  for k in range(1,l_sokusa + 1):
    if k + i <= l_sokusa + 1:
      res += 1
    elif k + i - l_sokusa - 1 <= cycle //2:
      res += 2
  if i >= 3 and i <= r_sokusa + l_sokusa:
    res += min(i - 2, min(r_sokusa, l_sokusa))
  elif i == r_sokusa + l_sokusa + 1:
    res += 1
  print(res)

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
ans = list(range(n - 1, 0, -1))
ans[0] += 1
ans[-1] -= 1
if n > 4:
  ans[abs(x - y) - 1] += 1
  ans[n - abs(x - y) - 1] -= 1
for i in range(n - 1):
  print(ans[i])

Submission status: Wrong Answer

Solution code:
N,X,Y=map(int,input().split())
print (N)
print (2*N+X-Y-4)
lists=[1,1,1,1]
t=0
for k in range(3,N):
  t=N+X-Y-k+1
  if k<Y-X:
    t=t+(N-1-k)
  if k<X-1:
    t=t-1
  if k<N-Y:
    t=t-1
  print (t)
  t=0

Submission status: Wrong Answer

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

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

dis = [0] * (N - 1)

for i in range((Y - X + 1) // 2):
    dis[i] += Y - X + 1

if (Y - X + 1) % 2 == 0:
    dis[(Y - X) // 2 - 1] //= 2

diss = [0]
for i in range((Y - X) // 2):
    diss.append(2)

if (Y - X) % 2 == 1:
    diss.append(1)

diss[1] -= 1
dis[0] -= 1

for i in range(X - 1):
    for index, j in enumerate(diss):
        dis[i + index] += j


for i in range(N - Y):
    for index, j in enumerate(diss):
        dis[i + index] += j

temp = X + 1 + N - Y

for i in range(temp - 1):
    dis[i] += temp - i - 1

print(*dis)

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x,y=INTM()
    z=y-x
    sc=y-x-1
    loop=y-x+1
    maxl=(n)-(y-x)
    for i in range(1,n):
        ct=0
        if ct==0:
            for j in range(1,n):
                if j+i<=x or j>=y:
                    if j+i<=n:
                        ct+=1
                else:
                    if j<=x:
                        if j+i+sc<=n:
                            ct+=1
                        temp=i-(x-j)
                        if temp>=2:
                            if loop>temp*2:
                                ct+=2
                            elif loop==temp*2:
                                ct+=1
                        else:
                            ct+=1
                        
                    else:
                        lpmin=min(y-j,+(j-x+1))
                        if lpmin==j-x+1:
                            if lpmin==y-j:
                                if lpmin+(n-y)>=i:
                                    ct+=1
                            else:
                                if lpmin>i:
                                    ct+=1
                                else:
                                    if lpmin+(n-y)>=i:
                                        ct+=1
                                    if loop>i*2:
                                        ct+=2
                                    elif loop==i*2:
                                        ct+=1
                        else:
                            if lpmin+(n-y)>=i:
                                ct+=1
                print(ct)
            print(ct)        
        else:
            print(ct)
                
        
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(N)

#base
for k in range(1,N):
    if k <= Y-X:
        ans= N-k
        ans += Y-X-k

    elif k > Y-X:
        ans= N-k
        ans += Y-X-k

    if N-k == Y-X:
        ans = 1
    if N-k < Y-X:
        ans = 0

    print(ans)

Submission status: Wrong Answer

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

def cnt(len, target):
    return len - target

for n in range(1, N, 1):
    if n == 1:
        print(N)
    elif N - 1 - (Y - X) + 1 < n:
        print(0)
    else:
        print(cnt(N - (Y - X), n) + cnt(Y - 1, n) + cnt(N - (X + 1), n) - cnt(X - 1, n) - cnt(N - Y, n) - cnt(Y - X, n))

Submission status: Wrong Answer

Solution code:
N,X,Y=map(int,input().split())
points=[(n,n+1) for n in range(1,N)]
points.append((X,Y))

def combinations(points,num):
    count_list=[]
    for point in points:
        temp=[point]
        other_points = list(set(points) - {point})
        for other_point in other_points:
            if point[1] == other_point[0]:
                temp.append(other_point)
            if len(temp) == num:
                count_list.append(temp)
                break
    return len(count_list)

for n in range(1,N): 
    print(combinations(points,n))

Submission status: Wrong Answer

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

for k in range(1,N):
    ans=0
    if k<Z:
        ans+=N-k+min(k,N-Y+1)
        if 2*k+2<=Z:
            ans+=max(min(k-1,Z-k-3),0)+min(k-1,N-Y+1)
        if 2*k<Z+2:
            ans+=max(k-2,0)
    elif Z<=k<=N-Z:
        ans+=min(X,X-k+N-Y+1)

    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

g = np.zeros((n, n), dtype=int)

# print(g)

for i in range(n):
  for j in range(i+1, n):
    if j != y-1:
      g[i,j] = g[i,j-1] + 1
    elif i < x:
      g[i,j] = g[i,x-1] + 1
    else: 
      g[i,j] = min((g[i,j-1] + 1), i+1-x + 1)

print(g)

for i in range(0, y):
  for j in range(y-1, x, -1):
    if g[i,j] + 1 < g[i,j-1]:
      g[i,j-1] = g[i,j] + 1

print(g)

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

Submission status: Wrong Answer

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

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
graph = np.zeros((n,n))
for i in range(n-1):
    graph[i][i+1] = 1
graph[x-1][y-1] = 1
s = floyd_warshall(graph,directed=False)

for i in range(1,n-1):
    print(np.sum(s==i)//2)

Submission status: Wrong Answer

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

print(n)

if n != 3:
  for i in range(n-2):
    p = n-1-(i+2)
    if y-x <= i+2:
      if y-x == i+2:
        print(p + 2)
      else:
        print(p)
    elif y-x < n-1:
      print(p + 4)
    else:
      print(n)
else:
  print(0)

Submission status: Wrong Answer

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

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

for i in range(1,n):
  print(ans[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)
    if k == 1:
        ans += y - x
    elif y - x + 1 > 2 * k:
        ans += y - x + 1
    elif y - x + 1 == 2 * k:
        ans += k
    if x > 1:
        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))
    if y < n:
        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:
# join 20/03/28
def ruiwa(n):
  c=0
  ans=[]
  for i in range(n):
    c+=i
    ans.append(c)
  return ans

n,x,y=map(int,input().split())
dp=[j for i in range(n)for j in range(1,n)]
r=ruiwa(n)
for i in range(1,n):
  for j in range(i+1,n+1):
    if j<x:continue
    p=(n-1)*i-(n-j)-r[x]
    dp[p]=min(dp[p],x-i-~abs(j-y))
for i in range(n):
  print(dp.count(i))

Submission status: Wrong Answer

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

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1,k):
    if i<=l:
      M += g(m,k-i)*2/m
  return M

A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(c)
for i in range(n-1):
  print(A[i])

Submission status: Wrong Answer

Solution code:
import copy
N, X, Y = map(int, input().split())
G = dict()
for i in range(1, N):
    G[i] = [i+1]
G[X].append(Y)


for _ in range(N-1):
    # print(G)
    print(sum(len(l) for l in G.values()))

    NewG = dict()
    for k in G.keys():
        for l in G[k]:
            if l in G.keys():
                NewG[k] = copy.deepcopy(G[l])
                for it in G[l]:
                    if it in G[k]:
                        NewG[k].remove(it)
    G = NewG

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
from collections import Counter
def key(x, y):
    return str(x)+str(y)
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    # M = {}
    M = []
    for i in range(N):
        M.append([-1 for _ in range(N)])

    for i in range(N):
        for j in range(i, N):
            M[i][j] = j - i
    
    def helper(x, y, from_cost):
        if 0 <= x <= N-1 and 0 <= y <= N-1:
            if M[x][y] >= 0 and M[x][y] > from_cost+1:
                M[x][y] = from_cost + 1
                cost = from_cost + 1

                helper(x-1,y, cost)
                helper(x+1,y, cost)
                helper(x,y-1, cost)
                helper(x,y+1, cost)
        
    helper(X, Y, 0)
    k = {i: 0 for i in range(N)}
    for i in range(N):
        for kk in range(N):
            k[kk] += M[i].count(kk+1)
            

    for key, v in k.items():
        print(v)


main()

Submission status: Wrong Answer

Solution code:
N, X, Y = list(map(int, input().split()))
path = list(range(1, N+1))
for i in range(N-1):
  i += 1
  if i == 1:
    count = 1
  else:
    count = 0
  for j in path:
    if j - i > 0:
      count += 1
  if i == (Y - X):
    count -= 1
  print(count)

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x,y=INTM()
    z=y-x
    sc=y-x-1
    loop=y-x+1
    maxl=(n)-(y-x)
    for i in range(1,n):
        ct=0
        if ct==0:
            for j in range(1,n):
                if j+i<=x or j>=y:
                    if j+i<=n:
                        ct+=1
                else:
                    if j<=x:
                        if j+i+sc<=n:
                            ct+=1
                        temp=i-(x-j)
                        if temp>=2:
                            if loop>temp*2:
                                ct+=2
                            elif loop==temp*2:
                                ct+=1
                        else:
                            ct+=1
                        
                    else:
                        lpmin=min(y-j,+(j-x+1))
                        if lpmin==j-x+1:
                            if lpmin==y-j:
                                if lpmin+(n-y)>=i:
                                    ct+=1
                            else:
                                if lpmin>=i:
                                    ct+=1
                                else:
                                    if lpmin+(n-y)>=i:
                                        ct+=1
                                    if loop>i*2:
                                        ct+=3
                                    elif loop==i*2:
                                        ct+=1
                        else:
                            if lpmin+(n-y)>=i:
                                ct+=1
                print(ct)
            print(ct)        
        else:
            print(ct)
                
        
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

Solution code:
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
# n = int(input())
n,x,y = map(int,input().split())
# A = list(map(int,input().split()))
# An = [list(map(int,input().split())) for i in range(n)]
l = np.zeros((n,n))
l[0][1] = 1
l[n-1][n-2] = 1
l[x-1][y-1] = 1
l[y-1][x-1] = 1
for i in range(n-3):
    l[i+1][i] = 1
    l[i+1][i+2] = 1

for j in range(n-1):
    print(np.count_nonzero(shortest_path(l)==j))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

circle = y - x + 1
a = [0 for _ in range(circle)]
for i in range(1, circle // 2 + 1):
    a[i] = i
    a[-i] = i
print(a)

dists = defaultdict(int)
for i in range(n - 1):
    if i >= y:
        for j in range(i + 1, n):
            dists[j - i] += 1
    elif x < i < y:
        for j in a[:y - i + 1]:
            dists[j] += 1
        for j in range(1, n - y):
            dists[a[y - i + 1] + j - 1] += 1
    else: # i <= x
        for j in range(i + 1, x):
            dists[j] += 1
        for j in a:
            dists[x - i + j] += 1
        for j in range(1, n - y):
            dists[x - i + a[-1] + j] += 1

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

Submission status: Wrong Answer

Solution code:
import sys
N, X, Y = map(int, sys.stdin.readline().split())
print(N)
k = 2
while k <= X + 1 + N-Y:
  a = N-k
  if Y-X-2 >= k:
    a += Y-X-k+k//2
  print(a)
  k += 1

while k <= N-1:
  print(0)
  k += 1

Submission status: Wrong Answer

Solution code:
import math

def leftcul(i):
    wakare = math.ceil((Y+X)/2) - 1
    for j in range(i+1, wakare):
        k = j-i
        kdict[k] = kdict[k] + 1
    for j in range(wakare, N+1):
        k = X - i + abs(j-Y)
        kdict[k] = kdict[k] + 1

def centercul(i):
    if(i < (X+Y)/2):
        wakare = math.ceil(i + (Y+1-X)/2) 
        for j in range(i+1, wakare):
            k = j-i
            kdict[k] = kdict[k] + 1
        for j in range(wakare, N+1):
            k = i -X + 1  + abs(j-Y)
            kdict[k] = kdict[k] + 1
    else:
        for j in range(i+1, N+1):
            k = j -i
            kdict[k] = kdict[k] + 1
            

def rightcul(i):
    for j in range(i+1, N+1):
        k = j -i
        kdict[k] = kdict[k] + 1


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

kdict = dict.fromkeys(range(1, N), 0)

for i in range(1, N):
    if(i < X):
        leftcul(i)
    else:
        if(i > Y):
            rightcul(i)
        else:
            centercul(i)

for i in kdict.values():
    print(i)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

g = np.zeros((n, n), dtype=int)

# print(g)

for i in range(n):
  for j in range(i+1, n):
    if j != y-1:
      g[i,j] = g[i,j-1] + 1
    elif i < x:
      g[i,j] = g[i,x-1] + 1
    else: 
      g[i,j] = min((g[i,j-1] + 1), i+1-x + 1)

# print(g)

for i in range(n):
  for j in range(y-1, x, -1):
    if g[i,j] + 1 < g[i,j-1]:
      g[i,j-1] = g[i,j] + 1

# print(g)

for i in range(0, y):
  print(np.count_nonzero(g == i))

Submission status: Wrong Answer

Solution code:
def function(N):
    if N % 2 == 0:
        for i in range(N // 2 - 1):
            A[i] = N
        A[N//2-1] = N//2
    else:
        for i in range(N // 2):
            A[i] = N
N,X,Y = map(int,input().split())
A = [0]*(N-1)


if X == 1 and Y == N:
    function(N)
    for k in A:
        print(k)
else:
    function(Y-X+1)
    B = [2]*(N-1)
    B[0] = 1
    for l in range(1,(Y-X+1)//2+1):
        B[-l] = 0
        if l == (Y-X+1)//2 and (Y-X+1) % 2 == 0:
            B[-l] = 1
    #print(B)

    for k in A:
        print(k)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 21:14:11 2020

@author: H_Hoshigi
"""

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

list_1 = list(range(1, N+1))
list_2 = list(range(1, X+1)) + list(range(Y, N+1))
list_3 = list(range(1, X+1)) + list(range(Y, (X+Y)//2, -1))

#print(list_1)
#print(list_2)
#print(list_3)

dist_list = [set() for i in range(N)]
answer_list = []
for k in range(1, N):
#    print("k = {}".format(k))
    answer_k = 0
    for i in range(N):
        set_i = set()
#        print("k = {}, i = {}".format(k, i))
        try:
            list_1[i+k]
        except IndexError:
            pass
        else:
            if list_1[i+k] not in dist_list[i]:
                set_i.add(list_1[i+k])
                dist_list[i].add(list_1[i+k])
        if i <= X-1:
            try:
                list_2[i+k]
            except IndexError:
                pass
            else:
                set_i.add(list_2[i+k])
                dist_list[i].add(list_2[i+k])
            try:
                list_3[i+k]
            except IndexError:
                pass
            else:
                set_i.add(list_3[i+k])
                dist_list[i].add(list_3[i+k])
#        print(dist_list[i][k])
        answer_k += len(set_i)
#    print("answer_{} = {}".format(k, answer_k))
    answer_list.append(answer_k)

for i in answer_list:
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, X, Y = [int(x) for x in input().split()]

list_adjlist = []
for i in range(N):
    if i == 0:
        list_adjlist.append([i+1])
    elif i == N-1:
        list_adjlist.append([i-1])
    else:
        list_adjlist.append([i-1, i+1])

list_adjlist[X-1].append(Y-1)
list_adjlist[Y-1].insert(0, X-1)

def FIFO(list1, node):
    if node != None:
        list1.append(node)
        return None
    return list1.pop(0)
def getShortestDistance(list_adjlist, initnode):
    # 既にスタックに入れた点かどうかをチェックするリストを初期化
    list_check = [False] * len(list_adjlist)
    #list_Dを初期化
    list_D = [-1 for _ in range(len(list_adjlist))]
    #始点の距離=0
    list_D[initnode] = 0
    #list_Tを初期化
    list_T = [-1 for _ in range(len(list_adjlist))]
    #FIFOキューを初期化
    list_FIFO = []
    # 始点の名前をFIFOキューに入れる
    FIFO(list_FIFO, initnode)
    list_T[initnode]
    list_check[initnode] = True
    #FIFOキューが空になるまで探索（ループ）
    while(len(list_FIFO)):
        v = FIFO(list_FIFO, None)
        for i in range(len(list_adjlist[v])):
            child = list_adjlist[v][i]
            if list_check[child] == False:
                FIFO(list_FIFO, child)
                list_check[child] = True
                list_T[child] = v
                list_D[child] = list_D[v] + 1
            else:
                pass
    #最短距離と最短経路を返す
    return list_D, list_T

anslist = [0 for _ in range(N)]

for i in range(N):
    list_D, list_T = getShortestDistance(list_adjlist, i)
    for k in range(N):
        anslist[k] += list_D.count(k+1)

for ans in anslist[:-1]:
    print(ans)

Submission status: Wrong Answer

Solution code:
n, x, y = map(int,input().split())
import numpy as np
import copy

ans = [n]*(n-1)
ans = np.array(ans)
diff1 = np.arange(1, n)
ans = ans - diff1

n2 = y-x+1
ans2 = [n2]*(n2-1)
ans2 = np.array(ans2)
diff2 = np.arange(1, n2)
ans2 = ans2 - diff2
ans2 = np.append(ans2, [0]*((n-1)-(y-x)))
ans2[-1] = ans2[-1]+1

n4 = copy.copy(x)
ans4 = [n4]*(n4-1)
ans4 = np.array(ans4)
diff4 = np.arange(1, n4)
ans4 = ans4 - diff4
ans4 = np.append(ans4, [0]*(n-x))

n5 = n-y+1
ans5 = [n5]*(n5-1)
ans5 = np.array(ans5)
diff5 = np.arange(1, n5)
ans5 = ans5 - diff5
ans5 = np.append(ans5, [0]*(n-n5))

n3 = n-(y-x-1)
ans3 = [n3]*(n3-1)
ans3 = np.array(ans3)
diff3 = np.arange(1, n3)
ans3 = ans3 - diff3
ans3 = np.append(ans3, [0]*(y-x-1))

ansz = ans2 + ans3 + ans4 + ans5
ansz = list(ansz)
ansz[0] = n


for i in ansz:
    print(i)

Submission status: Wrong Answer

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

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

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

        ans[dist] += 1

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

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n,x,y = mi()
dist = y-x
hh = x
th = n-y+1
# print(hh,th,dist)
for k in range(1,n):
    # hh
    a = 0 if hh < k else hh-k
    # th
    b = 0 if th < k else th-k
    #hh-c
    c = min((k-1)*2 , dist) - min(max(0, (k-hh)*2),dist) 
    #th-c
    d = min((k-1)*2 , dist) - min(max(0, (k-th)*2),dist) 
    #hh-th
    if hh+th-1 < k:
        e = 0
    elif k>2:
        e = min(k-2,hh-1,th-1)
    else:
        e = 0
    
    #c
    if k > ((dist+1)/2):
        f = 0
    else:
        f = dist+1

    # print(k,a,b,c,d,e,f)
    print(a+b+c+d+e+f)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

D = Y-X

import itertools
L = list(itertools.combinations(range(1,N+1), 2))

ans = [0] * N
for l in L:
    if l[0] > X or l[1] < Y:
        ans[l[1] - l[0]] += 1
    else:
        ans[l[1] - l[0] - D + 1] += 1

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

Submission status: Wrong Answer

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

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

    node = [[[] for _ in range(N)] for _ in range(N)]
    used = [[False] * N for _ in range(N)]

    for i in range(N):
        node[i][0].append(i)
        used[i][i] = True


    for k in range(1,N):
        ans = 0
        for i in range(N):
            for x in node[i][k-1]:
                if x == X-1 and (not used[i][Y -1]):
                    node[i][k].append(Y-1)
                    used[i][Y-1] = True
                    used[Y-1][i] = True
                    ans += 1

                if x == Y-1 and (not used[i][X -1]):
                    node[i][k].append(X-1)
                    used[i][X-1] = True
                    used[X-1][i] = True
                    ans += 1

                if (x - 1 >= 0 ) and (not used[i][x - 1]):
                    node[i][k].append(x - 1)
                    used[i][x - 1] = True
                    used[x-1][i] = True
                    ans += 1

                if (x + 1 < N) and (not used[i][x + 1]):
                    node[i][k].append(x + 1)
                    used[i][x + 1] = True
                    used[x+1][i] = True
                    ans += 1

        print(ans)

    for x in node:
        print(x)


if __name__ == "__main__":
    main()

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
    if y-x<i+1 and y-x<i+1 :
      
      current+=int(y-x/2)
    value+=current
    print (value)
  else :
    print(n-i)
    current=1

Submission status: Wrong Answer

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

for k in range(1,N):
    ans=0
    if k<Z:
        ans+=N-k
        if 2*k+2<=Z:
            ans+=max(min(k-1,Z-k-3),0)+min(k-1,N-Y+1)
        if 2*k<Z+2:
            ans+=max(k-2,0)
    elif Z<=k<=N-Z:
        ans+=min(X,X-k+N-Y+1)

    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from heapq import heappush, heappop


def main():
    # n, x, y = 7, 3, 7
    n, x, y = [int(s) for s in sys.stdin.readline().strip().split()]
    score = {i: 0 for i in range(1, n)}

    def bfs(start):
        seen = set()
        heap = [(0, start)]
        while heap:
            dist, cur = heappop(heap)
            pair = (min(start, cur), max(start, cur))
            if pair in seen:
                continue
            seen.add(pair)
            if dist > 0:
                score[dist] += 1
                print(dist, pair)

            if cur < n-1:
                heappush(heap, (dist+1, cur+1))
            if cur > 0:
                heappush(heap, (dist+1, cur-1))
            if cur == x-1:
                heappush(heap, (dist+1, y-1))
            if cur == y-1:
                heappush(heap, (dist+1, x-1))

    for i in range(n-1):
        bfs(i)
    for i in range(1, n):
        print(score[i])

main()

Submission status: Wrong Answer

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

print(N)

#base
for k in range(1,N-1):
    if k <= Y-X:
        ans= N-k
        ans += Y-X-k

    elif k > Y-X:
        ans= N-k
        ans += Y-X-k

    if N-k == Y-X:
        ans = 1
    if N-k < Y-X:
        ans = 0

    print(ans)

Submission status: Wrong Answer

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

for j in range(n-1):
    dis[j] = list(range(1,n-j))
dis[x-1][y-x-1] = 1

#for i in range(n-x):
#    key = y-x-1
#    dis[x-1][i] = min(dis[x-1][i],1+y-x-i-1)
for i in range(x-1,y-1):
    for j in range(y-i-1):
        dis[i][j] = min(dis[i][j],(i+1)-x+1+y-(i+1+j+1))

for i in range(x-1):
    for j in range(len(dis[i])):
        if i+1+j+1>x:
            dis[i][j] = (x-i-1)+dis[x-1][j+1+i-x]        
for i in range(n-2):
    dis[i+1] = dis[i] + dis[i+1]

tance = dis[n-2]

for a in range(1,n):
    print(tance.count(a))

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
            elif((i+1) > X) and (Y-(j+1)) < ((j+1)-(i+1)):
                tmp_x = (j+1) - (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()