随笔分类 -  最短路

摘要:这一题是一道比较好的最短路的变型题,大致思路是求得本身到本身的最短路,注意这一题路与路是相乘的关系,用floy的算法即可。AC code:View Code 1 #include <iostream> 2 #include <string> 3 #include <map> 4 #define INF 10000 5 using namespace std; 6 7 int n, m; //货币种类与兑换方式 8 9 map<string, int> v; //利用c++提供的模板库来为数据读入带来方便10 11 double dis[100][ 阅读全文
posted @ 2012-04-13 20:17 背着超人飞 阅读(215) 评论(0) 推荐(0)
摘要:题目大意是找出一个人作为源点,使得从这个人开始散播信息到全部人都得到信息所用时间最少,输出这个人的号码跟最少时间。算是一道典型的最短路的题目,用floyd算法即可解决。AC code: 1 #include <iostream> 2 #define MAX 101 3 #define INF 1000000 4 using namespace std; 5 int dist[MAX][MAX]; 6 int map[MAX][MAX]; 7 int n; 8 int contact; 9 void input()10 {11 int i, j;12 int id, time;1.. 阅读全文
posted @ 2012-02-27 23:30 背着超人飞 阅读(162) 评论(0) 推荐(0)