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 ...
随机推荐
- Spring AOP-xml配置
在spring AOP(一)中介绍了AOP的基本概念和几个术语,现在学习一下在XML中如何配置AOP. 在XML中AOP的配置元素有以下几种: AOP配置元素 描述 <aop:config> ...
- 生成chm格式帮助文档的步骤
开场前,道具先得被齐全了. 道具:struts2的开源代码(以生成struts2的帮助文档为例).chm格式生成工具jd2chm.exe(网上有) 好了,准备演出 1.在eclipse中新建一个jav ...
- npm --- Node.js包管理器
目录 1. 安装Node.js 2. 运行npm 3. npm介绍 3.1 安装插件 3.2 更新插件 3.3 卸载插件 3.4 查看当前目录中的插件列表 4. 使用cnpm 4.1 安装 npm( ...
- PB调用C# Windows窗体
以下是PB中的代码:String ls_filenameLong ll_wstyle=1long ll_hwnd,ll_nShowCmdstring ls_lpOperation,ls_lpFile, ...
- CS231n 2016 通关 第四章-NN 作业
cell 1 显示设置初始化 # A bit of setup import numpy as np import matplotlib.pyplot as plt from cs231n.class ...
- 【原】RHEL6.0企业版安装
作者:david_zhang@sh [转载时请以超链接形式标明文章] 链接:http://www.cnblogs.com/david-zhang-index/p/4166846.html 本文适用RH ...
- 方法名的string类型应用(补)
string strClass = "stringConvertClass.test"; //命名空间+类名 string strMethod = "Method&quo ...
- CF-796B
B. Find The Bone time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- HDOJ-2054
A == B ? Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- python 数据可视化
一.基本用法 import numpy as np import matplotlib.pyplot as plt x = np.linspace(-1,1,50) # 生成-1到1 ,平分50个点 ...