原题链接:https://cn.vjudge.net/article/371 ps:为了偷懒,以下建图都是用vector,悄悄和用链式前向星的对比下,(大部分情况下)发现链式前向星用的时间少了一半。
Network of SchoolsPOJ - 1236 题意:给一个有向图,求最少需要加几个网络到结点,使得这些网络能到达任意一个结点;以及最少需要加入多少个连边,使得图的任意一个点,可达任意其他点。 题解:先缩点,缩点后得到的树求其入度为0、出度为0的结点数in0、out0;答案就是in0和max(in0,out0),特判下只有一个连通分量的情况。
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn=110;
vector ve[maxn];
int n,cn;
int dfn[maxn],low[maxn],cnt;
int in[maxn],out[maxn],color[maxn];
stack s;
bool ins[maxn];
void init()
{
memset(dfn,0,sizeof(dfn));
memset(low,0,sizeof(low));
memset(ins,0,sizeof(ins));
cn=cnt=0;
memset(in,0,sizeof(in));
memset(out,0,sizeof(out));
for(int i=1;i
关注
打赏
热门博文