C - Heavy Transportation
//改版dijkstra
#include <iostream>
#include <algorithm> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = +;
using namespace std; const int INF = 0xfffff; int mp[maxn][maxn];
bool v[maxn];
int n, m;
int dis[maxn]; void dij(int be){
int Min, p;
v[be] = false;
for(int i = ;i <= n;i++){
dis[i] = mp[i][be];
}
dis[be] = ; for(int i = ;i <= n;i++){
Min = ;
for(int j = ;j <= n;j++){
if(v[j] && Min < dis[j]){
p = j;
Min = dis[j];
}
}
if(Min == )
break;
v[p] = false;
for(int j = ;j <= n;j++){
dis[j] = max(dis[j], min(dis[p],mp[p][j]));
}
}
} int main(){
Faster;
int t;
int cnt = ;
cin >> t;
while(t--){
cnt++;
cin >> n >> m;
for(int i = ;i <= n;i++){
dis[i] = ;
v[i] = true;
for(int j = ;j <= n;j++){
mp[i][j] = ;
}
}
for(int i = ;i < m;i++){
int x, y, z;
cin >> x >> y >> z;
if(mp[x][y] < z){
mp[x][y] = mp[y][x] = z;
}
} dij();
cout << "Scenario #" << cnt << ":"<< endl;
cout << dis[n] << endl << endl;
}
return ;
}
C - Heavy Transportation的更多相关文章
- POJ 1797 Heavy Transportation(最大生成树/最短路变形)
传送门 Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 31882 Accept ...
- Heavy Transportation(最短路 + dp)
Heavy Transportation Time Limit:3000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64 ...
- POJ 1797 Heavy Transportation (Dijkstra变形)
F - Heavy Transportation Time Limit:3000MS Memory Limit:30000KB 64bit IO Format:%I64d & ...
- poj 1797 Heavy Transportation(最短路径Dijkdtra)
Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 26968 Accepted: ...
- POJ 1797 Heavy Transportation
题目链接:http://poj.org/problem?id=1797 Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K T ...
- POJ 1797 Heavy Transportation (最短路)
Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 22440 Accepted: ...
- POJ 1797 Heavy Transportation (dijkstra 最小边最大)
Heavy Transportation 题目链接: http://acm.hust.edu.cn/vjudge/contest/66569#problem/A Description Backgro ...
- POJ1797 Heavy Transportation 【Dijkstra】
Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 21037 Accepted: ...
- #图# #最大生成树# #kruskal# ----- OpenJudge 799:Heavy Transportation
OpenJudge 799:Heavy Transportation 总时间限制: 3000ms 内存限制: 65536kB 描述BackgroundHugo Heavy is happy. Afte ...
- poj 1797 Heavy Transportation(最大生成树)
poj 1797 Heavy Transportation Description Background Hugo Heavy is happy. After the breakdown of the ...
随机推荐
- C++继承类同名数据成员被隐藏,其实都在内存里,转换后都可以被使用
#include "stdafx.h" class A { public: int i; A() { i=; } }; class B: public A { public: in ...
- HTTP Status 405
分析原因: 1.doPost()和getPost()两个方法继承了父类,造成出错.
- 关于myeclipse缓存问题
昨天在部署项目的时候发现,刚检出的项目jdk竟然不是1.6版本的了,而是新的(在此之前每次检出项目都会重新设置一下jdk),如图所示: 当时还在想,真好,以后就不用配置了,但是随之而来的是一个重大问题 ...
- 记一次FastJSON和Jackson解析json时遇到的中括号问题
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jadyer/article/details/24395015 完整版见https://jadyer. ...
- [Java SE] 字符串连接
Java 支持多种字符串连接方式,总结如下: package cn.spads.tool.string; import java.text.MessageFormat; /** * <b> ...
- Gym - 100676F Palindrome —— 并查集
题目链接:https://vjudge.net/contest/155789#problem/E 题解: 由于是回文串,所以可以先将在对称位置的字符放在同一个集合(如果期间有两个非‘?’,且不相等,则 ...
- linux系统配置之PATH环境变量的设置(centos)
Centos系统下修改环境变量PATH路径的方法 电脑脑中必不可少的就是操作系统.而Linux的发展非常迅速,有赶超微软的趋势.这里介绍Linux的知识,让你学好应用Linux系统.比如要把/etc/ ...
- World Finals 2017 (水题题解)
看大佬做2017-WF,我这种菜鸡,只能刷刷水题,勉强维持生活. 赛后补补水题. 题目pdf链接,中文的,tls翻译的,链接在这里 个人喜欢在vjudge上面刷题. E Need for Speed ...
- hdu-5754 Life Winner Bo(博弈)
题目链接: Life Winner Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- CNN中下一层Feature map大小计算
符号表示: $W$:表示当前层Feature map的大小. $K$:表示kernel的大小. $S$:表示Stride的大小. 具体来讲: 整体说来,和下一层Feature map大小最为密切的就是 ...