题目传送门 题目描述 输入输出格式 输入格式: 输出格式: 一行,包含一个整数,代表题目中所说的最小时间. 输入输出样例 样例输入 样例输出 提示 分析 我们设f[x]为遍历完以x为根的子树且将这棵子树上所有的电脑都安装完毕最终又回到x的最小安装时间 对于一棵子树,根节点所需要的安装时间自然是它本身的价值 那么各个子节点的价值可以直接拿来用吗?显然是不可以的 因为你从根节点遍历到子节点需要花费时间 所以这时就有遍历优先级的问题了 我们是先遍历安装时间最长的子树吗?这样是不可以的,比如下面这幅图…
题面 简化版题意: 有一棵 \(n\) 个点的树,有边权. 你初始在 \(1\) 号节点,你需要走遍整棵树为 \(2 \sim n\) 号点的居民分发电脑,但你的汽油只够经过每条边恰好两次. 一个居民拿到电脑后会马上开始安装软件, \(i\) 号点的居民安装需要 \(c_i\) 的时间.分发完成后你会回到 \(1\) 号点开始安装自己的软件. 求所有人的软件安装完成所需的最少时间. \(n ≤ 5 × 10^5\) 一眼树形\(\text{DP}\). 设\(dp_i\)表示遍历 \(i\) 的…
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 \(n\) 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 \(n\). The house no. 1 belongs to the village admi…
Problem 辣鸡bzoj权限题,洛谷链接 题意概要:一棵 \(n\) 个点有根树.\(Q\) 次询问给出一个 \(K\),回答遍历完整棵树所需最少操作次数.每次操作可以选择访问不超过 \(K\) 个未访问的点,且这些点的父亲必须在之前被访问过. Solution 一开始题意理解错了,以为同时段每个点都能扩展 \(k\) 次,然后就无耻地看了题解--但是有个证明网上都没写,这也正是写这篇博客的原因 大概意思是说,最优策略一定是先用 \(i\) 步取完前 \(i\) 层,然后选取剩下深度大于 \…