[poj2367]Genealogical tree_拓扑排序】的更多相关文章

Genealogical tree poj-2367 题目大意:给你一个n个点关系网,求任意一个满足这个关系网的序列,使得前者是后者的上级. 注释:1<=n<=100. 想法:刚刚学习toposort,什么是toposort? 就是每一个点的遍历或选取有先决条件,那么我们可以通过队列或者栈将控制当前点的点先遍历,这样弹栈或出队的序列,就是toposort的结果 我们先附上模板 int v[100100];//入度 bool map[110][110]={false};//是否存在控制与被控制…
裸拓扑排序. 拓扑排序 用一个队列实现,先把入度为0的点放入队列.然后考虑不断在图中删除队列中的点,每次删除一个点会产生一些新的入度为0的点.把这些点插入队列. 注意:有向无环图 g[] : g[i]表示从点i连出去的边 L[] :拓扑排序的结构 code: #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn = 100 + 5; vector…
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…
题目:火星人的血缘关系,简单拓扑排序.很久没用邻接表了,这里复习一下. import java.util.Scanner; class edge { int val; edge next; } public class Main { static int n; static int MAXV = 1001; static edge head[] = new edge[MAXV]; static int in[]; static boolean vis[]; public static void…
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…
[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…
火星人的血缘关系很奇怪,一个人可以有很多父亲,当然一个人也可以有很多孩子.有些时候分不清辈分会产生一些尴尬.所以写个程序来让n个人排序,长辈排在晚辈前面. 输入:N 代表n个人 1~n 接下来n行 第i行表示第i个人的孩纸,无序排列,可能为空.0代表一行输入结束. (大概我的智商真的不合适,否则怎么这么久了连个拓扑排序都写不好,T了三次..) 代码: /******************************************** Problem: 2367 User: Memory:…
很裸的拓扑排序~ //#include <bits/stdc++.h> #include<iostream> #include<string.h> #include<cstdio> #include<algorithm> using namespace std; typedef __int64 LL; const int N=1e2+10; int ma[N][N]; int pre[N]; int n; void tuopu() { int k…
http://poj.org/problem?id=2367 队列版 #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <string> #include <queu…