hdu 3631
来源:互联网 发布:java 重载的意义 编辑:程序博客网 时间:2024/04/24 19:04
hdu 3631 -->点我传送<--
#include<iostream>#include<cstring>#include<cstdio>using namespace std;const int maxn=305;const int inf=0x3f3f3f3f;int n;int dis[maxn][maxn];int test[maxn];void floyd(int u){ for(int i=0;i<=n;i++){ for(int j=0;j<=n;j++){ dis[i][j]=min(dis[i][j],dis[i][u]+dis[u][j]); } }}int main(){ int m,q,cnt=0; while(scanf("%d%d%d",&n,&m,&q)&&(m+n+q)){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ dis[i][j]=inf; } dis[i][i]=0; } while(m--){ int a,b,c; scanf("%d%d%d",&a,&b,&c); if(c<dis[a][b]) dis[a][b]=c; } if(cnt!=0) printf("\n"); printf("Case %d:\n",++cnt); int t,t1,t2,t3; memset(test,0,sizeof(test)); while(q--){ scanf("%d",&t); if(!t){ scanf("%d",&t1); if(test[t1]==0){ floyd(t1); test[t1]=1; } else printf("ERROR! At point %d\n",t1); } else{ scanf("%d%d",&t2,&t3); if(!test[t2]||!test[t3]) printf("ERROR! At path %d to %d\n",t2,t3); else if(dis[t2][t3]!=inf) printf("%d\n",dis[t2][t3]); else printf("No such path\n"); } } } return 0;}
0 0
- hdu 3631
- hdu 3631
- hdu 3631
- hdu 3631 Shortest Path
- HDU 4334 && ZOJ 3631
- hdu 3631 Shortest Path
- hdu 3631 Shortest Path
- Hdu 3631 Shortest Path
- HDU 3631 Shortest Path
- hdu 3631(floyd)
- HDU 3631 Shortest Path
- hdu 3631(Floyd变形)
- HDU 3631 Shortest Path
- HDU-3631-Shortest Path
- HDU 3631 floyd
- HDU-3631-floyd插点法
- hdu
- hdu
- MySQL的存储过程
- Material Design系列,自定义Behavior之上滑显示返回顶部按钮
- java读取properties文件的方法
- json
- Android Studio导入Project、Module的正确方法
- hdu 3631
- EMV规范(四)——读应用数据
- titanic survival 1
- Epic Games公司的虚幻(Unreal)
- 关于cocos2d-x的安卓打包的笔记
- ap
- dubbo 入门教程 基于zookeeper
- Poj 2411 铺砖问题
- 弱鸡的暑假图论安排