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:
N,X,Y = map(int,input().split())
length = [0]*(N+1)
for i in range(1,N+1):
  for j in range(i,N+1):
    ans = min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(X-j)+1+abs(Y-i))
    length[ans] += 1
for i in range(1,N+1):
  print(length[i])

Submission status: Wrong Answer

Solution code:
from collections import deque, defaultdict

N, X, Y = map(int, input().split())
# 全探索でいけるのでは？
# 有向グラフとしてN回幅優先すれば良いのでは？
tree = [[] for _ in range(N)]
for i in range(N-1):
    tree[i].append(i+1)
    tree[i+1].append(i)
tree[X-1].append(Y-1)
tree[Y-1].append(X-1)
ans = defaultdict(int)
q = deque()
# 更新されない時はqに追加しない
for i in range(N):
    distant = [N]*N
    q.append(i)  # 始まりのノード
    distant[i] = 0
    while len(q):
        # vは数字, 親のノードのインデックス
        v = q.pop()
        for e in tree[v]:
            if distant[e] != N:  # 到達済みなら次のノードへ
                continue
            distant[e] = min(distant[v]+1, distant[e])
            q.append(e)
    for d in distant:
        ans[d] += 1
for i in range(1, N):
    print(ans[i]//2)

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
l = [0]*n

for i in range(1, n):
    for j in range(i + 1, n + 1):
        diff1 = j - i
        diff2 = abs(x - i) + abs(y - j) + 1
        diff = min(diff1, diff2)
        l[diff] = l[diff] + 1
        print(i, j, diff1, diff2)

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

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split())
M = N-(Y-X-1)
for i in range(N-1):
    C = []
    for j in range(N-1):
        if(j+i+1 <= N-1):
            if not(j<X and Y-2<j+i+1):
                C.append([j+1, j+i+1+1])
        else:
            break
    for j in range(M-1):
        if(j+i+1 <= M-1):
            if(j<X and X<=j+i+1):
                C.append([j+1, j+i+1+Y-X-1+1])
    print(len(C))

Submission status: Wrong Answer

Solution code:
def end_point(start, k):
    return start-k

def judge(n, x, y, k):
    # 回り道をしない経路
    woop = n-((y-x)-1)-k
    # 回り道をする経路
    count=0
    no_woop=0
    flag=False
    start_point=x+1
    # スタートの設定(最後尾が1以上にする)
    while(end_point(start_point, k)<1):
        start_point=start_point+1

    # ｙまで届いてしまったらワープしてｙに行く方がはやいので０
    if(start_point>=y):
        flag=True
    if(flag==False):
        no_woop=no_woop+1
        while(start_point!=y-1):
            start_point=start_point+1
            no_woop=no_woop+1


    start_point=y
    # print("start_point",start_point)
    # print("end_point",end_point(start_point, k))
    while(end_point(start_point, k)<=x):
        start_point=start_point+1
    if(start_point>n):
        flag=True
    if(flag==False):
        no_woop=no_woop+1
        while(end_point(start_point, k)!=y-1 and start_point!=n):
            print(end_point(start_point, k))
            start_point=start_point+1
            no_woop=no_woop+1

    # print("k=",k,"no_woop",no_woop)
    # print("k=",k,"woop",woop)
    print(woop+no_woop)

n,x,y = map(int,input().split())
for i in range(1,n):
    judge(n, x, y, i)

Submission status: Wrong Answer

Solution code:
from itertools import combinations as combi
N, X, Y = map(int, input().split(" "))

main_list = list(combi(list(range(1, N + 1)), 2))
dis_list = [0] * (N - 1)

for c in main_list:
    x = c[0]
    y = c[1]
    if x <= X or y >= Y:
        dis = min(y - x, abs(X - x) + 1 + abs(y - Y), abs(Y - x) + 1 + abs(y - X))
    else:
        dis = y - x
    dis_list[dis - 1] += 1

