Anda di halaman 1dari 4

Veryshortanalysis.Feelfreetodiscussandaskback.

ProblemA:
Setter:ShahriarManzoor
AlternateWriter:DerekKisman
Category:Adhoc
Difficulty:Easy
Solution:Oneoftheveryinterestingproblemstatements.Onewaytosolvethisproblemisto
noticethat,difficultyisonly110.So,youcanmakeanarraycount[difficulty][leaked/not
leaked].Thenyoucanrun(d=10)^2tocountnumberofpairs.Buttherearemanydifferent
solutionspossible.Forexample,youcandothelaterpartinO(d=10).Oryoucankeeptwo
listsforleakedandnotleaked,sortthembydifficulty,thendolinesweeping.Andsoon.

ProblemB:
Setter:ShahriarManzoor
Alternate:MonirulHasan,MuhammedHedayet
Category:Adhoc
Difficulty:Easy
Solution:Easyproblem.Keepafewarrays.Firstone:month>numberofdays.Secondone:
dayname>daynumber(say:monday=0,tuesday=1).Itwillhelpyouifyoukeepthese
daynumbersconsecutiveoverweekdaysandstartfrom0.Because,nowyoucanincreaseday
numberandgetthenextday(withmod7).Soyoujustloopfornumberofdaysofthemonth
andcountnumberofweekends.

ProblemC:
Setter:ShipluHawlader
Alternate:MdMahbubulHasan
Category:Graph,Datastructure,Unionfind,Lca.
Difficulty:Medium
Solution:Niceproblem.First,weneedtofindoutAiandBifornontreeedges.Thecostscanbe
increasedindefinitely.ButcanbedecreaseduntilitchangestheMST.Soitisthehighestcost
treeedgebetweentwonodesofthisnontreeedge.Whichcanbeeasilyfoundbymodifiedlca.
NowweneedtofindAiandBifortreeedges.Firsttheycanbedecreasedindefinitely.Nowhow
muchwecanincrease?Wellforthatweneedtofindminimumweightnontreeedgesthatcover
thisedge.Letsspliteverynontreeedgesintotwoedgesoftypelcaend.Nowherecomesthe
trickysolutionwithunionfind.Sortthenontreesplitedgesaccordingtotheircosts.Takeone
byonefromlowesttolargest.Foreachonemergeallthenodesinthechainoftreeedges
insidetherangeofthisnontreeedges.Whenyoupickanewnonmergedtreeedgeupdateits
answer.AsIsaiditisabittricky:)

ProblemD:
Setter:MuhammedHedayet
Alternate:ShahriarManzoor

Category:Adhoc
Difficulty:Easy
Solution:Theansweriscountofminimumappearingcharacterinthestring.Why?How?Itis
easytoprovenecessity,butsufficiencymaybedifficult.Trytoprovebycontradiction,ormaybe
takealeapoffaith:)

ProblemE:
Setter:ShahriarManzoor
Alternate:DerekKisman
Category:Math
Difficulty:EasyMedium
Solution:First,letstrytofindoutwhichnumberscancontributetothesetwherelcmisN.They
aredivisorsofN.AllofthedivisorsofNcancontributetothisset.Andnoneothernumberscan
contribute.SoMSLCM(N)issumofNsdivisor.However,itturnsoutthatthisgivesTLE.Tobe
honest,ifIwerecontestantIwouldhavetriedinthiswayandcouldnotbelievethishappened.
Butitistruethatsomeconstantoptimizationcodetakes~1swhilethiscoderuns>5s.Sowe
needtodosomeoptimization.Oneoftheoptimizationsthatpopupinmymindis,Iwouldsend
atableof:2e7/1000=2e4numbersandthenpercaseweneedtocomputesumofdivisorsof
1000numbers,whichshouldnotbeverydifficult.IamnotsureifthatpassesTL.Anotherway
canbe,comeupwithsomemathematicalformulaandruntheinnerlooponlyforprime.Thatis,
foreachprimep,gotoallofitsmultiple,anddosomecomputation.Andjudgesolutiondoesso.
Thereareothersolutionsaswellwithoutanyprecomputation.Foreveryquerythendosome
sqrt(N)loopandsomemathematicalformulainside.SorrythatIcouldnotbeofmuchhelpwith
detailedmathematicalformula.

ProblemF:
Setter:AnindyaDas
Alternate:ShipluHawlader,MdMahbubulhasan
Category:Adhoc
Difficulty:Medium
Solution:Foreveryquerydependingonnumber>=or<hwecanreplacethenumberswith+1
or1.Thentheproblemturnsouttobe:findoutlargestrectanglewithnonnegativesum.The
trickistolimittworowsandsolveforthestrip.Oractually,wecanconvertthisstripto1darray
andthustheproblemistosolvefor1d:findthemaximumlengthwherethesumis
nonnegative.Onewaytosolveis,O(nlogn).ButmysolutiongetsTLE.Oneofthesolutions
fromcontestantsisalsoO(nlogn)typebuttheretheyoptimizedlog(n)part.Judgesolutionis
O(rc^2orr^2c)typewhichrunsfor2s/3.3setc,sothetimelimitof6ssoundslegit.Onenice
ideacanbe:twohandtechnique.Initiallyiandjbothareatthebeginningofthearray.Now,
check,whatisthemaximumnumberafterj,ifitisbiggerthannum[i],movejright.Onceyou
stop,updateyouranswerandmoveitorightuntilitbecomeslowerthannum[j].Thenagain
movejright.ThisisO(n)solutiontofindoutmaximumlengthnonnegativesegment,whichis
quitenice.

