Problem I. Tree
时间限制 1000 ms
内存限制 64 MB
Alice and Bob are playing with a magic tree This magic tree has $n$ nodes,with $n - 1$ magic paths connecting them into a connected block. Node $1$ is at the top of the magic tree (layer $0$). Node $i$ is at the $\text{kth}$ layer, where $k$ is the distance from the node $i$ to the node $1$. Alice and Bob give a mana value on each node. If a magic stone falls on node $i$, it will be sent up to the $k$ layer and appear on the $\text{kth}$ ancestor node of the $i$ layer($k$ is the mana value of node $i$). This node will continue to send up it, and so on. If the layer of node $i$ is less than $k$, this stone will be sent out of the magic tree. Alice is curious, she will modify the magic value of a node, and ask Bob: If you drop a magic stone on the node $x$, how many times does it take to transfer it out of the magic tree?
输入数据
输出数据
For each query with $\text{op} = = 1$, output the answer
样例输入
复制
1
4
1 2 3
1 1 1 1
3
1 4
2 3 2
1 4
样例输出
样例说明
For the first query: 4-\>3-\>2-\>1-\>out For the second query:4-\>3-\>1-\>out
$ Mathjax font initiator $