设为首页 加入收藏

TOP

hdu 4081 Qin Shi Huang's National Road System
2015-11-21 01:39:14 来源: 作者: 【 】 浏览:6
Tags:hdu 4081 Qin Shi Huang' National Road System
大白的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;
}

?


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇1055. The World's Richest (.. 下一篇hdu4082 Hou Yi's secret

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: