
Tarjan&LCA题集
文章平均质量分 78
zxxxxzzz
这个作者很懒,什么都没留下…
展开
-
hdu 2586 How far away ?(LCA离线)
记录下所有的提问,在建tarjan建一颗深搜树的时候询问。奇怪这道题的edge开4W会RE,,于是任性的开了40W妥妥过. #include #include #include #include using namespace std; const int N = 400005; const int M = 205; struct node{ int v, w, nxt; }e[原创 2014-12-17 20:02:43 · 416 阅读 · 0 评论 -
hdu 1827 Summer Holiday(tarjan)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1827 求联通块入度为0的数量及传递到整个图的最小花费。算是tarjan的模板题了 #include #include #include #include #include using namespace std; const int N = 1005; const int inf = 1 <原创 2014-12-12 17:17:35 · 453 阅读 · 0 评论 -
hdu 3836 Equivalent Sets hdu 2767 Proving Equivalences 强连通缩点入门
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3836 http://acm.hdu.edu.cn/showproblem.php?pid=2767 #include #include #include #include using namespace std; int n , cnt , index , sum; const i原创 2014-08-24 09:57:53 · 499 阅读 · 0 评论 -
POJ 1330 Nearest Common Ancestors
传送门:http://poj.org/problem?id=1330 LCA入门 #include #include #include #include using namespace std; const int N = 10005; int n; vector vec[N]; int pre[N]; bool vis[N]; bool root[N]; int u, v;原创 2014-08-16 21:06:18 · 636 阅读 · 0 评论 -
hdu 3861 The King’s Problem
The King’s Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1792 Accepted Submission(s): 652 Problem Description In the Kingd原创 2014-12-12 21:52:15 · 513 阅读 · 0 评论 -
hdu 4547 CD操作 LCA倍增算法
题意:给出一棵树之后求两个点的lca。这里用到在线的倍增算法。 主要核心在注释中。 #include #include #include #include #include #include #include #include #include #include ///cout << fixed << setprecision(13) << (double) x << en原创 2015-07-24 11:24:06 · 741 阅读 · 0 评论