hdu-4324(拓扑排序&强连通)
摘要:结论题:竞赛图中有环,则必存在三元环。拓扑排序判环,没什么好说的了。附代码:View Code #include <iostream>#include <string.h>#include <stdio.h>using namespace std;#define E 2002char a[E][E];int map[E][E];int count[E];bool Topsort(int n,int edge[][E]){ int i,top=-1; for(i=0;i<n;i++) if(count[i]==0) { count[i...
阅读全文
拓扑排序
摘要:邻接矩阵:View Code #include <iostream>#include <stdio.h>using namespace std;#define E 1001void Topsort(int count[],int n,int edge[][E]){ int i,top=-1; for(i=0;i<n;i++) if(count[i]==0) { count[i]=top; top=i; } for(i=0;i<n;i++) if(top==-1) ...
阅读全文