博客
关于我
【模板】有向图tarjan
阅读量:171 次
发布时间:2019-02-28

本文共 714 字,大约阅读时间需要 2 分钟。

#include 
using namespace std;const int N = 10005, M = 50005;vector
son[N];int dfn[N], low[N], num, s[N], out[N], top, cnt;int scc[N];int sz[N], n, m;void tarjan(int u) { low[u] = dfn[u] = ++num; s[++top] = u; for (int i = 0; i < son[u].size(); ++i) { if (dfn[son[u][i]] == 0) { tarjan(son[u][i]); low[u] = min(low[u], low[son[u][i]]); } else if (dfn[son[u][i]] < dfn[u]) { low[u] = min(low[u], dfn[son[u][i]]); } } if (low[u] == dfn[u]) { ++cnt; scc[cnt] = top; sz[cnt] = top - s[0] + 1; for (int v = s[top]; top-- < s[0]; v = s[--top]) { out[v] = cnt; sz[cnt]--; } }}

转载地址:http://iawn.baihongyu.com/

你可能感兴趣的文章
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
查看>>
org.tinygroup.serviceprocessor-服务处理器
查看>>
org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
查看>>
org/hibernate/validator/internal/engine
查看>>
SQL-36 创建一个actor_name表,将actor表中的所有first_name以及last_name导入改表。
查看>>
ORM sqlachemy学习
查看>>
Ormlite数据库
查看>>
orm总结
查看>>
os.path.join、dirname、splitext、split、makedirs、getcwd、listdir、sep等的用法
查看>>
os.system 在 Python 中不起作用
查看>>
OSCACHE介绍
查看>>
SQL--合计函数(Aggregate functions):avg,count,first,last,max,min,sum
查看>>
OSChina 周五乱弹 ——吹牛扯淡的耽误你们学习进步了
查看>>