poj 2263 Heavy Cargo(floyd)
来源:互联网 发布:机场 知乎 编辑:程序博客网 时间:2024/05/16 06:47
floyd
#include<stdio.h>#include<string.h>#include<algorithm>#include<string>#include<map>#include<iostream>using namespace std;int n,m,edge[250][250],vis[250],dist[250];map<string,int>a;void floyd(){ int i,j,k,t; for(k=1; k<=n; k++) for(i=1; i<=n; i++) for(j=1; j<=n; j++) { if(edge[i][k]==-1||edge[k][j]==-1) continue; t=min(edge[i][k],edge[k][j]); if(edge[i][j]==-1) edge[i][j]=t; else if(edge[i][j]<t) edge[i][j]=t; }}int main(){ int i,j,tot,st,ed,cas=0,u,v,w; string s1,s2; while(~scanf("%d%d",&n,&m)) { memset(edge,0,sizeof(edge)); if(n==0&&m==0) break; a.clear(); tot=1; for(i=0; i<m; i++) { cin>>s1>>s2>>w; if(a[s1]==0) { a[s1]=tot; tot++; } if(a[s2]==0) { a[s2]=tot; tot++; } u=a[s1]; v=a[s2]; edge[u][v]=w; edge[v][u]=w; } for(i=1; i<=n; i++) for(j=1; j<=n; j++) { if(edge[i][j]==0) edge[i][j]=-1; } cin>>s1>>s2; st=a[s1]; ed=a[s2]; floyd(); printf("Scenario #%d\n",++cas); printf("%d tons\n\n",edge[st][ed]); } return 0;}
0 0
- [floyd]POJ 2263 Heavy Cargo
- poj 2263 Heavy Cargo(floyd)
- poj 2263 Heavy Cargo(最短路+floyd)
- POJ 2263 Heavy Cargo(Floyd变形)
- POJ 2263 Heavy Cargo
- poj 2263 Heavy Cargo
- poj 2263 Heavy Cargo
- POJ 2263 Heavy Cargo
- poj 2263 Heavy Cargo
- POJ:2263 Heavy Cargo
- POJ-2263 Heavy Cargo
- POJ 2263 Heavy Cargo
- poj 2263 Heavy Cargo
- poj 2263||zoj 1952Heavy Cargo(short path floyd)
- floyd UVA544 Heavy Cargo
- poj 2263 Heavy Cargo floyd基础,就是输入的时候处理字符串纠结一点!!!!
- POJ 2263 Heavy Cargo(图的遍历)
- POJ 2263 Heavy Cargo(Dijkstra算法)
- LINUX命令
- JAVA实现的一个简单的Socket Server范例
- Android批量图片加载经典系列——使用xutil框架缓存、异步加载网络图片
- (二)SDN 控制器 NOX 源码分析之—— Component
- IOS通知机制(NSNotification)
- poj 2263 Heavy Cargo(floyd)
- 对汉字字符的统计
- 6.15 喜刷刷 oj 1 b 矩形类定义
- quartz入门(二)SimpleTrigger简单实例
- github 上 Fork 别人的项目后的常用的操作指南
- Red Hat Enterprise Linux 7(RHEL7)安装oracle11gr
- 编译speex过程
- hdu1134 Game of Connections(卡特兰数)
- 字典树:动物统计加强版 (nyoj)