Bus System(Flody)
2024-08-20 21:02:52
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 ;
}
最新文章
- 天气预报API开发
- mysql 安装以及运行
- AjaxControlToolKit--TabContainer控件的介绍
- 【Spark】---- Spark 硬件配置
- 二模 (3) day2
- php_2
- ural 1998 The old Padawan
- Android实例-闪光灯的控制(XE8+小米2)
- css制作导航栏的上下三角
- ping-tool
- EF6.0执行sql存储过程案例
- win10 uwp 无法附加到CoreCLR
- EntityFramework优化:第一次启动优化
- C#代码中插入X86汇编
- ssh: connect to host github.com port 22: Connection timed out
- java中常用的进制转换
- 笔记react router 4(三)
- RAID卡的缓存与磁盘自带的缓存的关系
- Python encode() 方法
- BZOJ4923 K小值查询(splay)
热门文章
- .net webservices 代理类生成命令
- 【Spring Boot&;&;Spring Cloud系列】Spring Boot初识
- 【Java基础】System的arraycopy方法拷贝数组
- sencha touch + Cordova 3.x下载文件
- [原]Openstack之identity server(keystone)
- vue生成路由实例, 使用单个vue文件模板生成路由
- MFC创建好的对话框如何移植到新程序中
- http get请求参数拼接
- [LintCode] Invert Binary Tree 翻转二叉树
- Python 基础知识(二)