HDU 3896 Greatest TC 双连通分量】的更多相关文章

题意 给一个连通的无向图,有两种询问: \(a, b, c, d\),问如果删掉\(c,d\)之间的边,\(a,b\)之间是否还连通 \(a, b, c\),问如果删掉顶点\(c\),\(a,b\)之间是否还连通 分析 首先DFS一遍求出进入节点的时间戳\(pre(u)\),离开节点的时间戳\(post(u)\)以及当前节点的子树中能连接到的最小的DFS序\(low(u)\). 然后预处理一下\(u\)的\(2^i\)级祖先,方便计算\(u\)的任意级祖先. 考虑第一种查询 不妨设\(c\)是\…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5458 Problem Description Given an undirected connected graph G with n nodes and m edges, with possibly repeated edges and/or loops. The stability of connectedness between node u and node v is defined by…
题意: 有一个边带权的无向图,敌人可以任意在图中加一条边,然后你可以选择删除任意一条边使得图不连通,费用为被删除的边的权值. 求敌人在最优的情况下,使图不连通的最小费用. 分析: 首先求出边双连通分量,缩点成树. 敌人如果选则树中\(u,v\)节点之间加一条边,则路径\(u \to v\)中所有的边都会变成环. 我们只能考虑删除其他的权值最小的边使图不连通. 从敌人的角度考虑:如果使树中权值最小的边成环,那么我们的费用会增加.在最小边成环的前提下,如果还能使次小边也成环,我们的费用又会增加,以此…
题意: 给出一个无向连通图,有\(m\)次操作,每次在\(u, v\)之间加一条边,并输出此时图中桥的个数. 分析: 先找出边双连通分量然后缩点得到一棵树,树上的每条边都输原图中的桥,因此此时桥的个数为树的节点个数减一. 然后每次添加一条边,相当于将树上对应节点\(u, v\)之间的边都变为非桥的边. 每次暴力修改每条边的标记即可,还想更快一点的话还可以用树链剖分加速. #include <cstdio> #include <cstring> #include <algori…
Problem Description TC (Tian Chao) is magical place, as you all know...The railways and the rail-stations in TC are fragile and always meet with different kinds of problems. In order to reach the destination safely on time, you are asked to develop a…
http://acm.hdu.edu.cn/showproblem.php?pid=2242 题意: 思路:首先求一下双连通分量,如果只有一个双连通分量,那么无论断哪根管子,图还是连通的. 最后只需要根据双连通分量重新建图,在树上进行dp,分成两部分的最小差值.这个具体看代码就可以了. 需要注意的是,这道题目是存在重边的,在这个点上我WA了好久,那么怎么处理重边呢? 设置一个重边标记,跳过第一次父亲结点的反向边,但是第二次的话就必须处理,此时就是双连通的了. 简单来说,如果图是没有重边的,那么我…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2460 思路:题目的意思是要求在原图中加边后桥的数量,首先我们可以通过Tarjan求边双连通分量,对于边(u,v),如果满足low[v]>dfn[u],则为桥,这样我们就可以知道图中桥的数目了.对于每一次query,可以考虑dfs树,树边肯定是桥,然后连上u,v这条边之后,就会形成一个环,这样环内的边就不是割边了,所以只要找到u,v的LCA,把这个路径上的桥标记为否就可以了. http://paste…
Warm up Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4612 Description N planets are connected by M bidirectional channels that allow instant transportation. It's always possible to travel bet…
Problem Description City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roa…
Warm up Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 90    Accepted Submission(s): 12 Problem Description N planets are connected by M bidirectional channels that allow instant transportatio…