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;}