Bus System(Flody)
http://acm.hdu.edu.cn/showproblem.php?pid=1690
坑爹的题,必须用__int64 %I64d(以前没用过)
因为这题的数据特别大,所以用-1
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
__int64 map[][];
__int64 L[],C[];
__int64 a[];
int n,m;
void Floy()
{
for(int k=;k<=n;k++)
{
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(map[i][k]==-||map[k][j]==-)//
continue;
if(map[i][j]==-||map[i][k]+map[k][j]<map[i][j])//执行这步,说明map[i][k],map[k][j]都存在
map[i][j]=map[i][k]+map[k][j];
}
}
}
} int main()
{
int T;
int K=;
scanf("%d",&T);
while(T--)
{
K++;
for(int i=;i<=;i++)
scanf("%I64d",&L[i]);
for(int i=;i<=;i++)
scanf("%I64d",&C[i]);
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%I64d",&a[i]);
}
__int64 t;
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{ t=abs(a[j]-a[i]);//这里自己出错了,输入时坐标是不会按顺序输入的 if(t==)
{
map[i][j]=;
map[j][i]=;
}
else if(t>&&t<=L[])
{
map[i][j]=C[];
map[j][i]=C[]; }
else if(t>L[]&&t<=L[])
{
map[i][j]=C[];
map[j][i]=C[]; }
else if(t>L[]&&t<=L[])
{ map[i][j]=C[];
map[j][i]=C[]; }
else if(t>L[]&&t<=L[])
{ map[i][j]=C[];
map[j][i]=C[]; }
else
{
map[i][j]=-;
map[j][i]=-;
} }
}
Floy();
printf("Case %d:\n",K);
int yy,uu;
for(int i=;i<m;i++)
{
scanf("%d%d",&yy,&uu);
if(map[yy][uu]==-)
printf("Station %d and station %d are not attainable.\n",yy,uu);
else
{
printf("The minimum cost between station %d and station %d is %I64d.\n",yy,uu,map[yy][uu]); }
} }
return ;
}
Bus System(Flody)的更多相关文章
- HDU ACM 1690 Bus System (SPFA)
Bus System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu1690 Bus System(最短路 Dijkstra)
Problem Description Because of the huge population of China, public transportation is very important ...
- hdu 1690 Bus System (有点恶心)
Problem Description Because of the huge population of China, public transportation is very important ...
- 关于system(”pause“);的作用和意义
注意:不要再return 的语句之后加,那样就执行不到了. system() 是调用系统命令:pause 暂停命令: 如果加有 system(”pause“): 这样在运行到此处时,会显示“Pres ...
- hdu1690 Bus System (dijkstra)
Problem Description Because of the huge population of China, public transportation is very important ...
- 关于system()的一些用法
C语库函数 函数名: system 功 能: 发出一个DOS命令 用 法: int system(char *command); 它包含头文件<stdlib.h> system ...
- system()函数
windows下system () 函数详解 windows操作系统下system () 函数详解(主要是在C语言中的应用) 函数名: system 功 能: 发出一个DOS命令 用 法: i ...
- hdu 1690 Bus System (最短路径)
Bus System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu 1690 Bus System(Dijkstra最短路)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1690 Bus System Time Limit: 2000/1000 MS (Java/Others ...
随机推荐
- 基于thinkphp和ajax的省市区三级联动
练习,就当练习. 省市区三级联动,样式如下图所示: 1,导入两个js文件并且导入数据库文件. 两个js文件分别是jquery-2.1.4.min.js和jquery-1.js,数据库文件,见附件. 2 ...
- Android设计和开发系列第二篇:Action Bar(Develop—API Guides)
Action Bar IN THIS DOCUMENT Adding the Action Bar Removing the action bar Using a logo instead of an ...
- 二、K3 Cloud 开发插件《K3 Cloud 常用数据表整理》
一.数据库查询常用表 --查询数据表select * from ( ),t1.FKERNELXML.query('//TableName')) as 'Item',t1.FKERNELXML,t2.F ...
- sencha touch Container 监听超链接插件
有时候内容直接从后台获取,有可能包含超链接,打包成应用之后,点击会造成不好的后果,这样做能够用外部浏览器打开.需要Cordova支持 监听插件代码: /* *监听a标签,用外部浏览器打开链接 */ E ...
- 23种设计模式之单例模式(Singleton)
单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例,这个类称为单例类,它提供全局访问的方法. public class SingleTon { private static Si ...
- python nose测试框架全面介绍七--日志相关
引: 之前使用nose框架时,一直使用--logging-config的log文件来生成日志,具体的log配置可见之前python nose测试框架全面介绍四. 但使用一段时间后,发出一个问题,生成的 ...
- 用mongoose实现mongodb增删改查
//用户 var mongoose = require("mongoose"), setting = require("./setting"); //配置连接数 ...
- [转]Android MediaPlayer状态机
翻译Android Reference Manual的MediaPlayer的状态机 对播放音频/视频文件和流的控制是通过一个状态机来管理的.下图显示一个MediaPlayer对象被支持的播放控制操作 ...
- #if 和 #ifdef 条件编译注意
之前写程序很少用到这两个条件编译,只是在头文件的开头使用过 #ifdef ....<CODE>.... #endif,他是防止头文件被重复包含,导致的变量被多处声明或定义. 最近写程序发 ...
- ajax跨域获取返回值
js代码 $.ajax({ async:false, url: 'https://***/api/prepareApi.getDanMu?sqlMapId=findBarrage', // 跨域URL ...