#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std; typedef __int64 ll;
#define inf 0x3f3f3f3f
//#define inf 0x7f7f7f7f7f7f7f7fLL
#define min(x,y) (x<y?x:y)
ll l1,l2,l3,l4,c1,c2,c3,c4;
int n,m;
ll x[];
ll dist[][]; void floyd(){
for(int k=;k<=n;k++){
for(int i=;i<=n;i++){
for(int j=;j<=n;j++){
if(dist[i][k]==inf||dist[k][j]==inf){
continue;
}
ll res=dist[i][k]+dist[k][j];
if(res<dist[i][j]){
dist[i][j]=res;
}
}
}
}
} int main(){
int T;
scanf("%d",&T);
for(int t=;t<=T;t++){
scanf("%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d",&l1,&l2,&l3,&l4,&c1,&c2,&c3,&c4);
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
scanf("%I64d",&x[i]);
}
for(int i=;i<=n;i++){
for(int j=i+;j<=n;j++){
ll d=x[i]-x[j];
if(d<){
d*=-;
}
if(<d&&d<=l1){
dist[i][j]=dist[j][i]=c1;
}
else if(l1<d&&d<=l2){
dist[i][j]=dist[j][i]=c2;
}
else if(l2<d&&d<=l3){
dist[i][j]=dist[j][i]=c3;
}
else if(l3<d&&d<=l4){
dist[i][j]=dist[j][i]=c4;
}
else{
dist[i][j]=dist[j][i]=inf;
}
}
}
floyd();
printf("Case %d:\n",t);
for(int i=;i<m;i++){
int a,b;
scanf("%d%d",&a,&b);
if(dist[a][b]==inf){
printf("Station %d and station %d are not attainable.\n",a,b);
}
else{
printf("The minimum cost between station %d and station %d is %I64d.\n",a,b,dist[a][b]);
}
}
}
}

HDU 1690 最短路的更多相关文章

  1. ACM: HDU 2544 最短路-Dijkstra算法

    HDU 2544最短路 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Descrip ...

  2. UESTC 30 &&HDU 2544最短路【Floyd求解裸题】

    最短路 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  3. hdu 5521 最短路

    Meeting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  4. HDU - 2544最短路 (dijkstra算法)

    HDU - 2544最短路 Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt.但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以 ...

  5. hdu 1690 Bus System(Dijkstra最短路)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1690 Bus System Time Limit: 2000/1000 MS (Java/Others ...

  6. HDU2112 HDU Today 最短路+字符串哈希

    HDU Today Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. hdu 2544 最短路

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2544 最短路 Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shi ...

  8. hdu 2544 最短路 Dijkstra

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目分析:比较简单的最短路算法应用.题目告知起点与终点的位置,以及各路口之间路径到达所需的时间, ...

  9. HDU - 2680 最短路 spfa 模板

    题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2680 题目大意,就是一个人可以从多个起点开始出发,看到终点的最短路是多少..只有可以运用和hdu2066 ...

随机推荐

  1. PAT甲级——1072 Gas Station

    A gas station has to be built at such a location that the minimum distance between the station and a ...

  2. 《DSP using MATLAB》Problem 8.21

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. jmeter命令行压测

    简介:使用非GUI模式,即命令行模式运行jmeter测试脚本能够大大缩减系统资源 1.配置jdk及添加环境变量 变量名:JAVA_HOME 变量值: C:\Program Files\Java\jdk ...

  4. css3之2D 转换

    浏览器支持 表格中的数字表示支持该属性的第一个浏览器版本号. 紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号. Chrome 和 Safari 要求 ...

  5. tomcat结构图

  6. Luogu P2101 命运石之门的选择(分治+搜索)

    P2101 命运石之门的选择 题意 题目描述 在某一条不知名世界线的冈伦今天突然接到了一条\(dmail\),上面说世界线将会发生巨大变动,未来的他无论如何都无法扭转这种变动回到原来的世界线.而世界线 ...

  7. Luogu P3558 [POI2013]BAJ-Bytecomputer(线性dp)

    P3558 [POI2013]BAJ-Bytecomputer 题意 给一个只包含\(-1,0,1\)的数列,每次操作可以让a[i]+=a[i-1],求最少操作次数使得序列单调不降.若无解则输出BRA ...

  8. ALS算法实现用户音乐打分预测

    很多人在决定是否看一部电影之前都会去豆瓣看下评分作为参考,看完电影也会给一个自己的分数.每个人对每个商品或者电影或是音乐都有一个心理的分数,这个分数标明用户是否对这个内容满意.作为内容的提供方,如果可 ...

  9. 组件:事件传递$emit

    <!DOCTYPE html> <html lang="zh"> <head> <title></title> < ...

  10. 使用jstl el表达式对form表单的功能进行区分 比如新建和修改共用一个form

    新建一个专栏,修改这个专栏信息 完全可以做在一个jsp的一个form中 但是,需要注意的是,使用mvc的对象属性自动封装的话 如果id为空,将会报错,无法进入controller中的 所以要在页面上判 ...