for c in dis_list:
    print(c)

Submission status: Wrong Answer

Solution code:
from itertools import combinations as combi
N, X, Y = map(int, input().split(" "))

main_list = list(combi(list(range(1, N + 1)), 2))
dis_list = [0] * (N - 1)

for c in main_list:
    x = c[0]
    y = c[1]
    if x <= X or y >= Y:
        dis = min(y - x, abs(X - x) + 1 + abs(y - Y))
    else:
        dis = y - x
    dis_list[dis - 1] += 1

for c in dis_list:
    print(c)

Submission status: Wrong Answer

Solution code:
from itertools import combinations as combi
N, X, Y = map(int, input().split(" "))

main_list = list(combi(list(range(1, N + 1)), 2))
dis_list = [0] * (N - 1)

for c in main_list:
    x = c[0]
    y = c[1]
    if x <= X and y >= Y:
        dis = (X - x) + (y - Y) + 1
    else:
        dis = y - x
    dis_list[dis - 1] += 1


for c in dis_list:
    print(c)

Submission status: Wrong Answer

Solution code:
from itertools import combinations as combi
N, X, Y = map(int, input().split(" "))

main_list = list(combi(list(range(1, N + 1)), 2))
dis_list = []

for c in main_list:
    x = c[0]
    y = c[1]
    if x <= X and y >= Y:
        dis_list.append((X - x) + (y - Y) + 1)
    else:
        dis_list.append(y - x)


for c in range(1, N, 1):
    print(dis_list.count(c))

Submission status: Wrong Answer

Solution code:
from itertools import combinations as combi
N, X, Y = map(int, input().split(" "))

main_list = list(combi(list(range(1, N + 1)), 2))
dis_list = []

for c in range(len(main_list)):
    x = main_list[c][0]
    y = main_list[c][1]
    if x <= X and y >= Y:
        dis_list.append((X - x) + (y - Y) + 1)
    else:
        dis_list.append(y - x)


