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…
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…
本题分两步: 1 使用Tarjan算法求全部最大子强连通图.而且标志出来 2 然后遍历这些节点看是否有出射的边,没有的顶点所在的子强连通图的全部点,都是解集. Tarjan算法就是模板算法了. 这里使用一个数组和一个标识号,就能够记录这个顶点是属于哪个子强连通图的了. 然后使用DFS递归搜索全部点及其边,假设有边的还有一个顶点不属于本子强连通图.那么就说明有出射的边. 有难度的题目: #include <stdio.h> #include <stdlib.h> #include &…
题意: 求出度为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…
题意:给出一个有向图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…
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…
题目地址: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…
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…
题目地址:POJ 2553 题目意思不好理解.题意是:G图中从v可达的全部点w,也都能够达到v,这种v称为sink.然后升序输出全部的sink. 对于一个强连通分量来说,全部的点都符合这一条件,可是假设这个分量还连接其它分量的话,则肯定都不是sink.所以仅仅须要找出度为0的强连通分量就可以. 代码例如以下: #include <iostream> #include <string.h> #include <math.h> #include <queue>…
/** problem: http://poj.org/problem?id=2553 将所有出度为0环中的点排序输出即可. **/ #include<stdio.h> #include<stack> #include<vector> #include<algorithm> using namespace std; class Graphics{ ; const static int MAXM = MAXN * MAXN; private: struct E…