WA了好多次... 这题要用long long 而且INF要设大一点

Sample Input
2 //T
1 2 3 4 1 3 5 7 //L1-L4 C1-C4 距离和花费
4 2 //结点数 询问次数
1 //结点的横坐标
2
3
4
1 4 //起点 终点
4 1
1 2 3 4 1 3 5 7
4 1
1
2
3
10
1 4

Sample Output
Case 1:
The minimum cost between station 1 and station 4 is 3.
The minimum cost between station 4 and station 1 is 3.
Case 2:
Station 1 and station 4 are not attainable.

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>
# include <queue>
# define LL long long
using namespace std ; const LL INF=0x7f7f7f7f7f7f7f7fLL;
const int MAXN=; LL L[] ;
LL C[] ;
LL x[MAXN] ; LL dis[MAXN][MAXN];
int n ; void floyed()//节点从1~n编号
{
int i,j,k;
for(k=;k<=n;k++)
for(i=;i<=n;i++)
for(j=;j<=n;j++)
if(dis[i][k]+dis[k][j] < dis[i][j] && dis[i][k] != INF && dis[k][j] != INF)
dis[i][j]=dis[i][k]+dis[k][j]; } LL Cost(LL d)
{
if (d < )
d *= - ;
if (d > && d<= L[])
return C[] ;
if (d > L[] && d<= L[])
return C[] ;
if (d > L[] && d<= L[])
return C[] ;
if (d > L[] && d<= L[])
return C[] ;
return INF ;
} int main ()
{
// freopen("in.txt","r",stdin) ;
int cnt ;
int T ;
cin>>T ;
int Case = ;
while (T--)
{
Case++ ;
cout<<"Case "<<Case<<":"<<endl ;
int i , j ;
LL w ;
for (i = ; i <= ; i++)
cin>>L[i];
for (i = ; i <= ; i++)
cin>>C[i]; cin>>n>>cnt ;
for (i = ; i <= n ; i++)
cin>>x[i];
for (i = ; i <= n ; i++)
for (j = ; j <= n ; j++)
{
if(i==j)dis[i][j]=;
else dis[i][j]=INF;
}
for (i = ; i <= n ; i++)
for (j = i+ ; j <= n ; j++)
{
LL d = x[i] - x[j] ;
w = Cost(d) ;
dis[i][j] = w ;
dis[j][i] = w ;
}
floyed() ;
int u , v ;
while(cnt--)
{
cin>>u>>v ;
if (dis[u][v] != INF)
cout<<"The minimum cost between station "<<u<<" and station "<<v<<" is "<<dis[u][v]<<"."<<endl ;
else
cout<<"Station "<<u<<" and station "<<v<<" are not attainable."<<endl ;
}
} return ;
}

hdu 1690 构图后Floyd 数据很大的更多相关文章

  1. MySQL数据很大的时候

    众所周知,mysql在数据量很大的时候查询的效率是很低的,因为假如你需要 OFFSET 100000 LIMIT 5 这样的数据,数据库就需要跳过前100000条数据,才能返回给你你需要的5条数据.由 ...

  2. hdu 3295 模拟过程。数据很水

    An interesting mobile game Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Ja ...

  3. 关于Sending build context to Docker daemon 数据很大的问题

    以往进行docker build的时候都是在新建的文件夹下面进行,这次为了图方便,就直接放在开发根目录下进行build,这样子问题就来了.于是就有了下面的文件大小发送量: Sending build ...

  4. 黄聪:Mysql数据库还原备份提示MySQL server has gone away 的解决方法(备份文件数据过大)

    使用mysql做数据库还原的时候,由于有些数据很大,会出现这样的错误:The MySQL Server returned this Error:MySQL Error Nr. MySQL server ...

  5. 后Hadoop时代的大数据架构(转)

    原文:http://zhuanlan.zhihu.com/donglaoshi/19962491 作者: 董飞       提到大数据分析平台,不得不说Hadoop系统,Hadoop到现在也超过10年 ...

  6. 后Hadoop时代的大数据技术思考:数据即服务

    1. Hadoop 的神话正在破灭 IBM leads BigInsights for Hadoop out behind barn. Shots heard IBM has announced th ...

  7. 后Hadoop时代的大数据架构

    提到大数据分析平台,不得不说Hadoop系统,Hadoop到现在也超过10年的历史了,很多东西发生了变化,版本也从0.x进化到目前的2.6版本.我把2012年后定义成后Hadoop平台时代,这不是说不 ...

  8. 斯坦福大学公开课机器学习:machine learning system design | data for machine learning(数据量很大时,学习算法表现比较好的原理)

    下图为四种不同算法应用在不同大小数据量时的表现,可以看出,随着数据量的增大,算法的表现趋于接近.即不管多么糟糕的算法,数据量非常大的时候,算法表现也可以很好. 数据量很大时,学习算法表现比较好的原理: ...

  9. 解决mysql导入数据量很大导致失败及查找my.ini 位置(my.ini)在哪

    数据库数据量很大的数据库导入到本地时,会等很久,然而等很久之后还是显示失败: 这是就要看看自己本地的没mysql是否设置了超时等待,如果报相关time_out这些,可以把mysql.ini尾部添加ma ...

随机推荐

  1. luogu2678 [NOIp2015]跳石头 (二分答案+贪心)

    先二分出一个x,我们要算使最近的跳跃距离>=x的最少移除数量是否<=M就可以了 然后就别dp了...贪心就完事了...我肯定能不移就不移比较好... #include<bits/st ...

  2. Android Service总结05 之IntentService

    Android Service总结05 之IntentService   版本 版本说明 发布时间 发布人 V1.0 添加了IntentService的介绍和示例 2013-03-17 Skywang ...

  3. 解题:NOI 2010 航空管制

    题面 常见的套路与不常见的套路 第一问是常见的套路,建反边用优先队列跑拓扑排序 第二问是不常见的套路,如何判断一个点最早什么时候起飞?先不加它来拓扑排序,直到拓扑排序不能进行下去了,这个时刻就是它必须 ...

  4. Luogu 2469 [SDOI2010]星际竞速 / HYSBZ 1927 [Sdoi2010]星际竞速 (网络流,最小费用流)

    Luogu 2469 [SDOI2010]星际竞速 / HYSBZ 1927 [Sdoi2010]星际竞速 (网络流,最小费用流) Description 10年一度的银河系赛车大赛又要开始了.作为全 ...

  5. SP422 TRANSP2 - Transposing is Even More Fun——置换群+反演

    挺神仙的置换题 SP422 TRANSP2 - Transposing is Even More Fun 这个博客除了开始举例子别的都是对的: https://blog.csdn.net/Braket ...

  6. springboot配置文件的配置

    转:https://www.cnblogs.com/zheting/p/6707036.html Spring Boot使用了一个全局的配置文件application.properties,放在src ...

  7. IAR ------ 基本使用

    1.编译结果: 6 887 bytes of readonly code memory 621 bytes of readonly data memory 331 bytes of readwrite ...

  8. Spark记录-Scala类与对象小例子

    //基类-Person class Person(val na: String, val ag: Int) { //属性 var name: String = na var age: Int = ag ...

  9. bzoj千题计划186:bzoj1048: [HAOI2007]分割矩阵

    http://www.lydsy.com/JudgeOnline/problem.php?id=1048 #include<cmath> #include<cstdio> #i ...

  10. git 学习小记

    话说 git 出了已经很久了,可是我一直没用过.其实也不是没用过,只不过在 github 上下载东西那根本就不是在用 git,只是单纯的HTTP下载而已.我们公司用的是 svn,所以我只会一点点svn ...