POJ2553】的更多相关文章

题意:很难懂!但是大体意思就是求有向图中从一个节点出发到达的点也能反向到达该节点的点.如a能到{b1,b2.....bx}这些点,而这些点也能到a,则a为要求的点.题目是求出所有的这种点. 对图进行缩点,缩点后出度为0的点(强连通分量)所包含的点就是答案.原因,自己思考一下..... #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<st…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 10114   Accepted: 4184 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ve…
题目是问,一个有向图有多少个点v满足∀w∈V:(v→w)⇒(w→v). 把图的强连通分量缩点,那么答案显然就是所有出度为0的点. 用Tarjan找强连通分量: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define MAXN 5555 #define MAXM 5555*5555 struct Edge{ int u,v,next; }edge[MAXM];…
题意:定义了一个图的底(bottom),是指在一个图中能够被所有点到达的点,问途中有哪些点是图的底. 首先是同一个强连通分量中的点都能够互相到达,强连通分量中一个点能到达其他点,也必然代表该强连通分量中的点能到达那个点,所以首先强连通,然后此时如果一个点是有出度的,那么它指向的点必然不能到它,所以其实就是求出度为 0 的强连通分量内的点. #include<stdio.h> #include<string.h> #include<stack> #include<q…
http://poj.org/problem?id=2553 The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8748   Accepted: 3625 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set…
题目链接:http://poj.org/problem?id=2553 [题意] 给n个点m条边构成一幅图,求出所有的sink点并按顺序输出.sink点是指该点能到达的点反过来又能回到该点. [思路] 不难想象sink点一定是在强连通分量中,而且强连通分量缩点后出度为0,就可以说明该强连通分量内所有的点都是sink点. 之前wa了一发是因为写成了out[i],注意是从缩点构成的dag中找出度为0的点,而不是从原来的图中找. [ac代码] #include <cstdio> #include &…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 12070   Accepted: 4971 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ve…
The Bottom of a Graph Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 9779   Accepted: 4063 Description We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called ver…
//求这样的sink点:它能达到的点,那个点必能达到他,即(G)={v∈V|任意w∈V:(v→w)推出(w→v)} //我法:tarjan缩点后,遍历点,如果该点到达的点不在同一个强连通中,该点排除,而且该点所在的 //的强连通分支所有点都排除(开始因为这个跪WA!慎思!) #include<iostream> //143MS, #include<vector> #include<cstdio> #include<cstring> #include<s…
题意:       给你一个有向图,然后问你有多少个满足要求的点,要求是: 这个点能走到的所有点都能走回这个点,找到所有的这样的点,然后排序输出. 思路:       可以直接一遍强连通缩点,所点之后出度为0的强连通点中所包含的点都是满足要求的,比较容易理解,在强连通里,所有点都能走回来,同时只要强连通所点后没有出度,那么就能保证里面的每个点到所有连接自己连接的点后都能走回来,还有就是这个题目我数组开到快 80000000了,还没MLE,这个我就不说什么了. #include<stdio.h>…