E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
leetcode#单调栈
POJ-2796-Feel Good-萌萌的
单调栈
给一数组设数组参考值为 该区间和乘上区间内最小值求数组内 最大的参考值 用的也是
单调栈
的思想做的这里区间和先用前缀和预处理好了;ps:看讨论区有人用什么rmq、dp+树状数组做的。
viphong
·
2015-08-26 09:00
POJ-2559-Largest Rectangle in a Histogram-
单调栈
一个可以优化的地方就是n次枚举中,有很多次是可以省略掉的,用到了
单调栈
的思想,就节省掉了不必要的很多遍历。。。
viphong
·
2015-08-25 22:00
jsoi2008最大数bzoj1012
题意就是维护一个队列,支持查询最近插入的L个数里面的最大值和插入,所以我们可以使用
单调栈
,单调队列之类的写,线段树平衡树当然可以只不过我们需要在比赛中尽量的节省时间,当然平常我们也可以练习一下,线段树很直观
BPM136
·
2015-08-25 11:00
数据结构
线段树
单调栈
单调队列
hdu 3738 The Sweat Shop
单调栈
加贪心思想
TheSweatShopTimeLimit:2000/1000MS(Java/Others) MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):90 AcceptedSubmission(s):28ProblemDescriptionManypeoplespendthierlivesinsweatshopinChina.Th
wust_ZJX
·
2015-08-25 09:00
Feel Good(
单调栈
(比之前更加完善的模板))
Link:http://poj.org/problem?id=2796FeelGoodTimeLimit:3000MSMemoryLimit:65536KTotalSubmissions:11341Accepted:3125CaseTimeLimit:1000MSSpecialJudgeDescriptionBillisdevelopinganewmathematicaltheoryforhuma
林下的码路
·
2015-08-23 20:10
ACM
数论
poj
STL
hdu4252
单调栈
给一些从正面看得到的楼的高度,问最少可能有多少楼。importjava.io.BufferedInputStream; importjava.io.BufferedReader; importjava.io.IOException; importjava.io.InputStream; importjava.io.InputStreamReader; importjava.io.OutputStr
u013491262
·
2015-08-19 22:00
POJ 2823 Sliding Window
单调队列和
单调栈
性质一样,内部元素严格单调递增排列。单调队列的一个典型应用就是本题的求滑动窗口的最值问题。那么怎么求解呢?首先,由于长度为k,因此我们可以先把0到k-1的下标全部试图入队列。
u014800748
·
2015-08-16 13:00
单调队列
POJ 2559 Largest Rectangle in a Histogram
1.题目描述:点击打开链接2.解题思路:本题利用
单调栈
解决。
单调栈
是满足从栈顶到栈底,元素大小严格递增或者严格递减的栈。
u014800748
·
2015-08-16 11:00
单调栈
扫描与维护
BZOJ 3791 作业 DP
单调栈
,单调队列各种一顿上,也转移不了。题太水,我太弱!f[i][j][p]前i个分j段的最后一段的值代码:#includ
wzq_QwQ
·
2015-08-13 19:00
dp
栈
91
单调栈
从某一个元素开始,以该元素为最值,一直向前延伸找最优值(若需要两个方向的解,则再从右往左扫描一遍即可).每个元素最多进出栈一次,复杂度O(n)应用:①栈维护上升序列求解不小于i的最大区间: 题目链接: hdu1506LargestRectangleinaHistogram 求直方图能覆盖的最大矩阵的面积,则矩阵的高度为其中直方图中的最小高度。对某个直方图h[i],向两边搜寻不小于该高度的区间。以左
ww32zz
·
2015-08-06 13:00
数据结构
栈
Codeforces 547B - Mike and Feet (
单调栈
)
res[x]表示长度为x区间的答案,那么如果i>j,res[i] #include #include #include #defineLLlonglong #include usingnamespacestd; intN; inta[200005]; intl[200005]; intr[200005]; intres[200005]; intmain(){ scanf("%d",&N); fo
Baoli1008
·
2015-08-04 09:00
单调栈
POJ 3250 Bad Hair Day(
单调栈
)
单调栈
其实很简单,,不懂的阔以先移步了解一下#include #include usingnamespacestd; //本题要求每头牛看到多少头牛的和,, //可以转化为每头牛被多少头牛看到的和。
acraz
·
2015-08-03 17:00
BZOJ 3039 玉蟾宫 最大子矩阵 算♂法②
题意:链接方法:最大子矩阵之算♂法②解析:首先这道题
单调栈
DP是肯定能过的,但是一点都不高端!什么年代了还用这种方式!所以如何彰显自己是个高端的人呢?悬线法能满足你的需求!什么是悬线法?
wzq_QwQ
·
2015-07-31 11:00
POJ 3250 Bad Hair Day(
单调栈
)
用一个栈来维护当前的递减序列,从左到右遍历,对于每个数cur,从栈顶开始把所有小于等于cur的数字都出栈,然后剩下的就都是可以看到cur的牛,并且保证了栈中的单调性。每次遍历对弹栈后的长度求和即可。代码:#include #include #include #include #include usingnamespacestd; #defineLLlonglong intN; intq[80005
Baoli1008
·
2015-07-22 12:00
单调栈
poj 2059
单调栈
单调栈
:顾名思义就是栈内元素单调递增的栈。每次插入数据来维护这个栈,如果当前需要插入的数据小于栈顶的元素,那就一直弹出栈顶的元素,直到满足当前需要插入的元素大于栈顶元素为止。
jibancanyang
·
2015-07-20 10:00
数据结构-单调栈
POJ 2559 Largest Rectangle in a Histogram(
单调栈
)
【题目链接】:clickhere~~【题目大意】:Ahistogramisapolygoncomposedofasequenceofrectanglesalignedatacommonbaseline.Therectangleshaveequalwidthsbutmayhavedifferentheights.Forexample,thefigureontheleftshowsthehistogr
u013050857
·
2015-07-14 21:00
poj
单调栈
一些POI的简单题解(2)
1436:Poi2003Trinomial直接上lucas1510:[POI2006]Kra-TheDisks
单调栈
,看被卡在哪里1529:[POI2005]skaPiggybanks很明显,是个有向图
IED98
·
2015-07-14 12:05
POJ 3250 Bad Hair Day(
单调栈
)
Description一群高度不完全相同的牛从左到右站成一排,每头牛只能看见它右边的比它矮的牛的发型,若遇到一头高度大于或等于它的牛,则无法继续看到这头牛后面的其他牛。给出这些牛的高度,要求每头牛可以看到的牛的数量的和。Input第一行为牛数n,之后n行每行一个整数表示牛的高度Output输出每头牛可以看到的牛的数量SampleInput610374122SampleOutput5Solution
V5ZSQ
·
2015-07-13 08:00
bzoj4172: 弹珠
思路:先用splay处理出弹珠序列,然后就是斜率优化了首先有f[i]=-a[i]*p[j]+q[j]稍微变形得q[j]=a[i]*p[j]+f[i]用
单调栈
维护上凸壳,询问时二分,然后就没有然后了。
thy_asdf
·
2015-07-11 15:00
斜率优化
splay
7.10省队集训梦工厂
思路:题面真心长....
单调栈
维护上凸壳即可设sum[i]为前i道工序的复杂度之和,g[i]为第i个快乐最早开始生产的时间。
thy_asdf
·
2015-07-10 15:00
斜率优化
Largest Rectangle in a Histogram(
单调栈
) 分类: 数据结构 2015-07-07 23:23 2人阅读 评论(0) 收藏
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 th
·
2015-07-07 23:00
数据结构
POJ 3250 Bad Hair Day 模拟
单调栈
BadHairDayTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 14989 Accepted: 4977DescriptionSomeofFarmerJohn's N cows(1≤ N ≤80,000)arehavingabadhairday!Sinceeachcowisself-consciousabouthermessyhai
wust_ZJX
·
2015-07-06 19:00
猴子向右看,FOJ上某题
单调栈
N(1 #include #include #include #include #include #include #include #defineN100009 usingnamespacestd; inta[N]; intmain() { intn; while(~scanf("%d",&n)) { for(inti=1;i=1;i--)//找右边第一个比a[i]小的位置 { inttt=
wust_ZJX
·
2015-07-06 19:00
【
单调栈
】POJ 2559 Largest Rectangle in a Histogram
利用
单调栈
找到木块左右的第一个比它矮的然后遍历一遍找到最大面积。。。因为是水题(?)所以就这样吧。。。
q79186954
·
2015-07-06 18:00
数据结构
栈
ACM
浅谈单调队列、
单调栈
初谈这个话题,相信许多人会有一种似有所悟,但又不敢确定的感觉。没错,这正是因为其中“单调”一词的存在,所谓单调是什么,学过函数的people都知道单调函数或者函数的单调性,直白一点说单调就是一直增或一直减。例如:1,3,5,9就是一个单调增数列,数列中不存在后一个数比前一个数小的现象。那么同样,在这里谈到的话题也有类似特点。
·
2015-07-05 17:00
队列
BZOJ3190 [JLOI2013]赛车(
单调栈
+半平面交)
数形结合思考:画出v-t图像,若一条直线在一、四象限有不被覆盖的部分,它代表的车就可以领跑 将直线按他们的斜率从小到大排序后,要维护一个下凸壳,由于一条新加入的直线,能覆盖的左边的直线是从右向左单调的,所以用
单调栈
来维护
cjk_cjk
·
2015-06-15 21:00
单调栈
半平面交
数形结合
Nanami's Digital Board(DP+ 双指针/
单调栈
)
B.Nanami'sDigitalBoardtimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputNanamiisanexpertatplayinggames.Thisday,Nanami'sgoodfriendHajimeinvitedhertowatchagameof
kalilili
·
2015-06-15 15:00
SGU133 Border
SGU133Border题目大意给出一维数轴上的N个区间,问有多少个区间被其他某个区间严格覆盖算法思路对区间右端点排序,扫描并维护左端点的
单调栈
,答案等于出栈元素的个数时间复杂度:O(NlogN)代码/
u010929036
·
2015-06-14 14:00
sgu
Codeforces548D:Mike and Feet(
单调栈
)
MikeisthepresidentofcountryWhat-The-Fatherland.Thereare n bearslivinginthiscountrybesidesMike.Allofthemarestandinginalineandtheyarenumberedfrom 1 to n fromlefttoright. i-thbearisexactly ai feethigh.Ag
libin56842
·
2015-06-12 17:00
codeforces
POJ - 2559 Largest Rectangle in a Histogram
单调栈
单调栈
的练手题,主要内容就是把每一个矩形右界限和左界限算出来比较大小就OK了。
lljjccsskk
·
2015-06-09 09:00
POJ3415:Common Substrings(后缀数组+
单调栈
)
DescriptionAsubstringofastring T isdefinedas:T(i, k)=TiTi+1...Ti+k-1,1≤i≤i+k-1≤|T|.Giventwostrings A, B andoneinteger K,wedefine S,asetoftriples(i, j, k):S ={(i, j, k)| k≥K, A(i, k)=B(j, k)}.Youaretog
libin56842
·
2015-06-07 22:00
poj
poj 3250 Bad Hair Day (
单调栈
)
BadHairDayTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 14883 Accepted: 4940DescriptionSomeofFarmerJohn's N cows(1≤ N ≤80,000)arehavingabadhairday!Sinceeachcowisself-consciousabouthermessyhai
u014253173
·
2015-06-03 22:00
算法
栈
ACM
单调栈
#305 (div.2) D. Mike and Feet
看好多人用
单调栈
解决的。
u014800748
·
2015-05-28 13:00
codeforces
思维题
扫描法
等价转换
#
leetcode#
Sort Colors
http://blog.csdn.net/linhuanmars/article/details/24286349Codeganker大神的第二种思路是怎么想到的?...。。。。跑了几个例子想明白了,遇到0或者1,就依次赋值,赋值的顺序总会使得0在最左边,然后是1,然后是2有一个地方需要注意: publicclassSolution{ publicvoidsortColors(int[]nums)
ChiBaoNeLiuLiuNi
·
2015-05-28 11:00
LeetCode
Codeforces Round #305 (Div. 2)D---Mike and Feet(
单调栈
)
MikeisthepresidentofcountryWhat-The-Fatherland.TherearenbearslivinginthiscountrybesidesMike.Allofthemarestandinginalineandtheyarenumberedfrom1tonfromlefttoright.i-thbearisexactlyaifeethigh.Agroupofbea
Guard_Mine
·
2015-05-27 20:00
单调栈
poj2796Feel Good
单调栈
//一个长度为n的序列,对于一个区间中的value为这个区间的最小值乘上这个区间的所有数的和//这就是找每一个点,找以其为最小值的区间//显然直接暴力法找必然超时//可以开一个单调递增栈,对于每一个新元素a[i]//当前值小于等于栈顶元素,表示以栈顶元素为最小值的区间的右端是i//栈顶元素a[j]出栈,由于是单调递增栈,新的栈顶元素a[k]必然小于a[j],故需要更新新的栈顶元素的//右端值,新元
cq_pf
·
2015-05-26 20:00
Codeforces Round #172 (Div. 1) BMaximum Xor Secondary
单调栈
//给一个长度为N的个不相同的序列,找出所有区间中最大值和第二大数的异或值最大的值//对于所有区间只需要找其最大值和第二大数,所以对于很多区间的结果是重复的//对于每一个数,它起作用的区间只有在其前面最多只有一个数是大于它的//可以用一个单调递减栈来做,对于每一个新的数a[i],在它前面第一个大于它的数a[j]//和第二个大于它的数之间的数到a[i]的区间的数的最大值和第二大数为a[j],a[i]
cq_pf
·
2015-05-26 19:00
POJ2452---Sticks Problem(
单调栈
+RMQ,方法不够优秀)
DescriptionXuanxuanhasnsticksofdifferentlength.Oneday,sheputsallhersticksinaline,representedbyS1,S2,S3,…Sn.AftermeasuringthelengthofeachstickSk(1FileName:POJ2452.cpp>Author:ALex>Mail:
[email protected]
Guard_Mine
·
2015-05-15 18:00
RMQ
单调栈
BZOJ 1012: [JSOI2008]最大数maxnumber
单调栈
单调栈
1012:[JSOI2008]最大数maxnumberTimeLimit: 3Sec MemoryLimit: 162MBSubmit: 4988 Solved: 2252[Submit][Status
u012797220
·
2015-05-12 23:00
fzu2190---非提的救赎 (
单调栈
)
ProblemDescription正如你所知道从前有一个人叫s_sin,她拥有着坐拥三千舰狼的梦想!然而天不遂人愿当她踏进hentaicollection的大门之后,现实让她领略到了无情。身为一个坚强的妹子,她知道即使出门大破,即使十一连抽全是R,也要坚信着“玄不救非,氪不改命”,而自己是一个欧白这样最初的信仰!有一天s_sin率领着她的舰狼们到达了某海峡,以一个N*M的矩阵表示,每一个元素为w
Guard_Mine
·
2015-05-11 18:00
单调栈
hdu4193---Non-negative Partial Sums(单调队列 or
单调栈
)
ProblemDescriptionYouaregivenasequenceofnnumbersa0,…,an-1.Acyclicshiftbykpositions(0FileName:hdu4193.cpp>Author:ALex>Mail:
[email protected]
>CreatedTime:2015年05月11日星期一14时13分22秒***********************
Guard_Mine
·
2015-05-11 15:00
单调栈
hdu1505---City Game(
单调栈
)
ProblemDescriptionBobisastrategygameprogrammingspecialist.Inhisnewcitybuildinggamethegamingenvironmentisasfollows:acityisbuiltupbyareas,inwhichtherearestreets,trees,factoriesandbuildings.Thereisstills
tokers
·
2015-05-10 22:01
hdu
算法
hdu1505---City Game(
单调栈
)
ProblemDescriptionBobisastrategygameprogrammingspecialist.Inhisnewcitybuildinggamethegamingenvironmentisasfollows:acityisbuiltupbyareas,inwhichtherearestreets,trees,factoriesandbuildings.Thereisstills
Guard_Mine
·
2015-05-10 22:00
单调栈
POJ3494---Largest Submatrix of All 1’s(
单调栈
)
DescriptionGivenam-by-n(0,1)-matrix,ofallitssubmatricesofall1’swhichisthelargest?Bylargestwemeanthatthesubmatrixhasthemostelements.InputTheinputcontainsmultipletestcases.Eachtestcasebeginswithmandn(1≤
Guard_Mine
·
2015-05-08 14:00
单调栈
POJ2082---Terrible Sets(
单调栈
)
DescriptionLetNbethesetofallnaturalnumbers{0,1,2,…},andRbethesetofallrealnumbers.wi,hifori=1…naresomeelementsinN,andw0=0.DefinesetB={|x,y∈Randthereexistsanindexi>0suchthat0|x,y∈Randx0FileName:POJ2082.
Guard_Mine
·
2015-05-07 20:00
单调栈
POJ2796---Feel Good(前缀和+
单调栈
维护)
DescriptionBillisdevelopinganewmathematicaltheoryforhumanemotions.Hisrecentinvestigationsarededicatedtostudyinghowgoodorbaddaysinfluentpeople’smemoriesaboutsomeperiodoflife.AnewideaBillhasrecentlydeve
tokers
·
2015-05-07 19:04
POJ
之旅
算法
POJ2796---Feel Good(前缀和+
单调栈
维护)
DescriptionBillisdevelopinganewmathematicaltheoryforhumanemotions.Hisrecentinvestigationsarededicatedtostudyinghowgoodorbaddaysinfluentpeople’smemoriesaboutsomeperiodoflife.AnewideaBillhasrecentlydeve
Guard_Mine
·
2015-05-07 19:00
单调栈
POJ3250---Bad Hair Day(
单调栈
)
DescriptionSomeofFarmerJohn’sNcows(1≤N≤80,000)arehavingabadhairday!Sinceeachcowisself-consciousabouthermessyhairstyle,FJwantstocountthenumberofothercowsthatcanseethetopofothercows’heads.Eachcowihasasp
Guard_Mine
·
2015-05-07 19:00
单调栈
hdu1506---Largest Rectangle in a Histogram(
单调栈
)
ProblemDescriptionAhistogramisapolygoncomposedofasequenceofrectanglesalignedatacommonbaseline.Therectangleshaveequalwidthsbutmayhavedifferentheights.Forexample,thefigureontheleftshowsthehistogramthatc
Guard_Mine
·
2015-05-07 18:00
单调栈
(
单调栈
)
Maybeyouthinkthisproblemisaboutgirlsandladies.Butyou’rewrong.‘Leftdress’means‘Eyesleft’.It’susedinarmedforces.Itwillmakeasquaremoreorderly.Nowseveralsoldiersstandinaline.Theyareindiffientheightorthesa
Guard_Mine
·
2015-05-07 18:00
单调栈
上一页
49
50
51
52
53
54
55
56
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他