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:
# -*- coding: utf-8 -*-
import numpy as np

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

sum_array = np.zeros((n - 1), dtype='int')


for i in range(1, n + 1):
    if i <= x:
        tmp = x - i + 1 + n - y + 1
        sum_array[:tmp] += 1
        for j in range(x + 1, y):
            len_1 = j - i
            len_2_1 = np.abs(x-i) + 1 + np.abs(y-j)
            len_2_2 = np.abs(x-j) + 1 + np.abs(y-i)
            len_2 = min(len_2_1, len_2_2)
            len_min = min(len_1, len_2)
            sum_array[len_min - 1] += 1
    else:
        for j in range(i + 1, n + 1):
            len_1 = j - i
            len_2_1 = np.abs(x-i) + 1 + np.abs(y-j)
            len_2_2 = np.abs(x-j) + 1 + np.abs(y-i)
            len_2 = min(len_2_1, len_2_2)
            len_min = min(len_1, len_2)
            sum_array[len_min - 1] += 1

for num in sum_array:
    print(num)

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
x = X - 1
y = Y - X
z = N - Y
F0 = False
F1 = False
for k in range(N - 1):
    k += 1
    if k >= y:
        F0 = True
    if k > x + z + 1:
        F1 = True
    left = max(x + 1 - k, 0)
    right = max(z + 1 - k, 0)
    base = N + x + z + 2 - 2 * k - left - right
    if F1 == True:
        print(0)
    elif F0 == True:
        left = max(x + y - k, 0)
        right = max(y + z - k, 0)
        print(base - ((N - k) - left - right))
    else:
        print(base)

Submission status: Wrong Answer

Solution code:
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())


n,x,y=IA()
ans=[0 for i in range(0,n)]


def out():
    for i in range(1,n):
        print(ans[i])
    print()
if x==y:
    for i in range(1,n+1):
        ans[i]=n-i
else:

    m=x+n-y+1

    for i in range(1,m+1):
        ans[i]=m-i
        
    cha=y-x-1
    for i in range(1,cha+1):
        ans[i]+=cha-i
    #out()
    tt=cha//2+1

    def f(tt,x,t=0):
        if tt==1 and x==1:
            ans[1+t]+=1
        add=1
        for i in range(1+t,max(tt,x)+t):
            ans[i]+=add
            if i<max(x,tt)+t:
                add+=1
        for i in range(max(tt,x)+1+t,max(tt,x)+min(x,tt)+t):
            ans[i]+=add
            add-=1
    if cha%2==1:
        f(tt,x)
        f(tt-1,n-y+1,1)
        
        f(tt,n-y+1)
        #out()
        f(tt-1,x,1)

        
    else:
        f(tt-1,x)
        f(tt-1,n-y+1,1)
        
        f(tt-1,n-y+1)
        f(tt-1,x,1)
for i in range(1,n):
    print(ans[i])

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)
print (2*N+X-Y-4)
lists=[1,1,1,1]
t=0
for k in range(3,N-1):
  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:
N,X,Y=input().split()
N=int(N)
X=int(X)
Y=int(Y)
k=0
if (3<=N<=2*10**5)and(1<=X,Y<=N)and(X+1<Y):
    for k in range(N-1):
        a=0
        if k<=Y-X:
            a+=N-X+1-k
            a+=Y-X+1
        else:
            a+=N-X+1-k
            if k+1<X+(Y-X)/2:
                a+=X+(Y-X)//2-k
            if Y-k>X+(Y-X)/2:
                if (Y-X)%2==0:
                    a+=N-X-(Y-X)//2+1-k
                if (Y-X)%2==1:
                    a+=N-X-(Y-X)//2-k
    a=int(a)
    print(a)
    k+=1

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
a,b=sorted([a,b])
r=[0]*n
#print(n,a,b)
"""for ii in range(n-1):
  fr[ii]=n-1-ii
r[0]+=1
"""
z=b-a
for ii in range(n-z):
  r[ii]=n-ii-z
r[0]+=z
r[1]+=z-1
if a>1:
  r[1]+=1
if b<n-1:
  r[1]+=1
if z>1:
  r[z-1]+=1
if z>2:
  r[z-1]+=1
