随笔分类 -  lca

poj 1330
摘要:模板题。LCA(u){Make-Set(u)ancestor[Find-Set(u)]=u对于u的每一个孩子v{LCA(v)Union(u)ancestor[Find-Set(u)]=u}checked[u]=true对于每个(u,v)属于P{ifchecked[v]=truethen{回答u和v的最近公共祖先为ancestor[Find-Set(v)]}}} 代码:#include<iostream>#include<fstream>using namespace std;struct e{ int data; e *next;}edge[10001];int f[1 阅读全文

posted @ 2011-03-19 11:22 宇宙吾心 阅读(305) 评论(0) 推荐(0)

导航