
DZYlovesPhysics,andheenjoyscalculatingdensity.Almosteverythinghasdensity,evenagraph.Wedefinethedensityofanon-directedgraph(nodesandedgesofthegraphhavesomevalues)asfollows:where v isthesumofthevaluesofthenodes, e isthesumofthevaluesoftheedges.OnceDZYgotagraph G,nowhewantstofindaconnectedinducedsubgraph G' ofthegraph,suchthatthedensityof G' isaslargeaspossible.Aninducedsubgrap...

Artemhasanarrayof n positiveintegers.Artemdecidedtoplaywithit.Thegameconsistsof n moves.Eachmovegoeslikethis.Artemchoosessomeelementofthearrayandremovesit.Forthat,hegetsmin(a, b) points,where a and b arenumbersthatwereadjacentwiththeremovednumber.Ifthenumberdoesn'thaveanadjacentnumbertotheleftorright,Artemdoesn'tgetanypoints.Aftertheelementisremoved,thetwopartsofthearraygluetoge...

Atthechildren'sday,thechildcametoPicks'shouse,andmessedhishouseup.Pickswasangryathim.Alotofimportantthingswerelost,inparticularthefavoritesetofPicks.Fortunately,Picksrememberssomethingabouthisset S:itselementsweredistinctintegersfrom 1 to limit;thevalueof wasequalto sum;here lowbit(x) equals 2k where k isthepositionofthefirstoneinthebinaryrepresentationof x.Forexample, low...

OnChildren'sDay,thechildgotatoyfromDelayyyasapresent.However,thechildissonaughtythathecan'twaittodestroythetoy.Thetoyconsistsof n partsand m ropes.Eachropelinkstwoparts,buteverypairofpartsislinkedbyatmostonerope.Tosplitthetoy,thechildmustremoveallitsparts.Thechildcanremoveasinglepartatatime,andeachremoveconsumeanenergy.Let'sdefineanenergyvalueofpart i as vi.Thechildspend vf1 + ...

Pashahasapositiveinteger a withoutleadingzeroes.Todayhedecidedthatthenumberistoosmallandheshouldmakeitlarger.Unfortunately,theonlyoperationPashacandoistoswaptwoadjacentdecimaldigitsoftheinteger.HelpPashacountthemaximumnumberhecangetifhehasthetimetomakeatmost k swaps.InputThesinglelinecontainstwointegers a and k (1 ≤ a ≤ 1018; 0 ≤ k ≤ 100).OutputPrintthemaximumnumbert...
![「BZOJ1634」[Usaco2007 Jan] Protecting the Flowers 护花](http://hzwer.com/wp-content/themes/ly/image/image_post/2014-12-10_12-41-02.jpg)
DescriptionFarmerJohnwenttocutsomewoodandleftN(2<=N<=100,000)cowseatingthegrass,asusual.Whenhereturned,hefoundtohishorrorthatthecowswereinhisgardeneatinghisbeautifulflowers.Wantingtominimizethesubsequentdamage,FJdecidedtotakeimmediateactionandtransportthecowsbacktotheirbarn.EachcowiisatalocationthatisTiminutes(1<=Ti<=2,000,000)awayfromthebarn.Furthermore,whilewaitingfortra...
![「BZOJ1629」[Usaco2007 Demo] Cow Acrobats](http://hzwer.com/wp-content/themes/ly/image/image_post/2014-12-10_13-08-45.jpg)
DescriptionFarmerJohn'sN(1<=N<=50,000)cows(numbered1..N)areplanningtorunawayandjointhecircus.Theirhoofedfeetpreventthemfromtightropewalkingandswingingfromthetrapeze(andtheirlastattemptatfiringacowoutofacannonmetwithadismalfailure).Thus,theyhavedecidedtopracticeperformingacrobaticstunts.Thecowsaren'tterriblycreativeandhaveonlycomeupwithoneacrobaticstunt:standingontopofeachothertoform...

Youhaveanarray a[1], a[2], ..., a[n],containingdistinctintegersfrom 1 to n.Yourtaskistosortthisarrayinincreasingorderwiththefollowingoperation(youmayneedtoapplyitmultipletimes):choosetwoindexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) isaprimenumber);swaptheelementsonpositions i and j;inotherwords,youareallowedtoapplythefollowingsequenceofassignments: tmp = a[i], a...
近期评论