POJ 1125-Stockbroker Grapevine

Source: Internet
Author: User

 

 

N individual stock trading, each person can report to others, 1st rows n, the first line x is the X-1 individual can report to several people, and the minimum time for the time ball and the number of people who start reporting

 

Water question, Floyd once;

ME 676KB

TI 16 MS

 

 

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include const int INF = 1e7;const int N = 105;using namespace std;int mapp[N][N],n;void init(){    for(int i = 1;i<=n;i++)    {        for(int j = 1;j<=n;j++)            {                mapp[i][j] = INF;            }    }}void Floyd(){    int k,j,i;    for(k = 1;k<=n;k++)    {        for(i = 1;i<=n;i++)        {            for(j=1;j<=n;j++)            {                if(mapp[i][j] > mapp[i][k] + mapp[k][j])                    mapp[i][j] = mapp[k][j] + mapp[i][k];            }        }    }}int main(){    int s,wz,ti;    while(scanf(%d,&n),n)    {        init();        for(int i = 1;i<=n;i++)        {            scanf(%d,&s);            for(int j = 1;j<=s;j++)            {                scanf(%d%d,&wz,&ti);                mapp[i][wz] = ti;            }        }        Floyd();        int st = -1,maxx = 0,ti = INF;        for(int i = 1;i<=n;i++)        {            maxx = 0;            for(int j = 1;j<=n;j++)            {                if(i==j)                    continue;                if(mapp[i][j]> maxx)                {                    maxx = mapp[i][j];                }            }            if(ti>maxx)            {                ti = maxx;                st = i;            }        }        if(st!=-1)            printf(%d %d,st,ti);            else                puts(disjoint);    }    return 0;}
     
    
   
  
 


 

Related Article

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.