码迷,mamicode.com
首页 > 其他好文 > 详细

Poj 2263 Heavy Cargo Floyd 求最大容量路

时间:2014-07-20 22:31:27      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   

f[i][j] = max(f[i][j],min(f[i][k],f[j][k]))

 

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <string>
#include <iostream>
#include <map>
#include <cstdlib>
#include <list>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
const int maxn = 205;
const int INF = INT_MAX / 4;
map<string,int> mp;
int d[maxn][maxn],n,m;
string a,b;

int id(string &s) {
    int now = mp.size();
    if(mp.count(s) == 0) mp[s] = now + 1;
    return mp[s];
}

int main() {
    int kase = 1;
    while(cin >> n >> m,n) {
        mp.clear();
        int dist;
        for(int i = 1;i <= n;i++) {
            for(int j = 1;j <= n;j++) {
                d[i][j] = -1;
            }
        }
        for(int i = 1;i <= m;i++) {
            cin >> a >> b >> dist;
            d[id(a)][id(b)] = d[id(b)][id(a)] = dist;
        }
        for(int k = 1;k <= n;k++) {
            for(int i = 1;i <= n;i++) {
                for(int j = 1;j <= n;j++) {
                    d[i][j] = max(d[i][j],
                            min(d[i][k],d[j][k]));
                }
            }
        }
        cin >> a >> b;
        cout << "Scenario #" << kase++ << endl;
        cout << d[id(a)][id(b)] << " " << "tons" << endl;
        cout << endl;
    }
    return 0;
}

Poj 2263 Heavy Cargo Floyd 求最大容量路,布布扣,bubuko.com

Poj 2263 Heavy Cargo Floyd 求最大容量路

标签:style   blog   color   os   io   for   

原文地址:http://www.cnblogs.com/rolight/p/3857286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!