由于第一问所求的正方形必定包含在所有极大子矩形中,因此利用极大化思想可以在O(nm)的时间复杂度内求出最大子矩形,在枚举所有极大子矩形的过程中记录下最大的较短边长度,其平方即是第一问的答案。
简单地说一下在O(nm)的时间复杂度内枚举所有极大子矩形的算法,枚举棋盘上的每个棋子,先求出其向上、向左和向右最大可拓展到的位置,分别用h[i,j]、l[i,j]和r[i,j]记录。然后再枚举一次全部棋子,若h[i,j]>1则l[i,j]=max(l[i,j],l[i-1,j]),r[i,j]=min(r[i,j],r[i-1,j])。这样既可得到每个棋子在其向上拓展最高的前提下的极大子矩形,这样就包含了所有的极大子矩形。
R1134170 Accepted 100 From IwfWcf- P1351 FPC Vijos Dolphin 2009-2-5 9:54:59
chenlina20160622
回复删除coach factory outlet
coach outlet
michael kors handbags
louis vuitton outlet
louis vuitton handbags
nike factory outlet
cheap oakley sunglasses
jordan 6
gucci handbags
oakley sunglasses cheap
rolex watches
kate spade handbags
tiffany outlet
coach outlet online
oakley outlet
coach outlet
ray bans
coach factory outlet
adidas superstars
celine bags
polo ralph lauren outlet
michael kors outlet clearance
nike roshe run
polo outlet
cheap jordan shoes
replica watches
adidas running shoes
coach outlet store online clearances
timberland outlet
ralph lauren outlet
ralph lauren uk
polo ralph kids
designer handbags
nike outlet
jordan 8
michael kors outlet online
jeremy scott shoes
michael kors outlet
kevin durant shoes 7
louis vuitton handbags
as
cheap uggs
回复删除oakley vault
kate spade
oakley sunglasses
beats earbuds
ugg australia
oakley sunglasses
cheap jordans
james shoes
fake rolex
20170112caiyan
miami heat jersey
回复删除fitflops sale
christian louboutin outlet
ralph lauren uk
ralph lauren polo
ferragamo shoes
packers jerseys
mlb jerseys
converse shoes
回复删除jordan 13
golden goose sneakers
nike basketball shoes
adidas tubular
nike air max 270
lebron 17
kyrie 5 shoes
goyard
converse outlet
additional info Dolabuy Bottega Veneta More Info high quality designer replica browse around these guys YSL Dolabuy
回复删除have a peek at this site go to these guys dig this anonymous go to my blog Ysl replica handbags
回复删除