"""for ii in range(n-1-z):
  r[z+ii]=0
r[n-1-z]=1"""
for ii in range(n-1): 
  print(r[ii])

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

Submission status: Wrong Answer

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

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

################################

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

##############################
cost = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(n):
  for j in range(n):
    if i+1==j or (i==x-1 and j==y-1) or i==j+1 or (i==y-1 and j==x-1):
      cost[i][j] = 1
      cost[j][i] = 1
for i in range(n):
    cost[i][i] = 0 #自身のところに行くコストは０
from collections import defaultdict
ans = [0]*(n+1)
for i in range(n):
  d = dijkstra(i,n,n,cost)
  for j in range(n)[i+1:]:
    if d[j] != float("inf"):
      ans[int(d[j])]+=1
for a in ans[1:]:
  print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, X, Y = map(int, input().split())
K = Y - X
ans = np.zeros(N-1,dtype = int)
for i in range(X-1):
  ans[i] += X-i-1
for i in range(N-Y-1):
  ans[i] += N-Y-i-1
for i in range(1, X+1):
  for j in range(X+1,N+1):
    ans[Y-j +X-i] += 1
for i in range(X+1, Y+1):
  for j in range(i+1,N+1):
    tmp = min(j-i,abs(Y-j) +1 + abs(X-i))
    ans[tmp-1] += 1
