大白的345 页。
题目:秦始皇要修一个道路的工程,使得所有城市全部联通。
然后道士徐福可以帮他修一条不需劳动力的路。
给出两个变量:
让这条路的起终点的人口和A
除以除此之外的路的劳动力之和B ?
秦始皇想让这条路修的位置,使得A/B 最大
思路:
用最小生成树首先生成一个全通图
再用DFS算出每一个城市之间唯一路径上的最大的权值的路
然后枚举每一个城市,用最小生成树计算出的SUM - maxcost[U][V]
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f
#define MAX(a,b) a>b?a:b
using namespace std;
struct point
{
int x,y,p;
}P[1005];
int set[1005];
struct line
{
int s,e;
double w;
bool operator < (const line &cmp)const
{
return wminmap[1005];
bool vis[1005];
int find(int x)
{
while(set[x]!=x)
x=set[x];
return x;
}
double dis(point tx,point ty)
{
return sqrt((double)(tx.x-ty.x)*(tx.x-ty.x)+(double)(tx.y-ty.y)*(tx.y-ty.y));
}
void dfs(int st,int pos)
{
for(int i=0;ians)ans=tt;
}
}
printf("%.2lf\n",ans);
}
return 0;
}
?