hdu2767之强联通缩点】的更多相关文章

Proving Equivalences Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2768    Accepted Submission(s): 1038 Problem Description Consider the following exercise, found in a generic linear algebra…
题意:给你一个无向连通图,每次加一条边后,问图中桥的数目. 思路:先将图进行双联通缩点,则缩点后图的边就是桥,然后dfs记录节点深度,给出(u,v)使其节点深度先降到同一等级,然后同时降等级直到汇合到同一个点为止.途中直接进行删边处理且桥的数目减少. 代码: #include<iostream> #include<cstring> #include<cstdio> #include<vector> using namespace std; #define M…
#pragma comment(linker,"/STACK:102400000,102400000")//总是爆栈加上这个就么么哒了 #include<stdio.h> #include<queue> #include<string.h> using namespace std; #define N 210000 #define inf 99999999 struct node { int u,v,w,next; }bian[N*20],biant…
题目地址:pid=2767">HDU 2767 题意:给一张有向图.求最少加几条边使这个图强连通. 思路:先求这张图的强连通分量.假设为1.则输出0(证明该图不须要加边已经是强连通的了).否则缩点. 遍历原图的全部边.假设2个点在不同的强连通分量里面,建边,构成一张新图.统计新图中点的入度和出度,取入度等于0和出度等于0的最大值(由于求强连通缩点后.整张图就变成了一个无回路的有向图.要使之强连通.仅仅须要将入度=0和出度=0的点加边就可以,要保证加边后没有入度和出度为0的点,所以取两者最大…
Intelligence System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1650    Accepted Submission(s): 722 Problem Description After a day, ALPCs finally complete their ultimate intelligence syste…
Traffic Real Time Query System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1929    Accepted Submission(s): 380 Problem Description City C is really a nightmare of all drivers for its traffi…
Description Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that tell you that cow A thinks that cow B is popula…
Proving Equivalences Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3743    Accepted Submission(s): 1374 Problem Description Consider the following exercise, found in a generic linear algebra…
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1093 分析: 首先肯定是先把强联通全部缩成一个点,然后成了一个DAG 下面要知道一点:原图的最大半联通子图实际是上是新DAG图的一个最长链 然后就像拓扑排序一样(不过这是以出度为0的点优先,拓扑排序以入度为0的点优先),设f[i]表示以节点i为起始节点的最长链的长度,s[i]表示以节点i为起始节点的最长链的条数,然后就DP一样搞…… 注意: 1.缩点的时候有可能有重边,要注意判断 2…
[题意]: 有N个房间,M条有向边,问能否毫无顾虑的随机选两个点x, y,使从①x到达y,或者,②从y到达x,一定至少有一条成立.注意是或者,不是且. [思路]: 先考虑,x->y或者y->x是什么意思,如果是且的话就简单了,就直接判断整个图是不是强联通图即可,但是这道题是或,那么可以随手画出一个DAG 比如1->3, 2->3 这样很明显是不行的,1,2没有联通,那么如果是这样1->2->3 就可以了,或者是1->2->3->1,这样也是可以的. 很…