HBC51641FaineantKomorebiLovesGame,数学,思维Inner World题解

三月梨花 数据结构基础 74 0
不断提升技能,才能在职场中立于不败之地!全网最全C++题库,助您成为编程领域的佼佼者。

Gromah and LZR are transfered to a forest, maybe it is the inner world of the great tomb. Initially, there are  n_{} n ​  rooted trees numbered from  1_{} 1 ​ to  n_{} n ​ with size  1_{} 1 ​ in the forest. For each tree, the only node is the root and labeled with 1_{} 1 ​ . After a while, here comes a farmer, and the farmer gives them  m_{} m ​ planting tasks, each can be described by a tuple (u,v,l,r)_{} (u,v,l,r) ​ , which means to add a labeled node  v_{} v ​ for all trees numbered from l_{} l ​ to r_{} r ​ , and their parent nodes are the nodes labeled with  u_{} u ​ for each tree. After finishing the planting tasks one by one, the farmer will give them  q_{} q ​ querying tasks, each can be described by a tuple (x,l,r)_{} (x,l,r) ​ , which means to query the sum of sizes of subtrees whose roots are the nodes labeled with  x_{} x ​ among the trees numbered from  l_{} l ​ to r_{} r ​ . Specially, if there isn't a node labeled with  x_{} x ​ in a tree, the size of subtree  x_{} x ​ is regarded as 0_{} ​ . If they complete all tasks perfectly, the farmer will help them pass the final level. Please help them handle these tasks.

成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC51641FaineantKomorebiLovesGame 数学 思维Inner World题解