[U] 2.4.3CowTours

Source: Internet
Author: User
I finally achieved a little graph topic ~ It means that the problem is coming. I still feel that I am too lazy, unwilling to spend time, and unwilling to believe in myself. This question is a little interesting. My code has timed out and I changed some things at will. I didn't expect it to be too much ~ Wow, haha ~ The second is missing. The solution is simple, but in the process

I finally achieved a little graph topic ~ It means that the problem is coming. I still feel that I am too lazy, unwilling to spend time, and unwilling to believe in myself. This question is a little interesting. My code has timed out and I changed some things at will. I didn't expect it to be too much ~ Wow, haha ~ The second is missing. The solution is simple, but in the process

I finally achieved a little graph topic ~ This means that the difficulties are coming.

I still feel that I am too lazy, unwilling to spend time, and unwilling to believe in myself.

This question is a little interesting. My code has timed out and I changed some things at will. I didn't expect it to be too much ~ Wow, haha ~ The second is missing.

It is easy to solve the problem, but it will go around many circles during the solution process, causing a headache.

Enumeration is not two vertices in a Unicom diagram. Edge join them, find the diameter of the farm according to the definition in the question, and then find the minimum value of the maximum value of the farm diameter. This is an example !!!

Code:

/*ID:sevenst4LANG:C++PROG:cowtour*/#include
 
  #include
  
   #define INF 1111111using namespace std;struct node{    double x,y;}p[160];int n;double dis[160][160];double max( double a,double b ){ return a>b?a:b; }double min( double a,double b ){ return a
   
    dis[a][i]?ret:dis[a][i];       return ret;}double getall(){    double ret=0;    for( int i=1;i<=n;i++ )   for( int j=1;j<=n;j++ )   if( i!=j && dis[i][j]!=INF )       ret=max(ret,dis[i][j]);   return ret;}int main(){ freopen( "cowtour.in","r",stdin ); freopen( "cowtour.out","w",stdout ); scanf( "%d",&n ); for( int i=1;i<=n;i++ )  scanf( "%lf %lf",&p[i].x,&p[i].y );for( int i=0;i<=n;i++ )for( int j=0;j<=n;j++ ) dis[i][j]=INF;char line[160];for( int i=1;i<=n;i++ ){  scanf( "%s",&line );  for( int j=0;j
    
     dis[i][k]+dis[k][j] )      dis[i][j]=dis[i][k]+dis[k][j];        double ans=INF;    for( int i=1;i<=n;i++ )    for( int j=1;j<=n;j++ )     if( i!=j && dis[i][j]==INF )     {   double m=gmdis(i)+dist(i,j)+gmdis(j);   if( m>ans )    continue;   ans=min( max( getall(),m ),ans );       }       printf( "%lf\n",ans ); 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.