书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

2011年11月26日

更加深入的了解Floyd

摘要: 下面来看一道简单的但是有点意思的最短路径的问题。本次用的解法是Floyd.题目:http://acm.swust.edu.cn/oj/problem/0819/在使用Floyd的时候有三点需要注意:一:map[][]数组的初始化 这个是十分的重要的,不然无法Floyd。具体点就是,map[i][i]=0; map[i][j]=INF;二、输入时候的选择性 只有做到这一步,才能保证是最短的,不然不行。具体点就是,if(map[u][v] > w) map[u][v] = map[v][u] = w; 这个主要用在题目中没有说明是否会多次输入同一条边的时候。三、只有一个结点的情况 毫无... 阅读全文

posted @ 2011-11-26 10:46 More study needed. 阅读(248) 评论(0) 推荐(0) 编辑

更加深入的了解SPFA

摘要: SPFA算法是求单源路径的经典算法,就是一点到其它所有点的最短路径。这个类似于Flyod但是效率要高很多。下面给出具体的演示。Minya Konka decided to go to Fuzhou to participate in the ACM regional contest at their own expense.Through the efforts, they got a small amount of financial support from their school, but the school could pay only one of those costs bet 阅读全文

posted @ 2011-11-26 10:38 More study needed. 阅读(364) 评论(0) 推荐(0) 编辑

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!