hdu-3671-tarjin/割点方案】的更多相关文章

As two icons of the Great Depression, Bonnie and Clyde represent the ultimate criminal couple. Stories were written, headlines captured, and films were made about the two bank robbers known as Romeo and Juliet in a getaway car. The new generation of…
http://acm.hdu.edu.cn/showproblem.php?pid=3671 给出一幅无向图,询问有多少种移除点对的方案使得剩下的连通分量个数大于1. 和上一题差不多的思路直接做n次tarjin即可. #include<iostream> #include<cstdio> #include<vector> #include<cstring> using namespace std; #define LL long long #define p…
题目链接: http://poj.org/problem?id=2117 题目大意:在一个非连通图中,求一个切除图中任意一个割点方案,使得图中连通分量数最大. 解题思路: 一个大陷阱,m可以等于0,这时候要特判,结果就是n-1. 同时出题者脑子秀逗了,也不给C的范围.我开了两倍点大小RE了,于是怒开了五倍点大小才A了. 本题不是连通图,需要先计算原始图中的连通分量.方法就是dfs染色. 然后dfs求割点. 之后枚举割点,由于是非连通图,所以连通分量数=原始分量数+block-1. -1的原因是,…
Tarjan求强连通分量 先来一波定义 强连通:有向图中A点可以到达B点,B点可以到达A点,则称为强连通 强连通分量:有向图的一个子图中,任意两个点可以相互到达,则称当前子图为图的强连通分量 强连通图: 如果在一个有向图中,每两个点都强连通,我们就叫这个图叫强连通图. (一张十分简洁的图) 如图,图中{1,2}就是一个强连通,也是这个图中的一个强连通分量 求强连通分量的算法有三种: Kosaraju算法,Tarjan算法,Gabow算法(然而我只会用Tarjan求) 这里就稍微介绍一下tarja…
题目: hdu3671 http://acm.hdu.edu.cn/showproblem.php?pid=3671 题意:给一个无向图,要求毁掉两个点,使图变得不连通,图一开始是连通的 因为要毁掉两个点,就不是简单的求割点,再看看数据范围,点数为1000,边数为10000,Tarjan的时间复杂度为O(E),如果用枚举法,先枚举要毁掉的第一个点,再用Tarjan进行处理来找割点会不会超时呢?答案是不会,时间为O(v*E),刚好是千万级别,不超 做法:先枚举要删除的第1个点,在原图中删除它,看看…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1026 题目大意:最短时间内出迷宫.迷宫里要杀怪,每个怪有一定HP,也就是说要耗一定时.输出方案. 解题思路: 要是没有输出方案,就是一个简单粗暴的BFS. 一开始解决输出方案问题时,简单粗暴地在每次状态里加个vector,然后连带vector一起转移. 结果vector的push_back实在太慢,无论怎么优化都是T. 于是参考了ACMan同学的方案,path[X][Y]记录下父亲点. 最后输出的…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4587 题意: 删除两个点,使连通块的数目最大化 题解: 枚举删除第一个点,然后对删除了第一个点的图跑割点更新答案. 代码: #include<algorithm> #include<iostream> #include<cstring> #include<vector> #include<cstdio> using namespace std; ;…
Fantasia Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1654    Accepted Submission(s): 429 Problem Description Professor Zhang has an undirected graph G with n vertices and m edges. Each vert…
Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description When the winter holiday comes, a lot of people will have a trip. Generally, there are a lot of souvenirs to sell, and sometimes…
Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1886    Accepted Submission(s): 699 Problem Description When the winter holiday comes, a lot of people will have a trip. Genera…