BZOJ4342 : CF348 Pilgrims】的更多相关文章

可以发现,每个特殊点可以贡献的部分在树上是一条链. 设三元组(v,x,y)表示路径长度,需要更新的端点,与当前点的lca为y. 对于每个节点x,通过两遍树形DP可以求出: d[x]:x到x子树内的某个特殊点的最优解. u[x]:x到x子树外的某个特殊点的最优解. pre[x]:x以及x之前的兄弟的d[]的最优解. suf[x]:x以及x之后的兄弟的d[]的最优解. 然后在树上打标记,最后dfs一遍统计答案即可. 时间复杂度$O(n)$. #include<cstdio> #define N 1…
#4342. CF348 Pilgrims 此题同UOJ#11 ydc的大树 Online Judge:Bzoj-4342,Codeforces-348E,Luogu-CF348E,Uoj-#11 Label:树的直径,树形dp,神题 题目描述 在很久以前有一片土地被称为 Dudeland.Dudeland 包含 n 个城镇,它们用 n − 1 条双向道路连接起来.这些城镇通过道路可以两两互达.这里有 m 个修道院坐落在 m 个不同的城镇.每个修道院有一个教徒.在一年之始,每个教徒会选择离他最远…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
题面 CF348E Pilgrims 有一棵 \(n\) 个点的 带权 树和 \(m\) 个关键点,要求杀了一个不关键的点,满足最多的关键点到离它最远的所有关键点的路径都被打断.求可以满足的最多关键点数和此时的杀点方案数. 数据范围:\(2\le m<n\le 10^5\). 题解 写了个奇怪的做法调了一个上午,写篇不行的题解. 很明显所有关键点到所有离它最远的关键的所有路径都经过一个点: 距离最远的一对关键点的中点(不需要取 \(\frac{dist}{2}\) 的位置建出一个新点!如果真正的…
Season 1, Episode 18: Bluff -Michael: Scofield Scofield Michael Scofield Michael Scofield -Patoshik: Doesn't ring a bell 记不起来 -Michael: wind back a while in Gen Pop Cell 40 cell: 囚室 回忆一下大牢房40号囚室? -Patoshik: Gen Pop 大牢房 -Michael: General Population. O…
#瓦登尔湖词频统计: import string path = 'D:/python3/Walden.txt' with open(path,'r',encoding= 'utf-8') as text: words = [raw_word.strip(string.punctuation).lower() for raw_word in text.read().split()] words_index = set(words) counts_dict = {index:words.count(…
You've probably heard the baleful reports. The number of college students majoring in the humanities is plummeting, according to a big study released last month by the American Academy of Arts & Sciences. The news has provoked a flood of high-minded…
By such means, and by taxing and oppressing the English people in every possible way, the Red King became very rich. When he wanted money for any purpose, he raised it by some means or other, and cared nothing for the injustice he did, or the misery…