
LCA
coldfresh
那我们开始吧
展开
-
How far away ? HDU - 2586 (LCA)
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this “How far is it if I want to go from house A to house B”? Usually it hard to原创 2017-07-26 19:00:39 · 287 阅读 · 0 评论 -
【HDU - 2586】How far away ? (树链剖分实现的LCA)
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this “How far is it if I want to go from house A to house B”? Usually it hard to...原创 2019-04-22 15:08:40 · 301 阅读 · 0 评论 -
【SPOJ - QTREE2】Query on a tree II(LCA、倍增)
题目链接给无根一棵树,有边权,有两种询问,一种给出两个点,问这两个点的距离是多少,另一个,给给三个点,a,b,k,问从a开始到b的路径的第k个点是的编号是多少。显然lca,关于第二询问,我们还是要求一下,这两个点的lca,因为我们要选择一个点往上倍增的去寻找第k个点,但是,万一x就是lca,x不能往上跳着找,所以,我们要交换一下,从a数第k个,相当于从b数第(路劲总点数-k+1)个,,然而我...原创 2019-03-18 15:08:33 · 231 阅读 · 0 评论 -
【Contest Hunter Round #56】异象石(lca)
第一行有一个整数 N,表示点的个数;接下来 N-1 行每行三个整数 x,y,z,表示点 x 和 y 之间有一条长度为 z 的双向边;第 N+1 行有一个正整数 M;接下来 M 行每行是一个事件,事件是以下三种格式之一:+ x:表示点 x 上出现了异象石;- x:表示点 x 上的异象石被摧毁;?:表示询问使当前所有异象石所在的点连通所需的边集的总长度最小是多少。输出格式对于每个 ? ...原创 2019-03-20 16:37:49 · 364 阅读 · 0 评论 -
【HDU - 5452 】Minimum Cut (树上差分)
Given a simple unweighted graph G (an undirected graph containing no loops nor multiple edges) with n nodes and m edges. Let T be a spanning tree of G. We say that a cut in G respects T if it cuts j...原创 2018-08-30 16:37:36 · 319 阅读 · 0 评论 -
Network POJ - 3417(倍增LCA+树上差分)
Yixght is a manager of the company called SzqNetwork(SN). Now she’s very worried because she has just received a bad news which denotes that DxtNetwork(DN), the SN’s business rival, intents to attack ...原创 2018-03-24 19:38:08 · 304 阅读 · 0 评论 -
Minimum spanning tree for each edge CodeForces - 609E(ST算法+树链剖分(或倍增LCA)+最小生成树)
Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges.For each edge (u, v) find the minimal possible weight of the spanning tree t...原创 2018-03-21 13:49:34 · 379 阅读 · 0 评论 -
How far away ? HDU - 2586(倍增实现的LCA)
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this “How far is it if I want to go from house A to house B”? Usually it hard to...原创 2018-03-23 23:50:42 · 525 阅读 · 0 评论 -
Connections between cities HDU - 2874(LCA)(RMQ)(dfs)(st算法)
After World War X, a lot of cities have been seriously damaged, and we need to rebuild those cities. However, some materials needed can only be produced in certain places. So we need to transport these原创 2017-09-15 16:38:59 · 356 阅读 · 0 评论 -
【ZOJ 4097】Rescue the Princess(边双连通分量+lca)
题目链接题目大意是给出一个无向图,每次询问给出三个点z,x,y,问是否存在x到z的路径和y到z的路的边不重合,如果是yes否则no。**思路:**其实这题我看完就有思路,而且很正确,但是不知道为什么比赛的时候一直T,这个很显然和边双连通分量有关。在这个分量里,任意两点的可达且存在两种不同的路径,那么我们首先要求的是图的桥,那么我们把边双连通分量缩点,用桥来建树,但是题目没说是连通图,所以可能存...原创 2019-04-22 18:37:58 · 240 阅读 · 0 评论