笛卡尔树
霜刃未曾试
这个作者很懒,什么都没留下…
展开
-
poj 2559 & hdu 1506 Largest Rectangle in a Histogram 笛卡尔树
题目:http://poj.org/problem?id=2559题意:有n个高度不等的矩形,问这些矩形的所能组成的新矩形的最大面积思路:单调栈,dp都可以做,笛卡尔树也可以做。按出现的次序做val,矩形高度做pri,然后O(n)建小顶堆的笛卡尔树,可以惊奇的发现,对于树上的每个节点,以它作为高的新矩形的面积就是以它为根的子树大小乘以它的高,为什么会这样?仔细想想构建小顶堆的笛卡尔树过程,就明白了#原创 2017-08-04 15:07:06 · 295 阅读 · 0 评论 -
ZOJ 2243 & POJ 1785 Binary Search Heap Construction 笛卡尔树 || 单调栈
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1243 http://poj.org/problem?id=1785题意:给一个数nn,然后有nn对形如label/prioritylabel/priority的二元组,用这nn对二元组建一个treaptreap,对labellabel满足二叉搜索树的性质,对priorit原创 2017-08-04 17:04:25 · 431 阅读 · 0 评论 -
POJ 2796 Feel Good 单调栈或者笛卡尔树
题目:http://poj.org/problem?id=2796题意:给定一个长度为nn的数组,一个区间的值为这个区间的中所有值的和与最小值的乘积,求区间的最大值,并输出区间的左右端点思路:明显的单调栈,笛卡尔树也可以做#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespa原创 2017-08-04 19:51:13 · 470 阅读 · 0 评论