概述
水题直接贴代码
#include <iostream>
#include <string.h>
#include <queue>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxn 1200
#define LL __int64
const LL
INF = 100000000002;
LL sit[maxn];
LL dis[maxn][maxn];
int
main()
{
#ifdef xxz
freopen("in.txt","r",stdin);
#endif // xxz
LL Case,L1,L2,L3,L4,C1,C2,C3,C4,n,m,v,T;
cin>>T;
Case = 1;
while(T--)
{
cin>>L1>>L2>>L3>>L4>>C1>>C2>>C3>>C4;
cin>>n>>m;
for(LL i = 1; i <= n; i++)
{
cin>>sit[i];
dis[i][i] = 0;
for(LL j = 1; j < i; j++ )
{
LL temp = max(sit[i],sit[j]) - min(sit[i],sit[j]);
if(temp > L4)
v = INF;
else if(temp > L3) v = C4;
else if(temp > L2) v= C3;
else if(temp > L1) v = C2;
else if(temp > 0) v = C1;
else v = 0;
dis[i][j] = dis[j][i] = v;
}
}
for(LL k = 1; k <= n; k++)
for(LL i = 1; i <= n; i++)
for(LL j = 1; j<= n; j++)
{
dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
}
printf("Case %d:n",Case++);
for(LL i = 0; i < m; i++)
{
LL a,b;
cin>>a>>b;
if(dis[a][b]== INF ) printf("Station %I64d and station %I64d are not attainable.n",a,b);
else printf("The minimum cost between station %I64d and station %I64d is %I64d.n",a,b,dis[a][b]);
}
}
return 0;
}
最后
以上就是灵巧帆布鞋为你收集整理的HDU1690(Floyd最短路)的全部内容,希望文章能够帮你解决HDU1690(Floyd最短路)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复