摘要: 求出强连通分量,缩点。得到新图DAG, 求DAG中max(入度为0的点数,出度为0的点数);渣代码:View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <stack> 5 6 using namespace std; 7 8 const int N = 20010; 9 const int M = 50010; 10 11 struct node { 12 int to; 13 node* next; 14 } *first[M]; 阅读全文
posted @ 2012-02-11 20:51 AC_Von 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 题目描述很吓人。。。题意就是求出强连通分量,然后缩点得到DAG, 求DAG中出度为0的缩点,并输出缩点包含的集合(可能有多个这样的缩点)渣代码:View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <stack> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int N = 5010; 10 const int M = 51000; 11 12 stru 阅读全文
posted @ 2012-02-11 19:55 AC_Von 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 将强连通分量进行缩点,然后找缩点后的图中出度为0的缩点所包含的结点数,就是最后结果。如果出现多个出度为0的缩点,则表示不存在所求的点。渣代码:View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <stack> 5 6 using namespace std; 7 8 const int M = 50010; 9 const int N = 10010;10 11 struct node {12 int to;13 int next; 阅读全文
posted @ 2012-02-11 16:51 AC_Von 阅读(378) 评论(0) 推荐(0) 编辑
摘要: Tarjan 它好贱,wa了10+次。。。 思路:用“它贱”进行强连通缩点。然后统计缩点后的图中入度为0的点的个数in和出度为0的点到个数out。A就是in, B就是max(in, out);渣代码:View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <stack> 5 6 using namespace std; 7 8 const int N = 110; 9 10 struct node {11 int to;12 int n 阅读全文
posted @ 2012-02-11 14:59 AC_Von 阅读(241) 评论(0) 推荐(0) 编辑