题解-POI2014 FAR-FarmCraft】的更多相关文章

Problem 辣鸡bzoj权限题,洛谷链接 题意概要:一棵 \(n\) 个点有根树.\(Q\) 次询问给出一个 \(K\),回答遍历完整棵树所需最少操作次数.每次操作可以选择访问不超过 \(K\) 个未访问的点,且这些点的父亲必须在之前被访问过. Solution 一开始题意理解错了,以为同时段每个点都能扩展 \(k\) 次,然后就无耻地看了题解--但是有个证明网上都没写,这也正是写这篇博客的原因 大概意思是说,最优策略一定是先用 \(i\) 步取完前 \(i\) 层,然后选取剩下深度大于 \…
Problem bzoj权限题,洛谷上可提交 洛谷上的奇葩翻译不要看,很多条件缺漏 题意简述:给定一棵树,每条边权为1,给定所有点点权,每条边仅能走两次,求以一定顺序遍历整棵树后,使所有点中的到达时间加点权的和的最大值最小(到达了就开始安装程序,点权即为安装时间,求最早什么时候所有电脑安装完毕) Solution 前置技能:树形Dp.贪心 这一类\(n\)在\(1e5\)范围的树上问题,一般都是树状Dp,考虑到题目中每条边仅能走两次,所以一旦到达了一个节点,一定会将以这个节点为根的子树全部遍历完…
POI2014题解 [BZOJ3521][Poi2014]Salad Bar 把p当作\(1\),把j当作\(-1\),然后做一遍前缀和. 一个合法区间\([l,r]\)要满足条件就需要满足所有前缀和\(\ge 0\),所有后缀和\(\ge 0\),也就是\(\forall i\in[l,r],sum_i-sum_{l-1}\ge 0,sum_r-sum_{i-1}\ge 0\). 也就是说\(sum_{l-1}\)要是\([l-1,r]\)内的最小值,\(sum_r\)要是\([l-1,r]\…
[BZOJ3829][Poi2014]FarmCraft Description In a village called Byteville, there are   houses connected with N-1 roads. For each pair of houses, there is a unique way to get from one to another. The houses are numbered from 1 to  . The house no. 1 belon…
[Poi2014]FarmCraft 题目 mhy住在一棵有n个点的树的1号结点上,每个结点上都有一个妹子. mhy从自己家出发,去给每一个妹子都送一台电脑,每个妹子拿到电脑后就会开始安装zhx牌杀毒软件,第i个妹子安装时间为Ci. 树上的每条边mhy能且仅能走两次,每次耗费1单位时间.mhy送完所有电脑后会回自己家里然后开始装zhx牌杀毒软件. 卸货和装电脑是不需要时间的. 求所有妹子和mhy都装好zhx牌杀毒软件的最短时间. INPUT 第一行输入一个整数N,表示有N个结点 第二行有N个整数…
题目描述 In a village called Byteville, there are   houses connected with N-1 roads. For each pair of houses, there is a unique way to get from one to another. The houses are numbered from 1 to  . The house no. 1 belongs to the village administrator Byte…
先贴一波题面... 3829: [Poi2014]FarmCraft Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 421  Solved: 197[Submit][Status][Discuss] Description In a village called Byteville, there are   houses connected with N-1 roads. For each pair of houses, there is a u…
原文地址:http://www.cnblogs.com/GXZlegend/p/6826667.html 题目描述 In a village called Byteville, there are   houses connected with N-1 roads. For each pair of houses, there is a unique way to get from one to another. The houses are numbered from 1 to  . The…
题目描述 In a village called Byteville, there are   houses connected with N-1 roads. For each pair of houses, there is a unique way to get from one to another. The houses are numbered from 1 to  . The house no. 1 belongs to the village administrator Byte…
题目链接 BZOJ3829 题解 设\(f[i]\)为从\(i\)父亲进入\(i\)之前开始计时,\(i\)的子树中最晚装好的时间 同时记\(siz[i]\)为节点\(i\)子树大小的两倍,即为从父亲进入并回到父亲的时间 那么有 \[f[i] = max\{C[i],f[to] + siz_{pre}\} + 1\] 我们只需给出一个合理的访问子树的顺序,以最小化\(f[i]\)的值 我们先考虑最后访问的一棵子树,记\(sum = \sum siz[to]\) 那么最后一棵子树的贡献 \[f[t…