雕刻时光

just do it……nothing impossible
随笔 - 547, 文章 - 0, 评论 - 82, 阅读 - 86万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  图的连通性

摘要:有一些由“_"和"#"组成的图形,图形中由"#"拼成了"B"、"M"、"W"三种字母,。用程序识别这些字母,统计三个字母的个数。___###############___________________________________###################_______________________________#####################_____________________________#####_____________#####_____ 阅读全文

posted @ 2012-03-18 19:43 huhuuu 阅读(384) 评论(0) 推荐(0) 编辑

摘要:有向图强连通分量的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 阅读(258) 评论(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 阅读(244) 评论(0) 推荐(1) 编辑

点击右上角即可分享
微信分享提示