摘要: SPFA题意:给定一张图,从1到n。求1到n的最短路,但是可能存在某条路被阻断了,即为inf了。这条路必定是存在最短路中。所以枚举最短路中的路径。。。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<queue> 5 #include<algorithm> 6 using namespace std; 7 const int maxn = 1005; 8 const int maxm = 1005*500; 9 con 阅读全文
posted @ 2013-02-21 23:26 xxx0624 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 题意:s到e,最短时间且至少经过k条边dis[ i ][ j ]:表示s到i至少经过了j条边的最少时间!二维spfaView Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<queue> 4 #include<algorithm> 5 #include<stdlib.h> 6 using namespace std; 7 const int maxn = 5005; 8 const int maxm = 100005; 9 const int inf = 9999999 阅读全文
posted @ 2013-02-21 22:03 xxx0624 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 最短路floydView Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn =11; 4 int sea[ maxn ]; 5 int mat[ maxn ][ maxn ]; 6 const int inf=999999; 7 8 void init(){ 9 memset( sea,0,sizeof(sea));10 for( int i=0;i<maxn;i++ )11 for( int j=0;j<maxn;j++ )12 mat[ i ][ j ]=... 阅读全文
posted @ 2013-02-21 16:11 xxx0624 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一些单词,前一个的尾和后一个的头相同时,才表示他们相连求最短路View Code 1 #include<stdio.h> 2 #include<string> 3 #include<stdlib.h> 4 #include<queue> 5 #include<map> 6 #include<algorithm> 7 using namespace std; 8 const int maxn = 1015; 9 const int inf = INT_MAX; 10 //map<string,int>m 阅读全文
posted @ 2013-02-21 16:09 xxx0624 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 题意:从一点到另外一点的最短距离因为点的个数较小 用floydView Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 const int maxn = 81; 8 struct node{ 9 int mat[ maxn ][ maxn ]; 10 }a[ maxn ]; 11 struct node2{ 12 int 阅读全文
posted @ 2013-02-21 11:46 xxx0624 阅读(336) 评论(0) 推荐(0) 编辑