![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论_强连通分量
wang2147483647
这个作者很懒,什么都没留下…
展开
-
poj 3114 Countries in War(强连通缩点+最短路)
题目地址:http://poj.org/problem?id=3114思路:Tarjan缩点+SPFA最短路。#include#include#include#include#include#define debuusing namespace std;const int maxn=500+50;const int maxm=250000+50;const int IN原创 2017-02-07 15:30:45 · 283 阅读 · 0 评论 -
poj 3160 Father Christmas flymouse(强连通缩点+最长路)
题目地址:http://poj.org/problem?id=3160思路:将所有点权值为负数的点设为0,,同一强连通分量中的点可全部选择,因此将其看做一点。在新图中求最长路径即可。最长路径:由于为给定起点,(1)从所有入度为0的点开始,进行DFS;(2)设置一虚拟节点,将其与入度为0的点相连,SPFA求最长路径。SPFA版#include#include#include#inc原创 2017-02-07 20:08:45 · 433 阅读 · 0 评论 -
Poj 3180 The Cow Prom(强连通分量)
题目地址:http://poj.org/problem?id=3180思路:强连通分量裸题,求点数大于1的强连通分量个数。#include#include#include#include#includeusing namespace std;const int maxn=1e4+50;int n,m,all,top,ans;vector g[maxn];int S[max原创 2017-03-14 21:31:32 · 623 阅读 · 0 评论 -
Hdu 6162 Ch’s gift(Tarjan+dp)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6162思路:1.强连通分量中的点必定两两可达,可将其看作一点,将图缩点。2.对于缩点后的图,将其节点的权值设为每个连通分量的节点数。单条路径上的点对于任一点u必定存在一点v使得u可达v。则最多能u达v或v达u的点数为DAG图上权值最大的路径。判断其是否等于总点数即可。3.dp[u]=ma原创 2017-08-25 21:04:12 · 482 阅读 · 0 评论