雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年7月29日

摘要: 有向图强连通分量的Tarjan算法有个比较好的讲解http://www.byvoid.com/blog/scc-tarjan/zh-hans/学习一下,贴个比较好的模板View Code #include <iostream>#include <stack>using namespace std; const int MAXN = 10000 + 10; // 点的最大数量const int MAXM = 50000 + 10; // 边的最大数量 // 假设对边u-->vstruct EDGE{ int v; // 从u点出发能到达的点v int next; / 阅读全文

posted @ 2011-07-29 16:07 huhuuu 阅读(256) 评论(0) 推荐(0) 编辑

摘要: 开始用floyd可以,不过时间太慢了(N*N*N)后来枚举牛做DFS连通性检验,O(N*M)View Code #include<stdio.h>#include<string.h>int net[1009][1009];bool visit[1009];int cow[109];int c[1009];void dfs(int x){ c[x]++; visit[x]=1; for(int i=1;i<=net[x][0];i++) { if(!visit[net[x][i]]) dfs(net[x][i]); }}int main(){ int k,n,m; 阅读全文

posted @ 2011-07-29 10:03 huhuuu 阅读(243) 评论(0) 推荐(1) 编辑