Heavy Transportation
题目大意:
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std; const int maxn = ;
const int oo = 0xfffffff; struct node
{
int y, weight;
node(int y, int weight):y(y), weight(weight){}
}; vector<node>G[maxn];
int v[maxn]; void spfa(int s)
{
queue<int> Q;
Q.push(s); while(Q.size())
{
s = Q.front(), Q.pop();
int len = G[s].size(); for(int i=; i<len; i++)
{
node q = G[s][i]; if(v[s] > v[q.y] && q.weight > v[q.y])
{
v[q.y] = min(v[s], q.weight);
Q.push(q.y);
}
}
}
} int main()
{
int T, t=; scanf("%d", &T); while(T--)
{
int N, M, a, b, w, i; scanf("%d%d", &N, &M); for(i=; i<=N; i++)
{
G[i].clear();
v[i] = -oo;
}
v[] = oo; for(i=; i<M; i++)
{
scanf("%d%d%d", &a, &b, &w);
G[a].push_back(node(b, w));
G[b].push_back(node(a, w));
} spfa(); printf("Scenario #%d:\n", t++);
printf("%d\n\n", v[N]);
} return ;
}
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 ...
随机推荐
- vpn的作用
1.可以用于远程对方桌面. 步骤: 1.浏览器中访问网址,输入用户名,密码即可 2.输入远程桌面用户名和网址
- Linux下使用NMON监控、分析系统性能 -转载
原帖地址:http://blog.itpub.net/23135684/viewspace-626439/ 谢谢原帖大人 一.下载nmon. 根据CPU的类型选择下载相应的版本:http://nmon ...
- 把cygwin加入右键菜单
第一步:修改windows注册表 1·开始->运行(或者win键+R),输入REGEDIT,回车,打开注册表编辑器: 2·找到HKEY_CLASSES_ROOT\Directory\Backgr ...
- 赋值,copy和deepcopy
python的复制,拷贝,和深拷贝. >>> a=[23,3]>>> b=a>>> b.append(234)>>> a[23, ...
- 如何让低版本的IE浏览器(IE6/IE7/IE8)支持HTML5 header等新标签
html5提供的一些新标签(article,aside,dialog,footer,header,section,footer,nav,figure,menu)使用起来非常的方便,但是低版本的IE浏览 ...
- PHP android ios相互兼容的AES加密算法
APP项目用户密码传输一直没有用HTTPS,考虑到用户的隐私暂时先用AES对密码加密,以后也可以用于手机端与服务端加密交互. PHP的免费版phpAES项目,手机端解码各种不对. 好不容易找了PHP ...
- PHP: 使用CURL访问FTP
今天要做FTP上传.本想用PHP自带的FTP函数来实现,结果发现这个模块没有编译进来,重新编译PHP太麻烦,改用其他方式实现吧 FTP上传 if (isset($_POST['Submit'])) ...
- VS2010 release 和 debug 调试区别
VC下Debug和Release区别 最近写代码过程中,发现 Debug 下运行正常,Release 下就会出现问题,百思不得其解,而Release 下又无法进行调试,于是只能采用printf方式逐步 ...
- tableview 编辑状态设置
#pragma mark - tableview 编辑状态设置 -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSI ...
- fragment 学习
fragment需要id是必须属性 <fragment android:id="@+id/frg1" android:name="com ...