随笔分类 - 图论—拓扑排序
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2819 1 #include 2 #include 3 #include 4 #include 5 #include 6 using nam...
阅读全文
摘要:题目:http://poj.org/problem?id=3687题意:n个重量为1~n的球,给定一些编号间的重量比较关系,现在给每个球编号,在符合条件的前提下使得编号小的球重量小。(先保证1号球最轻,其次2号……)然后,按照重量1~n的输出位置要倒序建图,优先选择编号大的 给编号大的 拓扑排序,注...
阅读全文
摘要:题目:http://poj.org/problem?id=1094题意:给定一个关系,判断三种情况 1、到第几组的时候就可以判断出 什么关系了 2、到第几组的时候可以判断矛盾 3、判断不出来 每次输入,都要 拓扑 判断 1 #include 2 #include 3 #include 4 #inc...
阅读全文
摘要:题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2140&cid=1186 1 #include 2 #include 3 int d[15],map[15][15],vis[15]; 4 int main() 5 { 6 int i...
阅读全文
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=2094//声明:该题不是我写的。 1 #include 2 #include 3 int nu,m,sum; 4 int map[1001][1001]; 5 int degree[1001]; 6...
阅读全文
摘要:1 #include 2 #include 3 int count,n,degree[505],map[505][505],vis[505],res[505]; 4 5 void topo(int x) 6 { 7 res[count] = x; 8 count++; 9 ...
阅读全文