for c in range(1, N, 1):
    print(dis_list.count(c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

inp = input().split()

N = int(inp[0])
X = int(inp[1])
Y = int(inp[2])
c = Y-X+1
a = X-1
b = N-Y
for k in range(1,N):
    ans = 0
    if c//2 >= k:
        ans += c
    #print(min(a,a+c//2-k),a+1-k)
    ans += 2*max(min(a,a+c//2-k+1),0)-max((a+1-k),0)
    ans += 2*max(min(b,b+c//2-k+1),0)-max((b+1-k),0)
    if a+b+2 > k:
        ans += max(min(k-2,a,b,a+b+2-k),0)
    print(ans)

Submission status: Wrong Answer

Solution code:
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(5, 2, 4), [5, 4, 1, 0])

    def test_2(self):
        self.assertEqual(think(3, 1, 3), [3, 0])

    def test_3(self):
        self.assertEqual(think(7, 3, 7), [7, 8, 4, 2, 0, 0])

    def test_4(self):
        self.assertEqual(think(10, 4, 8), [10, 12, 10, 8, 4, 1, 0, 0, 0])


def solve():
    n, x, y = read()
    result = think(n, x, y)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, x, y):
    # MAX_DISTANCE = 10 ** 9
    MAX_DISTANCE = 8
    result = [0] * n
    adjacent_matrix = [[MAX_DISTANCE for _ in range(n)] for _ in range(n)]
    for i in range(n - 1):
        adjacent_matrix[i][i] = 0
        adjacent_matrix[i][i + 1] = 1
        adjacent_matrix[i + 1][i] = 1
    adjacent_matrix[x - 1][y - 1] = 1
    adjacent_matrix[y - 1][x - 1] = 1
    warshall_floyd(adjacent_matrix)
    for i in range(n):
        for j in range(i + 1, n):
            distance = adjacent_matrix[i][j]
            result[distance] += 1
    return result[1:]


def write(result):
    for r in result:
        print(r)


def warshall_floyd(matrix):
    n = len(matrix)

    changed = True
    while changed:
        changed = False
        for i in range(n):
            for j in range(n):
                if i == j:
                    continue
                for k in range(n):
                    if k == i or k == j:
                        continue
                    old_distance = matrix[i][j]
                    matrix[i][j] = min(matrix[i][j], matrix[i][k] + matrix[k][j])
                    if matrix[i][j] < old_distance:
                        changed = True


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Wrong Answer

Solution code:
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(5, 2, 4), [5, 4, 1, 0])

    def test_2(self):
        self.assertEqual(think(3, 1, 3), [3, 0])

    def test_3(self):
        self.assertEqual(think(7, 3, 7), [7, 8, 4, 2, 0, 0])

    def test_4(self):
        self.assertEqual(think(10, 4, 8), [10, 12, 10, 8, 4, 1, 0, 0, 0])


def solve():
    n, x, y = read()
    result = think(n, x, y)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, x, y):
    # MAX_DISTANCE = 10 ** 9
    MAX_DISTANCE = 8
    result = [0] * n
    adjacent_matrix = [[MAX_DISTANCE for _ in range(n)] for _ in range(n)]
    for i in range(n - 1):
        adjacent_matrix[i][i + 1] = 1
        adjacent_matrix[i + 1][i] = 1
    adjacent_matrix[x - 1][y - 1] = 1
    adjacent_matrix[y - 1][x - 1] = 1
    warshall_floyd(adjacent_matrix)
    for i in range(n):
        for j in range(i + 1, n):
            distance = adjacent_matrix[i][j]
            result[distance] += 1
    return result[1:]


def write(result):
    for r in result:
        print(r)


def warshall_floyd(matrix):
    n = len(matrix)

    changed = True
    while changed:
        changed = False
        for i in range(n):
            for j in range(i + 1, n):
                for k in range(n):
                    if k == i or k == j:
                        continue
                    old_distance = matrix[i][j]
                    matrix[i][j] = min(matrix[i][j], matrix[i][k] + matrix[k][j])
                    if matrix[i][j] < old_distance:
                        changed = True


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Wrong Answer

Solution code:
from collections import deque
from collections import defaultdict


class Graph(object):
    """
    隣接リストによる無向グラフ
    重み無しで距離は１
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst):
        self.graph[src].append(dst)
        self.graph[dst].append(src)

    def get_nodes(self):
        return self.graph.keys()


if __name__ == "__main__":
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1

    g = Graph()
    for i in range(n-1):
        g.add_edge(i, i+1)
    g.add_edge(x, y)

    ans = [0] * (n-1)

    # BFSによる解法
    for i in range(n-1):
        # 始点からの距離
        # -1を未訪問とする
        dist = [-1] * n

        # 初期条件
        # 今回は頂点iから探索を行う
        dist[i] = 0
        que = deque([i])

        while len(que) != 0:
            vertex = que.popleft()
            for v in g.graph[vertex]:
                if dist[v] != -1 or v < i:
                    pass
                else:
                    tmp = dist[vertex] + 1
                    dist[v] = tmp
                    ans[tmp-1] += 1
                    que.extend(g.graph[vertex])

    for a in ans:
        print(a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)

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

import queue
# FIFOキューの作成
q = queue.Queue()

dst = [10**18] * (n+1)

kyori = [0] * (n+1)
"""
for i in range(n):
    dst[i+1][i+1] = 0
"""
#num = 1

for i in range(1,n):
    #num = 1
    dst[i] = 0
    q.put([i,0])
    while not q.empty():
        
        kari = q.get()
        tmp = kari[0]
        tmp_dst = kari[1]
        #print(tmp[0])
        #exit()
        if tmp >= n+1:
            continue
        if tmp < 1:
            continue
        if tmp == x:
            if dst[y] == 10**18:
                #kyori[tmp_dst+1] += 1
                dst[y] = tmp_dst+1
                q.put([y,tmp_dst+1])
                
        if tmp == y:
            if dst[x] == 10**18:
                #kyori[tmp_dst+1] += 1
                dst[x] = tmp_dst+1
                q.put([x,tmp_dst+1])
        if tmp+1 <= n:
            if dst[tmp+1] == 10**18:
                q.put([tmp+1,tmp_dst+1])
                #kyori[tmp_dst+1] += 1
                dst[tmp+1] = tmp_dst+1
        if tmp-1 >= 1:
            if dst[tmp-1] == 10**18:
                q.put([tmp-1,tmp_dst+1])
                #kyori[tmp_dst+1] += 1
                dst[tmp-1] = tmp_dst+1
        
        #num += 1
        #print(dst[i])
    #exit()
    for j in range(i+1,n+1):
        kyori[dst[j]] += 1
    dst = [10**18] * (n+1)
"""
#print(kyori)
print(dst)
exit()

kyori = [0] * (n+1)

for i in range(1,n):
    #print(dst[i],i)
    for j in range(i+1,n+1):
        #print(i,j,dst[i][j])
        kyori[dst[i][j]] += 1
"""
#print(kyori)
exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def check(i, j):
    
    a = j-i
    
    short = abs(x-i) + 1 + abs(j-y)
    if a==short:
        ans[a-1] += 2
    else:
        mini = min(a, short)
        ans[mini-1] += 1
        
for i in range(1, n):
    for j in range(i+1, n+1):
        check(i,j)


print(*ans, sep='\n')

Submission status: Wrong Answer

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

def check(i, j):
    
    a = j-i
    
    short = abs(x-i) + 1 + abs(j-y)
    if a==short:
        ans[a-1] += 2
    else:
        mini = min(a, short)
        ans[mini-1] += 1
        
for i in range(1, n):
    for j in range(i+1, n+1):
        check(i,j)


print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
N,X,Y = map(int,input().split())
matrix = [[0 for n in range(0,N)] for nn in range(0,N)]
for n in range(N):
    for i in range(n+1,N):
        s = i+1
        d = n+1
        p1 = abs(s-d)
        p2 = abs(s-X)+abs(d-Y)
        p3 = abs(s-Y)+abs(d-X)
        matrix[n][i] = min(p1,p2,p3)
matrix = sum(matrix,[])
for n in range(1,N):
    print(matrix.count(n))

Submission status: Wrong Answer

Solution code:
n,x,y = map(int,input().split())
#Will be running BFS on the graph
d = {}
for i in range(1,n):
    d[i] = 0

for i in range(1,n):
    q = [i]
    cnt = 1
    somr = 1  # somr and soma are being used to increase the distance counter
    soma = 0
    m = [0]*(n) #Visited nodes
    while(len(q) != 0):
        r = q.pop(0)
        somr = somr-1
        #print(r)
        m[r-1] = 1
        if r == x:
            if m[y-1] == 0:
                d[cnt] = d[cnt] + 1
                soma = soma + 1
                q.append(y)

        if r+1 < n+1:
            if m[r] == 0:
                d[cnt] = d[cnt] + 1
                q.append(r + 1)
                soma = soma+1

        if somr == 0:  #When somr will become zero,we will increase the counter
            cnt = cnt+1
            somr = somr+soma
            soma = 0

    #print(d)

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

Submission status: Wrong Answer

Solution code:
# D - Line++

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
cnt = [0] * N

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
n,x,y = map(int,input().split())
#Will be running BFS on the graph
d = {}
for i in range(1,n):
    d[i] = 0

for i in range(1,n):
    #print("Hi",i)
    q = [i]
    cnt = 1
    somr = 1
    soma = 0
    m = [0]*(n)
    while(len(q) != 0):
        r = q.pop(0)
        somr = somr-1
        #print(r)
        m[r-1] = 1
        if r == x:
            if m[y-1] == 0:
                d[cnt] = d[cnt] + 1
                soma = soma + 1
                q.append(y)

        if r+1 < n+1:
            if m[r] == 0:
                d[cnt] = d[cnt] + 1
                q.append(r + 1)
                soma = soma+1

        if somr == 0:
            cnt = cnt+1
            somr = somr+soma
            soma = 0

    #print(d)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque

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


def node_search(i):
    node_list = []
    if i != 1:
        node_list.append(i-1)
    if i != N:
        node_list.append(i+1)
    if i == X:
        node_list.append(Y)
    if i == Y:
        node_list.append(X)
    return node_list


def bfs(k):
    q = deque()
    dist = [N]*(N+1)
    q.append(k)
    check = [0]*(N+1)
    check[k] = 1
    dist[k] = 0
    while q:
        now_node = q.pop()
        check[now_node] = 1
        next_nodes = node_search(now_node)
        for node in next_nodes:
            if check[node] == 0:
                dist[node] = min(dist[now_node]+1, dist[node])
                q.appendleft(node)
    return dist


ans = [0]*N
for k in range(1, N+1):
    dist_list = bfs(k)
    print(dist_list)
    for i in range(k+1, N+1):
        ans[dist_list[i]] += 1

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)

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

import queue
# FIFOキューの作成
q = queue.Queue()

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

kyori = [0] * (n+1)

#num = 1

for i in range(1,n):
    num = 1
    q.put(i)
    while not q.empty():
        
        tmp = q.get()
        if tmp >= n:
            continue
        if tmp == x:
            if dst[i][y] == 0:
                kyori[num] += 1
                dst[i][y] = num
                q.put(y)
        if dst[i][tmp+1] == 0:
            q.put(tmp+1)
            kyori[num] += 1
            dst[i][tmp+1] = num
        num += 1
    #print(dst[i])

#print(kyori)
#print(dst)

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

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

d=deque()
for i in range(n):
    tmp=[0]*n
    tmp[i]=1
    d.append([[i],tmp])
# print(d)

x,y=x-1,y-1
for i in range(n):
    ans=0
    for j in range(n):
        now,itta=d.popleft()
        tugi=[]
        for k in now:
            if k==n-1:
                if itta[k-1]==0:
                    itta[k-1]=1
                    tugi.append(k-1)
                if y==k and itta[x]==0:
                    itta[x]=1
                    tugi.append(x)
            elif k==0:
                if itta[k+1]==0:
                    itta[k+1]=1
                    tugi.append(k+1)
                if x==k and itta[y]==0:
                    itta[y]=1
                    tugi.append(y)
            else:
                if itta[k-1]==0:
                    itta[k-1]=1
                    tugi.append(k-1)
                if y==k and itta[x]==0:
                    itta[x]=1
                    tugi.append(x)
                if itta[k+1]==0:
                    itta[k+1]=1
                    tugi.append(k+1)
                if x==k and itta[y]==0:
                    itta[y]=1
                    tugi.append(y)
        ans+=len(tugi)
        d.append([tugi,itta])
        # print(tugi)
        # print(itta)
    print(ans//2)
    ans=0

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# N=頂点数、X,Y=座標
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

# 未セットの値
INF = 10**4

# キューデータ(次の値、最短距離)
queue_list = []

# 最短距離ごとのリスト
min_e_list = [0 for i in range(N)]

for i in range(N):
    # キューデータ初期値をセット
    queue_list.append([i, 0])
    # 最短距離リスト(最短距離)
    min_dist_list = [INF for i in range(N)] 

    # キューデータが空になるまで繰り返す
    while(len(queue_list) != 0):
        
        # 先頭データを取り出す。
        pop_data = queue_list.pop(0)

        # 取り出した座標がセット済みの場合は何もしない
        if(min_dist_list[pop_data[0]] != INF):
            continue

        # 最短距離リストにデータセット
        min_dist_list[pop_data[0]] = pop_data[1]

        # 2重に数えないよう(i < 取り出した座標時)、最短距離ごとのリストにデータセット
        if(i < pop_data[0]):
            min_e_list[pop_data[1]] += 1

        # 1.隣の頂点(次の座標、+1,-1した値)
        if(pop_data[0]+1 < N):
            queue_list.append([pop_data[0]+1, pop_data[1]+1])
        if(pop_data[0] > 0 and pop_data[0]-1 < N):
            queue_list.append([pop_data[0]-1, pop_data[1]+1])
        
        # 2.X,Yで示した値
        if(pop_data[0] == X):
            queue_list.append([Y, pop_data[1]+1])
        if(pop_data[0] == Y):
            queue_list.append([X, pop_data[1]+1])

# 出力
for i in range(1, N):
    print(i)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

# N = 2000
# X = 100
# Y = 1900


X -= 1
Y -= 1

# @profile


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


main(N, X, Y)

Submission status: Wrong Answer

Solution code:

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

# N = 2000
# X = 100
# Y = 1900


X -= 1
Y -= 1

# @profile


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

    for a in ans[1:]:
        print(a//2)


main(N, X, Y)

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
x -= 1
y -= 1
ll = y-x+1
ans = [0]*(n-1)
for i in range(n-1):
  for j in range(i+1,n):
    if j <= x or i >= y:
      l = j - i
    elif i < x and x <= j <= y:
      l = x-i+min(j-x,ll-j+x)
    elif j > y and x <= i <= y:
      l = min(y-i,ll-y+i)+j-y
    else:
      l = min(j-i,ll-j+i)
    ans[l-1] += 1
for item in ans:
  print(item)

Submission status: Wrong Answer

Solution code:
N, X, Y = map(int, input().split(" "))
k = 0
while k < X:
    print(N-k)
    k += 1
nodes = [i for i in range(1, N+1)]
del nodes[(X+Y)//2-1]
k += 1
while k < N:
    print(len(nodes)-k)
    k += 1

Submission status: Wrong Answer

Solution code:
from collections import deque
N, X, Y = list(map(int, input().split()))

# N = 2000
# X = 100
# Y = 1900

X -= 1
Y -= 1


# @profile
def main(N, X, Y):
    ans = [0]*N
    for sv in range(N):
        # dist[v] = dist from sv to v
        dist = [float("inf")]*N
        visited = deque()
        dist[sv] = 0
        visited.append(sv)
        while visited:
            v = visited.pop()
            d = dist[v]
            if v+1 < N and dist[v+1] == float("inf"):
                dist[v+1] = d+1
                visited.append(v+1)
            if v-1 >= 0 and dist[v-1] == float("inf"):
                dist[v-1] = d+1
                visited.append(v-1)
            if v == X and dist[Y] == float("inf"):
                dist[Y] = d+1
                visited.append(Y)
            if v == Y and dist[X] == float("inf"):
                dist[X] = d+1
                visited.append(X)
        # print(dist)
        for d in dist:
            ans[d] += 1

    for a in ans[1:]:
        print(a//2)


main(N, X, Y)

Submission status: Wrong Answer

Solution code:

N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in range(len(ans)):
    if _ == 0:
        continue
    print(ans[_])

Submission status: Wrong Answer

Solution code:

N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in ans:
    if _ ==0:
        continue
    print(_)

Submission status: Wrong Answer

Solution code:
n, x, y = map(int, input().split())
x -= 1 #グラフを0からn-1までの数に対応させる
y -= 1 #
ans = [0]*n

for i in range(n):
  for j in range(i+1, n):#各頂点の距離を一組ずつ調べる
    a = min(j-i, abs(x-i) + abs(y-j) + 1)
    '''
    j-i                     :1～nまでの普通のルートでの距離
    abs(x-i) + abs(y-j) + 1 :ショートカットルートを使ったときの距離
    ''' 
    ans[a-1] += 1 #距離の長さに対応したリストに+1
for p in ans:
  print(p)

Submission status: Wrong Answer

Solution code:
N,X,Y=map(int,input().split())
list=[i+1 for i in range(N)]
#処理に用いる３つのリスト
#一つ目
newlist1=[i+1 for i in range(X)]
li_2=[i+1 for i in range(Y-1,N)]
newlist1.extend(li_2)
#二つ目
newlist2=[i+1 for i in range(X)]
li_3=[i+1 for i in range(X,Y)]
newlist2.extend(li_3[::-1])
#三つ目
newlist3=[i+1 for i in range(X-1,Y-1)][::-1]
li_4=[i+1 for i in range(Y-1,N)]
newlist3.extend(li_4)
#探索済みレコード
alreadyadded=[]
#探索用コード
for i in range(1,N):#間隔の設定
    counter=0
    for j in range(0,N-i):
            if not set([list[j],list[j+i]]) in alreadyadded:
                alreadyadded.append(set([list[j],list[i+j]]))
                counter+=1
    for j in range(0, len(newlist1)-i):
            if not set([newlist1[j],newlist1[j+i]]) in alreadyadded:
                    alreadyadded.append(set([newlist1[j],newlist1[i+j]]))
                    counter+=1
    for j in range(0, len(newlist2) - i):
            if not set([newlist2[j], newlist2[j + i]]) in alreadyadded:
                    alreadyadded.append(set([newlist2[j], newlist2[i + j]]))
                    counter += 1
    for j in range(0, len(newlist3) - i):
            if not set([newlist3[j], newlist3[j + i]]) in alreadyadded:
                    alreadyadded.append(set([newlist3[j], newlist3[i + j]]))
                    counter += 1
    print(counter)

Submission status: Wrong Answer

Solution code:
from collections import deque
INF = 1e10
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0 for _ in range(N)]
for sv in range(N):
  dist = [INF for _ in range(N)]
  q = deque([])

  def push(v, d):
    if dist[v] != INF: return
    dist[v] = d
    q.append(v)

    push(sv, 0)

    while q:
      sv = q.popleft()
      d = dist[sv]
      if sv > 0:
        push(sv-1, d+1)
        if sv < N-1:
          push(sv+1, d+1)
          if sv == X:
            push(Y, d+1)
            if sv == Y:
              push(X, d+1)

              for d in dist:
                ans[d] += 1

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

Submission status: Wrong Answer

Solution code:
s = input().split()
n=int(s[0])
x=int(s[1])-1
y=int(s[2])-1
inf=float('inf')
map=[[0]*n for i in range(n)]
map[x][y]=1
for i in range(n):
    for j in range(i+1,n):
        print(i,j)
        print(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        map[i][j]=min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))
print(map)
for i in range(1,n):
    count=0
    for j in map:
        count+=j.count(i)
    print(count)

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 - 2
    elif y - x + 1 > 2 * k:
        ans += y - x - 3
    elif y - x + 1 == 2 * k:
        ans += k - 2
    #print('#', ans)
    if x > 1:
        if k <= x - 1:
            if y - x + 1 > 2 * k:
                ans += 2 * k - 1
            else:
                ans += y - x - 1
        else:
            if y - x + 1 > 2 * k:
                ans += 2 * x
            else:
                ans += max(0, y - x - (k - x) * 2 + (-1 if k == x else 0))
    #print('#', ans)
    if y < n:
        if k <= n - y:
            if y - x + 1 > 2 * k:
                ans += 2 * k - 1
            else:
                ans += y - x - 1
        else:
            if y - x + 1 > 2 * k:
                ans += 2 * (n - y)
            else:
                ans += max(0, y - x - (k - (n - y + 1)) * 2 + (-1 if k == n - y + 1 else 0))
    print(ans)