HBC236071基因测序Colorful Tree题解

一个忧伤的美男子 算法基础篇 46 0
想要检验自己的编程水平?来试试全网最全C++题库,让您在挑战中不断进步。
Your task is to maintain a colorful tree and process queries. At the beginning, there is only one vertex numbered 111 with color CCC on the tree. Then there are qqq operations of two types comi

Your task is to maintain a colorful tree and process queries. At the beginning, there is only one vertex numbered 111 with color CCC on the tree. Then there are qqq operations of two types coming in order: 000 xxx ccc ddd: Add a new vertex indexed (n+1)(n+1)(n+1) with color ccc to the tree, where nnn is the current number of existing vertices. An edge connecting vertex xxx and (n+1)(n+1)(n+1) with length ddd will also be added to the tree. 111 xxx ccc: Change the color of vertex xxx to ccc. After each operation, you should find a pair of vertices uuu and vvv (1≤u,v≤n1 le u, v le n1≤u,v≤n) withdifferentcolors in the current tree so that the distance between uuu and vvv is as large as possible. The distance between two vertices uuu and vvv is the length of the shortest path from uuu to vvv on the tree.

HBC236071基因测序Colorful Tree题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC236071基因测序Colorful Tree题解