POJ 3180 The cow Prom Tarjan基础题】的更多相关文章

题目用google翻译实在看不懂 其实题目意思如下 给一个有向图,求点个数大于1的强联通分量个数 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<stack> #define M 50010 #define N 10010 using namespace std; ,ans,sz[N],belong[N],dfn[N],low[N],…
http://poj.org/problem?id=3180 The Cow Prom Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1428   Accepted: 903 Description The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their finest gowns, complete…
Description The N ( <= N <= ,) cows are so excited: it's prom night! They are dressed in their finest gowns, complete with corsages and new shoes. They know that tonight they will each try to perform the Round Dance. Only cows can perform the Round…
[题目链接] http://poj.org/problem?id=3180 [题目大意] N头牛,M条有向绳子,能组成几个歌舞团?要求顺时针逆时针都能带动舞团内所有牛. [题解] 等价于求点数大于1的SCC数量. [代码] #include <cstdio> #include <algorithm> #include <vector> #include <cstring> using namespace std; const int MAX_V=10000;…
原题 这是一道强连通分量板子题. 我们只用输出点数大于1的强连通分量的个数! #include<cstdio> #include<algorithm> #include<stack> #define N 10010 #define M 50010 using namespace std; int n,m,head[N],dfn[N],low[N],cnt=1,t,sum,bel[N],num[N],out[N],ans; bool instk[N]; stack <…
题目大意: 约翰的N(2≤N≤10000)只奶牛非常兴奋,因为这是舞会之夜!她们穿上礼服和新鞋子,别上鲜花,她们要表演圆舞.           只有奶牛才能表演这种圆舞.圆舞需要一些绳索和一个圆形的水池.奶牛们围在池边站好,顺时针顺序由1到N编号.每只奶牛都面对水池,这样她就能看到其他的每一只奶牛.为了跳这种圆舞,她们找了M(2≤M≤50000)条绳索.若干只奶牛的蹄上握着绳索的一端,绳索沿顺时针方绕过水池,另一端则捆在另一些奶牛身上.这样,一些奶牛就可以牵引另一些奶牛.有的奶牛可能握有很多绳…
题目链接 tarjan参考博客 题意:求在图上可以被所有点到达的点的数量. 首先通过tarjan缩点,将所有内部两两可达的子图缩为一点,新图即为一个有向无环图(即DAG). 在这个DAG上,若存在不止一个所有点均可到达的点,则所有点不满足题目要求.若存在一个,则该点所代表的连通分量的点数即为答案. //DAG(有向无环图)上面至少存在一个出度为0的点,否则必然可以成环. #include<cstdio> #include<cstring> #include<stack>…
Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25945   Accepted: 10612 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 &…
传送门:https://www.luogu.org/problemnew/show/P2863 思路:tarjan模板题,之前会的tarjan,一直想学缩点到底是什么操作,发现就是把同组的放在一个数组里(并查集可能又会有),或者重新建图:不知道为什么百度不到讲缩点的blog. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <s…
#include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<stack> #define M 50010 #define N 10010 using namespace std; ,ans,out[N],belong[N],dfn[N],low[N],indx,tar,miao; bool inst[N]; stack <int> s…