图论复习之强连通分量以及缩点—Tarjan算法
by RtPYH
------------------------------------------------------------------------------------------------
【强连通分量以及连通子图】
#define#
在一...
分类:
编程语言 时间:
2014-10-21 01:04:41
阅读次数:
278
Suppose there are N people in ZJU, whose ages are unknown. We have some messages about them. The i-th message shows that the age of person si is
not smaller than the age of person ti. Now we need to...
分类:
其他好文 时间:
2014-10-19 02:43:17
阅读次数:
195
Problem Description
To see a World in a Grain of Sand
And a Heaven in a Wild Flower,
Hold Infinity in the palm of your hand
And Eternity in an hour.
—— William Blake
听说...
分类:
其他好文 时间:
2014-10-19 01:28:31
阅读次数:
326
Problem Description
Kids in kindergarten enjoy playing a game called Hawk-and-Chicken. But there always exists a big problem: every kid in this game want to play the role of Hawk.
So the teacher ...
分类:
其他好文 时间:
2014-10-18 22:26:11
阅读次数:
291
Problem Description
To prove two sets A and B are equivalent, we can first prove A is a subset of B, and then prove B is a subset of A, so finally we got that these two sets are equivalent.
You ar...
分类:
其他好文 时间:
2014-10-18 03:05:05
阅读次数:
290
题目链接
题意:一个有向图,每对一个结点操作,就可以触发连锁反应,使得该结点及它直接或间接指向的点均获得标记,问至少需要操作多少个结点使得所有结点获得标记
思路:有向图的强连通分量,用Tarjan缩点之后找出入度为0的点的个数,即为答案。跟UVA11504一样的题目。
UVA11504
代码:
#include
#include
#include
#...
分类:
其他好文 时间:
2014-10-17 16:57:26
阅读次数:
169
题意:基环树最大独立集
思路:
像这种题就是朴素的树形dp非常容易的,我们用一些技巧转化为变体树。
直接套用仙人掌的动态规划做法:(基环树事实上也属于一种仙人掌)
首先利用tarjan算法,如果遇到自己与儿子之间的边为割边则按照树边处理。
Tarjan后看一下与自己相连的边,如果某个相邻点不是自己的儿子,并且入栈序比自己大,那么说明自己是环上的的最高点,此时我们对环上特别的进行d...
分类:
其他好文 时间:
2014-10-17 11:57:30
阅读次数:
371
题目链接
题意:多米诺骨牌的游戏,给出一些牌,以及哪张牌倒了之后会推倒哪张牌,求最少的推倒牌的张数,使得所有牌都倒下去。
思路:有向图的强连通分量,用Tarjan缩点之后找出入度为0的点的个数,即为答案。
代码:
#include
#include
#include
#include
using namespace std;
const int MAXN...
分类:
其他好文 时间:
2014-10-17 00:24:43
阅读次数:
225
题目链接
题意: 给定一张有向图,找出所有强连通分量,并输出。
思路:有向图的强连通分量用Tarjan算法,然后用map映射,便于输出,注意输出格式。
代码:
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 2000;
const in...
分类:
其他好文 时间:
2014-10-16 19:41:33
阅读次数:
210
http://poj.org/problem?id=2186
Popular Cows
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 23819
Accepted: 9767
Description
Every cow's dream...
分类:
移动开发 时间:
2014-10-14 15:47:28
阅读次数:
267