poj 2367】的更多相关文章

Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2920 Accepted: 1962 Special Judge Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They ga…
http://poj.org/problem?id=2367 题意:给你n个数,从第一个数到第n个数,每一行的数字代表排在这个行数的后面的数字,直到0. 这是一个特别裸的拓扑排序的一个题目,拓扑排序我也是刚刚才接触,想法还是挺简单的.实现起来也不复杂. #include <stdio.h> #include <string.h> ],n; ][]; int topsort() { ;i<=n;i++) ;j<=n;j++) //遍历n次,找到第一个度为0的点,度为0的点…
题目链接:http://poj.org/problem?id=2367 题意: 知道一个数n, 然后n行,编号1到n, 每行输入几个数,该行的编号排在这几个数前面,输出一种符合要求的编号名次排序. 拓扑排序: 先找入度为0的点,再根据这个点删掉与之相连的点之间的弧,入度减一. #include <stdio.h> ][]; ]; int main() { int n; scanf("%d",&n); ;i<=n;i++) { int to; while(sca…
题目连接 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…
题目链接 http://poj.org/problem?id=2367 题意就是给定一系列关系,按这些关系拓扑排序. #include<cstdio> #include<cstring> #include<queue> #include<vector> #include<algorithm> using namespace std; ; int ans; int n; int in[maxn]; //记录入度 int num[maxn]; //记…
今天网易的笔试,妹的,算法题没能A掉,虽然按照思路写了出来,但是尼玛好歹给个测试用例的格式呀,吐槽一下网易的笔试出的太烂了. 就一道算法题,比较石子重量,个人以为解法应该是拓扑排序. 就去POJ找了道拓扑排序的题:POJ2367 直接上代码吧: #include<stdio.h> #include<string> #define clr(x) memset(x,0,sizeof(x)) ][]; ]; ]; using namespace std; int main() { int…
火星人的血缘关系很奇怪,一个人可以有很多父亲,当然一个人也可以有很多孩子.有些时候分不清辈分会产生一些尴尬.所以写个程序来让n个人排序,长辈排在晚辈前面. 输入:N 代表n个人 1~n 接下来n行 第i行表示第i个人的孩纸,无序排列,可能为空.0代表一行输入结束. (大概我的智商真的不合适,否则怎么这么久了连个拓扑排序都写不好,T了三次..) 代码: /******************************************** Problem: 2367 User: Memory:…
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: 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…