【解析1】线段树
[分析]
这道题数据M
没想到随手写的居然一次AC了,以后要杜绝这种坏习惯。
[代码]#include
#include
#include
#include
using namespace std;
const int M=200001;
const int L=INT_MAX;
const int P=INT_MIN;
int m,d,q[M][2]...
分类:
其他好文 时间:
2015-07-22 22:46:55
阅读次数:
162
题意是说在水平轴上有很多建筑物(没有宽度),知道每个建筑物的位置与高度。有m个查询,每次查询位置x所能看到的天空的角度。方法是将建筑与查询一起排序,从左往右计算一遍,如果是建筑物,则比较最后两个(当前的与队尾的)斜率与队尾两个的斜率比较,如果较小则入队,否则一直出队尾元素直至满足条件(因为斜率为负数...
分类:
其他好文 时间:
2015-07-20 23:17:48
阅读次数:
106
题意:求柱状图中最大矩形面积。
单调栈:顾名思义就是栈内元素单调递增的栈。每次插入数据来维护这个栈,如果当前需要插入的数据小于栈顶的元素,那就一直弹出栈顶的元素,直到满足当前需要插入的元素大于栈顶元素为止。可以容易求出某个数左边或右边,第一个大于或小于它的数,且复杂度是O(n)O(n)。
思路:容易先想到一个好的枚举方式:以当前柱状为扩展点,往左边和右边扩展,当遇到一个比当前柱状小的柱状时停止扩展,...
分类:
其他好文 时间:
2015-07-20 13:03:53
阅读次数:
100
【题目链接】:click here~~
【题目大意】:
A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may
have different heights. For exampl...
分类:
其他好文 时间:
2015-07-14 22:38:58
阅读次数:
276
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing
in a line and they are numbered from 1 to n from
left to right...
分类:
其他好文 时间:
2015-07-13 22:34:37
阅读次数:
175
Description
A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on ...
分类:
其他好文 时间:
2015-07-13 22:33:34
阅读次数:
165
Description
Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can ...
分类:
其他好文 时间:
2015-07-13 14:01:45
阅读次数:
135
题目描述Description 这个月的pku月赛某陈没有参加,因为当时学校在考试[某陈经常逃课,但某陈还没有强大到考试也可以逃掉的程度].何况,对于北大校赛,水牛通常是没有什么希望考得好的[事实上某陈最好成绩是仅A了一道题]. 某陈郁闷.接下来他又将沉浸在无穷尽的刷题中,每天面对各种颜色的St.....
分类:
其他好文 时间:
2015-07-10 22:00:58
阅读次数:
151
看到这到题,第一反应当然是暴搜一遍,但是数据较大,暴搜铁定过不了,自然想到进行优化,优化的方案很多,每个人的思路可能不同,在这里我的思路仅供参考。 我的想法是用单调队列、单调栈,当然简单的单调队列、单调栈只适用于一行数据,对于这道题要进行一定的组合和变换。根据题目的介绍,可以大致总结出以下信息:第一...
分类:
其他好文 时间:
2015-07-09 00:44:15
阅读次数:
134
N (1 i (1 i
Each monkey is looking to his left toward those with higher index numbers. We say that monkey i "looks up" to monkey j if i ij. For each monkey i, we would like to know the index of th...
分类:
其他好文 时间:
2015-07-06 21:50:51
阅读次数:
153