ProblemG:
Setter:ShipluHawlader
Alternate:MdMahbubulHasan
Category:Adhoc,Geometry(notquite)
Difficulty:EasyMedium(tricky)
Solution:Firstmyattemptwastosolveitlike2dproblem.Thatisgivenpointsinnormal2d
cartesianplaneandsolveforrectangle/square.Thesolutioniseasy,youjustneedtofindout
max(dx)andmax(dy).Inhexagonalgrid,youcanrepresentthethirdaxisasz=x+yorxy
(dependingondirectionofalltheaxes).Nowfigureoutmax(dx),max(dy),max(dz).Youwillget
thediameteroftheanswerhexagonandthenyouneedtofigureoutaquadraticequationto
countnumberofcellsinsideahexagonandplugthediameter/radiusinit.Butitdoesnotsolve
theproblem.Therearesometrickycaseswherethissolutiondoesnotpass.Nowthinkinterms
ofalgebra.Weneedtofinda(center_x,center_y)suchthatdistancetoany(x,y)isminimized.
Whatisthedistancebetweentwonodesinhexagon?Well,youcantrytofigureout,butatthe
enditwillbecome:max(differenceofx),max(differenceofy)andmax(differenceofz).Firsttwo
areeasybutthethirdoneisabittricky.Butattheendoftheday,youcanwritesomeinequality
for(center_x,center_y)andradiusDwithmax(x),min(x)[actuallyyoudontneedcenter_x,
center_yattheend]Theinequalitiesareveryniceinmyopinion,soyoushouldtrytofigure
themoutbyyourself.YoucannowbinarysearchonDtoseewhichvalueofDsatisfythe
inequalitiesoryoucanwriteonesingleifelsetofigureouttheoptimalvalueofD.Inmyopinion
thisisthecutestproblemintheset.

ProblemH:
Setter:MdMahbubulHasan
Alternate:ShipluHawlader
Category:NumberTheoreticFFT
Difficulty:Hard
Solution:Itisobviousthat(0,0)hastobemedian.Tobeso,count(+,+)+count(+,)=count(,
+)+count(,).Andsimilarlywecanfindoutanotherequationfordividingbyyaxis.Andatthe
endoftheday,youwillseethat:count(+,+)=count(,)andcount(+,)=count(,+).Sofigureout
howmanywaysyoucanselect2xpointsfromcount(+,+)andcount(,)whichis:ncr(total(+,+),
x)*ncr(total(,),x).Similarlyforothertwoquadrantsyoufindoutsamethinghowtochoose2y
points.Nowtherestisnothingbutmultiplicationofthesetwopolynomials.Andweneedtodo
thisbynumbertheoreticFFT.Pleasenote,karatsubawillgetTLE.

ProblemI:
Setter:TasnimImranSunny
Alternate:ShipluHawlader,MdMahbubulHasan
Category:BitmaskDP+DigitDP
Solution:Youhave10differentdigits.Initiallyallofthedigitsareavailable,thenyoutakesome
setofthesedigitsandwilltrytousethem.Restofthedigitsgoestothesamefunction(bitmask
dp).Howmanywaystousethesedigits?Thatisanotherdp,thistimeyouneedtouseallthese
digitsandmustnotexceedN,sodigitdp.Youjustneedtobecarefulwithimplementation.


ProblemJ:
Setter:MonirulHasan
Alternate:ZobayerHasan,DerekKisman,MdMahbubulHasan
Category:Geometry
Solution:Typicalgeometry,butwaymorecornercasesthanyoucanimagine.Thedatawas
finallypreparedjust4hoursbeforethemaincontest.Initiallyaftercoupleofgiveandtake,two
solutions(AandB)fromjudgesagreedwitheachother.Butthentwomorejudges(CandD)
wrotesolutionsandnoneofthesesolutionsmatchedwitheachother,neitherwithprevioustwo
agreedsolutions.Wealsocouldfindsomecaseswhereeachofthecodeswasgivingwrong
answer.Oneofthejudges(B)rewrotehiscodeinasimulationsense,anotherjudge(C)
removedsomeoptimizationfromhiscodeandfinallytheyagreedonoutput.Butthehappy
momentdidnotlastmuch,oneoftheotherjudges(D)senthiscodewhichdisagreedwith(BC).
Soaftersomerandomsmallinput,wefoundasmallcasewherecodeofDfails.Dfixedhis
codeagainandBCDlivedhappilyeverafter.Andallthesehappened48hoursbeforethe
contest,mostly12hoursbeforethecontest.

Backtotheproblem,theproblemiseasyunlessyoutrytobesmart.Justbestupid.First,forthe
eachofthegivenpoints(r,t)findoutwhatistheoriginalt(sayt),thatis:t+2n*PI,youneedto
findthevalueofn.Alsogivent,findoutthetwolinesbetweenwhichthispointlies.Suppose
lineL1liesbeforethepointandL2afterthepoint.Sonow,findoutthespiralsegmentbysimply
looping(noteacanbe1inworstcaseandris100inworstcase).Youcoulddobinarysearch
orevenO(1)computationwhichyieldedtosomanycornercases.Alsodontforgetthatyou
mayneedtowraprotationtofindoutL1andL2.Onceyoufindoutallthe4cornersofthespiral
segment,restisjustintegration.Youdontneedanyfancyintegration,justsomeeasypolar
coordinateintegration.

Anda mungkin juga menyukai