
单调栈
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
*【HDU - 1506】【POJ - 2559】Largest Rectangle in a Histogram(单调栈或动态规划)
题干: 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 figu...原创 2018-07-16 23:44:49 · 235 阅读 · 0 评论 -
【CodeForces - 602D】Lipshitz Sequence(思维,单调栈,斜率单调性)
题干: A functionis called Lipschitz continuous if there is a real constantKsuch that the inequality|f(x) - f(y)| ≤ K·|x - y|holds for all. We'll deal with a more... discrete version of this term....原创 2019-08-25 14:26:45 · 269 阅读 · 0 评论 -
【2019牛客暑期多校训练营(第一场) - A】Equivalent Prefixes(单调栈,tricks)
题干: 链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m where RMQ(w,l,r...原创 2019-07-22 21:00:46 · 370 阅读 · 0 评论 -
【计蒜客 - 2019南昌邀请赛网络赛 - I】Max answer(单调栈,RMQ)
题干: Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to fin...原创 2019-04-20 20:31:28 · 419 阅读 · 0 评论 -
【牛客 - 551D】CSL 的字符串(单调栈,思维)
题干: CSL 以前不会字符串算法,经过一年的训练,他还是不会……于是他打算向你求助。 给定一个字符串,只含有可打印字符,通过删除若干字符得到新字符串,新字符串必须满足两个条件: 原字符串中出现的字符,新字符串也必须包含。 新字符串中所有的字符均不相同。 新字符串的字典序是满足上面两个条件的最小的字符串。 输入描述: 仅一行,有一个只含有可打印字符的字符串 s。 |s|≤105|s|...原创 2019-04-01 16:28:32 · 443 阅读 · 0 评论 -
*【牛客 - 318B】签到题(单调栈,水题)
题干: 众所周知,IG是英雄联盟S8世界总决赛冠军,夺冠之夜,数亿人为之欢呼! 赛后某百分百胜率退役ADC选手的某表情包意外走红,某苟会长看到此表情包也想模仿。 于是有n个友爱的萌新决定每人都送会长一根长为ai面包。(数据保证没有面包的长度相等) 会长无聊时把面包摆成一排,他惊人地发现他喜欢这样一类区间,区间[i, j]满足条件: 区间里的面包没有比左端点i号面包短的,同时也没有比右端点j号...原创 2018-12-24 09:12:37 · 441 阅读 · 0 评论 -
【Codeforces 631C 】Report(单调栈,思维模拟)
题干: Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one in...原创 2018-11-01 19:08:21 · 488 阅读 · 0 评论 -
【51Nod - 1215 】数组的宽度 (单调栈 或 分治 或 单调队列,算贡献,需去重)
题干: N个整数组成的数组,定义子数组aii..ajj的宽度为:max(ai..aj) - min(ai..aj),求所有子数组的宽度和。 Input 第1行:1个数N,表示数组的长度。(1 <= N <= 50000) 第2 - N + 1行:每行1个数,表示数组中的元素(1 <= Aii <= 50000) Output 输出所有子数组的宽度和。 Samp...原创 2018-10-02 18:06:24 · 318 阅读 · 0 评论 -
【51Nod - 1279】 扔盘子(思维)(on-p会超时)
题干: 有一口井,井的高度为N,每隔1个单位它的宽度有变化。现在从井口往下面扔圆盘,如果圆盘的宽度大于井在某个高度的宽度,则圆盘被卡住(恰好等于的话会下去)。 盘子有几种命运:1、掉到井底。2、被卡住。3、落到别的盘子上方。 盘子的高度也是单位高度。给定井的宽度和每个盘子的宽度,求最终落到井内的盘子数量。 如图井和盘子信息如下: 井:5 6 4 3 6 2 3 盘子:2...原创 2018-08-05 15:56:42 · 266 阅读 · 0 评论 -
【POJ - 3494】Largest Submatrix of All 1’s(加一点思维后化成 单调栈)
题干: Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements. Input The input contains multiple test cases. E...原创 2018-07-20 00:02:26 · 399 阅读 · 0 评论 -
【HDU - 3410 】 Passing the Message(单调栈)
题干: What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten are prepared to have an excursion. Before kicking off, teacher Liu tells them to stand in a row. ...原创 2018-07-24 16:52:18 · 299 阅读 · 0 评论 -
*【POJ - 2796】 Feel Good (前缀和优化+单调栈维护)
题干: Feel Good Time Limit:3000MS Memory Limit:65536K Total Submissions:12409 Accepted:3484 Case Time Limit:1000MS ...原创 2019-05-09 21:51:09 · 407 阅读 · 0 评论 -
【POJ - 3250 】Bad Hair Day (单调栈)
题干: 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 see the to...原创 2018-07-16 23:45:53 · 301 阅读 · 0 评论 -
【2019牛客暑期多校训练营(第二场) - H】Second Large Rectangle(单调栈,全1子矩阵变形)
题干: 链接:https://ac.nowcoder.com/acm/contest/882/H 来源:牛客网 题目描述 Given a N×MN \times MN×M binary matrix. Please output the size of second large rectangle containing all "1"\texttt{"1"}"1". Containing...原创 2019-08-21 14:15:56 · 249 阅读 · 0 评论