/**
[图论] hdu 3836 Equivalent Sets
求一个图中至少添加几条边成为强连通。
跑一遍tarjan缩点,统计0出度和0入度的点数x,y,则ans = max(x,y)
*/
#include <stdio.h>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;
#define N 20002
vector<int> vec[N];
int stop,cnt,scnt,id[N],pre[N],low[N],s[N],in[N],out[N];
void tarjan(int v,int n)
{
int t,minc = low[v] = pre[v] = cnt++;
vector<int>::iterator pv;
s[stop++] = v;
for(pv = vec[v].begin(); pv != vec[v].end(); ++pv)
{
if(-1 == pre[*pv])
tarjan(*pv,n);
if(low[*pv] < minc)
minc = low[*pv];
}
if(minc < low[v])
{
low[v] = minc;
r
[图论] hdu 3836 Equivalent Sets
最新推荐文章于 2020-05-04 14:15:27 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)