2012年8月26日
摘要: 我用的是Floyd算法求所有定点的最短边,这道题需要判重,由于我对于图论没啥经验,WA了N次。似乎判断d[i][j] + d[k][j]是否溢出的判断条件有小错误额。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintSIZE=1010;constintINF=0x3fffffff;intd[SIZE][SIZE];intn,m;voidFloyd(){inti,j,k;for(k=0;k<n;k++)for(i=0;i<n;i++ 阅读全文
posted @ 2012-08-26 21:14 有间博客 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 先试了试Floyd算法,结果没弄出来。然后试了试单源Dijsktra最短路径,两层循环找出最小的结果,建图的过程中遇到了小麻烦,有时间的话再写一写Floyd算法。CODE:#include<cstdio>#include<cstdlib>#include<string>usingnamespacestd;constintSIZE=1010;constintINF=0x3fffffff;intw[SIZE][SIZE];intv[SIZE],d[SIZE];intT,S,D,tot;intlink[SIZE],want[SIZE];intmax(intx,in 阅读全文
posted @ 2012-08-26 19:45 有间博客 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 图论入门题。第一次写的时候用的是比较麻烦的模板,第二次写的时候模板精简多啦。还得要多多努力~较麻烦的模板,CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintINF=0x0fffffff;constintSIZE=110;intgraph[SIZE][SIZE];intvis[SIZE],dis[SIZE];intn,m;voidDijkstra(intsrc){inti,j;intmin,v;for(i=1;i<=n;i++)dis[i 阅读全文
posted @ 2012-08-26 10:29 有间博客 阅读(162) 评论(0) 推荐(0) 编辑
摘要: HDU最短路题目:1.题号:2544难度:1题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2544分析小结:入门级别,甚至floyd都可以过。2.题号:2066难度:2题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2066分析小结:也是入门级别,求起点集合到终点集合的最短路。3.题号:2112难度:3题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2112分析小结:如果会用map容易,那么这题就是一道十足的水题,我用dijkstra O(n^2)的算法过 阅读全文
posted @ 2012-08-26 09:01 有间博客 阅读(3595) 评论(1) 推荐(0) 编辑