CF1137F Matches Are Not a Child's Play
题目描述
我们定义一棵树的删除序列为:每一次将树中编号最小的叶子删掉,将该节点编号加入到当前序列的最末端,最后只剩下一个节点时将该节点的编号加入到结尾。
![](https://cdn.luogu.org/upload/vjudge_pic/CF1137F/bc0d9649c17373120f77a2c7a539e99bc4a36a66.png)
例如对于上图中的树,它的删除序列为:2 4 3 1 5
现在给出一棵$n$个节点的树,有$m$次操作:
`up v`:将$v$号节点的编号变为当前所有节点编号的$\max + 1$
`when v`:查询$v$在当前树的删除序列中是第几号元素
`compare u v`:查询$u$和$v$在当前树的删除序列中谁更靠前
输入格式
无
输出格式
无
说明/提示
In the first example, the process of burning of the tree is illustrated on the following picture:
![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1137F/bc0d9649c17373120f77a2c7a539e99bc4a36a66.png)In particular, the vertices of the tree will burn out in the following order: $ [2, 4, 3, 1, 5] $ .
In the second example, after applying the "up" operation, the order of vertices will change to: $ [2, 4, 3, 5, 1] $ .