poj2367 Genealogical tree】的更多相关文章

裸拓扑排序. 拓扑排序 用一个队列实现,先把入度为0的点放入队列.然后考虑不断在图中删除队列中的点,每次删除一个点会产生一些新的入度为0的点.把这些点插入队列. 注意:有向无环图 g[] : g[i]表示从点i连出去的边 L[] :拓扑排序的结构 code: #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn = 100 + 5; vector…
思路: 拓扑排序,这里是用染色的dfs实现的.在有环的情况下可以判断出来,没有环的情况下输出拓扑排序序列. 实现: #include <vector> #include <cstring> #include <iostream> #include <algorithm> #define w 0 #define g 1 #define b 2 using namespace std; ; int G[N][N]; vector<int> res,…
[POJ2367]Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5696   Accepted: 3729   Special Judge Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where the…
Genealogical tree poj-2367 题目大意:给你一个n个点关系网,求任意一个满足这个关系网的序列,使得前者是后者的上级. 注释:1<=n<=100. 想法:刚刚学习toposort,什么是toposort? 就是每一个点的遍历或选取有先决条件,那么我们可以通过队列或者栈将控制当前点的点先遍历,这样弹栈或出队的序列,就是toposort的结果 我们先附上模板 int v[100100];//入度 bool map[110][110]={false};//是否存在控制与被控制…
Genealogical Tree Time limit: 1.0 secondMemory limit: 64 MB Background The system of Martians’ blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian…
题目连接 http://poj.org/problem?id=2367 Genealogical tree Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can…
Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3674   Accepted: 2445   Special Judge Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. T…
Genealogical tree Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 5   Accepted Submission(s) : 3 Special Judge Problem Description The system of Martians' blood relations is confusing enough. Ac…
Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8003   Accepted: 5184   Special Judge Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. T…
Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7285   Accepted: 4704   Special Judge Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. T…