您当前的位置: 首页 > 

对方正在debug

暂无认证

  • 7浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

2016 Multi-University Training Contest 1

对方正在debug 发布时间:2019-04-30 12:07:35 ,浏览量:7

题目:https://cn.vjudge.net/contest/296683

A - Abandoned country

HDU - 5723 求最小生成树,再求这个最小生成树上任意两个点的最短距离期望 任意两个点情况数就是C(n,2),任意两个点的距离和可以转化为求每条边的贡献和 而每条边的贡献就是u->v valsz[v](n-sz[v]用dp[u]储存所有和u相连的边的贡献和,简单树形Dp

#include
using namespace std;
#define ll long long
const int maxn=100010;
const int maxm=1000010;

struct edge{
	int u,v,w,nxt;
}e[maxm];
int head[maxn],tot;
int n,m;
int f[maxn];


void init()
{
	memset(head,-1,sizeof(head));
	tot=0;
}

void addedge(int u,int v,int w)
{
	e[tot].u=u;
	e[tot].v=v;
	e[tot].w=w;e[tot].nxt=head[u];
	head[u]=tot++;
}
int find1(int x)
{
	return x==f[x]?x:f[x]=find1(f[x]);
}
bool union1(int a,int b)
{
	int fa=find1(a),fb=find1(b);
	if(fa!=fb){
		f[fa]=fb;
		return false;
	}
	return true;
}

struct node{
	int a,b,c;
}hh[maxm];
bool cmp(const node& a,const node& b)
{
	return a.c            
关注
打赏
1664895754
查看更多评论
0.0735s