博客
关于我
【模板】有向图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/

你可能感兴趣的文章
pyhton验证码识别
查看>>
PyInstaller 中的 Kivy Garden - 试图跟踪导入
查看>>
Pyinstaller 和 PyQt5 macOS Mojave 兼容性问题
查看>>
pytorch tensor灰度图和RGB图相互转换的三种方法
查看>>
pyinstaller 打包资源文件
查看>>
PyInstaller 构建的 Windows EXE 因多处理而失败
查看>>
Pyinstaller--Windowed或--noconsole.exe不允许打开chromedriver
查看>>
Pyinstaller依赖项的许可证
查看>>
PyInstaller可执行文件找不到包含的flASK-COMPRESS
查看>>
Pyinstaller和海运
查看>>
PyInstaller图标选项在Mac上不起作用
查看>>
pyinstaller的使用
查看>>
pyinstaller超级加密 (加壳和转c)
查看>>
pyinstaller错误:OSError:找不到Python库:libpython3.4mu.so.1.0、libpython3.4m.so.1.0、libpython3.4.so.1.0
查看>>
Pyinstaller:‘;Fiona‘;没有属性‘;_loading‘;(很可能是由于循环导入)
查看>>
pyinstaller:更改应用程序图标
查看>>
Pylint“未解决的导入“;Visual Studio 代码中的错误
查看>>
pyLoad远程代码执行漏洞复现(CVE-2023-0297)
查看>>
pymongo update_one(),upsert=True,不使用$运算符
查看>>
pymongo 中的快速或批量更新
查看>>