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 ...
随机推荐
- Echarts使用随笔(2)-Echarts中mapType and data
本文出处:http://blog.csdn.net/chenxiaodan_danny/article/details/39081071 series : [ { ...
- C语言中,如何通过socket得到对端IP地址
struct sockaddr_in clientaddr1; memset(&clientaddr1, 0x00, sizeof(clientaddr1)); socklen_t nl=si ...
- &与&
- Xcode7插件开发:从开发到拉到恶魔岛
Xcode很强大,但是有些封闭,官方并没有提供Xcode插件开发的文档.喵神的教程比较全,也比较适合入门.本文的教程只是作为我在开发FKConsole的过程中的总结,并不会很全面. FKConsole ...
- 【转】 iOS开发之手势gesture详解
原文:http://www.cnblogs.com/salam/archive/2013/04/30/iOS_gesture.html 前言 在iOS中,你可以使用系统内置的手势识别 (Gesture ...
- 115个Java面试题和答案——终极列表
from http://www.importnew.com/10980.html#collection http://www.importnew.com/11028.html 下面的章节分为上下两篇, ...
- 【BZOJ1500】【块状链表】维修数列
Description Input 输入文件的第1行包含两个数N和M,N表示初始时数列中数的个数,M表示要进行的操作数目.第2行包含N个数字,描述初始时的数列.以下M行,每行一条命令,格式参见问题描述 ...
- javascript——操作符(~、&、|、^、<<、>>)
直接上代码吧! <script type="text/javascript"> //javascript操作符 //1.按位非~ var num1=25;// var ...
- 虚拟机VHD格式解析到NTFS文件系统解析
本来的需求是XEN下的镜像取证,但这篇仅包括他支持的一种格式,就是VHD,此项目从头开始大概用了两周时间,中间遇到了很多让人头大的问题,光是思考的笔记就写了十几页纸,不过实际上并没有那么难,主要是很久 ...
- skip-grant-tables的作用
skip-grant-tables:非常有用的mysql启动参数(不启动grant-tables授权表) skip-grant-tables:非常有用的mysql启动参数 介绍一个非常有用的mys ...