标签:des style blog io ar color os sp for
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 34172 Accepted Submission(s): 14834
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; #define inf 0x3f3f3f3f #define maxn 105 int mapn[maxn][maxn]; int n; void flyod() { for(int k=1;k<=n;k++) { for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { mapn[i][j]=min(mapn[i][j],mapn[i][k]+mapn[k][j]); } } } return ; } int main() { int m,n; while(scanf("%d%d",&n,&m)!=EOF) { if(m==0&&n==0) break; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(i==j) mapn[i][j]=0; mapn[i][j]=inf; } } for(int i=1;i<=m;i++) { int a,b,c; scanf("%d%d%d",&a,&b,&c); mapn[a][b]=c; mapn[b][a]=c; } flyod(); printf("%d\n",mapn[1][n]); } return 0; }
标签:des style blog io ar color os sp for
原文地址:http://www.cnblogs.com/qscqesze/p/4156540.html