UVA-10048 Audiophobia (Floyd application)

Source: Internet
Author: User

Test instructions: Find the minimum value of the maximum weights for all paths between two points.

Idea: Change the form of Floyd;

Note: Note the initialization problem and the output form of the UVA flower.

The code is as follows:

#include <iostream>#include<cstdio>#include<cstring>#include<string>#include<map>using namespacestd;#defineINF 0x3f3f3fintdp[ the][ the];intMain () {intN,m,q,a,b,w,ca =0;  while(cin>>n>>m>>q) {if(n+m+q==0) Break; if(CA! =0) printf ("\ n"); Memset (DP,0x3f,sizeof(DP));  for(inti =0; I < m; i++) {cin>>a>>b>>W; DP[A][B]= Dp[b][a] =W; }         for(inti =1; I <= N; i++) {Dp[i][i]=0; }         for(intK =1; K <= N; k++)        {             for(inti =1; I <= N; i++)            {                 for(intj =1; J <= N; J + +) {Dp[i][j]=min (Dp[i][j],max (dp[i][k],dp[k][j)); } }} cout<<"Case #"<<++ca<<Endl;  for(inti =0; i < Q; i++) {cin>>a>>C; if(Dp[a][b] >=inf) {cout<<"No path\n"; }            Elsecout<<dp[a][b]<<Endl; }    }    return 0;}

UVA-10048 Audiophobia (Floyd application)

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.