Poj 2263 Heavy Transportation

Source: Internet
Author: User
// Calculate the maximum transport volume from the start point to the end point // The transport volume depends on the maximum capacity of a single path // use Floyd Algorithm , Motion gauge # include <iostream >#include <map ># include <cstring> using namespace STD; # define maxn 201 # define INF 000000map <string, int> city; int weight [maxn] [maxn]; int edge [maxn] [maxn]; int t; int N, R; int citynumber; int querycity (string Str) {Map <string, int>: iterator ITER; iter = city. find (STR); If (ITER! = City. end () {return ITER-> second;} else {City [STR] = citynumber; citynumber ++; return City [STR] ;}} void Floyd () {for (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= N; j ++) {weight [I] [J] = edge [I] [J] ;}}for (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= N; j ++) {for (int K = 1; k <= N; k ++) {weight [I] [J] = max (weight [I] [J], min (weight [I] [K], weight [k] [J]) ;}}} int main () {T = 0; while (CIN >>> n >> R) {If (n = 0 & R = 0) break; citynumber = 1; t ++; For (INT I = 0; I <= N; I ++) {edge [I] [I] = inf; For (Int J = 0; j <= N; j ++) {if (I! = J) edge [I] [J] = 0 ;}for (INT I = 0; I <r; I ++) {string ca, CB; int ton; cin> Ca> CB> ton; int x = querycity (CA); int y = querycity (CB); edge [x] [Y] = ton; edge [y] [x] = ton;} Floyd (); string CS, CE; CIN> Cs> CE; int ST = querycity (CS ); int en = querycity (CE); cout <"Scenario #" <t <Endl; cout <weight [st] [En] <"tons" <Endl;} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.