摘要: 图不一定联通,所以用并查集找各个联通块的祖先分别建图,之后就和LCA的步骤差不多了 阅读全文
posted @ 2019-05-04 17:34 starve_to_death 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 在dfs的过程中维护三个数组: deep[i],表示i点在树中的深度; grand[x][i],表示x的第2^i个祖先的节点编号; dis[x][i],表示x到它2^i祖 先的距离。 阅读全文
posted @ 2019-05-04 14:45 starve_to_death 阅读(156) 评论(0) 推荐(0) 编辑