HBC15696Professional Manager题解 (每日一词:forest)

惰性的成熟 算法基础篇 33 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
It’s universally acknowledged that there’re innumerable trees in the campus of HUST. Thus a professional tree manager is needed. Your task is to write a program to help manage the trees. Initially, there are n forests and for the i-th forest there is only the i-th tree in it. Given four kinds of operations. 1 u v, merge the forest containing the u-th tree and the forest containing the v-th tree; 2 u, separate the u-th tree from its forest; 3 u, query the size of the forest which contains the u-th tree; 4 u v, query whether the u-th tree and the v-th tree are in the same forest.

It’s universally acknowledged that there’re innumerable trees in the campus of HUST.  Thus a professional tree manager is needed. Your task is to write a program to help manage the trees.  Initially, there are n forests and for the i-th forest there is only the i-th tree in it. Given four kinds of operations. 1 u v, merge the forest containing the u-th tree and the forest containing the v-th tree; 2 u, separate the u-th tree from its forest; 3 u, query the size of the forest which contains the u-th tree; 4 u v, query whether the u-th tree and the v-th tree are in the same forest.

HBC15696Professional Manager题解
(每日一词:forest)-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC15696Professional Manager题解