摘要: Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of the tree.Then Szh choose some nodes from the tree 阅读全文
posted @ 2018-03-01 20:14 LBNOQYX 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 树上倍增可以比较容易求得i节点的第k个父亲,我们定义一个二维数组fa[i][j]代表节点i的第2^j个父亲,关于有什么用我们等会再说,现在先学会怎么去求这个fa数组 我们可以通过从根节点开始一遍dfs求得所有fa数组,首先我们发现fa数组有这样一个特性,fa[i][j] = fa[ fa[i][j- 阅读全文
posted @ 2018-03-01 16:46 LBNOQYX 阅读(200) 评论(0) 推荐(0) 编辑