Heavy Transportation

题目大意:
雨果的沉重运输是快乐的,当浮空运输出现故障时候他可以扩展业务,
但他需要一个聪明的人告诉他是否真的是一种把他的客户构建了巨型钢起重机的地方需要的所有街道都可以承受重量(这句是直接有道翻译的......估计就是判断是不是所有的道路都能承受这个东西的重量),
不幸的是他不知道如何找到最大承载重量以重型起重机将如何告诉他的客户。
你将为这个城市拿出计划,描述一下一条街道的承重能力(两个十字路口中间),在编号1到n,你需要找出来最大的承重从编号1开到编号n
////////////////////////////////////////////////////////////////////////
还是求一条路上的最小的那个,貌似跟上一道题差不多。。。。
猜的不错,确实跟上一题差不多。。。。。不过还是PE了一次,每次输出都带一个空行.....
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;

const int maxn = 1005;
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=0; 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=1;

    scanf("%d", &T);

    while(T--)
    {
        int N, M, a, b, w, i;

        scanf("%d%d", &N, &M);

        for(i=1; i<=N; i++)
        {
            G[i].clear();
            v[i] = -oo;
        }
        v[1] = oo;

        for(i=0; 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(1);

        printf("Scenario #%d: ", t++);
        printf("%d ", v[N]);
    }

    return 0;

} 

原文地址:https://www.cnblogs.com/liuxin13/p/4653442.html