传统题 1000ms 256MiB

Ameba

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

You observed amoebae and kept some records.

Initially, there was one amoeba, numbered 11.

You made NN records. According to the ii-th record, the amoeba numbered AiA_i disappeared by dividing itself into two new amoebae, which were then numbered 2i2i and 2i+12i+1.

Here, amoeba AiA_i is said to be the parent of amoebae 2i2i and 2i+12i+1.

For each k=1,,2N+1k=1,\ldots,2N+1, how many generations away is amoeba kk from amoeba 11?

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • The records are consistent. That is:
    • 1Ai2i11\leq A_i \leq 2i-1.
    • AiA_i are distinct integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

Output

Print 2N+12N+1 lines. The kk-th line should contain the generation distance between amoeba 11 and amoeba kk.

Sample Input 1

2
1 2

Sample Output 1

0
1
1
2
2

From amoeba 11, amoebae 22 and 33 were born. From amoeba 22, amoebae 44 and 55 were born.

  • Amoeba 11 is zero generations away from amoeba 11.
  • Amoeba 22 is one generation away from amoeba 11.
  • Amoeba 33 is one generation away from amoeba 11.
  • Amoeba 44 is one generation away from amoeba 22, and two generations away from amoeba 11.
  • Amoeba 55 is one generation away from amoeba 22, and two generations away from amoeba 11.

Sample Input 2

4
1 3 5 2

Sample Output 2

0
1
1
2
2
3
3
2
2

2024暑期集训第二周小测

未参加
状态
已结束
规则
ACM/ICPC
题目
6
开始于
2024-7-10 19:00
结束于
2024-7-10 21:00
持续时间
2 小时
主持人
参赛人数
46