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 ...
随机推荐
- Linux就该这么学--命令集合3(文本文件编辑命令)
1.cat命令查看纯文本文件(较短):(cat [选项] [文件]) cat -n showpath.sh 附录: -n 显示行号 -b 显示行号(不包括空行) -A 显示出“不可见”的符号,如空格, ...
- Apache http server和tomcat的区别
Apache官方网站:http://www.apache.org/Tomcat官方网站:http://tomcat.apache.org/ 1. Apache是web服务器,Tomcat是应用(jav ...
- wireshark 学习 2
使用wireshark抓到的wifi数据包如果是加密的,就只能显示密文,无法得到真正的数据. 如果知道AP和SSID和key,就可以解密wifi数据包,显示上层协议的数据. 在wireshark中设置 ...
- IOS从背景图中取色
1. [代码][其他]代码 void *bitmapData; //内存空间的指针,该内存空间的大小等于图像使用RGB通道所占用的字节数. static CGContextRef Creat ...
- log4j 配置文件详解
[1]从零开始 a). 新建Java Project>>新建package>>新建java类: b). import jar包(一个就够),这里我用的是log4j-1.2.14 ...
- 烂笔头——JAVA/JSP
学艺不精,一些小零头放这里备忘 Object[] obj = (Object[])list.get(i);//取list的某个项目 jsp中出现out.println( )和System.out.pr ...
- Battle Ships(复习泛化物品**)
传送门Battle Ships Time Limit: 2 Seconds Memory Limit: 65536 KB Battle Ships is a new game which i ...
- java中的异常The given object has a null identifier
修改页面点击提交时报如下异常: org.hibernate.TransientObjectException: The given object has a null identifier: com. ...
- (原创)让mongodb的secondary支持读操作
对于replica set 中的secondary 节点默认是不可读的.在写多读少的应用中,使用Replica Sets来实现读写分离.通过在连接时指定或者在主库指定slaveOk,由Secondar ...
- POJ2274(后缀数组应用)
Long Long Message Time Limit: 4000MS Memory Limit: 131072K Total Submissions: 25272 Accepted: 10 ...