题意:有n个房子,这些房子被n-1条道路连接,有一些运动员从一个房子为起点尽可能跑最远的距离且不能通过一条道路超过两次,这些运行员不能选择同样的起点,这些运动员跑的最远距离和最近距离的差值不能超过Q,这些运行员的起点房间编号都是连续的,问最多可以选择多少个运动员跑步? 分析:就是给出一颗树形图,先用dp求出每个点所能经过的最远距离,然后用rmq求区间最值,最后用单调队列询问结果(n)的复杂度 #include"stdio.h" #include"string.h"…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4123 题目大意: 给一棵树,n个节点,每条边有个权值,从每个点i出发有个不经过自己走过的点的最远距离Ma[i],有m个询问,每个询问有个q,求最大的连续节点区间长度ans,使得该区间内最大的M[i]和最小的M[j]之差不超过q. 解题思路一: 这套题目好卡时间. 树形dp+二分+单调队列,几个基本的知识点杂糅在一起. 先用树形dp求出从任意一点i出发的Ma[i].两遍dfs,第一遍求出每个节点为根…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4123 参考博客:两种解法-树形dp+二分+单调队列(或RMQ)-hdu-4123-Bob’s Race - cc_again的专栏 - CSDN博客  https://blog.csdn.net/cc_again/article/details/12011757 题意:给出一棵有n个点的树,每条树边都有一个权值,对于每一个点,它都有一个编号,我们取它到其他点的最大距离记录下来,现在q个询问,每个询问…
http://acm.hdu.edu.cn/showproblem.php? pid=4123 Problem Description Bob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads in his village. Each road connects two houses,…
                                     Largest Rectangle in a Histogram 这么经典的题硬是等今天碰到了原题现场懵逼两小时才会去补题...废话不多说: 题意:截取一个矩形使其面积最大,随你怎么截,反正面积要最大.输出最大面积,注意爆int. 思路:dp或单调队列.核心思路是从一个小矩形往两边扩散,分别找两边第一个小于这个矩形的位置,其中面积就是这个小矩形与区间长度的乘积,我们预处理出所有的小矩形的这两个端点值,然后扫一遍即可更新到最…
题目: Bob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads in his village. Each road connects two houses, and all houses are connected together. To make the race more in…
题目链接 Problem Description Bob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads in his village. Each road connects two houses, and all houses are connected together. To…
One hundred layer Problem Description   Now there is a game called the new man down 100th floor. The rules of this game is: 1.  At first you are at the 1st floor. And the floor moves up. Of course you can choose which part you will stay in the first…
Bob’s Race Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 378   Accepted: 119 Description Bob wants to hold a race to encourage people to do sports. He has got trouble in choosing the route. There are N houses and N - 1 roads in his vil…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3507 题目大意:给你n个数,然后问你怎么分割当前的这n个数位那几组,使得每一组的权值加起来最大.每一组权值的计算方法在题目上说了. 具体思路: 一开始打了一波两重for循环的,一直求一个tile,但是wa了.然后就学了斜率优化的方法 https://www.cnblogs.com/ka200812/archive/2012/08/03/2621345.html 就是把表达式转换成斜率类型的表达式,然…