#abc274c. C - Ameba
C - Ameba
Score : points
问题描述
你观察了变形虫并记录了一些数据。
最初,有一只编号为 的变形虫。
你共记录了 条数据。根据第 条记录,编号为 的变形虫通过分裂自身,产生了两个新的变形虫,并分别编号为 和 。
此时,称变形虫 是变形虫 和 的父代。
对于每个 ,变形虫 距离变形虫 有多少代?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You observed amoebae and kept some records.
Initially, there was one amoeba, numbered .
You made records. According to the -th record, the amoeba numbered disappeared by dividing itself into two new amoebae, which were then numbered and . Here, amoeba is said to be the parent of amoebae and .
For each , how many generations away is amoeba from amoeba ?
Constraints
- The records are consistent. That is:
- .
- are distinct integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the generation distance between amoeba and amoeba .
Sample Input 1
2
1 2
Sample Output 1
0
1
1
2
2
From amoeba , amoebae and were born. From amoeba , amoebae and were born.
- Amoeba is zero generations away from amoeba .
- Amoeba is one generation away from amoeba .
- Amoeba is one generation away from amoeba .
- Amoeba is one generation away from amoeba , and two generations away from amoeba .
- Amoeba is one generation away from amoeba , and two generations away from amoeba .
Sample Input 2
4
1 3 5 2
Sample Output 2
0
1
1
2
2
3
3
2
2
update @ 2024/3/10 11:32:26