*[topcoder]TheTree - 阿牧遥 - 博客园
这道题有意思。给了树的根和每层节点的个数,求树的直径。做法是如果该层有两个节点,那么可能是有上有下,直径加二;如果该层只有一个节点,那么从这层开始,往下都只能加一。同时,该直径不一定经过根。
Read full article from *[topcoder]TheTree - 阿牧遥 - 博客园
Manao is working in the Tree Research Center. It may come as a surprise that the trees they research are not the ones you can see in a park. Instead, they are researching special graphs. (See Notes for definitions of terms related to these trees.) Manao's daily job is reconstructing trees, given some partial information about them. Today Manao faced a difficult task. He needed to find the maximum possible diameter of a tree, given the following information:
|