随笔分类 -  最短路径

摘要:View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<algorithm>using namespace std;const int maxn = 315;const int maxm = 5015;const int inf = 9999999;int cnt,head[ maxn ];int n,m,k;int dis[ maxn ],vis[ maxn ];struct node{ int u,val,next 阅读全文
posted @ 2013-04-22 10:08 zlyblog 阅读(181) 评论(0) 推荐(0) 编辑
摘要:杭电1690不理解View Code 1 #include<stdio.h> 2 #include<iostream> 3 using namespace std; 4 #define maxint 0x7f7f7f7f7f7f7f7fLL 5 typedef __int64 LL; 6 LL mat[105][105]; 7 LL cor[105]; 8 LL l1,l2,l3,l4,c1,c2,c3,c4; 9 int n;10 LL change(LL x)11 {12 if(x<0) x=-x;13 if(x>0&&x<=l1) 阅读全文
posted @ 2012-07-26 17:29 zlyblog 阅读(192) 评论(0) 推荐(0) 编辑
摘要:杭电2680Problem DescriptionOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s home so that she can take. You may suppos 阅读全文
posted @ 2012-07-26 15:23 zlyblog 阅读(276) 评论(0) 推荐(0) 编辑
摘要:杭电1596其实本题思路还是运用迪杰斯特拉算法,与前面题有所不同的是本题找最大值,这就要注意,在选取过程中,变量的控制;View Code 1 //杭电1596 2 #include<stdio.h> 3 #include<string.h> 4 #define M 999999999 5 #define N 1010 6 int b[N]; 7 double map[N][N],a[N]; 8 int panduan(double x) 9 {10 return x>0?1:0;//实数与零比较11 }12 13 int main()14 {15 int n,m 阅读全文
posted @ 2012-07-26 10:34 zlyblog 阅读(222) 评论(0) 推荐(0) 编辑
摘要:最短路径求解View Code 1 //杭电1874(最短路径) 2 #include<stdio.h> 3 #define Max 10000 4 int n,m,start,end; 5 int a[210],b[210],map[210][210]; 6 void bfs() 7 { 8 int i,j,k,min; 9 for(i=0;i<n;i++)10 a[i]=map[start][i];11 a[start]=0;12 b[start]=1;13 for(i=0;i<n;i++)14 {15 mi... 阅读全文
posted @ 2012-07-25 16:46 zlyblog 阅读(195) 评论(0) 推荐(0) 编辑
摘要:杭电2112View Code 1 //杭电2112 2 #include<stdio.h> 3 #include<string.h> 4 #include<stdlib.h> 5 #define M 99999999 6 #define N 160 7 char s[N][50]; 8 int a[N],b[N],map[N][N]; 9 int n,t,num,k,p,d;10 int MIN(int a,int b)11 {12 return a<b?a:b;13 }14 int look(char a[])15 {16 int i;17 for 阅读全文
posted @ 2012-07-25 16:45 zlyblog 阅读(174) 评论(0) 推荐(0) 编辑

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