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

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	/**
	 * for (int i = 0; i < N; i++) {}
	 * System.out.println();
	 * HashMap<Integer, Integer> hm = new HashMap<>();
	 * int[] s = new int[M];
	 * ArrayDeque<Integer> deq = new ArrayDeque<>();
	 *
	 * 文字列のSort
	 * String sorted = S.chars()
						.sorted()
						.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
						.toString();
	 * for (char i = 'a'; i <= 'z'; i++) {}
	 */
	public void run() {
		FastScannerMainD3 sc = new FastScannerMainD3(System.in);

		try {
			//String S = sc.nextLine().trim();
			// 5 2 4
			int N = sc.nextInt();
			int X = sc.nextInt();
			int Y = sc.nextInt();

			//隣接リストの作成
			HashMap<Integer, NextList> hm = new HashMap<Integer, NextList>();
			for (int i = 0; i < N; i++) {
				NextList nextList = new NextList();
				nextList.val = i;
				if (i == 0) {
					nextList.neighbours.add(i + 1);
				} else if (i == N - 1) {
					nextList.neighbours.add(i - 1);
				} else {
					nextList.neighbours.add(i + 1);
					nextList.neighbours.add(i - 1);
				}
				hm.put(i, nextList);
			}

			hm.get(X - 1).neighbours.add(Y - 1);
			hm.get(Y - 1).neighbours.add(X - 1);

			int[] ans = new int[N];
			for (int i = 0; i < N; i++) {
				//System.out.println(i + " " + hm.get(i).neighbours);
				
				int[] each =bfs(i,hm,N);
				
				//System.out.println(Arrays.toString(each));
				//System.out.println("-------------------");
				for (int j = 0; j < each.length; j++) {
					ans[each[j]]++;
				}
			}

			//System.out.println(Arrays.toString(ans));
			for (int i = 1; i < N; i++) {
				System.out.println(ans[i]/2);
			}

			

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	private int[] bfs(int start, HashMap<Integer, NextList> hm,int N) {
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		pq.offer(start);
		boolean[] visit = new boolean[N];
		visit[start] = true;

		int[] distance = new int[N];
		Arrays.fill(distance,Integer.MAX_VALUE);
		distance[start] = 0;

		while(pq.size()>0){
			int loc = pq.poll();
			//System.out.println("loc:"+loc +" "+hm.get(loc).neighbours);
			//System.out.println(Arrays.toString(distance));
			for(int i: hm.get(loc).neighbours){
				if(!visit[i]){
					//System.out.println(i);
					pq.offer(i);
					visit[i] = true;
					distance[i] = distance[loc]+1;
				}else{
					if(distance[i] > distance[loc]+1){
						pq.offer(i);
						distance[i] = distance[loc]+1;
					}
				}
			}
		}
		//System.out.println(Arrays.toString(distance));
		return distance;
	}

}

class Bfs {

}

class NextList {
	List<Integer> neighbours = new ArrayList<>();
	int val;
}

//高速なScanner
class FastScannerMainD3 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMainD3(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}