题意: 求出度为0的强连通分量. 思路: 缩点 具体有两种实现: 1.遍历所有边, 边的两端点不在同一强连通分量的话, 将出发点所在强连通分量出度+1. #include <cstdio> #include <cstring> #include <stack> #include <algorithm> using namespace std; //0.03s 4856K const int MAXN = 5005; struct Pool { int pre…
POJ 2553 The Bottom of a Graph 题目链接 题意:给定一个有向图,求出度为0的强连通分量 思路:缩点搞就可以 代码: #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <stack> using namespace std; const int N = 5005; int n, m; vector&l…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 9641   Accepted: 4008 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ver…
题意: 求出图中所有汇点 定义:点v是汇点须满足 --- 对图中任意点u,若v可以到达u则必有u到v的路径:若v不可以到达u,则u到v的路径可有可无. 模板:http://www.cnblogs.com/Jadon97/p/8328750.html 分析: 很显然, 图中强连通分量中所有的点属性都是一样的, 要么都是汇点, 要么都不是. 如果有一个强连通分量A的边连向强连通分量B, 那么A一定不是汇点, 因为B不会有边连向A(如果有的话A.B就是同一个强连通分量了). 求出所有强连通分量, 然后…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 11981   Accepted: 4931 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ve…
Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called vertices (or nodes). Let E be a subset of the Cartesian product V×V, its elements being called edges. Then G…
本题分两步: 1 使用Tarjan算法求全部最大子强连通图.而且标志出来 2 然后遍历这些节点看是否有出射的边,没有的顶点所在的子强连通图的全部点,都是解集. Tarjan算法就是模板算法了. 这里使用一个数组和一个标识号,就能够记录这个顶点是属于哪个子强连通图的了. 然后使用DFS递归搜索全部点及其边,假设有边的还有一个顶点不属于本子强连通图.那么就说明有出射的边. 有难度的题目: #include <stdio.h> #include <stdlib.h> #include &…
题意:给出一个有向图G,寻找所有的sink点.“sink”的定义为:{v∈V|∀w∈V:(v→w)⇒(w→v)},对于一个点v,所有能到达的所有节点w,都能够回到v,这样的点v称为sink. 分析:由(v→w),(w→v)可知,节点v,w构成强连通,很自然的想到要缩点.缩点之后,DAG上的每一条边,都是单向的(v->w),无回路(w->v). 错误:对于v可达的点w,不仅是直接连边——从一个强连通子集A到另一个强连通子集B,意味着,子集A中的点都不可能是sink点. #include<c…
题目地址:http://poj.org/problem?id=2553 The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 7881   Accepted: 3263 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finit…
图论之强连通复习开始- - 题目大意:给你一个有向图,要你求出这样的点集:从这个点出发能到达的点,一定能回到这个点 思路:强连通分量里的显然都可以互相到达 那就一起考虑,缩点后如果一个点有出边,一定不在点集内,因为缩点后是DAG,无环,因此一定不能回到原来的点,所以找到出度为0的点即可 #include<cstdio> #include<string.h> #include<math.h> #include<algorithm> #include<io…