![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LCA
淡蓝色的狼
这个作者很懒,什么都没留下…
展开
-
tarjan 离线 lca hdu2586
lca的离线操作:这篇博客写的很好 https://www.cnblogs.com/JVxie/p/4854719.html。。我实现的代码#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn=80010; struct node {原创 2017-11-08 21:27:00 · 209 阅读 · 0 评论 -
lca 离线tarjan模板
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn=10101; const int qmaxn=501010; int F[maxn]; int find(int x) { if(F[x]==-1)return x;原创 2017-10-14 20:37:10 · 315 阅读 · 0 评论 -
lca 倍增模板 求u,v的最近公共祖先
#include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> using namespace std; const int maxn=10010; const int DEG=20; struct edge { i...原创 2018-04-06 17:37:45 · 160 阅读 · 0 评论 -
lca+倍增+最大生成树
NOIP2013货车运输 题目描述 Description A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有 q 辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 输入描述 Input Description 第一行有两个用一个空格隔开的整数 n,m,表示 A 国有 n 座城市和 m 条道...原创 2018-04-06 21:23:42 · 298 阅读 · 0 评论 -
树上同一种颜色的点之间的最长距离 牛客网 漂亮的公园
链接:https://www.nowcoder.com/acm/contest/161/D 来源:牛客网 题目描述 小N所在城市有n个漂亮的公园。有恰好n-1条双向道路连接这n个公园,保证公园间相互可以通过道路到达。每个公园i都有一个专属的属性c[i],表示这个公园的特色。 现在小N有q个疑问。每次他会有两个特定的特色x和y(这两个数可能相同)。他想知道,假如他随便选取一个特色为x的公园...原创 2018-09-02 16:01:20 · 482 阅读 · 0 评论 -
ST求LCA的模板
预处理的时间复杂度是 O(nlog2n) 查询时间是 O(1) #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 10010; int rmq[2 * MAXN]; // rmq数组,就是欧拉序列对应的...原创 2018-09-02 17:08:06 · 200 阅读 · 0 评论 -
Query on a tree II SPOJ - QTREE2
You are given a tree (an undirected acyclic connected graph) with N nodes, and edges numbered 1, 2, 3...N-1. Each edge has an integer value assigned to it, representing its length. We will ask you to...原创 2018-09-06 21:22:02 · 89 阅读 · 0 评论 -
Minimum Cut HDU - 5452
题意: 给出一个图G和它的一个生成树T。 现在要求删除生成树上的一条边和若干条其他边,使得图不连通。 求能删除的最小边数。 #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> using namespac...原创 2018-09-06 21:53:08 · 121 阅读 · 0 评论