hdu 1690 Bus System
来源:互联网 发布:阿里云 cdn 清除缓存 编辑:程序博客网 时间:2024/05/01 20:54
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;const __int64 inf=1e18;const __int64 N=100+5;__int64 edge[N][N],use[N],g[N],l1,l2,l3,l4,c1,c2,c3,c4,n,m;__int64 getsum(__int64 x,__int64 y){ __int64 t; if(x-y<0) t=y-x; else t=x-y; if(t==0) return 0; if(t>l4) return -1; else if(t<=l4&&t>l3) return c4; else if(t<=l3&&t>l2) return c3; else if(t<=l2&&t>l1) return c2; else return c1;}void floyd(){ __int64 i,j,k; for(k=0; k<n; k++) { for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(edge[i][k]>=inf||edge[k][j]>=inf) continue; edge[i][j]=min(edge[i][j],edge[i][k]+edge[k][j]); } } }}int main(){ __int64 ans,_,t,k,i,j,x,y; scanf("%I64d",&_); for(t=1; t<=_; t++) { scanf("%I64d%I64d%I64d%I64d %I64d%I64d%I64d%I64d",&l1,&l2,&l3,&l4,&c1,&c2,&c3,&c4); for(i=0; i<N; i++) for(j=0; j<N; j++) { if(i==j) edge[i][j]=0; else edge[i][j]=inf; } scanf("%I64d%I64d",&n,&m); for(i=0; i<n; i++) { scanf("%I64d",&g[i]); } for(i=0;i<n;i++) for(j=0;j<n;j++) { if(getsum(g[i],g[j])==-1) continue; edge[i][j]=min(getsum(g[i],g[j]),edge[i][j]); } floyd(); printf("Case %I64d:\n",t); for(i=0; i<m; i++) { scanf("%I64d%I64d",&x,&y); if(edge[x-1][y-1]>=inf) printf("Station %I64d and station %I64d are not attainable.\n",x,y); else printf("The minimum cost between station %I64d and station %I64d is %I64d.\n",x,y,edge[x-1][y-1]); } } return 0;}
0 0
- HDU 1690 Bus System
- HDU 1690 Bus System
- hdu 1690 Bus System
- HDU 1690 Bus System
- HDU 1690 Bus System
- hdu 1690 Bus System
- hdu 1690 Bus System
- HDU 1690 Bus System.
- hdu-1690 Bus System
- hdu 1690 Bus System
- hdu 1690 Bus System
- HDU-1690-Bus System
- HDU-1690-Bus System
- HDU 1690:Bus System
- HDU-1690-Bus System
- hdu 1690 Bus System--floyd
- hdu 1690 Bus System ---Floyd
- hdu 1690 Bus System<java>
- linux命令2--chgrp命令
- nginx配置静态文件目录,压缩传输
- RxJava使用介绍
- HDOJ 1021 Fibonacci Again
- 关于extjs5.0下的mixins
- hdu 1690 Bus System
- (Java实现)HTML页面转PDF解决方案
- 使用excel进行数据挖掘(2)----分析关键影响因素
- tar 压缩与解压缩打包命令
- C/C++文件读取报错:stack around the variable 'x' was corrupted.
- leetcode[169]:Majority Element
- Python 字符串操作
- vs中c、c++屏蔽警告
- apache+tomcat 报错 Internal Server Error