本题有一种很形象的解法,在[l,r]上种树可以表示为在l处添加一个左括号,在r处添加一个右括号。求[l,r]之间种的树的种类数即[1,r]中左括号的数量-[1,l-1]中右括号的数量。而求和操作可以利用树状数组在O(logn)的时间复杂度内完成,所以总的时间复杂度是O(mlogn)。
注意在种树时要维护的数组变量的元素的下标在计算中有可能会超过word的范围,要用longint。之前没发现这一点,以为是Vijos对writeln处理的bug导致最后两个点超时多交了几次。
R1185426 Accepted 100 From IwfWcf- P1448 FPC Vivid Puppy 2009-3-23 23:50:35
toms outlet, http://www.tomsoutlet-stores.com/
回复删除nike roshe, http://www.nikerosherunshoes.co.uk/
prada handbags, http://www.pradahandbagsoutlet.co.uk/
soccer jerseys, http://www.cheapsoccerjersey.net/
michael kors outlet store, http://www.michaelkorsoutlet-store.us.com/
true religion jeans, http://www.truereligionjeansoutlets.us.com/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
nike free 5, http://www.nikefree5.us/
louis vuitton bags, http://www.louisvuittonbag.us.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
chanel handbags, http://www.chanelhandbags-outlet.us.com/
louis vuitton handbags, http://www.louisvuittonhandbag.us/
louis vuitton outlet, http://www.louisvuittonoutlet.in.net/
ghd hair straighteners, http://www.ghdhairstraightenerssale.co.uk/
nba jerseys, http://www.nbajerseys.us.com/
coach outlet, http://www.coachoutletstores.com.co/
true religion jeans, http://www.truereligionjeanscanada.com/
swarovski crystal, http://www.swarovskicrystals.co.uk/
mbt shoes, http://www.mbtshoesoutlet.us.com/
michael kors handbags, http://www.michaelkorshandbags.in.net/
chanel handbags, http://www.chanelhandbagsoutlet.in.net/
michael kors outlet online, http://www.michaelkorsoutletonline.in.net/
polo ralph lauren, http://www.poloralphlauren.us.org/
the north face clearance, http://www.thenorthfaceclearances.us.com/
jordan shoes, http://www.jordan-shoes.us.com/
beats by dr dre, http://www.beatsbydrdre-headphones.us.com/
the north face uk, http://www.thenorthfaces.org.uk/
1003maoqiuyun
red sole shoes
回复删除louboutin outlet
cheap jordans
cheap jordan shoes
Jordan 11 Retro 72 10
Air Jordan 4 Alternate 89
kate spade outlet
kate spade purses
Michael Kors Store
2015 michael kors outlet
Cheap Michael Kors
michael kors selma
michael kors bracelet
michael kors sale
michael kors outlet online
michael kors Premium Outlets
michael kors factory outlet
michael kors outlet online store 49.00 outlet
jordans for sale
jordan retro 7
kobe 9
kobe shoes
nike air max 90
nike air max thea
nike free 3.0
nike free 5.0 womens
christian louboutin uk
black christian louboutin
mbt Shoes
mbt shoes sale
fitflops on sale
fitflop sandals
ığdır
回复删除maraş
afyon
bandırma
hakkari
Z60