for i in range(N-1):
  print(ans[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 == Y - 1:
      dp[i][X - 1] = min(dp[i][X - 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][X - 1] = min(dp[i][X - 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:
# -*- coding: utf-8 -*-
N, X, Y = map(int, input().split())

min_dist_list = []
ans_list = [N]
for k in range(2, N):
    temp_ans = 0
    for i in range(1, N):
        if i + k <= X:
            temp_ans += 1
#             print(1, k, i)
        elif i > X - k and i < X + k and i + k <= N:
            if i >= X + (Y - X) // 2:
                temp_ans += 1
            elif i + k < Y - (k - abs(i - X)) - 1:
                temp_ans += 2
            elif i + k == Y - (k - abs(i - X)) - 1:
                temp_ans += 1
            
            if Y + (k - abs(i - X)) - 1 <= N:
                temp_ans += 1
#             print(2, k, i, temp_ans, Y + (k - abs(i - X)) - 1)
        elif i >= X + k:
            if i + k <= N:
                temp_ans += 1
#             print(3, k, i, temp_ans)
    ans_list.append(temp_ans)
                
print("\n".join(map(str, ans_list)))

Submission status: Wrong Answer

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

pairs = [(i, i+1) for i in range(1, N)]
pairs.append((X, Y))
found_pairs = []


def not_found_judge(pairs, found_pairs):
    if pairs in found_pairs:
        return False
    elif (pairs[1], pairs[0]) in found_pairs:
        return False
    else:
        return True


for i in range(1, N):
    new_pairs = []
    if i == 1:
        print(len(pairs))
        found_pairs.extend(pairs)
        continue
    for pair in pairs:
        start, end = pair
        if end == X and not_found_judge((start, Y), found_pairs):
            found_pairs.append((start, Y))
            new_pairs.append((start, Y))
        if end < N and not_found_judge((start, end+1), found_pairs):
            found_pairs.append((start, end+1))
            new_pairs.append((start, end+1))
    for j in range(1, min(i+1, Y-X)):
        if not_found_judge((X+j, Y-i+j+1), found_pairs) and Y-i+j+1 <= N and X+j < Y-i+j+1:
            found_pairs.append((X+j, Y-i+j+1))
            new_pairs.append((X+j, Y-i+j+1))
        if not_found_judge((X-j, Y-i+j+1), found_pairs) and Y-i+j+1 <= N and X-j < Y-i+j+1:
            found_pairs.append((X-j, Y-i+j+1))
            new_pairs.append((X-j, Y-i+j+1))
        if not_found_judge((X+j, Y+i-j-1), found_pairs) and Y+i-j-1 <= N and X+j < Y+i-j-1:
            found_pairs.append((X+j, Y+i-j-1))
            new_pairs.append((X+j, Y+i-j-1))
    pairs = new_pairs
    print(len(pairs))

Submission status: Wrong Answer

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

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


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

from collections import defaultdict

ans = defaultdict(int)
for i in range(N):
    for j in range(N):
        if d[i][j]:
            ans[d[i][j]] += 1

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

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
from collections import Counter

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

nodes = list(range(1, N + 1))
distance_counter = Counter()
a = Y - X - 1
p = (Y - X) // 2 + X
ans = []
for i, j in combinations(nodes, 2):
    if j - i == 1:
        continue
    if i <= X:
        if j < Y:
            jtoX = Y - j + 1 if j > p else j - X
            distance = X - i + jtoX
        else:
            distance = j - i - a
    else:
        if j < Y:
            d1 = j - i
            d2 = i - X + Y - j + 1
            distance = min(d1, d2)
        else:
            itoY = Y - i if i > p else i - X + 1
            distance = j - Y + itoY
    distance_counter[distance] += 1

for k in range(1, N):
    if k == 1:
        ans.append(str(N))
    else:
        ans.append(str(distance_counter.get(k, 0)))

print('\n'.join(ans))

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//2 + 1, k)
    not23 = calcd(sec2//2 + 1, 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())
route_list = [[0 for i in range(N)] for i in range(N)]
route_list[X-1][Y-1] = 1
for i in range(N-1):
    route_list[i][i + 1] = 1

import math
import sys

def get_target_min_index(min_index, distance, unsearched_nodes):
    start = 0
    while True:
        index = distance.index(min_index, start)
        found = index in unsearched_nodes
        if found:
            return index
        else:
            start = index + 1

def hoge(route_list):
    node_num = len(route_list)  #ノードの数
#    print(node_num)
    
    unsearched_nodes = list(range(node_num)) # 未探索ノード
    distance = [sys.maxsize] * node_num # ノードごとの距離のリスト
    previous_nodes = [-1] * node_num # 最短経路でそのノードのひとつ前に到達するノードのリスト
    distance[0] = 0 # 初期のノードの距離は0とする
    while(len(unsearched_nodes) != 0): #未探索ノードがなくなるまで繰り返す
        # まず未探索ノードのうちdistanceが最小のものを選択する
        posible_min_distance = sys.maxsize # 最小のdistanceを見つけるための一時的なdistance。初期値は inf に設定。
        for node_index in unsearched_nodes: # 未探索のノードのループ
            if posible_min_distance > distance[node_index]: 
                posible_min_distance = distance[node_index] # より小さい値が見つかれば更新
        target_min_index = get_target_min_index(posible_min_distance, distance, unsearched_nodes) # 未探索ノードのうちで最小のindex番号を取得
        unsearched_nodes.remove(target_min_index) # ここで探索するので未探索リストから除去

        target_edge = route_list[target_min_index] # ターゲットになるノードからのびるエッジのリスト
        for index, route_dis in enumerate(target_edge):
            if route_dis != 0:
                if distance[index] > (distance[target_min_index] + route_dis):
                    distance[index] = distance[ target_min_index] + route_dis # 過去に設定されたdistanceよりも小さい場合はdistanceを更新
                    previous_nodes[index] =  target_min_index #　ひとつ前に到達するノードのリストも更新

    # 以下で結果の表示

#    print("-----経路-----")
    previous_node = node_num - 1
    while previous_node != -1:
#        if previous_node !=0:
#            print(str(previous_node + 1) + " <- ", end='')
#        else:
#            print(str(previous_node + 1))
        previous_node = previous_nodes[previous_node]

#    print("-----距離-----")
#    print(distance[node_num - 1])
    return distance
ans = [0] * N
#print(hoge(route_list))
for i in (hoge(route_list)):
    if i == 0:
        continue
    ans[i] += 1

for i in range(1, len(route_list)):
    for j in route_list[i:]:
        j.pop(0)
    #print(hoge(route_list[i:]))
    for i in hoge(route_list[i:]):
        if i == 0:
            continue
        ans[i] += 1
ans.pop(0)
for i in ans:
    print(i)

Submission status: Wrong Answer

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

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

for i in range(1, N-1):
  k = i+1
  if k <= N+X-Y:
    ans[i] += N+X-Y-k+1
  if 2*k < Y-X+1:
    ans[i] += Y-X+1
  elif 2*k == Y-X+1:
    ans[i] += k
  
  saigo = (Y+X+1)//2
  kmax = max(X-1, saigo-X)
  kmin = min(X-1, saigo-X)
  if kmin + 1 >= k:
    ans[i] += k-1
  elif kmin + 1 < k <= kmax + 1:
    ans[i] += kmin
  else:
    ans[i] += max(0, kmax + kmin - k + 1)
  
  saigo = (Y+X)//2
  kmax = max(N-Y, Y-saigo)
  kmin = min(N-Y, Y-saigo)
  if kmin + 1 >= k:
    ans[i] += k-1
  elif kmin + 1 < k <= kmax + 1:
    ans[i] += kmin
  else:
    ans[i] += max(0, kmax + kmin - k + 1)
  
  if Y-X <= 3:
    continue
  elif (Y-X)%2 == 0:
    saigo = (Y+X)/2 + 1
  else:
    saigo = (X+Y+3)/2
  kmax = max(X-1, Y-saigo)
  kmin = min(X-1, Y-saigo)
  if kmin + 2 >= k:
    ans[i] += k-2
  elif kmin + 2 < k < kmax + 2:
    ans[i] += kmin
  else:
    ans[i] += max(0, kmax + kmin + 2 - k)
  
  if (Y-X)%2 == 0:
    saigo = (Y+X)/2 - 1
  else:
    saigo = (X+Y-3)/2
  kmax = max(N-Y, saigo-X)
  kmin = min(N-Y, saigo-X)
  if kmin + 2 >= k:
    ans[i] += k-2
  elif kmin + 2 < k < kmax + 2:
    ans[i] += kmin
  else:
    ans[i] += max(0, kmax + kmin + 2 - k)

for j in ans:
  print(j)

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+1
  if Y-X == k:
    a -= 1
  print(a)
  k += 1

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

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
dxy = y - x
r = dxy + 1
for k in range(1, n):
    ans = 0
    # i,j<x
    ans += max(0, x - k - 1)

    # i<x<=j<=y
    l = x - 1
    if r % 2 == 0 and r // 2 < k <= l + r // 2:
        ans += 1
    s = max(-(r // 2), 1 - k)
    t = min(0, l - k)
    if s <= t:
        ans += 2 * (t - s + 1)
        if t == 0:
            ans -= 1
    # i<x<y<j
    s = max(1, x + 2 - k)
    t = min(x - 1, x + 1 + n - y - k)
    if s <= t:
        ans += t - s + 1

    # x<=i<j<=y
    ans += 0 if k > r / 2 else r if k < r / 2 else r // 2
    # x<=i<=y<j
    l = n - y
    if r % 2 == 0 and r // 2 < k <= l + r // 2:
        ans += 1
    s = max(-(r // 2), 1 - k)
    t = min(0, l - k)
    if s <= t:
        ans += 2 * (t - s + 1)
        if t == 0:
            ans -= 1
    # y<i, j
    ans += max(0, n - y - 1 - k)

    print(ans)

Submission status: Wrong Answer

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

result = [0] * n
for i in range(n):
    for j in range(i, n, 1):
        if i == j:
            continue
        if i <= x:
            if j <= x:
                result[(j - i - 1)] += 1 # 普通に+1
            elif x < j and j < y:
                minij = min([(j - i - 1), ((x - i + 1) + (y - j) - 1)])
                result[minij] += 1
            elif y <= j:
                minij = min([(j - i - 1), ((x - i + 1) + (j - y) - 1)])
                result[minij] += 1
        elif x < i and i < y:
            if x < j and j < y:
                result[(j - i - 1)] += 1 # 普通に+1
            elif y <= j:
                minij = min([(j - i - 1), ((i - x + 1) + (j - y) - 1)])
                result[minij] += 1
        elif y <= i:
            result[(j - i - 1)] += 1  # 普通に+1
for i in range(n-1):
    print(result[i])

Submission status: Wrong Answer

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

net1 = list(range(1,n+1)) 
net2 = list(range(1,x+1)) + list(range(y,n+1))  

for a in range(1,n):
  lisa = []
  seta = set()

  for i in range(len(net1)-a):
    lisa.append(net1[i:i+a+1])

  for i in range(len(net2)-a):
    lisa.append(net2[i:i+a+1])

  for l in lisa:
    seta.add(tuple(l))

  print(len(seta))

Submission status: Wrong Answer

Solution code:
nxy=list(map(int, input().split()))
n=nxy[0]
x=nxy[1]
y=nxy[2]
ans=[0]*n
ans[0]=n
g1=x-1
g3=n-y
g2=n-g1-g3
for i in range(g1-1):
    ans[i+1]+=g1-(i+1)
for i in range(g3-1):
    ans[i+1]+=g3-(i+1)
g2s, g2v=divmod(g2, 2)
for i in range(g2s):
    ans[i+1]+=g2
for i in range(g1):
    for j in range(g3):
        ans[i+j+3]=1
for i in range(g1):
    ans[i+1]+=1
    if g2v==1:
        for j in range(g2s):
            ans[i+j+2]+=2
    else:
        for j in range(g2s-1):
            ans[i+j+2]+=2
        ans[i+g2s+11]+=1
for i in range(g3):
    ans[i+1]+=1
    if g2v==1:
        for j in range(g2s):
            ans[i+j+2]+=2
    else:
        for j in range(g2s-1):
            ans[i+j+2]+=2
        ans[i+g2s+11]+=1
for i in range(1, n-1):
    print(ans[i])

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:
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][X - 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][X - 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, 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 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 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 collections 
N, X, Y = list(map(int, input().split()))
table = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
    for j in range(i, N):
        table[i][j] = j-i
#print(table)

dif = Y-X-1
#print('dif', dif)

for i in range(0, X):
    for j in range(Y-1, N):
        table[i][j] -= dif
#print(table)

for i in range(0, X):
    for j in range(Y-1, 0, -1):
        #print('j',j)
        if table[i][j] < table[i][j-1]-1:
            #print('j-1', j-1)
            table[i][j-1] = 1+table[i][j]

for i in range(Y-1, N):
    for j in range(X-1, N-1):
        #print('j',j)
        if table[j][i] < table[j+1][i]-1:
            #print('j+1', j+1)
            table[j+1][i] = 1+table[j][i]
#print(table)

cnt = collections.Counter(str(table))

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


N, X, Y = inp_list()
ans = [0] * (N - 1)

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

shortcut = Y - X
for k in range(1, N - 2):
    if sum(ans[:k]) == N * (N + 1) // 2:
        ans[k:] = [0] * (N - 1 - k + 1)
        break
    if k < shortcut:
        ans[k] += 2
    elif k == shortcut:
        ans[k] -= 1
        ans[k] += 2
    else: # k > shortcut
        if X > 1 and Y < N:
           ans[k] += 1 


ans[-1] = N * (N + 1) // 2 - sum(ans[:-1])

for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N, X, Y = list(map(int, input().split(' ')))
X -= 1
Y -= 1
dist_map = {}

def search(origin):
  dist = []
  # X, Yの辺がない場合
  for i in range(N):
    dist.append(abs(origin - i))
  # X, Yの辺がある場合
  if dist[X] < dist[Y]:
    dist[Y] = dist[X] + 1
  elif dist[Y] < dist[X]:
    dist[X] = dist[Y] + 1
  for i in range(X+1, Y):
    dist[i] = min(dist[i-1]+1, dist[i+1]+1, dist[i])
  for i in range(N):
    if i - 1 >= 0:
      dist[i] = min(dist[i], dist[i-1]+1)
    if i + 1 < N:
      dist[i] = min(dist[i], dist[i+1]+1)
  for i in reversed(range(N)):
    if i - 1 >= 0:
      dist[i] = min(dist[i], dist[i-1]+1)
    if i + 1 < N:
      dist[i] = min(dist[i], dist[i+1]+1)
  #print(*dist)
  return dist


for i in range(N):
  dist_map[i] = search(i)

print(N)
count = [0 for i in range(N)]
for i in range(N):
  #print('i='+str(i))
  #dist = dist_map[i]
  #print(*dist)
  dist = dist_map[i]
  for dis in dist:
    count[dis] += 1
for i in range(1, N):
  print(count[i]//2)

Submission status: Wrong Answer

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

# x, yを使うルート＋飛ばされたところを含むルート
# x, yを使った場合の端から端の距離
dis_xy = n - (y - x) + 1
# x,y間の数aについて、xに近い点数、yに近い点数、等距離の点数を計算
near_x = (y - x - 1) // 2
near_y = (y - x - 1) // 2
equal_xy = (y - x - 1) % 2

for k in range(1, n):
    c_xy = max(0, dis_xy - k)
    tmp1 = max(0, near_x + 1 - k)
    tmp2 = max(0, min(near_x, x + near_x - k)) - tmp1
    tmp3 = max(0, min(near_x, (n - y + 2) + near_x - k)) - tmp1
    tmp4 = max(0, near_y + 1 - k)
    tmp5 = max(0, min(near_y, (n - y + 1) + near_y - k)) - tmp4
    tmp6 = max(0, min(near_y, (x + 1) + near_y - k)) - tmp4
    tmp7 = 0
    if equal_xy == 1:
        z = (x + y) // 2
        if z - k > 0:
            tmp7 += 1
        if (n - z + 1) - k > 0:
            tmp7 += 1
    tmp8 = 0
    if (y - x + 1) >= 2 * k:
        tmp8 = (y - x + 1) - tmp1 - tmp4
        if equal_xy == 1:
            if z - k >= x:
                tmp8 -= tmp7
        z = (x + y) // 2
        if (y - (z + 1) + 1) >= k:
            if k > 1:
                tmp8 -= 2
            else:
                tmp8 -= 1
        tmp8 = max(0, tmp8)
    else:
        tmp8 = 0
    print(c_xy + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 + tmp7 + tmp8)

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
xpath_length = x - 1
ypath_length = n - y
cycle_length = y - x + 1
for k in range(1, n):
    ans = 0
    if k <= cycle_length // 2:
        ans += cycle_length
    ans += max(0, xpath_length - k + 1)
    ans += max(0, ypath_length - k + 1)
    ans += int(max(0, min(k - 1, xpath_length) - max(0, k - cycle_length // 2 - 1)) * 2)
    ans += int(max(0, min(k - 1, ypath_length) - max(0, k - cycle_length // 2 - 1)) * 2)
    ans += max(0, min(k - 2, xpath_length, ypath_length, xpath_length + ypath_length - k + 2))
    print(ans)

Submission status: Wrong Answer

Solution code:
_in = list(map(int, input().split()))
n = _in[0]
x = _in[1]
y = _in[2]
l = [0]*n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        d = j-i
        if i<=x<y<=j:
            d = d + x - y + 1
        elif i<=x<j<y:
            if d>y-j+1:
                d = y-j+1+x-i
        elif x<i<y<=j:
            if d>i-x+1:
                d = i-x+1+j-y
        elif i<=x<y<=j:
            d = j-y+x-i+1
        l[d]+=1
for i in range(1,len(l)):
    print(l[i])

Submission status: Wrong Answer

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

pairs = [(i, i+1) for i in range(1, N)]
pairs.append((X, Y))
found_pairs = []


def not_found_judge(pairs, found_pairs):
    if pairs in found_pairs:
        return False
    elif (pairs[1], pairs[0]) in found_pairs:
        return False
    else:
        return True


for i in range(1, N):
    new_pairs = []
    if i == 1:
        print(len(pairs))
        found_pairs.extend(pairs)
        continue
    for pair in pairs:
        start, end = pair
        if end == X and not_found_judge((start, Y), found_pairs):
            found_pairs.append((start, Y))
            new_pairs.append((start, Y))
        if end < N and not_found_judge((start, end+1), found_pairs):
            found_pairs.append((start, end+1))
            new_pairs.append((start, end+1))
    for j in range(1, min(i+1, Y-X)):
        if not_found_judge((X+j, Y-i+j+1), found_pairs) and Y-i+j+1 <= N and X+j != Y-i+j+1:
            found_pairs.append((X+j, Y-i+j+1))
            new_pairs.append((X+j, Y-i+j+1))
        if not_found_judge((X-j, Y-i+j+1), found_pairs) and Y-i+j+1 <= N and X-j != Y-i+j+1:
            found_pairs.append((X-j, Y-i+j+1))
            new_pairs.append((X-j, Y-i+j+1))
        if not_found_judge((X+j, Y+i-j-1), found_pairs) and Y+i-j-1 <= N and X-j != Y+i-j-1:
            found_pairs.append((X+j, Y+i-j-1))
            new_pairs.append((X+j, Y+i-j-1))
    pairs = new_pairs
    print(len(pairs))