UVA 1357 Cells
摘要:
考虑一颗普通的树,DFS一遍后得到每个点的DFS前序历遍顺序值dfsid[] ,和以改点为根的子树的总结点数num[]。(比如第一组样例dfsid[]={0,1,6,8,2,3,7,9,4,5} num[]={10,5,2,2,1,3,1,1,1,1});那么要判断a是否为b的祖先,只要满足dfsid[a]#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;t 阅读全文
posted @ 2014-03-23 23:12 BMan、 阅读(271) 评论(0) 推荐(0) 编辑