/**
[强连通]poj 2553 The Bottom of a Graph
这个题目的意思还是得认真读原题,不得不吐槽那本图论的书上中文坑爹的翻译。
题目定义了有向图上一个叫做sink的东西,结点u是sink的条件是,图上任意一点w,
如果u能到达w,那么w也能到达u。
思路,强连通缩点后位于叶子上的即使sink
*/
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define N 5001
vector<int> g[N],cg[N],sinks ;
int low[N],pre[N],id[N],stk[N],sp,cnt,scnt,out[N];
int n,m;
void tarjan(int u){
int t,minc = low[u] = pre[u] = cnt ++;
stk[sp++] = u;
for(int i = 0; i < g[u].size(); ++i){
int v = g[u][i];
if(-1 == pre[v])
tarjan(v);
if(minc > low[v])
minc = low[v];
}
if(minc < low[u]){
low[u] &#
[强连通]poj 2553 The Bottom of a Graph
最新推荐文章于 2019-11-08 02:59:08 发布