「BZOJ1232」 [Usaco2008Nov]安慰奶牛cheer
发布日期:2021-08-28 20:23:39 浏览次数:55 分类:技术文章

本文共 685 字,大约阅读时间需要 2 分钟。

「BZOJ1232」 [Usaco2008Nov]安慰奶牛cheer

Solution

最终的图显然是一棵树

把每条边视作两条有向边。在树的情况下,一定需要走完所有的有向边。除了出发点以外,走一条有向边\((u,v)\)对答案的贡献为\(w(u,v)+c[v]\),亦即每条无向边对答案的贡献为\(w(u,v)*2+c[u]+c[v]\),将其作为边权跑最小生成树。生成树的权值加上最小的点权即为答案

Code

#include 
#include
#include
#include
#include
#include
#define maxn 10005#define maxm 100005using namespace std;typedef long long ll; int n,m;int c[maxn];int ans; struct edge{ int u,v,w;}g[maxm]; int prt[maxn]; int getroot(int u){ return prt[u]==u?u:prt[u]=getroot(prt[u]);} bool cmp(const edge &a,const edge &b){ return a.w

转载于:https://www.cnblogs.com/lizbaka/p/10505662.html

转载地址:https://blog.csdn.net/weixin_33970449/article/details/94328989 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:《陶哲轩实分析》部分勘误
下一篇:深入浅出HTTP协议(WEB开发和面试必备)

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月06日 06时47分09秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章