摘要: 拓扑排序模板题,判断 当前点出度与入度。 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 5 struct N 6 { 7 int data; 8 int n; 9 struct N *next;10 }*head[510];11 12 void init(int n)13 {14 for(int i = 1;i <= n; i++)15 {16 head[i] = (struct N *)malloc(sizeof(struct N));17 h... 阅读全文
posted @ 2013-04-19 21:08 好小孩 阅读(116) 评论(0) 推荐(0)
摘要: 大体思路就是简单的拓扑排序。写的时候没有看模板,都是自己一点一点改的,应该没有模板效率高。还用了一点优先队列的思想,用了并查集的方法检查是否存在环。 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 5 using namespace std; 6 7 struct N 8 { 9 int data; 10 int n,money; 11 N *next; 12 }*head[10010]; 13 14 void init(int n)//初始化函数 15 { 16 ... 阅读全文
posted @ 2013-04-19 21:05 好小孩 阅读(159) 评论(0) 推荐(0)