CF BUDDY
← Problems·

1098C · Construct a tree

2400 · binary search, constructive algorithms, dfs and similar

Problem: Misha walked through the snowy forest and he was so fascinated by the trees to decide to draw his own tree!

Misha would like to construct a rooted tree with nn vertices, indexed from 1 to nn, where the root has index 1. Every other vertex has a parent pip_i, and ii is called a child of vertex pip_i. Vertex uu belongs to the subtree of vertex vv iff vv is reachable from uu while iterating over the parents (uu, pup_{u}, ppup_{p_{u}}, ...). Clearly, vv belongs to its own subtree, and the number of vertices in the subtree is called the size of the subtree. Misha is only interested in trees where every vertex belongs to the subtree of vertex 11.

Below there is a tree with 66 vertices. The subtree of vertex 22 contains vertices 22, 33, 44, 55. Hence the size of its subtree is 44.

The branching coefficient of the tree is defined as the maximum number of children in any vertex. For example, for the tree above the branching coefficient equals 22. Your task is to construct a tree with nn vertices such that the sum of the subtree sizes for all vertices equals ss, and the branching coefficient is minimum possible.

Input Format: The only input line contains two integers nn and ss — the number of vertices in the tree and the desired sum of the subtree sizes (2n1052 \le n \le 10^5; 1s10101 \le s \le 10^{10}).

Output Format: If the required tree does not exist, output «No». Otherwise output «Yes» on the first line, and in the next one output integers p2p_2, p3p_3, ..., pnp_n, where pip_i denotes the parent of vertex ii.

Note: Below one can find one of the possible solutions for the first sample case. The sum of subtree sizes equals 3+1+1=53 + 1 + 1 = 5, and the branching coefficient equals 22.

Below one can find one of the possible solutions for the third sample case. The sum of subtree sizes equals 6+3+2+1+2+1=156 + 3 + 2 + 1 + 2 + 1 = 15, and the branching coefficient equals 22.

Sample Cases

Case 1

Input

3 5

Output

Yes
1 1

Case 2

Input

4 42

Output

No

Case 3

Input

6 15

Output

Yes
1 2 3 1 5

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback