From 690dbd0ca4874c3695019eb8b7a34b292771ae20 Mon Sep 17 00:00:00 2001 From: Nemo Date: Tue, 1 May 2018 23:45:51 +0530 Subject: [PATCH] Re-run markdown --- _problems/challenge/L2GRAPH.md | 2 +- _problems/easy/A1.md | 3 +- _problems/easy/A2.md | 1 - _problems/easy/A3.md | 3 +- _problems/easy/A4.md | 1 - _problems/easy/ABABAABA.md | 2 +- _problems/easy/ABREPEAT.md | 2 +- _problems/easy/ABROADS.md | 2 +- _problems/easy/ABX01.md | 2 +- _problems/easy/ABX02.md | 2 +- _problems/easy/ADDMUL.md | 14 +- _problems/easy/ADIGIT.md | 6 +- _problems/easy/ADMAG.md | 2 +- _problems/easy/ADTRI.md | 2 +- _problems/easy/AEHASH.md | 3 +- _problems/easy/ALETHIO.md | 4 +- _problems/easy/ALEXNUMB.md | 6 +- _problems/easy/AMMEAT.md | 2 +- _problems/easy/AMMEAT2.md | 2 +- _problems/easy/AMR15D.md | 4 +- _problems/easy/AMSGAME1.md | 2 +- _problems/easy/AMSGAME2.md | 2 +- _problems/easy/ANKGAME.md | 4 +- _problems/easy/ANKPAL.md | 4 +- _problems/easy/ANKPAREN.md | 14 +- _problems/easy/ANUARM.md | 3 +- _problems/easy/ANUBTG.md | 2 +- _problems/easy/ANUDTC.md | 2 +- _problems/easy/ANUTHM.md | 8 +- _problems/easy/ANUWTA.md | 2 +- _problems/easy/APPROX.md | 4 +- _problems/easy/APPROX2.md | 2 +- _problems/easy/ARRANGE.md | 1 - _problems/easy/ARRGAME2.md | 2 +- _problems/easy/ASP.md | 1 - _problems/easy/ASTRGAME.md | 2 +- _problems/easy/ASTRING.md | 2 +- _problems/easy/ATOMS.md | 1 - _problems/easy/ATTIC.md | 2 +- _problems/easy/AVGSHORT.md | 2 +- _problems/easy/BANDMATR.md | 7 +- _problems/easy/BANROB.md | 4 +- _problems/easy/BASE.md | 10 +- _problems/easy/BEARSEG.md | 2 +- _problems/easy/BEX.md | 1 - _problems/easy/BGQRS.md | 2 +- _problems/easy/BIGPIZA.md | 4 +- _problems/easy/BINOP.md | 2 +- _problems/easy/BINTOUR.md | 3 +- _problems/easy/BINTREE.md | 2 +- _problems/easy/BIPIN3.md | 2 +- _problems/easy/BLACKCOM.md | 2 +- _problems/easy/BOGOSORT.md | 1 - _problems/easy/BOUQUET.md | 4 +- _problems/easy/BROKPHON.md | 2 +- _problems/easy/BTAR.md | 1 - _problems/easy/BUYING2.md | 2 +- _problems/easy/BWALL.md | 1 - _problems/easy/BWCELL.md | 2 +- _problems/easy/BWKNIGHT.md | 3 - _problems/easy/BYTEISLE.md | 2 +- _problems/easy/C4.md | 4 +- _problems/easy/CAKEDOOM.md | 6 +- _problems/easy/CALC.md | 2 +- _problems/easy/CANDLE.md | 1 + _problems/easy/CAOS1.md | 2 +- _problems/easy/CAOS2.md | 1 - _problems/easy/CAPIMOVE.md | 3 +- _problems/easy/CAPPLE.md | 2 +- _problems/easy/CARVANS.md | 2 +- _problems/easy/CBALLS.md | 2 +- _problems/easy/CBARG.md | 2 +- _problems/easy/CENTREE.md | 2 +- _problems/easy/CHAHG.md | 6 +- _problems/easy/CHAIRS.md | 8 +- _problems/easy/CHBLLNS.md | 2 +- _problems/easy/CHBLLS.md | 8 +- _problems/easy/CHCINEMA.md | 14 +- _problems/easy/CHCOINSG.md | 2 +- _problems/easy/CHCUBE.md | 2 +- _problems/easy/CHDOGS.md | 2 +- _problems/easy/CHEARMY.md | 2 +- _problems/easy/CHEFA.md | 1 - _problems/easy/CHEFARC.md | 6 +- _problems/easy/CHEFARK.md | 3 +- _problems/easy/CHEFARRB.md | 3 +- _problems/easy/CHEFAXR.md | 5 +- _problems/easy/CHEFBEST.md | 4 +- _problems/easy/CHEFBM.md | 6 +- _problems/easy/CHEFBR.md | 1 - _problems/easy/CHEFCBA.md | 2 +- _problems/easy/CHEFCCYL.md | 6 +- _problems/easy/CHEFCH.md | 2 +- _problems/easy/CHEFCK.md | 2 +- _problems/easy/CHEFCOUN.md | 2 +- _problems/easy/CHEFCRUN.md | 2 +- _problems/easy/CHEFDICE.md | 2 +- _problems/easy/CHEFELEC.md | 2 +- _problems/easy/CHEFEQ.md | 2 +- _problems/easy/CHEFFA.md | 2 +- _problems/easy/CHEFFED.md | 4 +- _problems/easy/CHEFFILT.md | 2 +- _problems/easy/CHEFGP.md | 2 +- _problems/easy/CHEFGR.md | 4 +- _problems/easy/CHEFHACK.md | 4 +- _problems/easy/CHEFHAM.md | 1 - _problems/easy/CHEFHPAL.md | 2 +- _problems/easy/CHEFIHG.md | 3 +- _problems/easy/CHEFLCM.md | 2 +- _problems/easy/CHEFLR.md | 4 +- _problems/easy/CHEFMATH.md | 2 +- _problems/easy/CHEFMOVR.md | 2 +- _problems/easy/CHEFPATH.md | 2 +- _problems/easy/CHEFPDIG.md | 2 +- _problems/easy/CHEFQUE.md | 2 +- _problems/easy/CHEFRP.md | 2 +- _problems/easy/CHEFRRUN.md | 9 +- _problems/easy/CHEFSEG.md | 2 +- _problems/easy/CHEFSETC.md | 2 +- _problems/easy/CHEFSIGN.md | 2 +- _problems/easy/CHEFSOC2.md | 2 +- _problems/easy/CHEFSOCK.md | 2 +- _problems/easy/CHEFSPL.md | 2 +- _problems/easy/CHEFSQUA.md | 4 +- _problems/easy/CHEFSSET.md | 2 +- _problems/easy/CHEFST.md | 14 +- _problems/easy/CHEFSTON.md | 2 +- _problems/easy/CHEFSUBA.md | 2 +- _problems/easy/CHEFTEAM.md | 1 - _problems/easy/CHEFTET.md | 2 +- _problems/easy/CHEFTMA.md | 2 +- _problems/easy/CHEFTOWN.md | 1 - _problems/easy/CHEFTWOS.md | 2 +- _problems/easy/CHEFVOTE.md | 2 +- _problems/easy/CHEFYODA.md | 9 +- _problems/easy/CHEFZOT.md | 4 +- _problems/easy/CHFANS.md | 1 - _problems/easy/CHFNFRN.md | 3 +- _problems/easy/CHINFL.md | 3 +- _problems/easy/CHMOD.md | 1 - _problems/easy/CHN01.md | 2 +- _problems/easy/CHN03.md | 2 +- _problems/easy/CHN05.md | 2 +- _problems/easy/CHNGFUNC.md | 2 +- _problems/easy/CHNGSUM.md | 5 +- _problems/easy/CHODE.md | 1 - _problems/easy/CHPLGNS.md | 2 +- _problems/easy/CHRECT.md | 2 +- _problems/easy/CHSGMNTS.md | 2 +- _problems/easy/CHSHIFU.md | 4 +- _problems/easy/CHSQR.md | 1 - _problems/easy/CHSTAMP.md | 2 +- _problems/easy/CHSTR.md | 2 +- _problems/easy/CIELDIST.md | 4 +- _problems/easy/CIELMAP.md | 1 + _problems/easy/CIELTOMY.md | 2 + _problems/easy/CIRCUITS.md | 1 - _problems/easy/CIRKILL.md | 2 +- _problems/easy/CKISSHUG.md | 2 + _problems/easy/CLEANUP.md | 1 - _problems/easy/CLETAB.md | 2 +- _problems/easy/CLIQUED.md | 2 +- _problems/easy/CLMBSTRS.md | 2 +- _problems/easy/CLOST.md | 2 +- _problems/easy/CLPERM.md | 2 +- _problems/easy/CLRL.md | 2 +- _problems/easy/CNOTE.md | 2 +- _problems/easy/CODECRCK.md | 2 +- _problems/easy/COLARR.md | 4 +- _problems/easy/COLLIDE.md | 4 +- _problems/easy/COMM3.md | 1 - _problems/easy/COMMUTE.md | 1 - _problems/easy/COMPCLUB.md | 10 +- _problems/easy/COMPILER.md | 5 +- _problems/easy/CONFLIP.md | 2 +- _problems/easy/CONSESNK.md | 2 +- _problems/easy/COOK82B.md | 4 +- _problems/easy/COOK82C.md | 2 +- _problems/easy/COOKGAME.md | 2 +- _problems/easy/COOLGUYS.md | 2 +- _problems/easy/COOLING.md | 1 + _problems/easy/COUNTPAL.md | 1 - _problems/easy/COUNTREL.md | 1 - _problems/easy/COURSE.md | 1 + _problems/easy/CPERM.md | 2 +- _problems/easy/CPLAY.md | 2 +- _problems/easy/CPOINT.md | 1 - _problems/easy/CRAWA.md | 2 +- _problems/easy/CROWD.md | 8 +- _problems/easy/CSEQ.md | 2 +- _problems/easy/CSUB.md | 2 +- _problems/easy/CSUMD.md | 5 +- _problems/easy/CTEAMS.md | 1 - _problems/easy/CUBE.md | 6 +- _problems/easy/CUBESUM.md | 1 - _problems/easy/CVOTE.md | 6 +- _problems/easy/D1.md | 1 - _problems/easy/DAILY.md | 3 +- _problems/easy/DBOY.md | 2 +- _problems/easy/DCE03.md | 5 +- _problems/easy/DCE04.md | 1 - _problems/easy/DCE05.md | 1 - _problems/easy/DCGAME.md | 2 +- _problems/easy/DDISH.md | 2 +- _problems/easy/DECSTR.md | 3 +- _problems/easy/DEFACING.md | 4 +- _problems/easy/DELISH.md | 2 +- _problems/easy/DESTROY.md | 2 +- _problems/easy/DEVCLASS.md | 14 +- _problems/easy/DEVJERRY.md | 2 +- _problems/easy/DEVLDISC.md | 3 +- _problems/easy/DEVPERF.md | 2 +- _problems/easy/DEVSTR.md | 2 +- _problems/easy/DIAMOND.md | 4 +- _problems/easy/DIGITSEP.md | 6 +- _problems/easy/DIGJUMP.md | 4 +- _problems/easy/DIGROT.md | 3 +- _problems/easy/DIRECTI.md | 4 +- _problems/easy/DISCHAR.md | 2 +- _problems/easy/DISHLIFE.md | 2 +- _problems/easy/DISHOWN.md | 4 +- _problems/easy/DISTCODE.md | 2 +- _problems/easy/DIVGOLD.md | 2 +- _problems/easy/DIVIDING.md | 2 - _problems/easy/DIVMAC.md | 6 +- _problems/easy/DIVNINE.md | 6 +- _problems/easy/DIVQUERY.md | 1 - _problems/easy/DONUTS.md | 2 +- _problems/easy/DOWNLOAD.md | 4 +- _problems/easy/DRAGNXOR.md | 4 +- _problems/easy/DRANGE.md | 4 +- _problems/easy/DREAM.md | 4 +- _problems/easy/DRGHTS.md | 5 +- _problems/easy/DRGNBOOL.md | 2 +- _problems/easy/DUMPLING.md | 1 - _problems/easy/E1.md | 1 - _problems/easy/EASYPROB.md | 1 - _problems/easy/EGBOBRD.md | 2 +- _problems/easy/EGRCAKE.md | 4 +- _problems/easy/EMITL.md | 2 +- _problems/easy/EQIDLIS.md | 4 +- _problems/easy/EQUALITY.md | 2 +- _problems/easy/EQUALIZ.md | 2 +- _problems/easy/EQUALIZE.md | 10 +- _problems/easy/EQUATION.md | 3 +- _problems/easy/ERROR.md | 1 + _problems/easy/EXPTREE.md | 2 +- _problems/easy/EXTRAN.md | 2 +- _problems/easy/EZNO.md | 2 +- _problems/easy/F1.md | 1 - _problems/easy/FATCHEF.md | 1 - _problems/easy/FCBARCA.md | 2 +- _problems/easy/FCTRL2.md | 3 +- _problems/easy/FENWITER.md | 5 +- _problems/easy/FFCOMB.md | 2 +- _problems/easy/FGFS.md | 6 +- _problems/easy/FIBQ.md | 4 +- _problems/easy/FILLMTR.md | 5 +- _problems/easy/FIRE.md | 1 - _problems/easy/FIRESC.md | 4 +- _problems/easy/FLAGS.md | 2 +- _problems/easy/FLOORI4.md | 2 +- _problems/easy/FLUSHOT.md | 2 +- _problems/easy/FLYMODE.md | 5 +- _problems/easy/FORESTGA.md | 2 +- _problems/easy/FORGETPW.md | 1 - _problems/easy/FRIEMEET.md | 1 - _problems/easy/FRNDMTNG.md | 1 - _problems/easy/FROGV.md | 4 +- _problems/easy/FSTSQ.md | 2 +- _problems/easy/FTRIP.md | 6 +- _problems/easy/GALACTIK.md | 1 - _problems/easy/GAMEAAM.md | 2 +- _problems/easy/GAMEBALL.md | 21 +- _problems/easy/GARDENSQ.md | 4 +- _problems/easy/GCAC.md | 2 +- _problems/easy/GCD2.md | 3 +- _problems/easy/GENARSEQ.md | 3 +- _problems/easy/GERALD03.md | 1 - _problems/easy/GERALD04.md | 1 - _problems/easy/GERALD05.md | 4 +- _problems/easy/GERMANDE.md | 6 +- _problems/easy/GIFTCHEF.md | 2 +- _problems/easy/GOODNUMB.md | 4 +- _problems/easy/GRANAMA.md | 8 +- _problems/easy/GRAYSC.md | 1 - _problems/easy/GRGUY.md | 5 +- _problems/easy/GRID.md | 2 +- _problems/easy/GROWGOLD.md | 4 +- _problems/easy/H1.md | 4 +- _problems/easy/HAREJUMP.md | 1 - _problems/easy/HDELIVER.md | 4 +- _problems/easy/HELLO.md | 6 +- _problems/easy/HELPLIRA.md | 1 - _problems/easy/HHAL.md | 2 +- _problems/easy/HOLES.md | 1 - _problems/easy/HOMDEL.md | 7 +- _problems/easy/HORSES.md | 7 +- _problems/easy/HOTEL.md | 4 +- _problems/easy/HS08TEST.md | 5 +- _problems/easy/HULLSUM.md | 2 +- _problems/easy/ICPC16C.md | 2 +- _problems/easy/ICPC16D.md | 2 +- _problems/easy/ICPC16E.md | 3 +- _problems/easy/IGAME.md | 4 +- _problems/easy/INSOMB1.md | 1 - _problems/easy/INSOMB6.md | 3 +- _problems/easy/INTEG.md | 8 +- _problems/easy/INTERVAL.md | 2 +- _problems/easy/INTEST.md | 1 - _problems/easy/IPCTRAIN.md | 2 +- _problems/easy/ISSNAKE.md | 5 +- _problems/easy/J7.md | 1 - _problems/easy/JOHNY.md | 2 +- _problems/easy/K1.md | 2 +- _problems/easy/KBIGNUMB.md | 4 +- _problems/easy/KFUNC.md | 4 +- _problems/easy/KGOOD.md | 4 +- _problems/easy/KINGCON.md | 6 +- _problems/easy/KINGSHIP.md | 1 - _problems/easy/KIRLAB.md | 2 +- _problems/easy/KNICOV.md | 2 +- _problems/easy/KNIGHTMV.md | 1 - _problems/easy/KOL1502.md | 2 +- _problems/easy/KOL1504.md | 2 +- _problems/easy/KOL1506.md | 6 +- _problems/easy/KOL1509.md | 2 +- _problems/easy/KOL16F.md | 3 +- _problems/easy/KOL16H.md | 1 - _problems/easy/KPRIME.md | 1 - _problems/easy/KSPHERES.md | 2 +- _problems/easy/KSUBSUM.md | 4 +- _problems/easy/KSUM.md | 2 +- _problems/easy/KTHMAX.md | 1 - _problems/easy/L3.md | 1 - _problems/easy/LAPIN.md | 3 +- _problems/easy/LASTDIG.md | 4 +- _problems/easy/LCKYST.md | 2 +- _problems/easy/LCPESY.md | 2 +- _problems/easy/LEALCO.md | 10 +- _problems/easy/LEBALONS.md | 3 +- _problems/easy/LEBAMBOO.md | 3 +- _problems/easy/LEBOMBS.md | 7 +- _problems/easy/LECARDS.md | 1 - _problems/easy/LEDIV.md | 2 +- _problems/easy/LEEXAMS.md | 1 - _problems/easy/LELEMON.md | 3 +- _problems/easy/LEMAGIC.md | 17 +- _problems/easy/LEMOUSE.md | 6 +- _problems/easy/LEMUSIC.md | 2 +- _problems/easy/LEPERMUT.md | 2 +- _problems/easy/LEVY.md | 2 +- _problems/easy/LEXOPAL.md | 4 +- _problems/easy/LFEB14B.md | 2 +- _problems/easy/LFSTACK.md | 2 +- _problems/easy/LIFE.md | 3 +- _problems/easy/LIGHTHSE.md | 2 +- _problems/easy/LIKECS02.md | 6 +- _problems/easy/LIKECS03.md | 10 +- _problems/easy/LNGHW.md | 6 +- _problems/easy/LOKBIL.md | 1 - _problems/easy/LRQUER.md | 2 +- _problems/easy/LTM40CD.md | 1 - _problems/easy/LUCKY1.md | 1 - _problems/easy/LUCKY10.md | 2 +- _problems/easy/LUCKY2.md | 2 +- _problems/easy/LUCKY5.md | 1 - _problems/easy/LUCKYBAL.md | 2 +- _problems/easy/LUCKYSTR.md | 4 +- _problems/easy/LUMPYBUS.md | 4 +- _problems/easy/LWS.md | 4 +- _problems/easy/MAANDI.md | 1 - _problems/easy/MAKEART.md | 3 +- _problems/easy/MAKETRI.md | 2 +- _problems/easy/MANYCHEF.md | 2 +- _problems/easy/MARBLEGF.md | 2 +- _problems/easy/MARCHA1.md | 3 +- _problems/easy/MARCHA2.md | 1 - _problems/easy/MATDYS.md | 7 +- _problems/easy/MATTEG.md | 3 +- _problems/easy/MAXCOMP.md | 2 +- _problems/easy/MAXCOUNT.md | 1 - _problems/easy/MAXDIFF.md | 2 +- _problems/easy/MAXDIST.md | 2 +- _problems/easy/MAXIEDGE.md | 2 +- _problems/easy/MAXISUM.md | 2 +- _problems/easy/MAXNUM3.md | 1 - _problems/easy/MAXPR.md | 1 - _problems/easy/MAXSEGM.md | 6 +- _problems/easy/MCHAIRS.md | 1 - _problems/easy/MCHEF.md | 2 +- _problems/easy/MEX.md | 6 +- _problems/easy/MEXDIV.md | 3 +- _problems/easy/MFREQ.md | 4 +- _problems/easy/MGCRNK.md | 1 - _problems/easy/MIKE1.md | 4 +- _problems/easy/MIKE3.md | 2 +- _problems/easy/MIME2.md | 3 +- _problems/easy/MINIMAX.md | 3 +- _problems/easy/MINPERM.md | 2 +- _problems/easy/MINSUBAR.md | 1 - _problems/easy/MISINTER.md | 3 +- _problems/easy/MKSQR.md | 4 +- _problems/easy/MMSUM.md | 2 +- _problems/easy/MONTRANS.md | 2 +- _problems/easy/MOVES.md | 3 +- _problems/easy/MTRNSFRM.md | 4 +- _problems/easy/MTRWY.md | 4 +- _problems/easy/MTRXMOD.md | 6 +- _problems/easy/MVCOIN.md | 3 +- _problems/easy/MXMEDIAN.md | 2 +- _problems/easy/MXSUBARR.md | 2 +- _problems/easy/N1.md | 1 - _problems/easy/NAME1.md | 2 +- _problems/easy/NAME2.md | 2 +- _problems/easy/NDIFFPAL.md | 1 + _problems/easy/NDLVOTE.md | 2 +- _problems/easy/NDUNGEON.md | 3 +- _problems/easy/NEO01.md | 6 +- _problems/easy/NEWSCH.md | 2 +- _problems/easy/NI01.md | 1 - _problems/easy/NI02.md | 1 - _problems/easy/NICEQUAD.md | 1 - _problems/easy/NOCODING.md | 6 +- _problems/easy/NOLOGIC.md | 2 +- _problems/easy/NOTATRI.md | 3 +- _problems/easy/NUKES.md | 3 +- _problems/easy/NUMBERS.md | 2 +- _problems/easy/NUMGAME.md | 5 +- _problems/easy/NUMGAME2.md | 10 +- _problems/easy/OBTTRNGL.md | 2 +- _problems/easy/ODDDIV.md | 2 +- _problems/easy/OJUMPS.md | 6 +- _problems/easy/OMAX.md | 1 - _problems/easy/ONCHESS.md | 2 +- _problems/easy/ONOZ.md | 4 +- _problems/easy/ONP.md | 3 +- _problems/easy/ORACLCS.md | 2 +- _problems/easy/PACKBAND.md | 4 +- _problems/easy/PAIRING.md | 1 - _problems/easy/PAIRSUM.md | 1 - _problems/easy/PALHAM.md | 4 +- _problems/easy/PALINGAM.md | 2 +- _problems/easy/PANSTACK.md | 3 +- _problems/easy/PCYCLE.md | 11 +- _problems/easy/PERMEXIS.md | 2 +- _problems/easy/PERMSUFF.md | 1 - _problems/easy/PERMUT2.md | 3 +- _problems/easy/PERPALIN.md | 2 +- _problems/easy/PETERSEN.md | 5 +- _problems/easy/PIANO1.md | 2 +- _problems/easy/PIZPAR.md | 2 +- _problems/easy/PLANEDIV.md | 2 +- _problems/easy/PLUSMUL.md | 5 +- _problems/easy/PLZLYKME.md | 2 +- _problems/easy/PNTNG.md | 4 +- _problems/easy/POINTS.md | 1 - _problems/easy/POKER.md | 1 - _problems/easy/POSTTREE.md | 2 +- _problems/easy/POTATOES.md | 2 +- _problems/easy/PPCTS.md | 2 +- _problems/easy/PPNUM.md | 2 +- _problems/easy/PPTEST.md | 2 +- _problems/easy/PREDICT.md | 2 +- _problems/easy/PREFINVS.md | 2 +- _problems/easy/PRETNUM.md | 4 +- _problems/easy/PRGIFT.md | 3 +- _problems/easy/PRIMES2.md | 3 +- _problems/easy/PRLADDU.md | 2 +- _problems/easy/PROB.md | 4 +- _problems/easy/PROSUM.md | 4 +- _problems/easy/PROTEPOI.md | 2 +- _problems/easy/PRPALIN.md | 1 - _problems/easy/PRPALN.md | 2 +- _problems/easy/PRPOTION.md | 2 +- _problems/easy/PUPPYGM.md | 2 +- _problems/easy/QMAXTRIX.md | 2 +- _problems/easy/RACELANE.md | 1 - _problems/easy/RAINBOW.md | 2 +- _problems/easy/RAINBOWB.md | 1 - _problems/easy/RANKLIST.md | 2 +- _problems/easy/RDF.md | 4 +- _problems/easy/REARRSTR.md | 2 +- _problems/easy/RECIPE.md | 4 +- _problems/easy/RECRECOV.md | 1 - _problems/easy/RECTCNT.md | 1 - _problems/easy/RECTLOVE.md | 2 +- _problems/easy/RECTQUER.md | 1 - _problems/easy/REIGN.md | 2 +- _problems/easy/RESCALC.md | 2 +- _problems/easy/RESERVOI.md | 16 +- _problems/easy/RESN04.md | 1 - _problems/easy/RESN05.md | 1 - _problems/easy/RESQ.md | 2 +- _problems/easy/RETPO.md | 2 +- _problems/easy/REVERSE.md | 2 +- _problems/easy/RHOUSE.md | 1 - _problems/easy/RIGHTRI.md | 4 +- _problems/easy/RIGHTTRI.md | 1 - _problems/easy/RNUM.md | 2 +- _problems/easy/ROBOTG.md | 2 +- _problems/easy/ROTATION.md | 2 +- _problems/easy/ROWCOLOP.md | 2 +- _problems/easy/ROWSOLD.md | 2 +- _problems/easy/RRCODE.md | 2 +- _problems/easy/RRCOPY.md | 2 +- _problems/easy/RRECIPE.md | 2 +- _problems/easy/RRGAME.md | 4 +- _problems/easy/RRSTONE.md | 3 +- _problems/easy/RRSUM.md | 1 - _problems/easy/SAD.md | 6 +- _problems/easy/SALARY.md | 4 +- _problems/easy/SAMESNAK.md | 2 +- _problems/easy/SANSKAR.md | 6 +- _problems/easy/SCHEDULE.md | 12 +- _problems/easy/SEAARASU.md | 2 +- _problems/easy/SEACO.md | 2 +- _problems/easy/SEAGRP.md | 1 - _problems/easy/SEALINE.md | 4 +- _problems/easy/SEALUP.md | 4 +- _problems/easy/SEATL.md | 6 +- _problems/easy/SEATRSF.md | 1 - _problems/easy/SEATSTR2.md | 1 - _problems/easy/SECUBE.md | 4 +- _problems/easy/SETDIFF.md | 2 +- _problems/easy/SETELE.md | 4 +- _problems/easy/SGARDEN.md | 2 +- _problems/easy/SHIRO.md | 6 +- _problems/easy/SHOPTRIP.md | 2 +- _problems/easy/SIGNWAVE.md | 2 +- _problems/easy/SKYSCR.md | 3 +- _problems/easy/SNACKUP.md | 1 - _problems/easy/SNAKEEAT.md | 2 +- _problems/easy/SNAKY.md | 1 - _problems/easy/SNCK04.md | 1 - _problems/easy/SNCOUP.md | 2 +- _problems/easy/SNSOCIAL.md | 5 +- _problems/easy/SNTEMPLE.md | 2 +- _problems/easy/SPCANDY.md | 4 +- _problems/easy/SPECIES.md | 2 +- _problems/easy/SPOON.md | 4 +- _problems/easy/SPOTWO.md | 1 - _problems/easy/SPREAD.md | 4 +- _problems/easy/SPRNMBRS.md | 2 +- _problems/easy/STACKS.md | 2 +- _problems/easy/STDYTAB.md | 2 +- _problems/easy/STEM.md | 2 +- _problems/easy/STEPUP.md | 7 +- _problems/easy/STFM.md | 4 +- _problems/easy/STONES.md | 1 - _problems/easy/STRBIT.md | 2 +- _problems/easy/STROPR.md | 2 +- _problems/easy/STRQ.md | 2 +- _problems/easy/STRSUB.md | 12 +- _problems/easy/SUBANAGR.md | 2 +- _problems/easy/SUBGCD.md | 2 +- _problems/easy/SUBMIN.md | 2 +- _problems/easy/SUMPAIR.md | 2 +- _problems/easy/SUMQ.md | 2 +- _problems/easy/SUMTRIAN.md | 2 +- _problems/easy/SUPERPLN.md | 1 - _problems/easy/SUPVIL.md | 2 +- _problems/easy/TAAPLUSB.md | 2 +- _problems/easy/TAASEQ.md | 2 +- _problems/easy/TACHSTCK.md | 4 +- _problems/easy/TAPALIN.md | 2 +- _problems/easy/TAVISUAL.md | 2 +- _problems/easy/TEST.md | 1 - _problems/easy/THREEDIF.md | 2 +- _problems/easy/TIDRICE.md | 5 +- _problems/easy/TIMEASR.md | 4 +- _problems/easy/TLG.md | 7 +- _problems/easy/TMSLT.md | 3 +- _problems/easy/TOTR.md | 2 +- _problems/easy/TOURISTS.md | 5 +- _problems/easy/TOURMAP.md | 9 +- _problems/easy/TOURNAM.md | 1 - _problems/easy/TPRODUCT.md | 4 +- _problems/easy/TRAVELER.md | 2 +- _problems/easy/TREECAKE.md | 2 +- _problems/easy/TREEGAME.md | 1 - _problems/easy/TRIP.md | 5 +- _problems/easy/TRMAG.md | 1 - _problems/easy/TSORT.md | 3 +- _problems/easy/TUZGMBR.md | 2 +- _problems/easy/TWODOGS.md | 2 +- _problems/easy/TWSTR.md | 1 - _problems/easy/UASEQ.md | 3 +- _problems/easy/UGLYF.md | 5 +- _problems/easy/UNICOURS.md | 2 +- _problems/easy/UNIONSET.md | 2 +- _problems/easy/UNIVERSE.md | 5 +- _problems/easy/VK18.md | 2 +- _problems/easy/VOTERS.md | 7 +- _problems/easy/WALK.md | 2 +- _problems/easy/WCOUNT.md | 3 +- _problems/easy/WEICOM.md | 1 - _problems/easy/WEIGHT.md | 9 +- _problems/easy/WINDOW2.md | 2 +- _problems/easy/WITMATH.md | 1 - _problems/easy/WORLDCUP.md | 3 +- _problems/easy/WOUT.md | 4 +- _problems/easy/WSITES01.md | 2 +- _problems/easy/WSTRING.md | 8 +- _problems/easy/XORNUBER.md | 2 +- _problems/easy/XORSUB.md | 2 +- _problems/easy/YNOUTPUT.md | 6 +- _problems/hard/A5.md | 2 +- _problems/hard/A7.md | 2 +- _problems/hard/A8.md | 3 +- _problems/hard/ADADET.md | 2 +- _problems/hard/ADJLEAF.md | 2 +- _problems/hard/ALICE.md | 1 + _problems/hard/ALLPOLY.md | 4 +- _problems/hard/ALMROW.md | 2 +- _problems/hard/AMR15E.md | 2 +- _problems/hard/ANUAAA.md | 8 +- _problems/hard/ANUDTQ.md | 6 +- _problems/hard/ANUSAR.md | 2 +- _problems/hard/ANUSFR.md | 4 +- _problems/hard/APRPS.md | 2 +- _problems/hard/ARCHPLG.md | 9 +- _problems/hard/ARRANGE2.md | 3 - _problems/hard/ARRAYSUM.md | 2 +- _problems/hard/ASTRD.md | 2 +- _problems/hard/AUTHEN.md | 3 +- _problems/hard/AVDWAST.md | 2 +- _problems/hard/BB.md | 4 +- _problems/hard/BEARS.md | 3 +- _problems/hard/BESTTRI.md | 6 +- _problems/hard/BIGTREE.md | 4 +- _problems/hard/BIKE.md | 6 +- _problems/hard/BINOMSUM.md | 2 +- _problems/hard/BNGAME.md | 3 +- _problems/hard/BOUNCE.md | 4 +- _problems/hard/BTREE.md | 3 +- _problems/hard/BUYLAND.md | 2 +- _problems/hard/BWGAME.md | 2 +- _problems/hard/BYTESHOP.md | 4 - _problems/hard/C1.md | 1 - _problems/hard/CAKE2AM.md | 4 +- _problems/hard/CAPTCITI.md | 2 +- _problems/hard/CARDSHUF.md | 1 - _problems/hard/CBAL.md | 2 +- _problems/hard/CHANGE.md | 2 +- _problems/hard/CHEFBOOK.md | 1 - _problems/hard/CHEFC.md | 3 +- _problems/hard/CHEFFIB.md | 3 +- _problems/hard/CHEFKC.md | 2 - _problems/hard/CHEFONM.md | 1 - _problems/hard/CHEFPC.md | 4 +- _problems/hard/CHEFPOL.md | 2 - _problems/hard/CHEFSPAG.md | 10 +- _problems/hard/CHEFTRAF.md | 2 +- _problems/hard/CHEFTRE.md | 1 - _problems/hard/CHEFTREE.md | 1 - _problems/hard/CHEFTRI4.md | 2 +- _problems/hard/CHEF_GAM.md | 4 +- _problems/hard/CHMAGIC.md | 2 +- _problems/hard/CHN04.md | 2 +- _problems/hard/CHN10.md | 2 +- _problems/hard/CHN12.md | 5 +- _problems/hard/CHNBGMT.md | 10 +- _problems/hard/CIELBALL.md | 2 + _problems/hard/CIELHACK.md | 4 +- _problems/hard/CIELKARA.md | 6 +- _problems/hard/CIELQUAK.md | 3 +- _problems/hard/CIELWALK.md | 4 + _problems/hard/CKSCHOOL.md | 4 +- _problems/hard/CLONES.md | 1 - _problems/hard/CLOWAY.md | 4 +- _problems/hard/CLUE.md | 2 + _problems/hard/CNTDIGIT.md | 1 - _problems/hard/CNTDSETS.md | 3 +- _problems/hard/CONNECT.md | 1 - _problems/hard/CONPOIN.md | 6 +- _problems/hard/COOK82E.md | 2 +- _problems/hard/COOLNUM.md | 6 +- _problems/hard/COT5.md | 1 - _problems/hard/COUNTARI.md | 3 +- _problems/hard/COVERING.md | 4 +- _problems/hard/CPP.md | 2 +- _problems/hard/CROCDILE.md | 14 +- _problems/hard/CUCUMBER.md | 2 +- _problems/hard/CUSTPRIM.md | 4 +- _problems/hard/CYDB.md | 8 +- _problems/hard/D4.md | 1 - _problems/hard/D7.md | 4 +- _problems/hard/DAGCH.md | 8 +- _problems/hard/DEG3MAXT.md | 2 +- _problems/hard/DEVLOCK.md | 3 +- _problems/hard/DFSGRID.md | 1 - _problems/hard/DGCD.md | 4 +- _problems/hard/DIFTRIP.md | 2 +- _problems/hard/DIGFORST.md | 1 - _problems/hard/DIGITS.md | 1 + _problems/hard/DIGITS2.md | 3 +- _problems/hard/DISTNUM.md | 4 +- _problems/hard/DISTNUM2.md | 5 +- _problems/hard/DIVIDEN.md | 1 + _problems/hard/DIVISORS.md | 2 +- _problems/hard/DIVNODIV.md | 2 +- _problems/hard/DMCS.md | 2 +- _problems/hard/DOMNOCUT.md | 3 +- _problems/hard/DORADM01.md | 1 - _problems/hard/DPOWPERM.md | 2 +- _problems/hard/DRAGONST.md | 2 +- _problems/hard/DUALPAL.md | 2 +- _problems/hard/E3.md | 1 - _problems/hard/EASYEX.md | 10 +- _problems/hard/ELPHANT.md | 16 +- _problems/hard/ESCAPE.md | 2 +- _problems/hard/EST.md | 3 +- _problems/hard/EVENPOLY.md | 2 +- _problems/hard/EVILBOOK.md | 2 + _problems/hard/EXPCOMM.md | 2 +- _problems/hard/F4.md | 1 - _problems/hard/F6.md | 1 - _problems/hard/FARASA.md | 2 +- _problems/hard/FBCHEF.md | 4 +- _problems/hard/FIBTREE.md | 8 +- _problems/hard/FINDSEQ.md | 2 +- _problems/hard/FLOWERPO.md | 2 +- _problems/hard/FLYDIST.md | 2 +- _problems/hard/FN.md | 3 +- _problems/hard/FSFSFS.md | 2 +- _problems/hard/FUNCTION.md | 4 +- _problems/hard/FURGRAPH.md | 1 - _problems/hard/G4.md | 3 +- _problems/hard/G5.md | 1 - _problems/hard/GENETICS.md | 1 - _problems/hard/GENIND.md | 1 - _problems/hard/GEOCHEAT.md | 4 +- _problems/hard/GERALD07.md | 1 - _problems/hard/GERALD08.md | 3 +- _problems/hard/GERALD2.md | 1 - _problems/hard/GNUM.md | 2 +- _problems/hard/GOODGAL.md | 4 +- _problems/hard/GQUERY.md | 2 +- _problems/hard/GRAPHCNT.md | 2 +- _problems/hard/GRAPHCT.md | 3 - _problems/hard/GRIDGAME.md | 4 +- _problems/hard/GST.md | 3 +- _problems/hard/GTHRONES.md | 2 +- _problems/hard/H3.md | 2 +- _problems/hard/HAMILG.md | 2 +- _problems/hard/HARMONY.md | 2 +- _problems/hard/HAUNTED.md | 1 - _problems/hard/HBEAR.md | 4 +- _problems/hard/HIGH.md | 1 - _problems/hard/HLD.md | 2 +- _problems/hard/HPARITY.md | 10 +- _problems/hard/HULL.md | 2 +- _problems/hard/HYPER.md | 3 +- _problems/hard/ICPC16F.md | 1 - _problems/hard/IMPROVE.md | 2 +- _problems/hard/INSOMB4.md | 5 +- _problems/hard/INSOMB8.md | 4 +- _problems/hard/INVBINCF.md | 6 +- _problems/hard/INVERT.md | 4 +- _problems/hard/IRONISL.md | 1 - _problems/hard/ISOARRAY.md | 2 +- _problems/hard/J5.md | 1 - _problems/hard/J6.md | 1 - _problems/hard/JAKKU.md | 2 +- _problems/hard/JUMP.md | 2 +- _problems/hard/KILLER.md | 2 +- _problems/hard/KNGHTMOV.md | 2 +- _problems/hard/KOL1511.md | 2 +- _problems/hard/KOL16C.md | 3 +- _problems/hard/KOL16D.md | 1 - _problems/hard/KOL16G.md | 1 - _problems/hard/KOL16I.md | 2 +- _problems/hard/L2.md | 1 - _problems/hard/L5.md | 1 - _problems/hard/LAMQUGAM.md | 2 +- _problems/hard/LCH15JGH.md | 3 +- _problems/hard/LCM.md | 1 - _problems/hard/LEBOXES.md | 3 +- _problems/hard/LECOINS.md | 2 +- _problems/hard/LELUCKYN.md | 2 +- _problems/hard/LEPAPER.md | 2 +- _problems/hard/LIGHTING.md | 1 - _problems/hard/LKYEDGE.md | 1 - _problems/hard/LMATRIX3.md | 6 +- _problems/hard/LOGO.md | 5 +- _problems/hard/LONGART.md | 4 +- _problems/hard/LPARTY.md | 4 +- _problems/hard/LUCKYDAY.md | 2 + _problems/hard/LYRC.md | 1 - _problems/hard/M1.md | 1 - _problems/hard/M2.md | 1 - _problems/hard/M4.md | 1 - _problems/hard/M5.md | 1 - _problems/hard/MAGIC.md | 3 +- _problems/hard/MARCHA3.md | 3 +- _problems/hard/MARCHA6.md | 2 +- _problems/hard/MARTARTS.md | 2 +- _problems/hard/MATCH.md | 4 +- _problems/hard/MATRIXUM.md | 1 - _problems/hard/MAXCIR.md | 3 +- _problems/hard/MEETUP.md | 2 +- _problems/hard/MGCH3D.md | 2 +- _problems/hard/MGCHGEOM.md | 1 - _problems/hard/MGCHGYM.md | 5 +- _problems/hard/MGCHPERM.md | 2 +- _problems/hard/MINDEG.md | 2 +- _problems/hard/MINESREV.md | 1 - _problems/hard/MINPOLY.md | 3 +- _problems/hard/MINWDSUM.md | 12 +- _problems/hard/MISINT2.md | 3 +- _problems/hard/MIXFLVOR.md | 2 +- _problems/hard/MONOPLOY.md | 4 +- _problems/hard/MSTONES.md | 1 - _problems/hard/MUFFINS.md | 1 - _problems/hard/MUFFINS2.md | 4 +- _problems/hard/MULDIG.md | 2 +- _problems/hard/N2.md | 3 +- _problems/hard/NPIN.md | 2 +- _problems/hard/NPLANAR.md | 2 +- _problems/hard/OAK.md | 14 +- _problems/hard/ORDERS.md | 3 +- _problems/hard/OVENTIME.md | 2 +- _problems/hard/OVERPNT.md | 4 +- _problems/hard/PALPROB.md | 4 +- _problems/hard/PALSTR.md | 4 +- _problems/hard/PARADE.md | 4 +- _problems/hard/PARSIN.md | 1 + _problems/hard/PERMUTE.md | 2 +- _problems/hard/POLY.md | 1 - _problems/hard/POST.md | 4 +- _problems/hard/POSTERS.md | 1 - _problems/hard/PPTREE.md | 6 +- _problems/hard/PRDIVSUM.md | 2 +- _problems/hard/PRIMEDST.md | 2 +- _problems/hard/PRUNING.md | 1 - _problems/hard/PTOSS.md | 2 +- _problems/hard/PUPPYGCD.md | 2 +- _problems/hard/PUSHFLOW.md | 1 - _problems/hard/QGRID.md | 2 +- _problems/hard/QMARKS.md | 2 +- _problems/hard/QPOINT.md | 2 +- _problems/hard/QPOLYSUM.md | 8 +- _problems/hard/QRECT.md | 1 + _problems/hard/QSTRING.md | 2 - _problems/hard/QTREE.md | 2 +- _problems/hard/QUERY.md | 6 +- _problems/hard/RANKA.md | 2 +- _problems/hard/REACHRIG.md | 1 - _problems/hard/REALSET.md | 2 +- _problems/hard/REARRAN.md | 2 +- _problems/hard/REBTET.md | 1 - _problems/hard/RESN02.md | 1 - _problems/hard/RESN03.md | 1 - _problems/hard/REVERSED.md | 1 - _problems/hard/RIN.md | 2 +- _problems/hard/RNG.md | 2 +- _problems/hard/ROUTES.md | 2 +- _problems/hard/RRTREE2.md | 3 +- _problems/hard/RUSHHOUR.md | 3 +- _problems/hard/SADPAIRS.md | 3 +- _problems/hard/SEAARC.md | 1 - _problems/hard/SEABOX.md | 3 +- _problems/hard/SEAEQ.md | 1 - _problems/hard/SEAINCR.md | 1 - _problems/hard/SEAINVS.md | 3 +- _problems/hard/SEALCM.md | 1 - _problems/hard/SEAORD.md | 1 - _problems/hard/SEAPERM3.md | 4 +- _problems/hard/SEAPERMS.md | 2 +- _problems/hard/SEGMENTQ.md | 2 +- _problems/hard/SEINC.md | 3 +- _problems/hard/SEQCOUNT.md | 2 +- _problems/hard/SEQTOWER.md | 4 +- _problems/hard/SERVERS.md | 2 +- _problems/hard/SEZ.md | 2 +- _problems/hard/SFUNC.md | 2 +- _problems/hard/SHORT.md | 3 +- _problems/hard/SHORT2.md | 3 +- _problems/hard/SHORTCIR.md | 2 +- _problems/hard/SIGFIB.md | 1 + _problems/hard/SINSUMQ.md | 1 - _problems/hard/SKIRES.md | 1 - _problems/hard/SLIS.md | 2 +- _problems/hard/SNCK02.md | 2 +- _problems/hard/SNCK03.md | 4 +- _problems/hard/SPMATRIX.md | 2 +- _problems/hard/SPSHORT.md | 3 +- _problems/hard/STARROAD.md | 4 +- _problems/hard/STEPNUMS.md | 1 - _problems/hard/STREDUC.md | 4 +- _problems/hard/STREETTA.md | 2 +- _problems/hard/STRQUER.md | 4 +- _problems/hard/STRQUERY.md | 7 +- _problems/hard/SUBGRAPH.md | 1 - _problems/hard/SUBQUERY.md | 2 +- _problems/hard/SUMDIS.md | 1 + _problems/hard/TABISHOP.md | 4 +- _problems/hard/TACTQUER.md | 2 +- _problems/hard/TAPAIR.md | 2 +- _problems/hard/TASUFFIX.md | 4 +- _problems/hard/TDRIVER.md | 1 - _problems/hard/TEAMSEL.md | 1 - _problems/hard/TERVEC.md | 2 +- _problems/hard/TESTERS.md | 1 - _problems/hard/TICKETS.md | 4 +- _problems/hard/TKCONVEX.md | 2 +- _problems/hard/TMP01.md | 2 +- _problems/hard/TRCNTCT.md | 2 +- _problems/hard/TREECNT2.md | 2 +- _problems/hard/TREEPATH.md | 2 +- _problems/hard/TRICONT.md | 2 +- _problems/hard/TRIPS.md | 1 - _problems/hard/TROOT.md | 1 - _problems/hard/TSPAGAIN.md | 5 +- _problems/hard/TSUBSTR.md | 1 - _problems/hard/TULIPS.md | 2 +- _problems/hard/TUPLES.md | 1 - _problems/hard/TUPLES2.md | 1 + _problems/hard/TUZTRN.md | 2 +- _problems/hard/TWOCOMP.md | 2 +- _problems/hard/TWOROADS.md | 2 +- _problems/hard/UNGAME.md | 2 +- _problems/hard/UPDTREE.md | 2 +- _problems/hard/WALKBT.md | 2 +- _problems/hard/WAYPA.md | 2 +- _problems/hard/WEASELSC.md | 8 +- _problems/hard/WESTAND.md | 2 +- _problems/hard/WINDOW.md | 2 +- _problems/hard/WIQ.md | 2 +- _problems/hard/WRDSUM.md | 2 +- _problems/hard/WTHINGS.md | 2 +- _problems/hard/XETF.md | 8 +- _problems/hard/XORTREEH.md | 4 +- _problems/hard/XRMTRX.md | 9 +- _problems/hard/XRQRS.md | 1 - _problems/hard/YASEQ.md | 4 +- _problems/medium/ABCSTR.md | 2 +- _problems/medium/ABX03.md | 2 +- _problems/medium/ADDFRAC.md | 5 +- _problems/medium/ADDMULT.md | 2 +- _problems/medium/AGENTS.md | 2 +- _problems/medium/AHWORK.md | 2 +- _problems/medium/ALEXROSE.md | 2 +- _problems/medium/ALOST.md | 4 +- _problems/medium/AMBALLS.md | 2 +- _problems/medium/AMR15B.md | 2 +- _problems/medium/AMR15C.md | 4 +- _problems/medium/AMROOK.md | 5 +- _problems/medium/AMSEQT.md | 4 +- _problems/medium/AMSTRING.md | 2 +- _problems/medium/AMXOR.md | 2 +- _problems/medium/ANCESTOR.md | 2 +- _problems/medium/ANCOIMP.md | 12 +- _problems/medium/AND.md | 2 +- _problems/medium/ANDGRAPH.md | 2 +- _problems/medium/ANDMIN.md | 3 +- _problems/medium/ANDOOR.md | 6 +- _problems/medium/ANDTUPLE.md | 2 +- _problems/medium/ANKINTER.md | 4 +- _problems/medium/ANKLEX.md | 4 +- _problems/medium/ANKMARKS.md | 4 +- _problems/medium/ANKNIM2.md | 5 +- _problems/medium/ANUAHR.md | 4 +- _problems/medium/ANUBGC.md | 6 +- _problems/medium/ANUBTT.md | 2 +- _problems/medium/ANUCBC.md | 2 +- _problems/medium/ANUGCD.md | 2 +- _problems/medium/ANUMLA.md | 4 +- _problems/medium/ANURRZ.md | 2 +- _problems/medium/ANUTDP.md | 4 +- _problems/medium/ARIGEOM.md | 1 + _problems/medium/ARITHPR.md | 1 - _problems/medium/ARRAYTRM.md | 3 - _problems/medium/ASHIGIFT.md | 2 +- _problems/medium/AX.md | 3 +- _problems/medium/B1.md | 3 +- _problems/medium/B3.md | 1 - _problems/medium/B5.md | 1 - _problems/medium/BAKE.md | 2 +- _problems/medium/BALANCED.md | 2 +- _problems/medium/BALANPOL.md | 2 +- _problems/medium/BBSYSTEM.md | 3 + _problems/medium/BCYCLES.md | 2 +- _problems/medium/BEAUTY.md | 2 +- _problems/medium/BESTSUM.md | 5 +- _problems/medium/BICO.md | 6 +- _problems/medium/BINTREEQ.md | 2 +- _problems/medium/BIPARTRE.md | 2 +- _problems/medium/BLOCKING.md | 1 - _problems/medium/BMASTER.md | 4 +- _problems/medium/BOMBING.md | 1 - _problems/medium/BRIBETR.md | 1 + _problems/medium/BRKTREE.md | 4 +- _problems/medium/BUTTONS.md | 1 - _problems/medium/BUYING.md | 2 +- _problems/medium/C2.md | 3 +- _problems/medium/C3.md | 3 +- _problems/medium/C5.md | 4 +- _problems/medium/CAKECUT.md | 3 +- _problems/medium/CALLSCHE.md | 7 +- _problems/medium/CANDY.md | 4 + _problems/medium/CANDYGAM.md | 8 +- _problems/medium/CAOS3.md | 2 +- _problems/medium/CARDLINE.md | 2 +- _problems/medium/CARDS777.md | 2 +- _problems/medium/CAREFUL.md | 3 +- _problems/medium/CARLOS.md | 4 +- _problems/medium/CATCHSM.md | 2 +- _problems/medium/CBARS.md | 7 +- _problems/medium/CFTREE.md | 1 - _problems/medium/CHEFAFD.md | 2 +- _problems/medium/CHEFANUP.md | 4 +- _problems/medium/CHEFAOR.md | 4 +- _problems/medium/CHEFB.md | 1 - _problems/medium/CHEFCLOS.md | 2 +- _problems/medium/CHEFCODE.md | 2 +- _problems/medium/CHEFD.md | 1 - _problems/medium/CHEFDIV.md | 3 +- _problems/medium/CHEFDOMA.md | 2 +- _problems/medium/CHEFDTRE.md | 2 +- _problems/medium/CHEFEXQ.md | 1 - _problems/medium/CHEFGAME.md | 2 +- _problems/medium/CHEFGIRL.md | 2 - _problems/medium/CHEFGRPH.md | 12 +- _problems/medium/CHEFHCK2.md | 8 +- _problems/medium/CHEFHOME.md | 1 - _problems/medium/CHEFINS.md | 2 +- _problems/medium/CHEFINV.md | 2 +- _problems/medium/CHEFKLCS.md | 2 +- _problems/medium/CHEFLAND.md | 4 +- _problems/medium/CHEFLIQD.md | 2 +- _problems/medium/CHEFLKJ.md | 2 +- _problems/medium/CHEFNUM.md | 2 +- _problems/medium/CHEFNUMK.md | 1 - _problems/medium/CHEFPASS.md | 6 +- _problems/medium/CHEFPCHF.md | 4 +- _problems/medium/CHEFPOLY.md | 2 +- _problems/medium/CHEFPRAD.md | 1 - _problems/medium/CHEFPRES.md | 2 +- _problems/medium/CHEFSHOP.md | 3 +- _problems/medium/CHEFUNI.md | 2 +- _problems/medium/CHEFVEC.md | 2 +- _problems/medium/CHEFWD.md | 15 +- _problems/medium/CHEFWORD.md | 5 +- _problems/medium/CHESSGM.md | 1 - _problems/medium/CHFQUEUE.md | 2 +- _problems/medium/CHGIFT1.md | 2 +- _problems/medium/CHGLSTGT.md | 1 + _problems/medium/CHIEFETT.md | 4 +- _problems/medium/CHINSM.md | 2 +- _problems/medium/CHITHH.md | 6 +- _problems/medium/CHN02.md | 2 +- _problems/medium/CHN06.md | 2 +- _problems/medium/CHN07.md | 2 +- _problems/medium/CHN11.md | 2 +- _problems/medium/CHNGSEQ.md | 3 +- _problems/medium/CHPLNTS.md | 2 +- _problems/medium/CHRL1.md | 2 +- _problems/medium/CHRL3.md | 3 +- _problems/medium/CHSEQ22.md | 4 +- _problems/medium/CHSPARR.md | 2 +- _problems/medium/CHSQARR.md | 9 +- _problems/medium/CHXORR.md | 2 +- _problems/medium/CIELBTL.md | 2 +- _problems/medium/CIELNUM3.md | 1 + _problems/medium/CIELQUIZ.md | 2 + _problems/medium/CIRCLEQ.md | 13 +- _problems/medium/CK87DANC.md | 2 +- _problems/medium/CK87MEAD.md | 4 +- _problems/medium/CLONEME.md | 2 +- _problems/medium/CLOSEFAR.md | 2 +- _problems/medium/CLOSESTQ.md | 2 +- _problems/medium/CNPIIM.md | 2 +- _problems/medium/CNR.md | 2 +- _problems/medium/CNTSOLS.md | 2 +- _problems/medium/CNTWAYS.md | 4 +- _problems/medium/COALSCAM.md | 2 +- _problems/medium/COFFEE.md | 2 +- _problems/medium/COINS.md | 3 +- _problems/medium/COLCHAIN.md | 1 - _problems/medium/COLLECT.md | 1 - _problems/medium/COLORING.md | 1 - _problems/medium/COMB4SUM.md | 6 +- _problems/medium/COOK82D.md | 2 +- _problems/medium/COOKOFF.md | 4 +- _problems/medium/COOKOFF2.md | 3 +- _problems/medium/COPRIME3.md | 2 +- _problems/medium/CORRCHK.md | 2 +- _problems/medium/COTA.md | 6 +- _problems/medium/COUNTIES.md | 1 - _problems/medium/COUNTWAY.md | 2 +- _problems/medium/COUPON.md | 6 +- _problems/medium/CROWNS.md | 2 +- _problems/medium/CSS2.md | 4 +- _problems/medium/CSUBQ.md | 4 +- _problems/medium/CUTSQRS.md | 3 +- _problems/medium/CYCLRACE.md | 3 +- _problems/medium/CYLINDER.md | 2 +- _problems/medium/D2.md | 2 +- _problems/medium/D3.md | 2 +- _problems/medium/DCE01.md | 14 +- _problems/medium/DDILEMMA.md | 1 - _problems/medium/DECORATE.md | 1 - _problems/medium/DEVBDAY.md | 2 +- _problems/medium/DEVGOSTR.md | 4 +- _problems/medium/DEVHAND.md | 2 +- _problems/medium/DEVSHOW.md | 2 +- _problems/medium/DEVVOTE.md | 2 +- _problems/medium/DGTCNT.md | 2 +- _problems/medium/DIGITLIS.md | 4 +- _problems/medium/DIGVIRUS.md | 2 +- _problems/medium/DINING.md | 2 +- _problems/medium/DIREL.md | 2 +- _problems/medium/DISTNUM3.md | 3 +- _problems/medium/DIVGAME.md | 1 - _problems/medium/DIVIDE.md | 2 +- _problems/medium/DIVPAIR.md | 1 - _problems/medium/DIVPRO.md | 10 +- _problems/medium/DIVSET.md | 2 +- _problems/medium/DIVSUBS.md | 2 +- _problems/medium/DYNAINV.md | 1 - _problems/medium/E2.md | 1 - _problems/medium/E4.md | 1 - _problems/medium/ECODE.md | 6 +- _problems/medium/EQUAKE.md | 8 +- _problems/medium/EQUATIO.md | 3 +- _problems/medium/ES.md | 4 +- _problems/medium/EXAMCOPY.md | 3 +- _problems/medium/EXGCD.md | 4 +- _problems/medium/EXNETWRK.md | 2 +- _problems/medium/EXPALIN.md | 2 +- _problems/medium/EXPGAME.md | 2 +- _problems/medium/F2.md | 2 +- _problems/medium/F3.md | 2 +- _problems/medium/FACTSUM.md | 3 +- _problems/medium/FAIRPAIR.md | 2 +- _problems/medium/FALLDOWN.md | 6 +- _problems/medium/FAVGAME.md | 4 +- _problems/medium/FAVNUM.md | 9 +- _problems/medium/FCUBE.md | 2 +- _problems/medium/FDIVGAME.md | 2 +- _problems/medium/FFUNCT.md | 4 +- _problems/medium/FLOORDIS.md | 2 +- _problems/medium/FLOORSMV.md | 2 +- _problems/medium/FLY.md | 6 +- _problems/medium/FOMBRO.md | 2 +- _problems/medium/FOURPTS.md | 2 +- _problems/medium/FOURSQ.md | 4 +- _problems/medium/FRBSUM.md | 2 +- _problems/medium/FRJUMP.md | 2 +- _problems/medium/FRMQ.md | 6 +- _problems/medium/FUNAGP.md | 2 +- _problems/medium/FUNC.md | 1 + _problems/medium/G1.md | 2 +- _problems/medium/G2.md | 1 - _problems/medium/G3.md | 2 +- _problems/medium/GAMCOUNT.md | 4 +- _problems/medium/GAMSTICK.md | 1 - _problems/medium/GANGAAM.md | 2 +- _problems/medium/GAPFILL.md | 4 +- _problems/medium/GERALD06.md | 1 - _problems/medium/GERALD3.md | 1 - _problems/medium/GIVCANDY.md | 1 + _problems/medium/GLASS.md | 4 +- _problems/medium/GPD.md | 4 +- _problems/medium/GRAPLANE.md | 1 - _problems/medium/GRIDCHEF.md | 4 +- _problems/medium/GRIDCOL.md | 2 +- _problems/medium/GRIDCONN.md | 2 +- _problems/medium/GROUPING.md | 3 +- _problems/medium/GRTRIP.md | 10 +- _problems/medium/H2.md | 1 - _problems/medium/H4.md | 1 - _problems/medium/HAIRCUT.md | 2 +- _problems/medium/HAPPY.md | 1 - _problems/medium/HBIRD.md | 8 +- _problems/medium/HCLEAN.md | 2 +- _problems/medium/HILLJUMP.md | 2 +- _problems/medium/HISTJUNK.md | 2 +- _problems/medium/HLDOTS.md | 2 +- _problems/medium/HOB.md | 14 +- _problems/medium/HOB2.md | 10 +- _problems/medium/IDOLS.md | 2 +- _problems/medium/INCXOR.md | 2 +- _problems/medium/INSOMA3.md | 1 - _problems/medium/INSOMA4.md | 1 - _problems/medium/INSOMA5.md | 4 +- _problems/medium/INSOMB3.md | 4 +- _problems/medium/INVITES.md | 2 +- _problems/medium/ISONUM.md | 2 +- _problems/medium/J1.md | 1 - _problems/medium/J2.md | 1 - _problems/medium/JABO.md | 3 +- _problems/medium/JRNTREE.md | 6 +- _problems/medium/JTREE.md | 2 +- _problems/medium/JUNONGF.md | 2 +- _problems/medium/K3.md | 1 - _problems/medium/KCHIPS.md | 4 +- _problems/medium/KCONNECT.md | 2 +- _problems/medium/KINT.md | 6 +- _problems/medium/KIRMEME.md | 1 - _problems/medium/KMHAMHA.md | 1 - _problems/medium/KNIGHTS.md | 4 +- _problems/medium/KNODES.md | 2 +- _problems/medium/KNPSK.md | 2 +- _problems/medium/KOL1501.md | 6 +- _problems/medium/KOL1503.md | 2 +- _problems/medium/KOL1505.md | 2 +- _problems/medium/KOL1507.md | 2 +- _problems/medium/KOL1508.md | 2 +- _problems/medium/KOL1510.md | 2 +- _problems/medium/KOL16A.md | 3 +- _problems/medium/KOL16E.md | 1 - _problems/medium/KOL16K.md | 2 +- _problems/medium/KOL16L.md | 5 +- _problems/medium/KTHCON.md | 1 - _problems/medium/KUNIQUE.md | 5 +- _problems/medium/L1.md | 2 +- _problems/medium/L4.md | 3 +- _problems/medium/LABEL.md | 2 +- _problems/medium/LCH15CD.md | 1 - _problems/medium/LCH15JEF.md | 3 +- _problems/medium/LEBINARY.md | 6 +- _problems/medium/LEBLOCKS.md | 3 +- _problems/medium/LEBOBBLE.md | 1 - _problems/medium/LEFEED.md | 4 +- _problems/medium/LEMOVIE.md | 4 +- _problems/medium/LEPAINT.md | 3 +- _problems/medium/LFEB14A.md | 2 +- _problems/medium/LFIVES.md | 2 +- _problems/medium/LIGHT.md | 1 - _problems/medium/LIKECS04.md | 6 +- _problems/medium/LIKECS05.md | 6 +- _problems/medium/LISLDS.md | 2 +- _problems/medium/LMA1.md | 2 +- _problems/medium/LOGGERS.md | 3 +- _problems/medium/LOTERY.md | 3 +- _problems/medium/LPAIR.md | 4 +- _problems/medium/LSTGRPH.md | 2 +- _problems/medium/LTM40EF.md | 1 - _problems/medium/LTM40GH.md | 1 - _problems/medium/LUCKFILL.md | 3 +- _problems/medium/LUCKG.md | 4 +- _problems/medium/LUCKY3.md | 3 +- _problems/medium/LUCKY4.md | 2 +- _problems/medium/LUCKY8.md | 4 +- _problems/medium/LUCKY9.md | 1 - _problems/medium/LUCKYCOM.md | 2 +- _problems/medium/LUCKYSWP.md | 2 +- _problems/medium/LVGFT.md | 2 +- _problems/medium/M3.md | 1 - _problems/medium/MACGUN.md | 1 - _problems/medium/MADHAT.md | 4 +- _problems/medium/MAKELIS.md | 1 + _problems/medium/MAKPALIN.md | 2 +- _problems/medium/MANYLIST.md | 2 +- _problems/medium/MARBLES.md | 1 - _problems/medium/MARCHA4.md | 1 - _problems/medium/MARRAYS.md | 2 +- _problems/medium/MATCUT.md | 3 +- _problems/medium/MATRIX2.md | 2 +- _problems/medium/MAXGAME.md | 4 +- _problems/medium/MAXGRID.md | 2 +- _problems/medium/MAXMATCH.md | 2 +- _problems/medium/MAXOR.md | 2 +- _problems/medium/MAZE.md | 2 +- _problems/medium/MBOARD.md | 16 +- _problems/medium/MCKTUR.md | 2 +- _problems/medium/MDIST.md | 4 +- _problems/medium/MEANMEDI.md | 4 +- _problems/medium/MEDIAN.md | 1 - _problems/medium/MENU.md | 1 - _problems/medium/METEORAK.md | 3 +- _problems/medium/MIKE2.md | 2 +- _problems/medium/MINSHIFT.md | 1 + _problems/medium/MINXOR.md | 2 +- _problems/medium/MIXTURES.md | 2 +- _problems/medium/MLCHEF.md | 18 +- _problems/medium/MMADNESS.md | 2 +- _problems/medium/MMATCH.md | 1 - _problems/medium/MMPROD.md | 2 +- _problems/medium/MONEY.md | 1 - _problems/medium/MOREFB.md | 2 +- _problems/medium/MOSTDIST.md | 5 +- _problems/medium/MOU1H.md | 6 +- _problems/medium/MOU2H.md | 4 +- _problems/medium/MSTQS.md | 4 +- _problems/medium/MTMXSUM.md | 7 +- _problems/medium/MTRICK.md | 3 +- _problems/medium/MULTQ3.md | 3 - _problems/medium/MXSM.md | 2 +- _problems/medium/N3.md | 1 - _problems/medium/NETWORK.md | 2 + _problems/medium/NEWREST.md | 1 + _problems/medium/NI03.md | 1 - _problems/medium/NI04.md | 1 - _problems/medium/NI05.md | 1 - _problems/medium/NOKIA.md | 2 +- _problems/medium/NONPALIN.md | 2 +- _problems/medium/NUMFACT.md | 6 +- _problems/medium/NUMSUM.md | 1 - _problems/medium/NWAYS.md | 4 +- _problems/medium/ODDBIN.md | 1 + _problems/medium/OLYMPIC.md | 2 +- _problems/medium/ONEKING.md | 2 +- _problems/medium/OPTSSET.md | 3 +- _problems/medium/ORDERAAM.md | 2 +- _problems/medium/PAINTBOX.md | 2 +- _problems/medium/PAINTING.md | 4 +- _problems/medium/PAIRCLST.md | 2 +- _problems/medium/PALIN3.md | 2 +- _problems/medium/PALINDR.md | 2 +- _problems/medium/PALIPALI.md | 1 - _problems/medium/PARALLEL.md | 2 +- _problems/medium/PARITREE.md | 2 +- _problems/medium/PARPOLY.md | 2 + _problems/medium/PATTMATC.md | 2 +- _problems/medium/PDSNUM.md | 1 - _problems/medium/PEAKS.md | 2 +- _problems/medium/PEOPLOVE.md | 2 +- _problems/medium/PERMDIG.md | 2 +- _problems/medium/PERSHFTS.md | 2 +- _problems/medium/PHOTOS.md | 1 - _problems/medium/PHRASES.md | 3 +- _problems/medium/POLYEVAL.md | 8 +- _problems/medium/POSTAL.md | 1 - _problems/medium/POUR1.md | 3 +- _problems/medium/POWERMUL.md | 2 +- _problems/medium/POWSUMS.md | 6 +- _problems/medium/PP.md | 2 +- _problems/medium/PPERM.md | 2 +- _problems/medium/PPLUCKY.md | 2 +- _problems/medium/PPXOR.md | 6 +- _problems/medium/PREFIXOR.md | 1 - _problems/medium/PREPARE.md | 1 - _problems/medium/PRIME1.md | 3 +- _problems/medium/PRMQ.md | 2 +- _problems/medium/PROPOSAL.md | 7 +- _problems/medium/PSHTBRTH.md | 3 +- _problems/medium/PSHTTR.md | 1 - _problems/medium/PUPPYCT.md | 10 +- _problems/medium/PUPPYPLM.md | 4 +- _problems/medium/PUZZLES.md | 2 +- _problems/medium/QCHEF.md | 6 +- _problems/medium/QNUMBER.md | 2 +- _problems/medium/QSET.md | 4 +- _problems/medium/QUEHEA.md | 2 +- _problems/medium/RAINFALL.md | 6 +- _problems/medium/REBXOR.md | 4 +- _problems/medium/REDBLUE.md | 1 - _problems/medium/REFUELS.md | 1 + _problems/medium/REGIONS.md | 10 +- _problems/medium/REIGN2.md | 1 - _problems/medium/REPSTR.md | 2 +- _problems/medium/RESN01.md | 1 - _problems/medium/RESTEXP.md | 6 +- _problems/medium/RESTOCK.md | 1 - _problems/medium/RESTPERM.md | 1 - _problems/medium/RIPPLE.md | 2 +- _problems/medium/RIVPILE.md | 2 +- _problems/medium/RNDGRID.md | 5 +- _problems/medium/ROBOTDAG.md | 2 +- _problems/medium/ROTPTS.md | 1 - _problems/medium/ROTSTRNG.md | 4 +- _problems/medium/RRBIGNUM.md | 4 +- _problems/medium/RRDAG.md | 1 - _problems/medium/RRFRNDS.md | 2 +- _problems/medium/RRJAM.md | 3 +- _problems/medium/RRPLAYER.md | 2 +- _problems/medium/RRSERVER.md | 2 +- _problems/medium/RRTREE.md | 1 - _problems/medium/RSRECIPE.md | 2 +- _problems/medium/SANDWICH.md | 2 +- _problems/medium/SBSTCNT.md | 6 +- _problems/medium/SBSWAP.md | 2 +- _problems/medium/SEABAL.md | 2 +- _problems/medium/SEABUB.md | 3 +- _problems/medium/SEADIV.md | 1 - _problems/medium/SEAGCD.md | 1 - _problems/medium/SEAGCD2.md | 1 - _problems/medium/SEAGM.md | 3 +- _problems/medium/SEAGM2.md | 1 - _problems/medium/SEAKAM.md | 3 +- _problems/medium/SEAPAIR.md | 5 +- _problems/medium/SEAPERM2.md | 1 - _problems/medium/SEAPROAR.md | 16 +- _problems/medium/SEASTONE.md | 2 +- _problems/medium/SEATR.md | 3 +- _problems/medium/SEATR2.md | 2 +- _problems/medium/SEATSR.md | 3 +- _problems/medium/SEAVOTE.md | 4 +- _problems/medium/SEEDLING.md | 2 +- _problems/medium/SEEDS.md | 1 - _problems/medium/SEGPROD.md | 5 +- _problems/medium/SEGTREE2.md | 10 +- _problems/medium/SELECT.md | 8 +- _problems/medium/SEQLCS.md | 2 +- _problems/medium/SEQUAT2.md | 4 +- _problems/medium/SEQUENCE.md | 1 - _problems/medium/SEREJA.md | 2 +- _problems/medium/SHAIKHGN.md | 9 +- _problems/medium/SHDWCMP.md | 10 +- _problems/medium/SHGAME.md | 2 +- _problems/medium/SHOOTING.md | 1 - _problems/medium/SHTARR.md | 3 +- _problems/medium/SHUFFL.md | 6 +- _problems/medium/SKIING.md | 2 +- _problems/medium/SMARKET.md | 4 +- _problems/medium/SNCK01.md | 2 +- _problems/medium/SNCK05.md | 1 - _problems/medium/SNDISCUS.md | 2 +- _problems/medium/SNGRAPH.md | 2 +- _problems/medium/SOCIAL.md | 4 +- _problems/medium/SOLDIER.md | 1 - _problems/medium/SORTING.md | 2 +- _problems/medium/SPCLN.md | 2 +- _problems/medium/SPOONS.md | 2 +- _problems/medium/SQNUMBF.md | 2 +- _problems/medium/SQUAGAME.md | 1 - _problems/medium/SQUIRREL.md | 4 +- _problems/medium/SSTORY.md | 4 +- _problems/medium/STABLEMP.md | 3 +- _problems/medium/STADIUM.md | 3 +- _problems/medium/STDPRGS.md | 8 +- _problems/medium/STETSKLX.md | 2 +- _problems/medium/STRAB.md | 2 +- _problems/medium/STREGGS.md | 2 + _problems/medium/STRINGRA.md | 2 +- _problems/medium/SUBARR.md | 2 +- _problems/medium/SUBARRAY.md | 2 +- _problems/medium/SUBINVER.md | 6 +- _problems/medium/SUBLCM.md | 2 +- _problems/medium/SUBSEG2.md | 1 + _problems/medium/SUBSGM.md | 2 +- _problems/medium/SUBTREE.md | 2 +- _problems/medium/SUMCUBE.md | 4 +- _problems/medium/SUMPP.md | 7 +- _problems/medium/SUMSLOPE.md | 3 - _problems/medium/SVNTR.md | 2 +- _problems/medium/SWARM.md | 1 - _problems/medium/SWINDOW.md | 2 +- _problems/medium/TAACUTE.md | 4 +- _problems/medium/TAAND.md | 6 +- _problems/medium/TABLECOV.md | 2 +- _problems/medium/TABUS.md | 6 +- _problems/medium/TACHEMIS.md | 2 +- _problems/medium/TACNTSTR.md | 2 +- _problems/medium/TADELIVE.md | 2 +- _problems/medium/TAEDITOR.md | 4 +- _problems/medium/TAKEAWAY.md | 4 +- _problems/medium/TALCA.md | 2 +- _problems/medium/TANGDIV.md | 2 +- _problems/medium/TANGLED.md | 1 + _problems/medium/TAPOINT.md | 2 +- _problems/medium/TAQTREE.md | 2 +- _problems/medium/TARPRACT.md | 4 +- _problems/medium/TASHIFT.md | 1 - _problems/medium/TASTR.md | 2 +- _problems/medium/TASTRMAT.md | 4 +- _problems/medium/TASTYD.md | 6 +- _problems/medium/TASUMOBC.md | 1 - _problems/medium/TAUT.md | 3 +- _problems/medium/TCP.md | 5 +- _problems/medium/TEAMSIZE.md | 6 +- _problems/medium/TELEPORT.md | 2 +- _problems/medium/TERM.md | 1 - _problems/medium/TETRA.md | 1 - _problems/medium/TFOSS.md | 4 +- _problems/medium/THEGAME.md | 2 +- _problems/medium/THREECOL.md | 4 +- _problems/medium/TKCHOCS.md | 4 +- _problems/medium/TMRATING.md | 8 +- _problems/medium/TOMJERGA.md | 2 +- _problems/medium/TOOLS.md | 2 +- _problems/medium/TR2.md | 1 - _problems/medium/TRAINING.md | 4 +- _problems/medium/TRANSFIG.md | 6 +- _problems/medium/TRAVELAL.md | 2 +- _problems/medium/TRAVTREE.md | 4 +- _problems/medium/TREE.md | 3 +- _problems/medium/TREEDIAM.md | 2 +- _problems/medium/TREEFUN.md | 2 +- _problems/medium/TREEP.md | 2 +- _problems/medium/TREEPROD.md | 2 +- _problems/medium/TREERGB.md | 4 +- _problems/medium/TREEROOT.md | 4 +- _problems/medium/TREES.md | 3 - _problems/medium/TRIPCOST.md | 12 +- _problems/medium/TRIQUERY.md | 1 - _problems/medium/TSHIRTS.md | 2 +- _problems/medium/TWINRO.md | 1 - _problems/medium/TWOCHEFS.md | 4 + _problems/medium/TWOCOINS.md | 2 +- _problems/medium/TWONIM.md | 1 - _problems/medium/TWTCLOSE.md | 4 +- _problems/medium/TYTACTIC.md | 3 +- _problems/medium/UNFRIEND.md | 6 +- _problems/medium/UNIQUE.md | 2 +- _problems/medium/UNPAIR.md | 4 +- _problems/medium/URBANDEV.md | 1 - _problems/medium/VISITALL.md | 1 - _problems/medium/VOTING.md | 5 +- _problems/medium/WALL.md | 1 - _problems/medium/WEAPONS.md | 2 +- _problems/medium/WEASELTX.md | 12 +- _problems/medium/WORDS1.md | 3 +- _problems/medium/WORKCHEF.md | 8 +- _problems/medium/WPLAY.md | 11 +- _problems/medium/WPROB.md | 2 +- _problems/medium/WSC.md | 6 +- _problems/medium/WSCAGAIN.md | 8 +- _problems/medium/WW2.md | 2 +- _problems/medium/XOR.md | 4 +- _problems/medium/XORGRID.md | 5 +- _problems/medium/XORPATH.md | 4 +- _problems/medium/XORSUMS.md | 2 +- _problems/medium/XRGRD.md | 2 +- _problems/medium/YALOP.md | 2 +- _problems/medium/ZENCALC.md | 6 +- _problems/school/ADACRA.md | 2 +- _problems/school/ALEXTASK.md | 2 +- _problems/school/ALPHABET.md | 2 +- _problems/school/ALTARAY.md | 2 +- _problems/school/AMR15A.md | 10 +- _problems/school/ANKTRAIN.md | 1 - _problems/school/BOOKCHEF.md | 2 +- _problems/school/BRACKETS.md | 3 +- _problems/school/BRLADDER.md | 2 +- _problems/school/BUGCAL.md | 1 - _problems/school/C00K0FF.md | 2 +- _problems/school/CANDY123.md | 2 +- _problems/school/CATSDOGS.md | 2 +- _problems/school/CFRTEST.md | 2 +- _problems/school/CHCHCL.md | 2 +- _problems/school/CHEFAPAR.md | 2 +- _problems/school/CHEFARRP.md | 2 +- _problems/school/CHEFDETE.md | 6 +- _problems/school/CHEFKEY.md | 2 +- _problems/school/CHEFROUT.md | 2 +- _problems/school/CHEFSQ.md | 3 +- _problems/school/CHEFSTLT.md | 4 +- _problems/school/CHEFSTUD.md | 2 +- _problems/school/CHEFSUM.md | 7 +- _problems/school/CHN08.md | 2 +- _problems/school/CHN09.md | 2 +- _problems/school/CHNGOR.md | 2 +- _problems/school/CHOPRT.md | 2 +- _problems/school/CHRL2.md | 3 +- _problems/school/CHRL4.md | 2 +- _problems/school/CIELRCPT.md | 2 + _problems/school/CK87MEDI.md | 2 +- _problems/school/COLOR.md | 4 +- _problems/school/COMM3.md | 1 - _problems/school/COOK82A.md | 2 +- _problems/school/COOMILK.md | 1 + _problems/school/COPS.md | 2 +- _problems/school/DEVARRAY.md | 2 +- _problems/school/DEVUGRAP.md | 2 +- _problems/school/DWNLD.md | 4 +- _problems/school/EGRANDR.md | 2 +- _problems/school/ELEVSTRS.md | 1 - _problems/school/ENTEXAM.md | 4 +- _problems/school/FBMT.md | 1 - _problems/school/FCTRL.md | 5 +- _problems/school/FCTRL2.md | 3 +- _problems/school/FLOW001.md | 1 - _problems/school/FLOW002.md | 1 - _problems/school/FLOW004.md | 1 - _problems/school/FLOW005.md | 1 - _problems/school/FLOW006.md | 1 - _problems/school/FLOW007.md | 1 - _problems/school/FLOW008.md | 1 - _problems/school/FLOW009.md | 1 - _problems/school/FLOW010.md | 1 - _problems/school/FLOW011.md | 1 - _problems/school/FLOW013.md | 1 - _problems/school/FLOW014.md | 1 - _problems/school/FLOW015.md | 1 - _problems/school/FLOW016.md | 1 - _problems/school/FLOW017.md | 1 - _problems/school/FLOW018.md | 1 - _problems/school/FRGTNLNG.md | 1 - _problems/school/FRUITS.md | 2 +- _problems/school/FSQRT.md | 1 - _problems/school/GDOG.md | 2 +- _problems/school/GIT01.md | 1 - _problems/school/GOODSET.md | 2 +- _problems/school/HEADBOB.md | 2 +- _problems/school/HS08TEST.md | 5 +- _problems/school/ICPC16A.md | 4 +- _problems/school/ICPC16B.md | 2 +- _problems/school/INTEST.md | 1 - _problems/school/KOL16B.md | 5 +- _problems/school/KOL16J.md | 2 +- _problems/school/KTTABLE.md | 8 +- _problems/school/LADDU.md | 2 +- _problems/school/LCH15JAB.md | 1 - _problems/school/LCOLLIS.md | 2 +- _problems/school/LIKECS01.md | 6 +- _problems/school/LISDIGIT.md | 6 +- _problems/school/LONGSEQ.md | 2 +- _problems/school/LOSTMAX.md | 2 +- _problems/school/LTM40AB.md | 1 - _problems/school/LUCKFOUR.md | 5 +- _problems/school/MATPAN.md | 3 +- _problems/school/MISSP.md | 2 - _problems/school/MNMX.md | 2 +- _problems/school/MOVIEWKN.md | 2 +- _problems/school/MUFFINS3.md | 4 +- _problems/school/MXZERO.md | 4 +- _problems/school/NITIKA.md | 2 +- _problems/school/NOTINCOM.md | 2 +- _problems/school/NW1.md | 2 +- _problems/school/OMWG.md | 6 +- _problems/school/ONP.md | 3 +- _problems/school/PALL01.md | 1 - _problems/school/PERFCONT.md | 2 +- _problems/school/PERMUT2.md | 3 +- _problems/school/PPSUM.md | 2 +- _problems/school/PRB01.md | 1 - _problems/school/RAINBOWA.md | 2 +- _problems/school/RECIPE.md | 4 +- _problems/school/RECTSQ.md | 1 - _problems/school/REMISS.md | 3 +- _problems/school/RGAME.md | 2 +- _problems/school/RNDPAIR.md | 1 - _problems/school/RRJOKE.md | 4 +- _problems/school/SEBIHWY.md | 6 +- _problems/school/SEGM01.md | 2 +- _problems/school/SIMDISH.md | 2 +- _problems/school/SIMPSTAT.md | 4 +- _problems/school/SMPAIR.md | 2 +- _problems/school/SMRSTR.md | 2 +- _problems/school/SNAKPROC.md | 2 +- _problems/school/SNAPE.md | 1 - _problems/school/SNELECT.md | 2 +- _problems/school/SPALNUM.md | 2 +- _problems/school/START01.md | 3 +- _problems/school/STICKS.md | 2 +- _problems/school/STRPALIN.md | 4 +- _problems/school/STUDVOTE.md | 4 +- _problems/school/SUBINC.md | 2 +- _problems/school/SUMTRIAN.md | 4 +- _problems/school/TALAZY.md | 2 +- _problems/school/TEAMFORM.md | 2 +- _problems/school/TEMPLELA.md | 2 +- _problems/school/TEST.md | 1 - _problems/school/TICKETS5.md | 1 - _problems/school/TLG.md | 7 +- _problems/school/TRICOIN.md | 2 +- _problems/school/TRISQ.md | 1 - _problems/school/TSORT.md | 3 +- _problems/school/TTENIS.md | 2 +- _problems/school/TWEED.md | 2 +- _problems/school/TWONMS.md | 2 +- _problems/school/TWOSTR.md | 2 +- _problems/school/UTMOPR.md | 3 +- _problems/school/VCS.md | 2 +- _problems/school/VILTRIBE.md | 1 - _problems/school/WDTBAM.md | 8 +- _problems/school/XENTASK.md | 2 +- composer.lock | 713 ++++++++++++--------------------- 1663 files changed, 2420 insertions(+), 3117 deletions(-) diff --git a/_problems/challenge/L2GRAPH.md b/_problems/challenge/L2GRAPH.md index f236bacb..510f3127 100644 --- a/_problems/challenge/L2GRAPH.md +++ b/_problems/challenge/L2GRAPH.md @@ -67,8 +67,8 @@ Each test case will be given a score d\*L/K where d is the dimension provided in 2 3 - ### Explanation Of Sample Data + The provided answers are certainly not optimal for either test case, but they are valid solutions according to the output specification and such output would be accepted. The score for this output would be as follows. In the first test case, we would have K = 1 since the Euclidean distance from the point representing node 2 to the points representing either 0 or 1 is exactly 2 and the Euclidean distance between the points representing nodes 0 and 1 exceeds 1. We also have L = sqrt(8)/1 since sqrt(8) is the distance between the points representing nodes 0 and 1 and 1 is distance between nodes 0 and 1 in the original graph. Thus, the score for this case is d\*L/K = 2\*sqrt(8) = 5.6568542. diff --git a/_problems/easy/A1.md b/_problems/easy/A1.md index e132dc28..1f704805 100644 --- a/_problems/easy/A1.md +++ b/_problems/easy/A1.md @@ -132,5 +132,4 @@ Yes Yes No Yes - -**Explanation:** For example, in the last case you have to pay up, since: 6+3+123=132. \ No newline at end of file +**Explanation:** For example, in the last case you have to pay up, since: 6+3+123=132. diff --git a/_problems/easy/A2.md b/_problems/easy/A2.md index 66f16c0a..b94133cc 100644 --- a/_problems/easy/A2.md +++ b/_problems/easy/A2.md @@ -91,5 +91,4 @@ For each test case, output a line containing exactly one of the words 'Yes' or ' Output: Yes No - \ No newline at end of file diff --git a/_problems/easy/A3.md b/_problems/easy/A3.md index 57ec0172..42734bda 100644 --- a/_problems/easy/A3.md +++ b/_problems/easy/A3.md @@ -113,5 +113,4 @@ For each test case output a line containing a single integer, equal to the minim 0 1 2 - -**Explanation:** for the respective test cases, the number picked by Johnny could have been e.g. _n_=100, _n_=5, and _n_=1. \ No newline at end of file +**Explanation:** for the respective test cases, the number picked by Johnny could have been e.g. _n_=100, _n_=5, and _n_=1. diff --git a/_problems/easy/A4.md b/_problems/easy/A4.md index 877dff2e..4d387528 100644 --- a/_problems/easy/A4.md +++ b/_problems/easy/A4.md @@ -87,5 +87,4 @@ For each test case, print out one line containing two numbers, separated by a sp Output 25 56 387 489 - \ No newline at end of file diff --git a/_problems/easy/ABABAABA.md b/_problems/easy/ABABAABA.md index 578de4e8..78d69909 100644 --- a/_problems/easy/ABABAABA.md +++ b/_problems/easy/ABABAABA.md @@ -108,8 +108,8 @@ BAB Output: -1 B - ### Explanation + **Test case #1**: - The string "AAAA" appears once as a subsequence in itself. diff --git a/_problems/easy/ABREPEAT.md b/_problems/easy/ABREPEAT.md index f415f6b8..e0ee03d6 100644 --- a/_problems/easy/ABREPEAT.md +++ b/_problems/easy/ABREPEAT.md @@ -111,8 +111,8 @@ abzbabzbazab 6 2 64197148392731290 - ### Explanation + **Test case 1.** Limak repeated the string "abcb" 2 times, and so he got "abcbabcb". There are 6 occurrences of the subsequence "ab": - ABcbabcb (the two letters marked uppercase) diff --git a/_problems/easy/ABROADS.md b/_problems/easy/ABROADS.md index 7885b0f0..9d7e0876 100644 --- a/_problems/easy/ABROADS.md +++ b/_problems/easy/ABROADS.md @@ -130,8 +130,8 @@ D 3 6 13 10 - ### Explanation + - After the first query, the populations are **(3, 2, 3)** and the most populated region is **{1, 2, 3}**. - After the second query the populations and the regions remain the same. - After the third query the populations are **(3, 3, 3)** and the most populated region is again **{1, 2, 3}**. diff --git a/_problems/easy/ABX01.md b/_problems/easy/ABX01.md index d43382cc..cbbea22a 100644 --- a/_problems/easy/ABX01.md +++ b/_problems/easy/ABX01.md @@ -128,8 +128,8 @@ For each test case, print a single line containing one integer — the value of 7 4 1 - ### Explanation + **Example case 1:** F(5 · 5) = F(25) = F(2+5) = F(7) = 7 **Example case 2:** F(7 · 7) = F(49) = F(4+9) = F(13) = F(1+3) = F(4) = 4 diff --git a/_problems/easy/ABX02.md b/_problems/easy/ABX02.md index ceefef01..ac2dc9aa 100644 --- a/_problems/easy/ABX02.md +++ b/_problems/easy/ABX02.md @@ -135,8 +135,8 @@ For each test case, print a single line containing one integer — the number of 2 1024 - ### Explanation + **Example case 1:** We have 2 sweets in box 1 and 2 sweets in box 2. All possible sequences **P1..4** are: 1122, 2211, 1212, 2121, 1221 and 2112. Out of them, only 1212 and 2121 are valid, since **S1** = **S2** = 1. **Example case 2:** All possible 210 sequences are valid. diff --git a/_problems/easy/ADDMUL.md b/_problems/easy/ADDMUL.md index 4de4d477..6ee9bf10 100644 --- a/_problems/easy/ADDMUL.md +++ b/_problems/easy/ADDMUL.md @@ -82,23 +82,23 @@ You are given a one dimensional integer array **A** of length **N**. You need to for (i = x; i <= y; i++) Ai += v; Ai %= M; - -
**Query 2** : 2 x y v  This implies multiplying the scalar v with the array **A** for all the indices from x to y, i.e.,
+
**Query 2** : 2 x y v 
+ This implies multiplying the scalar v with the array **A** for all the indices from x to y, i.e.,
 ``
 
  ```
 for (i = x; i <= y; i++)	
         Ai *= v
         Ai %= M
-
-
**Query 3** : 3 x y v This implies initializing the array **A** at all the indices from x to y with the value v, i.e., +
**Query 3** : 3 x y v + This implies initializing the array **A** at all the indices from x to y with the value v, i.e., `` ``` for (i = x; i <= y; i++) Ai = v -
**Query 4** : 4 x y
+
  This is a report query which needs to find the sum of the values in **A** from x to y, i.e.,
 ``
 
@@ -108,8 +108,8 @@ for (i = x; i <= y; i++)
 	sum += Ai
 	sum %= M
 Output sum.
-
 
**Note:** a%b represents the remainder of a when divided by b. + ### Input - First line contains two space separated integers **N**, **Q**. @@ -149,8 +149,8 @@ Output sum. 10 69 -
### Explanation
+
 Initial **A** : \[1, 2, 3, 4\]
  Result of first query : 1 + 2 + 3 + 4 = 10
  **A** after second query: \[ 11, 12, 13, 4\]
diff --git a/_problems/easy/ADIGIT.md b/_problems/easy/ADIGIT.md
index afbd146d..e4108990 100644
--- a/_problems/easy/ADIGIT.md
+++ b/_problems/easy/ADIGIT.md
@@ -76,7 +76,7 @@ All submissions for this problem are available.###  Read problems statements in
 
 - On each step he choose an index **x** from **1** to **n**.
 - For all indices **y (y < x)** he calculated the difference **by** = **ax** - **ay**.
-- Then he calculated **B1** - sum of all **by** which are greater than  and **B2** - sum of all **by** which are less than .
+- Then he calculated **B1** - sum of all **by** which are greater than 0 and **B2** - sum of all **by** which are less than 0.
 - The answer for this step is **B1 - B2**.
 
 Chef remembers the game, but forgot the answer. Please, help him!
@@ -93,7 +93,7 @@ Chef remembers the game, but forgot the answer. Please, help him!
 ### Constraints
 
 - **1** ≤ **n, m** ≤ **10^5**
-- ≤ **ai** ≤ **9**
+- 0 ≤ **ai** ≤ **9**
 - **1** ≤ **x** ≤ **n**
 
 ### Example
@@ -110,7 +110,6 @@ Chef remembers the game, but forgot the answer. Please, help him!
 7
 9
 
-
 
 

 

Explanation

@@ -135,5 +134,4 @@ and the answer is 7.

so B1 = 2 + 1 = 3, B2 = -1 -2 -3 = -6 and the answer is 9.

-
\ No newline at end of file diff --git a/_problems/easy/ADMAG.md b/_problems/easy/ADMAG.md index 45e712c8..875e018f 100644 --- a/_problems/easy/ADMAG.md +++ b/_problems/easy/ADMAG.md @@ -107,8 +107,8 @@ Seeing you thoroughly puzzled, she explains that she can apply the trick so fast Output: 1 3 - ### Explanation + - **In example 1**, only **1** card containing **{1}** will work. - **In example 2**, make **3** cards containing **{1,4}, {2}** and **{3,4}**. - Assume you thought of **1**, then you will select the 1st card **{1,4}**, then she will correctly figure out the integer you thought being **1**. diff --git a/_problems/easy/ADTRI.md b/_problems/easy/ADTRI.md index 769ccc7d..9139d0a0 100644 --- a/_problems/easy/ADTRI.md +++ b/_problems/easy/ADTRI.md @@ -108,6 +108,6 @@ For each test case, output "YES" if the triangle transformation is possible, oth Output: YES NO - ### Explanation + - In test case 1, make the length of any one side **6**, and it will suffice. diff --git a/_problems/easy/AEHASH.md b/_problems/easy/AEHASH.md index afab88f8..1adb01bc 100644 --- a/_problems/easy/AEHASH.md +++ b/_problems/easy/AEHASH.md @@ -24,6 +24,7 @@ The pseudocode of the hash function is as below. hash(S) is the hash value of a return result end function The function split in the above pseudocode takes a binary string S as the parameter and returns a pair of binary strings (S1, S2) such that: + - |S1| <= |S2|. - The difference of |S1| and |S2| is at most 1. - The concatenation of S1 and S2 (in that order) is S. @@ -62,8 +63,8 @@ For each test case, output a single line consisting the number of different bina 1 3 4 - ### Explanation + For the last test case, the solutions are: - AAEAAE - AEAAAE - AAEAEA diff --git a/_problems/easy/ALETHIO.md b/_problems/easy/ALETHIO.md index de56b0c5..bad80e52 100644 --- a/_problems/easy/ALETHIO.md +++ b/_problems/easy/ALETHIO.md @@ -72,7 +72,7 @@ All submissions for this problem are available.Lyra Belacqua is a very gifted gi The alethiometer had four needles, out of which the user would direct three of them to lie over symbols on the face of the device to ask a question. The fourth needle then swung into action and pointed to various symbols one after another, thus telling the answer. -For this problem, consider the alethiometer consisting of symbols : digits ''-'**9**' and letters '**A**'-'**Z**'. Learned scholars were debating the age of the Universe, and they requested Lyra to find out the age from the alethiometer. Having asked the question, the fourth needle started spouting out symbols, which Lyra quickly recorded. In that long string of characters, she knows that some substring corresponds to the age of the Universe. She also knows that the alethiometer could have wrongly pointed out atmost one digit (0-9) as a letter (A-Z). She then wonders what is the maximum possible age of the Universe. +For this problem, consider the alethiometer consisting of symbols : digits '0'-'**9**' and letters '**A**'-'**Z**'. Learned scholars were debating the age of the Universe, and they requested Lyra to find out the age from the alethiometer. Having asked the question, the fourth needle started spouting out symbols, which Lyra quickly recorded. In that long string of characters, she knows that some substring corresponds to the age of the Universe. She also knows that the alethiometer could have wrongly pointed out atmost one digit (0-9) as a letter (A-Z). She then wonders what is the maximum possible age of the Universe. Given the set of symbols the alethiometer pointed out, help her find the maximum age of the Universe, which could correspond to a substring of the original string with atmost one letter changed. @@ -107,8 +107,8 @@ C0D3C43F Output2: 3943 - ### Explanation + In the first example, there is no choice as to what the number can be. It has to be 6,454. In the second example, there are a total of 41 possible strings (one for the original, and 10 for changing each letter). You can verify that the maximum number as a substring is got by making the string "C0D3943F". diff --git a/_problems/easy/ALEXNUMB.md b/_problems/easy/ALEXNUMB.md index afa3b9ad..57610b94 100644 --- a/_problems/easy/ALEXNUMB.md +++ b/_problems/easy/ALEXNUMB.md @@ -85,7 +85,7 @@ For each test case, output a single line containing number of pairs for correspo - **1** ≤ **T** ≤ **4** - **1** ≤ **n** ≤ **100000** -- ≤ **ai** ≤ **109** +- 0 ≤ **ai** ≤ **109** - All the ai are distinct ### Example @@ -96,13 +96,13 @@ For each test case, output a single line containing number of pairs for correspo 2 1 3 3 1 2 - **Output:** +
 1
 3
-
 
### Explanation + Case 1: Only one such pair: (2,1) Case 2: 3 possible pairs: (2,1), (2,3), (3,1) diff --git a/_problems/easy/AMMEAT.md b/_problems/easy/AMMEAT.md index 0eefba15..e231dc88 100644 --- a/_problems/easy/AMMEAT.md +++ b/_problems/easy/AMMEAT.md @@ -96,6 +96,6 @@ For each test case, output an integer, denoting the minimum number of plates. If Output: 2 - ### Explanation + If he takes **3**rd and **4**th plates, then we may eat **P3 + P4 = 7** meatballs in Las Vegas. This is the only way for eating at least **M = 7** meatballs with **2** plates. diff --git a/_problems/easy/AMMEAT2.md b/_problems/easy/AMMEAT2.md index 17daf621..d16579df 100644 --- a/_problems/easy/AMMEAT2.md +++ b/_problems/easy/AMMEAT2.md @@ -99,8 +99,8 @@ For each test case, output **K** distinct integers, denoting the number of selec Output: 45 63 35 -1 - ### Explanation + **Example case 1**: One of the possible choices is that he takes **45**th plate, **63**rd plate, and **35**th plate. Because **GCD(45, 63) = 9**, **GCD(45, 35) = 5**, diff --git a/_problems/easy/AMR15D.md b/_problems/easy/AMR15D.md index 46f8acd6..ded5ef16 100644 --- a/_problems/easy/AMR15D.md +++ b/_problems/easy/AMR15D.md @@ -93,7 +93,7 @@ Output exactly **Q** integers on separate lines, where the output on the **ith** - **1** ≤ **N** ≤ **105** - **1** ≤ **Q** ≤ **105** -- ≤ **K** ≤ **N-1** +- 0 ≤ **K** ≤ **N-1** - **1** ≤ **Ai** ≤ **104** ### Example @@ -108,8 +108,8 @@ Output exactly **Q** integers on separate lines, where the output on the **ith** Output: 10 3 - ### Explanation + **For the first query**, **K = 0**. Hence, Bhallaladeva cannot take gold plates from any of the houses for free. It will cost him 3 + 2 + 1 + 4 = **10** nimbdas. **For the second query**, **K = 2**. In the first step Bhallaladeva can pay **2** nimbdas for gold plates in house number 2, and take the gold in houses 1 and 4 for free (Note that house 1 has 3 gold plates and house 4 has 4 gold plates). Now, he has looted houses 1, 2 & 4. Now in the second step, he loots house 3, by paying **1** nimbda. Hence, the total cost = 1 + 2 = **3**. Note that there might be multiple ways to achieve the minimum cost, and we have explained only one of them. diff --git a/_problems/easy/AMSGAME1.md b/_problems/easy/AMSGAME1.md index 240fa660..aec5a71a 100644 --- a/_problems/easy/AMSGAME1.md +++ b/_problems/easy/AMSGAME1.md @@ -109,8 +109,8 @@ For each test case, **output a single integer** - the value of all the numbers w 1 1 - ### Explanation + **Test Case 1:** Since there are only two numbers, the operations are forced. - { 10, 12 } => Replace 12 with ( 12 - 10 = 2 ) => { 10, 2 } diff --git a/_problems/easy/AMSGAME2.md b/_problems/easy/AMSGAME2.md index cbd49d3f..cdb76857 100644 --- a/_problems/easy/AMSGAME2.md +++ b/_problems/easy/AMSGAME2.md @@ -112,8 +112,8 @@ For each test case, **output a single integer** - the number of **sub-sequences* 7 1 - ### Explanation + **Test Case 1:** The following 11 sub-sequences are counted. - { 2, 3 } diff --git a/_problems/easy/ANKGAME.md b/_problems/easy/ANKGAME.md index d9483823..c18210d5 100644 --- a/_problems/easy/ANKGAME.md +++ b/_problems/easy/ANKGAME.md @@ -107,14 +107,14 @@ For each test case, output a single integer corresponding to the answer for that 2 2 3 - **Sample Output:** +
 2
 2
 
-
 
**Explanation:** + **Case 1:** The following different orders are possible: diff --git a/_problems/easy/ANKPAL.md b/_problems/easy/ANKPAL.md index 8c735a23..d33e4cab 100644 --- a/_problems/easy/ANKPAL.md +++ b/_problems/easy/ANKPAL.md @@ -111,15 +111,15 @@ ababa 1 3 3 5 2 4 1 5 - **Sample Output:** +
 Yes
 No
 Yes
 Yes
-
 
### Explanation: + **Query 1:**The string becomes a**ab**ba. The queried substring is _bb_, which is a palindrome. **Query 2:**The string becomes **ba**aba. The queried substring is _ab_, which is not a palindrome. diff --git a/_problems/easy/ANKPAREN.md b/_problems/easy/ANKPAREN.md index ea6caf05..3077264b 100644 --- a/_problems/easy/ANKPAREN.md +++ b/_problems/easy/ANKPAREN.md @@ -118,8 +118,8 @@ Output exactly **T** lines, each containing answer to the corresponding query. (()) 3 - **Sample Output:** +
 )
 (()
@@ -127,8 +127,8 @@ Output exactly **T** lines, each containing answer to the corresponding query.
 ())
 -1
 
-
 
### Explanation: + **Case 1:**Following are the subsequences:
@@ -138,8 +138,8 @@ Length   Subsequence   Regular/Non-Regular
   1			)			Non-regular
   2			()			Regular
 
-
-
There are two non-regular subsequences of equal length:'(' and ')'.We are asked for the lexicographically 2nd, so output should be ')'. +There are two non-regular subsequences of equal length:'(' and ')'. +We are asked for the lexicographically 2nd, so output should be ')'. **Case 2:**Following are the subsequences: @@ -151,8 +151,8 @@ Length Subsequence Regular/Non-Regular 2 () Regular 3 (() Non-Regular - In this case, there are non-regular subsequences of lengths 1, 2, and 3. But, as 3 is the maximum among these, we choose, **(()**. + **Case 3:** The string is same as Case 2, and we realize that there is only one subsequence of the maximum length 3, thus we must output -1. @@ -164,8 +164,8 @@ Length Subsequence 3 ()) 3 (() - -In lexicographical order, we have following subsequences: \[ ((), ()) \]The query asks for 2nd subsequence, thus the required output is ()). +In lexicographical order, we have following subsequences: \[ ((), ()) \] +The query asks for 2nd subsequence, thus the required output is ()). **Case 5:** This is the same sequence as last case, and we know that there are exactly 2 distinct subsequences of maximum length. Thus, answer should be -1. diff --git a/_problems/easy/ANUARM.md b/_problems/easy/ANUARM.md index 0cc59b3a..085f8fc5 100644 --- a/_problems/easy/ANUARM.md +++ b/_problems/easy/ANUARM.md @@ -93,7 +93,7 @@ For each test case, output one line with **N** space separated integers. - **1** ≤ **M** ≤ **10^5** - **1** ≤ **Sum of N over all testcases** ≤ **10^5** - **1** ≤ **Sum of M over all testcases** ≤ **10^5** -- ≤ **Positions selected by captain** ≤ **N-1** +- 0 ≤ **Positions selected by captain** ≤ **N-1** ### Example @@ -108,5 +108,4 @@ For each test case, output one line with **N** space separated integers. 1 0 1 2 3 2 1 1 2 3 - \ No newline at end of file diff --git a/_problems/easy/ANUBTG.md b/_problems/easy/ANUBTG.md index d5898148..8a8a7cbf 100644 --- a/_problems/easy/ANUBTG.md +++ b/_problems/easy/ANUBTG.md @@ -105,8 +105,8 @@ For each test case, output a single line containing the required answer. 4 210 14 - ### Explanation + **Example case 1** Suraj pays for 2 costly items and gets other 2 for free. diff --git a/_problems/easy/ANUDTC.md b/_problems/easy/ANUDTC.md index 7cc04f37..0c57e6c9 100644 --- a/_problems/easy/ANUDTC.md +++ b/_problems/easy/ANUDTC.md @@ -115,8 +115,8 @@ Answers for 3 questions (in the order above) must be space separated on the same Output: y y y n y y - ### Explanation + **Example case 1.** Is it possible to make **N** equal pieces? diff --git a/_problems/easy/ANUTHM.md b/_problems/easy/ANUTHM.md index 1c332376..0b9e16f4 100644 --- a/_problems/easy/ANUTHM.md +++ b/_problems/easy/ANUTHM.md @@ -104,17 +104,17 @@ For each test case, output a single line containing the required answer. Answers Output: 3.000000 6.000000 - ### Explanation + **Example case 1** Probability matrix P for N=2, M=2 is -1\.0 0.5 -0\.5 1.0 +1.0 0.5 +0.5 1.0 You are at (1, 1) initially. So the probablity of visiting (1, 1) is 1. At (1, 1) you have 2 options, move below to (2, 1) or to right cell (1, 2). Probablity of going to (1, 2) is 0.5. Probability of going to (2, 1) is 0.5. You always end up at (2, 2), so P\[2\]\[2\] is 1. Required sum = 1.0 + 0.5 + 0.5 + 1.0 = 3.0 **Example case 2** Probability matrix P for N=1, M=6 is -1\.0 1.0 1.0 1.0 1.0 1.0 +1.0 1.0 1.0 1.0 1.0 1.0 Because at any position there is only one possible next position. diff --git a/_problems/easy/ANUWTA.md b/_problems/easy/ANUWTA.md index a1375518..65ba70c2 100644 --- a/_problems/easy/ANUWTA.md +++ b/_problems/easy/ANUWTA.md @@ -97,8 +97,8 @@ For each test case, output the distance you walked. Output 2 5 - ### Explanation + **Testcase #2** You are initially at (0, 0) Right most on-light is (2, 0). Distance = 2. diff --git a/_problems/easy/APPROX.md b/_problems/easy/APPROX.md index 05cfe13c..896167d8 100644 --- a/_problems/easy/APPROX.md +++ b/_problems/easy/APPROX.md @@ -84,7 +84,7 @@ For each test case output a single line containing the value of **103993/33102** ### Constraints -- ≤ **K** ≤ **106** +- 0 ≤ **K** ≤ **106** - **1** ≤ **T** ≤ **2000** - The sum of **K** over the input does not exceed **106** @@ -101,8 +101,8 @@ For each test case output a single line containing the value of **103993/33102** 3 3.141592 3.14159265301190260407 - ### Explanation + **Example case 1.** Here **K = 0** so we don't need to output any digits after the decimal point. The decimal point itself also should not be output. **Example case 2.** Note that here we **truncate** (not round) the actual value of **103993/33102** to **6** digits after the decimal point. As you see from example case 3 rounded value here differs from truncated one. diff --git a/_problems/easy/APPROX2.md b/_problems/easy/APPROX2.md index 44c58a7c..8a07ed5c 100644 --- a/_problems/easy/APPROX2.md +++ b/_problems/easy/APPROX2.md @@ -104,6 +104,6 @@ For each test case, output a single line containing two single space separated i Output: 1 4 - ### Explanation: + The minimal possible absolute difference of **1** can be obtained by taking the pairs of **a1** and **a2**, **a1** and **a4**, **a2** and **a4**, **a3** and **a4**. diff --git a/_problems/easy/ARRANGE.md b/_problems/easy/ARRANGE.md index cda10689..5024e97e 100644 --- a/_problems/easy/ARRANGE.md +++ b/_problems/easy/ARRANGE.md @@ -39,5 +39,4 @@ For each test case you are to output the scrambled message on a single line. Output: cehf eayejpuinpopolre - \ No newline at end of file diff --git a/_problems/easy/ARRGAME2.md b/_problems/easy/ARRGAME2.md index b0388762..1ce8ed91 100644 --- a/_problems/easy/ARRGAME2.md +++ b/_problems/easy/ARRGAME2.md @@ -120,6 +120,6 @@ For each test case, output a single line containing answer for corresponding tes 0.000000 - ### Explanation + **Example case 1.** Game will have only 1 turn. Chef will choose 3, while Sasha will choose 4. Since 34>43 girl will kiss boy. Hence answer is 1. diff --git a/_problems/easy/ASP.md b/_problems/easy/ASP.md index 3ad4c72b..edb0b064 100644 --- a/_problems/easy/ASP.md +++ b/_problems/easy/ASP.md @@ -107,5 +107,4 @@ For each test case, output "YES" or "NO" (without quotes) to indicate whether th Output: YES NO - \ No newline at end of file diff --git a/_problems/easy/ASTRGAME.md b/_problems/easy/ASTRGAME.md index bfc94834..45b1181f 100644 --- a/_problems/easy/ASTRGAME.md +++ b/_problems/easy/ASTRGAME.md @@ -50,8 +50,8 @@ ppi Tracy Tracy Teddy - ### Constraints + - 1 <= _T_ <= 5 - 1 <= _N_ <= 30 - 1 <= |_S_| <= 30 diff --git a/_problems/easy/ASTRING.md b/_problems/easy/ASTRING.md index cf63b4d0..abbb9b07 100644 --- a/_problems/easy/ASTRING.md +++ b/_problems/easy/ASTRING.md @@ -110,8 +110,8 @@ bacb Output: abc ab - ### Explanation + **Example case 1.** "abc" is the smallest lexicographical subsequence out of \["abd", "bdc", "abc", "adc"\]. **Example case 2.** "ab" is the smallest lexicographical subsequence of length 2. diff --git a/_problems/easy/ATOMS.md b/_problems/easy/ATOMS.md index bcf49a7d..22bc4970 100644 --- a/_problems/easy/ATOMS.md +++ b/_problems/easy/ATOMS.md @@ -41,5 +41,4 @@ For each test case you are to output a single integer indicating the minimum num Output: 3 4 - \ No newline at end of file diff --git a/_problems/easy/ATTIC.md b/_problems/easy/ATTIC.md index 66fa5335..4fb8ff05 100644 --- a/_problems/easy/ATTIC.md +++ b/_problems/easy/ATTIC.md @@ -116,8 +116,8 @@ For each case, output the number of days it takes them to cross the passage. 2 1 2 - ### Explanation + For the first example, they do not need to learn any jump size. They are able to cross the entire passage by "jumping" lengths 1-1-1. For the second example case, they get stuck at the first '.', and take one day learning to jump length 2. When they come back the next day, they get stuck at '..' and take one day to learn to jump length 3. diff --git a/_problems/easy/AVGSHORT.md b/_problems/easy/AVGSHORT.md index e04ef611..ff62ef8e 100644 --- a/_problems/easy/AVGSHORT.md +++ b/_problems/easy/AVGSHORT.md @@ -130,6 +130,6 @@ If there is no path at all, output just **-1** on the corresponding line of the Output: 1.5 1.0 - ### Explanation + **Example case 1.** The walk 1 -> 2 and 2 -> 3 has average length of 3/2 = 1.5. Any other walks in the graph will have more or equal average length than this. diff --git a/_problems/easy/BANDMATR.md b/_problems/easy/BANDMATR.md index b6250ce4..2a79570c 100644 --- a/_problems/easy/BANDMATR.md +++ b/_problems/easy/BANDMATR.md @@ -83,8 +83,8 @@ For example, for the below given matrix, the bandwith of this matrix is 2. 1 0 0 0 1 1 1 1 0 - Bandwidth of the below matrix is 1. ![](https://codechef_shared.s3.amazonaws.com/download/upload/MARCH17/bandmatr1.png) + Bandwidth of the below matrix is 2. ![](https://codechef_shared.s3.amazonaws.com/download/upload/MARCH17/bandmatr2.png) Bandwidth of the below matrix is also 2. ![](https://codechef_shared.s3.amazonaws.com/download/upload/MARCH17/bandmatr3.png) @@ -147,8 +147,8 @@ For each test case, output a single integer corresponding to the minimum bandwid 1 1 3 - ### Explanation + **Example case 1.** The bandwidth of a matrix will all zero entries will be zero. This is the minimum bandwidth you can get, so there is no need of performing any swap operation. **Example case 2.** The bandwidth of a diagonal matrix will also be zero. @@ -163,5 +163,4 @@ For each test case, output a single integer corresponding to the minimum bandwid 1 0 0 0 1 1 0 1 1 - -The bandwidth of this matrix is 1. **Example case 6.** The swap operations won't have any effect on the matrix. Its bandwidth is equal to 3. \ No newline at end of file +The bandwidth of this matrix is 1. **Example case 6.** The swap operations won't have any effect on the matrix. Its bandwidth is equal to 3. diff --git a/_problems/easy/BANROB.md b/_problems/easy/BANROB.md index da364926..b792d6ff 100644 --- a/_problems/easy/BANROB.md +++ b/_problems/easy/BANROB.md @@ -94,7 +94,7 @@ For each test case, output a single line containing two space-separated doubles ### Constraints and subtasks - **1** ≤ **T** ≤ **105** -- ≤ **p** ≤ **1** +- 0 ≤ **p** ≤ **1** **Subtask 1** (15 points) : **1** ≤ **M** ≤ **3** @@ -114,6 +114,6 @@ For each test case, output a single line containing two space-separated doubles Output: 1000000000.0 0.0 500000000.0 500000000.0 - ### Explanation + **Example case 1.** In the second case, if decision isn't made at **t = 0**, total amount of money decreases to 5\*108 at **t = 1** which leads to a situation worse than the given solution. diff --git a/_problems/easy/BASE.md b/_problems/easy/BASE.md index e790b575..34ef7107 100644 --- a/_problems/easy/BASE.md +++ b/_problems/easy/BASE.md @@ -89,16 +89,16 @@ For each test case, output a single line containing the number of bases **b**, o ### Subtasks **Subtask #1 (16 points):**- **1** ≤ **T** ≤ **103** -- ≤ **N** 103 +- 0 ≤ **N** 103 **Subtask #2 (24 points):**- **1** ≤ **T** ≤ **103** -- ≤ **N** 106 +- 0 ≤ **N** 106 **Subtask #3 (28 points):**- **1** ≤ **T** ≤ **103** -- ≤ **N** 1012 +- 0 ≤ **N** 1012 **Subtask #4 (32 points):**- **1** ≤ **T** ≤ **105** -- ≤ **N** 1012 +- 0 ≤ **N** 1012 ### Example @@ -114,6 +114,6 @@ For each test case, output a single line containing the number of bases **b**, o 7 8 14 - ### Explanation + In the first test case, **6** has a leading digit **1** in bases **2**, **4**, **5** and **6**: **610 = 1102 = 124 = 115 = 106**. diff --git a/_problems/easy/BEARSEG.md b/_problems/easy/BEARSEG.md index 77fa1295..e3cfc555 100644 --- a/_problems/easy/BEARSEG.md +++ b/_problems/easy/BEARSEG.md @@ -123,8 +123,8 @@ For each test case, output two space separated integers denoting the maximum sco 4 2 9 1 2 2 - ### Explanation + **Example case 1.** There are three segments - \[1\], \[2\] and \[1, 2\]. Sum of these segments are 1, 2 and 3 respectively. Sum of these segments modulo 3 will be 1, 2 and 0. Maximum score among these is 2. There is also only one segment with this score. **Example case 2.** There are six segments - \[2\], \[4\], \[3\], \[2, 4\], \[4, 3\] and \[2, 4, 3\]. Sum of these segments are 2, 4, 3, 6, 7, 9 respectively. Sum of these segments modulo 5 will be 2, 4, 3, 1, 2, 4. Maximum score among these is 4. And there are two segments with this score. diff --git a/_problems/easy/BEX.md b/_problems/easy/BEX.md index 9da154e2..bf2f60d3 100644 --- a/_problems/easy/BEX.md +++ b/_problems/easy/BEX.md @@ -108,5 +108,4 @@ For each -1 in the input, output a single line containing the number of books Ha Output: 1 mathematics 0 graphics - \ No newline at end of file diff --git a/_problems/easy/BGQRS.md b/_problems/easy/BGQRS.md index ce93dbbc..cb135d85 100644 --- a/_problems/easy/BGQRS.md +++ b/_problems/easy/BGQRS.md @@ -123,8 +123,8 @@ For each test case, output a single line containing the sum of answers of all th Output: 5 - ### Explanation + Array: **\[2, 4, 3, 5, 5\]** - 1st query: **\[4, 3, 5\]**, 4 \* 3 \* 5 = 60 : answer 1. diff --git a/_problems/easy/BIGPIZA.md b/_problems/easy/BIGPIZA.md index 24180ba6..a14718c2 100644 --- a/_problems/easy/BIGPIZA.md +++ b/_problems/easy/BIGPIZA.md @@ -44,8 +44,8 @@ Arjuna Arjuna Bhima Arjuna - -**Explanation:** + +**Explanation:** Let the people around the table are numbered 1, 2, ... , N in clock-wise order as shown in the image diff --git a/_problems/easy/BINOP.md b/_problems/easy/BINOP.md index 8aec8fa7..4f04562c 100644 --- a/_problems/easy/BINOP.md +++ b/_problems/easy/BINOP.md @@ -135,8 +135,8 @@ Lucky Chef 2 Unlucky Chef - ### Explanation + **Example case 1.** - Applying XOR operation with indices i = 1 and j = 2. Resulting string will be 011. diff --git a/_problems/easy/BINTOUR.md b/_problems/easy/BINTOUR.md index 39efb5cf..b9d3d6f1 100644 --- a/_problems/easy/BINTOUR.md +++ b/_problems/easy/BINTOUR.md @@ -107,7 +107,6 @@ Output should consist of **2K** lines. The **i**'th line should contain the numb Output: 2 2 -
Input:
 2
 
@@ -116,8 +115,8 @@ Output should consist of **2K** lines. The **i**'th line should contain the numb
 8
 16
 24
-
 
### Explanation + In the first example we have **N**=2 knights. Let's consider each initial configuration that could appear and simulate the tournament. (1, 2) -> (2) diff --git a/_problems/easy/BINTREE.md b/_problems/easy/BINTREE.md index 92b8148e..d047fd25 100644 --- a/_problems/easy/BINTREE.md +++ b/_problems/easy/BINTREE.md @@ -99,6 +99,6 @@ For each query, print the required answer in one line. 1 2 3 - ### Explanation + For first query, 1 is directly connected to 2 by an edge. Hence distance 1. diff --git a/_problems/easy/BIPIN3.md b/_problems/easy/BIPIN3.md index 7aa770d3..40c81366 100644 --- a/_problems/easy/BIPIN3.md +++ b/_problems/easy/BIPIN3.md @@ -122,8 +122,8 @@ For each test-case, output a single line denoting the answer of the problem. Output: 2 12 - ### Explanation + In the first sample test case, there are 2 zombies. Let us name them Z1 and Z2. Let one hierarchy be one in which Z1 is parent of Z2. There are 2 colors, suppose red and blue. If Z1 takes red, then Z2 should take a blue. If Z1 takes blue, then Z2 should take red. Note that one other possible hierarchy could be one in which Z2 is a parent of Z1. In that hierarchy also, number of possible ways of assigning cars is 2. So there maximum number of possible ways is 2. diff --git a/_problems/easy/BLACKCOM.md b/_problems/easy/BLACKCOM.md index 2f35f1bf..cd2a6b1d 100644 --- a/_problems/easy/BLACKCOM.md +++ b/_problems/easy/BLACKCOM.md @@ -119,8 +119,8 @@ Yes Yes No No - ### Explanation + **Query 1**: The subgraph containing the nodes {6, 7, 9} is a connected subgraph because (6, 7) and (6, 9) are edges in the original tree. And it has exactly two black nodes (7 and 9). So, there is at least one connected subgraph of size exactly 3 which has exactly 2 black nodes. Hence the answer is "Yes". **Query 2**: The subgraph containing the nodes {1, 2, 3, 4, 6, 7, 8} is a connected subgraph. And it has exactly three black nodes (2, 4 and 7). So, there is at least one connected subgraph of size exactly 7 which has exactly 3 black nodes. Hence the answer is "Yes". diff --git a/_problems/easy/BOGOSORT.md b/_problems/easy/BOGOSORT.md index b512802c..f71f2d2f 100644 --- a/_problems/easy/BOGOSORT.md +++ b/_problems/easy/BOGOSORT.md @@ -40,5 +40,4 @@ For each test case output the expected amount of shuffles needed for the improve 1826/189 877318/35343 - \ No newline at end of file diff --git a/_problems/easy/BOUQUET.md b/_problems/easy/BOUQUET.md index df57151f..56c7bede 100644 --- a/_problems/easy/BOUQUET.md +++ b/_problems/easy/BOUQUET.md @@ -92,7 +92,7 @@ The third line of each test case contains three space-separated integers **PG PY ### Output -For each test case, output a single line containing the maximal amount of flowers in _nice_ bouquet, satisfying all conditions or if it's impossible to create any bouquet, satisfying the conditions. +For each test case, output a single line containing the maximal amount of flowers in _nice_ bouquet, satisfying all conditions or 0 if it's impossible to create any bouquet, satisfying the conditions. ### Constraints @@ -110,6 +110,6 @@ For each test case, output a single line containing the maximal amount of flower Output: 7 - ### Explanation + **Example case 1.** We can create a bouquet with **7** leaves, for example, by collecting all yellow leaves. This is not the only way to create the nice bouquet with **7** leaves (for example, Sergey can use all but one red leaves), but it is impossible to create a nice bouquet with more than **7** leaves. diff --git a/_problems/easy/BROKPHON.md b/_problems/easy/BROKPHON.md index 0812ff99..5007f5c7 100644 --- a/_problems/easy/BROKPHON.md +++ b/_problems/easy/BROKPHON.md @@ -120,7 +120,7 @@ Please help Chef to find the number of players that could mishear the message or 4 3 0 - ### Explanation + - **Example 1**: The **3-rd**, **4-th**, **6-th** and **7-th** player could mishear the message or whisper it wrongly. - **Example 2**: First **3** players could mishear the message or whisper it wrongly. diff --git a/_problems/easy/BTAR.md b/_problems/easy/BTAR.md index 947e0be5..55d4cb0c 100644 --- a/_problems/easy/BTAR.md +++ b/_problems/easy/BTAR.md @@ -109,5 +109,4 @@ For each test case, print a single line containing one number — the minimum nu Output: 3 - \ No newline at end of file diff --git a/_problems/easy/BUYING2.md b/_problems/easy/BUYING2.md index 3e65f2c9..55e6bc7a 100644 --- a/_problems/easy/BUYING2.md +++ b/_problems/easy/BUYING2.md @@ -59,8 +59,8 @@ For each test case output exactly one line containing a single integer: -1 1 7 - ### Explanation + In the first test case, the total amount of money received from the customer is 27. He can't buy more than 3 sweets with this amount. If you throw away the banknote of value 5 (or of value 4), it will still be possible to buy 3 sweets. Hence the customer is inadequate. In the second test case, it's clear that he wants to buy just one sweet (note that this number should be positive). diff --git a/_problems/easy/BWALL.md b/_problems/easy/BWALL.md index 6c6f6a85..928343ae 100644 --- a/_problems/easy/BWALL.md +++ b/_problems/easy/BWALL.md @@ -58,5 +58,4 @@ X#

XX #X - \ No newline at end of file diff --git a/_problems/easy/BWCELL.md b/_problems/easy/BWCELL.md index 0a7bcfcd..1dae4ac7 100644 --- a/_problems/easy/BWCELL.md +++ b/_problems/easy/BWCELL.md @@ -100,8 +100,8 @@ BWBB Chef Aleksa Aleksa - ### Explanation + - **Test 1 :** Aleksa cannot make a move in her first turn as there is no black cell in the given configuration. - **Test 2 :** Aleksa can remove 1 black cell lying on the left of white cell in her turn. But then, Chef cannot make a move in his turn as there will be no black cells left. - **Test 3 :** Figure out yourself. diff --git a/_problems/easy/BWKNIGHT.md b/_problems/easy/BWKNIGHT.md index da5938b3..9c8027cd 100644 --- a/_problems/easy/BWKNIGHT.md +++ b/_problems/easy/BWKNIGHT.md @@ -28,17 +28,14 @@ Sample Input : 2 3 4 5 -
 Sample Output :
 12
 26
 312
 
-
 
 Constraints :
 1 <= T <= 10000
 1 <= N,M <= 100000
-
 
\ No newline at end of file diff --git a/_problems/easy/BYTEISLE.md b/_problems/easy/BYTEISLE.md index e11041e8..6d3e1239 100644 --- a/_problems/easy/BYTEISLE.md +++ b/_problems/easy/BYTEISLE.md @@ -51,8 +51,8 @@ For each test case, output two lines. In the first line, output a single integer 0000 1 101 - ### Constraints + - 1 <= _T_ <= 5 - 1 <= _N_ <= 50000 - 0 <= _ai_ <= _bi_ <= _N_ diff --git a/_problems/easy/C4.md b/_problems/easy/C4.md index 6f40be4b..0b545b07 100644 --- a/_problems/easy/C4.md +++ b/_problems/easy/C4.md @@ -50,8 +50,8 @@ baba IMPOSSIBLE aaa ab - -**Comments:** + +**Comments:** For the first guest we have five ingredients: a, b, c, d, e with protein values 12 1 12 4 4 respectively. To achieve a total protein value equal to 2 we need two ingredients b. But there is only one, thus the answer is IMPOSSIBLE. diff --git a/_problems/easy/CAKEDOOM.md b/_problems/easy/CAKEDOOM.md index 714671cb..52e46249 100644 --- a/_problems/easy/CAKEDOOM.md +++ b/_problems/easy/CAKEDOOM.md @@ -84,7 +84,7 @@ What does it mean? Let's numerate positions for the cherries by the numbers **1**, **2**, ..., **N** starting from one of the positions in a clockwise direction. Then the current (possibly partial) arrangement of the cherries can be represented by a string of **N** characters. For each position **i** of the arrangement if the cherry of the color **C** is placed at this position then the **i**th character of the string is equal to the digit **C**. Otherwise, it is equal to the question mark **?**. We identify the arrangement with the string that represents it. -One arrangement is called _lexicographically smaller_ than the other arrangement if at the first position where they differ the first one has smaller digit (we compare only complete arrangements so we don't care about relation between digits and the question mark). For example, the arrangement **1230123** is lexicographically smaller than **1231230** since they have first **3** equal characters but the **4**th character in the first arrangement is and it is less than **1** which is the **4**th character of the second arrangement. +One arrangement is called _lexicographically smaller_ than the other arrangement if at the first position where they differ the first one has smaller digit (we compare only complete arrangements so we don't care about relation between digits and the question mark). For example, the arrangement **1230123** is lexicographically smaller than **1231230** since they have first **3** equal characters but the **4**th character in the first arrangement is 0 and it is less than **1** which is the **4**th character of the second arrangement. **Notes** @@ -116,7 +116,7 @@ Each character in **S** is either the digit from the set **{0, 1, ..., K – 1}* ### Output -For each test case output the lexicographically smallest valid arrangement of the cherries in the cake that can be obtained from the given arrangement by replacement of each question mark by some digit from to **K – 1**. If it is impossible to place the cherries output **NO** (output is case sensitive). +For each test case output the lexicographically smallest valid arrangement of the cherries in the cake that can be obtained from the given arrangement by replacement of each question mark by some digit from 0 to **K – 1**. If it is impossible to place the cherries output **NO** (output is case sensitive). ### Example @@ -146,8 +146,8 @@ NO 021 01012 012 - ### Explanation + **Case 2.** The only possible replacement here is **10**. Note that we output **10** since we **can not rotate the answer** to obtain **01** which is smaller. **Case 3.** Arrangement is impossible because cherries at the first and the last positions are already of the same color. Note that **K = 10** but the string has length **9**. It is normal. **K** and **|S|** don't have any connection. diff --git a/_problems/easy/CALC.md b/_problems/easy/CALC.md index 8321badf..fb4b8d6e 100644 --- a/_problems/easy/CALC.md +++ b/_problems/easy/CALC.md @@ -113,8 +113,8 @@ For each test case, output a single line containing the answer to this test case 12 3 9 - ### Explanation + **Example case 1.** There are 10 units of energy available. Pressing second button takes 2 units of energy. Chef can achieve 12 on the second screen as follows. - Press first button to get scores (1, 0). 9 units of energey is left. diff --git a/_problems/easy/CANDLE.md b/_problems/easy/CANDLE.md index 7eb286cb..b90d5e9c 100644 --- a/_problems/easy/CANDLE.md +++ b/_problems/easy/CANDLE.md @@ -29,6 +29,7 @@ For each test case, output on a single line the smallest positive integer that c 2 2 1 2 1 1 3 1 1 1 ### Sample output: +
4
 10
 22
diff --git a/_problems/easy/CAOS1.md b/_problems/easy/CAOS1.md
index c387fd73..0be680d1 100644
--- a/_problems/easy/CAOS1.md
+++ b/_problems/easy/CAOS1.md
@@ -133,8 +133,8 @@ For each test case, output a single line containing the number of cells where mo
 Output:
 0
 1
-
 
### Explanation + **Example case 1.** There is no cell for which minimum of L, R, T, B is greater than some prime P. **Example case 2.** The cell at \[3, 4\], (1-based indexing) is the only CPC. diff --git a/_problems/easy/CAOS2.md b/_problems/easy/CAOS2.md index 2d536eb3..4ac413ec 100644 --- a/_problems/easy/CAOS2.md +++ b/_problems/easy/CAOS2.md @@ -134,5 +134,4 @@ For each test case, output a single line containing the number of monsters the m Output: 0 3 - \ No newline at end of file diff --git a/_problems/easy/CAPIMOVE.md b/_problems/easy/CAPIMOVE.md index 273b474b..34bbfda4 100644 --- a/_problems/easy/CAPIMOVE.md +++ b/_problems/easy/CAPIMOVE.md @@ -98,7 +98,7 @@ Next **N-1** lines contain two space-separated integers each **V** and **U** den ### Output -For each test case, output a single line containing **N** integers **A1**, **A2**, ..., **AN** separated by a space. Here **Ai** denotes the number of the planet picked to be new capital in case infection starts spreading from the planet **i**. In case infection affects all the planets output . +For each test case, output a single line containing **N** integers **A1**, **A2**, ..., **AN** separated by a space. Here **Ai** denotes the number of the planet picked to be new capital in case infection starts spreading from the planet **i**. In case infection affects all the planets output 0. ### Constraints @@ -129,5 +129,4 @@ For each test case, output a single line containing **N** integers **A1**, **A2* Output: 6 6 6 2 6 5 - \ No newline at end of file diff --git a/_problems/easy/CAPPLE.md b/_problems/easy/CAPPLE.md index 3848fb85..07edcfe7 100644 --- a/_problems/easy/CAPPLE.md +++ b/_problems/easy/CAPPLE.md @@ -116,8 +116,8 @@ For each of the **T** test cases, output a single line - the minimum time to plu Output 1 3 - ### Explanation + For test 1, Chef can select all the trees and can pluck all the apples in 1 minute. For test 2, there are many ways Chef can pluck all of the apples in 3 minutes. Here is one example: diff --git a/_problems/easy/CARVANS.md b/_problems/easy/CARVANS.md index c22e48aa..580b40d1 100644 --- a/_problems/easy/CARVANS.md +++ b/_problems/easy/CARVANS.md @@ -98,8 +98,8 @@ For each test case, output a single line containing the number of cars which wer 1 2 2 - ### Constraints + 1 ≤ T ≤ 100 1 ≤ N ≤ 10,000 All speeds are distinct positive integers that fit in a 32 bit signed integer. diff --git a/_problems/easy/CBALLS.md b/_problems/easy/CBALLS.md index d36a405b..d2395455 100644 --- a/_problems/easy/CBALLS.md +++ b/_problems/easy/CBALLS.md @@ -104,6 +104,6 @@ For each test case, output a line containing a single integer — the answer for Output: 3 - ### Explanation + Add one ball to each of the buckets. diff --git a/_problems/easy/CBARG.md b/_problems/easy/CBARG.md index 0c763b9d..775ea5c2 100644 --- a/_problems/easy/CBARG.md +++ b/_problems/easy/CBARG.md @@ -122,8 +122,8 @@ Subtask 3 (70 points): 1 5 3 - ### Explanation + **Example case 1.** Initially, there was no memory allocated. For running first test file, there was a memory allocation of 1 MBs. There was no allocation/ deallocation for running your program on second test file. **Example case 2.** On running on each test file, there was a further allocation of 1 MBs from previous one. So, there are total 5 MBs of memory allocated while running the program. diff --git a/_problems/easy/CENTREE.md b/_problems/easy/CENTREE.md index 20ac322d..6cc11ee6 100644 --- a/_problems/easy/CENTREE.md +++ b/_problems/easy/CENTREE.md @@ -113,6 +113,6 @@ YES 1 2 1 3 1 4 - ### Explanation + Vertex 1 is the center and centroid of the tree. diff --git a/_problems/easy/CHAHG.md b/_problems/easy/CHAHG.md index f2318940..6adce836 100644 --- a/_problems/easy/CHAHG.md +++ b/_problems/easy/CHAHG.md @@ -100,8 +100,8 @@ The test cases are designed in such a way that the total output won't exceed 2 M - **1** ≤ **T** ≤ **105** - **1** ≤ **n** ≤ **10** -- Subtask 1 (23 points): ≤ ****hi**, **mi**** ≤ **10** -- Subtask 2 (77 points): ≤ ****hi**, **mi**** ≤ **109** +- Subtask 1 (23 points): 0 ≤ ****hi**, **mi**** ≤ **10** +- Subtask 2 (77 points): 0 ≤ ****hi**, **mi**** ≤ **109** - **1** ≤ sum of **n** over a test cases in a single test file ≤ **5 × 105** ### Example @@ -127,6 +127,6 @@ The test cases are designed in such a way that the total output won't exceed 2 M 0 0 2 Inf 0 - ### Explanation + **Example case 1.** In the first case **0 2 0** is already a _zig-zag_ sequence, but on the 2nd second it will become **2 6 6** and will never turn back into _zig-zag_ diff --git a/_problems/easy/CHAIRS.md b/_problems/easy/CHAIRS.md index 19ae29ea..27fd38d3 100644 --- a/_problems/easy/CHAIRS.md +++ b/_problems/easy/CHAIRS.md @@ -104,8 +104,8 @@ For each test case, output a single line containing a single integer donating mi Output: 2 - ### Explanation + The initial configuration is:
       
@@ -114,16 +114,16 @@ The initial configuration is:
            1          0
               0    0
                   1
-
 
We can tell the child who is **boldened** to move counter-clockwise, and the new configuration will be: +
       
                  0
               1    0
            1          0
               0    0
                   1
-
 
because he has moved to the first empty chair on his way. + Now, we again tell him to move counter-clockwise, and now the new configuration will be:
       
@@ -132,8 +132,8 @@ Now, we again tell him to move counter-clockwise, and now the new configuration
            1          0
               1    0
                   1
-
 
because he moved counter-clockwise, found an occupied chair, and hence kept moving. The next chair was vacant, and he sat down there. + Note that, in this example, we moved the same child twice, but this need not be the case. We can move different children in different moves. You can check that this is the best we can do, and 2 is the minimum. diff --git a/_problems/easy/CHBLLNS.md b/_problems/easy/CHBLLNS.md index acd0ff25..5add4b06 100644 --- a/_problems/easy/CHBLLNS.md +++ b/_problems/easy/CHBLLNS.md @@ -112,6 +112,6 @@ For each test case, output a single line containing one integer - the minimum nu Output: 1 4 - ### Explanation + **Example case 2.** In the worst-case scenario first three balloons will be of the three different colors and only after fourth balloon Chef will have two balloons of the same color. So, Chef might need to fetch 4 balloons diff --git a/_problems/easy/CHBLLS.md b/_problems/easy/CHBLLS.md index 04d1e350..eddc5551 100644 --- a/_problems/easy/CHBLLS.md +++ b/_problems/easy/CHBLLS.md @@ -120,8 +120,8 @@ Please note that the content in left side denotes output of your program where c -1 2 5 - ### Example 2 +
Input and Output
 1
 3 1 2 5
@@ -137,16 +137,16 @@ Please note that the content in left side denotes output of your program where c
 					-2
 2
 5
-
 
### Explanation + In the **first example**, you first printed :
 1
 1 1
 1 1
-
 
This means that you want to use the scale. Each of the first and second pan has one ball of colour 1. Don't forget to flush the standard output after printing this. + After that you should read the input, the difference of weights between the two pans, in this case, it will be 0. Now you printed : @@ -155,8 +155,8 @@ Now you printed : 1 1 1 1 5 - It means, that you decided to use scale again. Now first pan contains one ball of colour 1 and the second pan contains one ball of colour 5. + Now, you should read the input, the difference of weights between the two pans, in this case, it will be -1. Now, you realize that ball of colour 5 is heavier than of colour 1. It means that 5th colour is the colour of heaviest ball. So your print 2 followed by 5 in separate lines and exit your program. diff --git a/_problems/easy/CHCINEMA.md b/_problems/easy/CHCINEMA.md index 19312b41..28f51013 100644 --- a/_problems/easy/CHCINEMA.md +++ b/_problems/easy/CHCINEMA.md @@ -91,18 +91,18 @@ For each test case, output a line containing the answer for the task. - **1** ≤ **T** ≤ **105** **Subtask 1 : 10 points** - **1** ≤ **N, M** ≤ **3** -- ≤ **Z**, **L**, **R**, **B** ≤ **3** +- 0 ≤ **Z**, **L**, **R**, **B** ≤ **3** **Subtask 2 : 20 points** - **1** ≤ **N, M** ≤ **30** -- ≤ **Z**, **L**, **R** ≤ **30** -- ≤ **B** ≤ **109** +- 0 ≤ **Z**, **L**, **R** ≤ **30** +- 0 ≤ **B** ≤ **109** **Subtask 3 : 30 points**- **1** ≤ **N, M** ≤ **106** -- ≤ **Z**, **L**, **R** ≤ **106** -- ≤ **B** ≤ **1016** +- 0 ≤ **Z**, **L**, **R** ≤ **106** +- 0 ≤ **B** ≤ **1016** **Subtask 4 : 40 points**- **1** ≤ **N, M** ≤ **108** -- ≤ **Z**, **L**, **R**, **B** ≤ **1016** +- 0 ≤ **Z**, **L**, **R**, **B** ≤ **1016** ### Example @@ -114,8 +114,8 @@ For each test case, output a line containing the answer for the task. Output: 4 8 - ### Explanation + 'L' - needs left 'R - needs right 'Z' - doesn't need any diff --git a/_problems/easy/CHCOINSG.md b/_problems/easy/CHCOINSG.md index 5ad7a95e..42e35974 100644 --- a/_problems/easy/CHCOINSG.md +++ b/_problems/easy/CHCOINSG.md @@ -113,8 +113,8 @@ Chef plays first. Your task is to find out who will win the game, provided that Output: Chef Chef - ### Explanation + **Example case 1.** Chef will remove the only coin from the pile and will win the game. **Example case 2.** Chef will remove all 8 coins from the pile and win the game. Chef can remove 8 coins because 8 is a prime power, as 8 = 23. diff --git a/_problems/easy/CHCUBE.md b/_problems/easy/CHCUBE.md index 43fd68cf..9f9ffa1a 100644 --- a/_problems/easy/CHCUBE.md +++ b/_problems/easy/CHCUBE.md @@ -112,8 +112,8 @@ green yellow green orange black green Output: NO YES -
### Explanation
+
 **Example case 1.**
 
 There are no three sides with the same color.
diff --git a/_problems/easy/CHDOGS.md b/_problems/easy/CHDOGS.md
index 1bbaa687..ab61b636 100644
--- a/_problems/easy/CHDOGS.md
+++ b/_problems/easy/CHDOGS.md
@@ -109,6 +109,6 @@ For each test case, output a single line containing a real number corresponding
 Output:
 0.266667
 0.0000001
-
 
### Explanation + Due to the triangle being very small, but the dogs running extremely fast, they will meet after less than 1e-6 seconds. Thus, due to remark about absolute or relative error in the output section, any answer within \[0, 1e-6\] will be considered correct. diff --git a/_problems/easy/CHEARMY.md b/_problems/easy/CHEARMY.md index 5b1d0d36..64a9b23c 100644 --- a/_problems/easy/CHEARMY.md +++ b/_problems/easy/CHEARMY.md @@ -120,7 +120,7 @@ Original Constraints Output: 2 8 - ### Explanation + **Example case 1.** 2 is the 2nd magical number, since it satisfies the property of the magical number. The first magical number will be of course 0. diff --git a/_problems/easy/CHEFA.md b/_problems/easy/CHEFA.md index 6db296ee..0fa33f41 100644 --- a/_problems/easy/CHEFA.md +++ b/_problems/easy/CHEFA.md @@ -109,5 +109,4 @@ For each test case, output a single line containg the maximum number of stones t Output: 4 3 - \ No newline at end of file diff --git a/_problems/easy/CHEFARC.md b/_problems/easy/CHEFARC.md index 5b68e637..6099e6a5 100644 --- a/_problems/easy/CHEFARC.md +++ b/_problems/easy/CHEFARC.md @@ -81,7 +81,7 @@ Chef plans to join the competition and has two robots with the movable range **K The first line of the input contains an integer **T** denoting the number of test cases. The description of **T** test cases follows. - The first line of each test case contains **4** space-separated integers **N M K1 K2** denoting the number of rows and columns in the table and the movable ranges of the first and second robot of Chef. -- The next **N** lines, each line contains **M** space-separated numbers either or **1** denoting whether the robots can move to this cell or not ( means robots can move to this cell, **1** otherwise). It makes sure that values in cell **(1, 1)** and cell **(1, M)** are . +- The next **N** lines, each line contains **M** space-separated numbers either 0 or **1** denoting whether the robots can move to this cell or not (0 means robots can move to this cell, **1** otherwise). It makes sure that values in cell **(1, 1)** and cell **(1, M)** are 0. ### Output @@ -91,7 +91,7 @@ For each test case, output a single line containing the minimum number of moves - **1** ≤ **T** ≤ **10** - **1** ≤ **N, M** ≤ **100** -- ≤ **K1, K2** ≤ **10** +- 0 ≤ **K1, K2** ≤ **10** ### Subtasks @@ -120,8 +120,8 @@ Original Constraints Output: 5 -1 - ### Explanation + **Example case 1.** Robot 1 can move (1, 1) -> (2, 1) -> (3, 1) -> (4, 1) -> (4, 2) -> (4, 3), and robot 2 can move (1, 4) -> (2, 4) -> (3, 4) -> (4, 4) -> (4, 3) -> (4, 3), they meet at cell (4, 3) after 5 moves. **Example case 2.** Because the movable range of both robots is 1, robot 1 can not move from (3, 1) to (4, 2), and robot 2 can not move from (3, 4) to (4, 3. Hence, they can not meet each other. diff --git a/_problems/easy/CHEFARK.md b/_problems/easy/CHEFARK.md index e416d635..83c1467e 100644 --- a/_problems/easy/CHEFARK.md +++ b/_problems/easy/CHEFARK.md @@ -116,8 +116,8 @@ As answer could be quite large, print it modulo **109 + 7**. 1 3 4 - ### Explanation + **Example case 1.**Chef has only one element and must apply the operation 3 times to it. After applying the operations, he will end up with -100. That is the only array he will get. **Example case 2.**Chef can apply operation to one of three elements. So, he can obtain three different arrays. @@ -131,5 +131,4 @@ In summary, Chef can get following four arrays. [-1, -2, 1] [-1, 2, -1] [1, -2, -1] - \ No newline at end of file diff --git a/_problems/easy/CHEFARRB.md b/_problems/easy/CHEFARRB.md index 329c3862..c8c3d449 100644 --- a/_problems/easy/CHEFARRB.md +++ b/_problems/easy/CHEFARRB.md @@ -90,7 +90,7 @@ For each test case, output an integer corresponding to the number of _good_ sub- ### Constraints 11. **1** ≤ **T**, **N**, ≤ **100,000** -12. ≤ **A**i, **K** ≤ **109** +12. 0 ≤ **A**i, **K** ≤ **109** 13. **1** ≤ Sum over all values of **N** in the input in a single test file ≤ **100,000** ### Example @@ -104,5 +104,4 @@ For each test case, output an integer corresponding to the number of _good_ sub- Output: 4 2 - \ No newline at end of file diff --git a/_problems/easy/CHEFAXR.md b/_problems/easy/CHEFAXR.md index 7cef8f11..9566288e 100644 --- a/_problems/easy/CHEFAXR.md +++ b/_problems/easy/CHEFAXR.md @@ -111,8 +111,8 @@ For each test case, output a single line containing the maximal **bitwise XOR** Output: 15 - ### Explanation + Chef can pick the following submatrix in order to make the XOR of elements equal to **15**:
@@ -120,5 +120,4 @@ Chef can pick the following submatrix in order to make the XOR of elements equal
 1 8 6
 1 2 3
 
-
-
This submatrix can be defined by **x1 = 1**, **y1 = 1**, **x2 = 3**, **y2 = 2**. \ No newline at end of file +This submatrix can be defined by **x1 = 1**, **y1 = 1**, **x2 = 3**, **y2 = 2**. diff --git a/_problems/easy/CHEFBEST.md b/_problems/easy/CHEFBEST.md index 46a05181..c8353b61 100644 --- a/_problems/easy/CHEFBEST.md +++ b/_problems/easy/CHEFBEST.md @@ -118,13 +118,13 @@ For each test case, output a single integer on a new line corresponding to the n 0 1 1 1 0 1 1 0 1 1 5 0 1 0 1 1 - **Output:** +
 7
 3
-
 
### Explanation + **Test case 1:** Initially, student's arrangement is **\[0 1 1 1 0 1 1 0 1 1\]** diff --git a/_problems/easy/CHEFBM.md b/_problems/easy/CHEFBM.md index 1580d5fc..d43878ee 100644 --- a/_problems/easy/CHEFBM.md +++ b/_problems/easy/CHEFBM.md @@ -119,8 +119,8 @@ Then Chef needs to calculate the following: -1 4 - ### Explanation +
 

Here is the whole matrix after P commands:

1 2 3 4 @@ -128,7 +128,7 @@ Then Chef needs to calculate the following: 1 4 3 4 1 2 5 5

Explanations to the answer:

- -
- The first line is without changes: 4-3=1, 3-2=1, 2-1=1. answer = 3.- The second line: 4-3=1, 3-3=0, 3-1=2. The answer is 3. +- The first line is without changes: 4-3=1, 3-2=1, 2-1=1. answer = 3. +- The second line: 4-3=1, 3-3=0, 3-1=2. The answer is 3. - The third line: 4-3=1, 3-4=-1, Chef can't move to the first number here. Therefore, the answer is -1. - The fourth line: 5-5=0, 5-2=3, 2-1=1. The answer is 4. diff --git a/_problems/easy/CHEFBR.md b/_problems/easy/CHEFBR.md index 06286bff..1690b1be 100644 --- a/_problems/easy/CHEFBR.md +++ b/_problems/easy/CHEFBR.md @@ -119,5 +119,4 @@ In a single line print the required answer. Output: 12 -
\ No newline at end of file
diff --git a/_problems/easy/CHEFCBA.md b/_problems/easy/CHEFCBA.md
index 310f70c5..5f32369b 100644
--- a/_problems/easy/CHEFCBA.md
+++ b/_problems/easy/CHEFCBA.md
@@ -96,6 +96,6 @@ Print "Possible" if it is possible to shuffle **a, b, c, d** to make proportion,
 
 Output:
 Possible
-
 
### Explanation
+
 By swapping 4 and the second 2, we get 1 2 2 4. Note that 1 2 2 4 make proportion as 1 : 2 = 2 : 4. Hence answer is "Possible"
diff --git a/_problems/easy/CHEFCCYL.md b/_problems/easy/CHEFCCYL.md
index 24c759e7..45c0e3f7 100644
--- a/_problems/easy/CHEFCCYL.md
+++ b/_problems/easy/CHEFCCYL.md
@@ -139,8 +139,8 @@ For each query, output a single integer corresponding to the total weight of the
 2
 3
 5
-
 
### Explanation + **Example case 1.** Here is the description of the graph. @@ -151,14 +151,14 @@ There are **3** cycles. Cycle 1: 3 nodes. Edges: (1, 2) = 1, (2, 3) = 2, (3, 1) = 2. Cycle 2: 2 nodes. Edges: (1, 2) = 1, (2, 1) = 2. Cycle 3: 3 nodes. Edges: (1, 2) = 1, (2, 3) = 4, (3, 1) = 1. -
Connections between adjacent cycles: +
 Cycle 1 node 2 is connected to Cycle 2 node 1 with edge of weight 2. 
 Cycle 2 node 2 is connected to Cycle 3 node 1 with edge of weight 5.
 Cycle 3 node 3 is connected to Cycle 1 node 1 with edge of weight 3.
-
 
**Queries** + Best path from node **2** cycle **1** to node **1** cycle **2** is of the cost 2. Best path from node **1** cycle **1** to node **1** cycle **2** is: edge **(1, 2)** of cycle **1** + edge **(2, 1)** between cycles **1** and **2**. diff --git a/_problems/easy/CHEFCH.md b/_problems/easy/CHEFCH.md index 264ef3db..e116f61a 100644 --- a/_problems/easy/CHEFCH.md +++ b/_problems/easy/CHEFCH.md @@ -105,8 +105,8 @@ Chef had a hard day and want to play little bit. The game is called "Chain". Che Output: 2 3 - ### Explanation + **Example case 1.** We can change symbol **2** from '**-**' to '**+**' and symbol **9** from '**+**' to '**-**' and receive '**-+-+-+-+-+**'. diff --git a/_problems/easy/CHEFCK.md b/_problems/easy/CHEFCK.md index 62f95586..0b8e038f 100644 --- a/_problems/easy/CHEFCK.md +++ b/_problems/easy/CHEFCK.md @@ -144,8 +144,8 @@ Output two space separated integers: Output: 13 13 -
### Explanation
+
 - The array **A** comes out to be **{1, 3, 13, 83}** and the first dish has **L = 3** and **R = 4**. The minimum in this range is **13**, thus the sum and product both are **13** and hence the answer.
  
 ### Note
diff --git a/_problems/easy/CHEFCOUN.md b/_problems/easy/CHEFCOUN.md
index 6b7cc910..f2133af2 100644
--- a/_problems/easy/CHEFCOUN.md
+++ b/_problems/easy/CHEFCOUN.md
@@ -93,7 +93,7 @@ A newbie programmer was trying to solve this problem. He didn't take care of the
 	for (int i = 1; i 
 
-Assume that an _unsigned int_ is 4 bytes long, i.e. it stores values from up to **232 - 1**. Addition of two unsigned int's **x** and **y** is done as **(x + y) modulo 232**. This way, you can see that whenever the value of an unsigned int exceeds the maximum possible value (**232 - 1**), it wraps around. +Assume that an _unsigned int_ is 4 bytes long, i.e. it stores values from 0 up to **232 - 1**. Addition of two unsigned int's **x** and **y** is done as **(x + y) modulo 232**. This way, you can see that whenever the value of an unsigned int exceeds the maximum possible value (**232 - 1**), it wraps around. Chef as a problem setter knows that the above program should not get an AC. Hence, he wants to generate a counter case to fail this solution. He asks your help in generating such a counter case. diff --git a/_problems/easy/CHEFCRUN.md b/_problems/easy/CHEFCRUN.md index d81710e3..50af5d1b 100644 --- a/_problems/easy/CHEFCRUN.md +++ b/_problems/easy/CHEFCRUN.md @@ -118,8 +118,8 @@ For each test case, output a single line containing the minimal possible cost Ch Output: 2 -8 - ### Explanation + **Example case 1.** Chef's walk starts with node 1. He goes to node **4** by incurring a cost of 1. Then from node 4, he goes to node 3 by incurring a cost of 1 more. Total cost incurred is 2. **Example case 2.** Chef goes from **1** to **2** by incurring a cost of **-5**. Then from **2** to **1** using the edge **second time** and incurring cost of **-5** again. Now, he can not use the edge between 1 and 2 again, as he has traversed the edge already twice. Now he will go from node 1 to node 4 by paying a cost of 2. Total sum of costs incurred is -5 + -5 + 2 = -8. This is the minimum possible cost that Chef can have. diff --git a/_problems/easy/CHEFDICE.md b/_problems/easy/CHEFDICE.md index 5f0f7dcf..42c4450c 100644 --- a/_problems/easy/CHEFDICE.md +++ b/_problems/easy/CHEFDICE.md @@ -126,8 +126,8 @@ All submissions for this problem are available.### Read problems statements in [ 4 5 6 1 2 3 -1 - ### Explanation + **Example case 1:** See below. ![](https://codechef_shared.s3.amazonaws.com/download/upload/LTIME52/2.png) diff --git a/_problems/easy/CHEFELEC.md b/_problems/easy/CHEFELEC.md index a314a855..810d9a12 100644 --- a/_problems/easy/CHEFELEC.md +++ b/_problems/easy/CHEFELEC.md @@ -119,8 +119,8 @@ For each test case, output a single line containing a integer corresponding to t Output: 1 5 - ### Explanation + **In the first example**, first village does not have electricity. If we put a wire between village 1 and 2 of length 1, then both the villages will have electricity. **In the second example**, diff --git a/_problems/easy/CHEFEQ.md b/_problems/easy/CHEFEQ.md index 28d51d33..a5aaa901 100644 --- a/_problems/easy/CHEFEQ.md +++ b/_problems/easy/CHEFEQ.md @@ -112,6 +112,6 @@ The assistant wants to do this task as fast as possible. So he wants to know the Output: 3 - ### Explanation + - In test case 1, if you decide to convert all the piles to contain either of 1, 2, 3, or 4 coins you will have to change the other 3 piles. For any other choice you will have to alter more than 3 (i.e. 4) piles. diff --git a/_problems/easy/CHEFFA.md b/_problems/easy/CHEFFA.md index ca5e7d2b..0028785f 100644 --- a/_problems/easy/CHEFFA.md +++ b/_problems/easy/CHEFFA.md @@ -112,8 +112,8 @@ For each test case, output answer modulo 109+7 in a single line. 9 4 9 - ### Explanation + **Example case 1.** We'll list the various single steps that you can take (ie. in one single usage of the operation): diff --git a/_problems/easy/CHEFFED.md b/_problems/easy/CHEFFED.md index a973712b..8d16244b 100644 --- a/_problems/easy/CHEFFED.md +++ b/_problems/easy/CHEFFED.md @@ -95,15 +95,15 @@ Output single integer in a line denoting the count of number of positive integer Output: 1 - ### Example 2 +
Input:
 9939
 
 Output:
 4
-
 
### Explanation + **Example 1**. Only one positive integer **X = 2** satisfies the equation **X + S(X) + S(S(X)) = 6**, as **X + S(X) + S(S(X)) = 2 + 2 + 2 = 6**. **Example 2**.**X** can be 9898, 9907, 9910 and 9913. diff --git a/_problems/easy/CHEFFILT.md b/_problems/easy/CHEFFILT.md index 3af74c8c..83a08ed9 100644 --- a/_problems/easy/CHEFFILT.md +++ b/_problems/easy/CHEFFILT.md @@ -139,8 +139,8 @@ bbbbbbbbbb 0 2 4 - ### Explanation + **Example case 1.** There is no filter or combination of filters transforming the picture to whole black. **Example case 2.** Chef can either apply the first filter (and invert all whites) or apply the second and third filters in any order. diff --git a/_problems/easy/CHEFGP.md b/_problems/easy/CHEFGP.md index 845d5a6e..3c61a939 100644 --- a/_problems/easy/CHEFGP.md +++ b/_problems/easy/CHEFGP.md @@ -135,8 +135,8 @@ abba aa*abaa a*a*a*a aa*aa*a - ### Explanation + **Example 1**. The way of distributing fruits already makes everyone happy. **Example 2**. The second person will be disgruntled as he receives apple same as the person ahead of him. One possible way of having good impression is to distribute in the order aba. diff --git a/_problems/easy/CHEFGR.md b/_problems/easy/CHEFGR.md index 0313bc28..0d64d60c 100644 --- a/_problems/easy/CHEFGR.md +++ b/_problems/easy/CHEFGR.md @@ -46,7 +46,7 @@ Chef wants to spend **exactly** **M** cubes. Can he make this in such way that t - **1** ≤ **T** ≤ **10^2** - **1** ≤ **N** ≤ **10^2** - **1** ≤ **Ai** ≤ **10^2** -- ≤ **M** ≤ **10^4** +- 0 ≤ **M** ≤ **10^4** ### Example @@ -63,8 +63,8 @@ Chef wants to spend **exactly** **M** cubes. Can he make this in such way that t Yes No No - ### Explanation + In the first case we can put cubes on columns in such count: **1, 1, 0, 2, 3**. The sum equals **M**. In the second case we can't make the columns equal as we will receive something like **44443**. diff --git a/_problems/easy/CHEFHACK.md b/_problems/easy/CHEFHACK.md index 2567c655..d944755f 100644 --- a/_problems/easy/CHEFHACK.md +++ b/_problems/easy/CHEFHACK.md @@ -128,7 +128,7 @@ For each test case, output a single line containing the number of unsuccessful t - **1** ≤ **T** ≤ **8** - **1** ≤ **N** ≤ **350** -- ≤ **each password** < **107** +- 0 ≤ **each password** < **107** ### Example @@ -146,8 +146,8 @@ For each test case, output a single line containing the number of unsuccessful t Output: 20 13 - ### Explanation + **Example case 1.** The type of each server can be found in the following table. diff --git a/_problems/easy/CHEFHAM.md b/_problems/easy/CHEFHAM.md index 46663c8c..61ded3ee 100644 --- a/_problems/easy/CHEFHAM.md +++ b/_problems/easy/CHEFHAM.md @@ -129,5 +129,4 @@ Note that it's guaranteed that no element in **A** appears more than twice, i.e. 2 1 1 4 6 2 2 5 - \ No newline at end of file diff --git a/_problems/easy/CHEFHPAL.md b/_problems/easy/CHEFHPAL.md index 4af9c11f..fc088dc5 100644 --- a/_problems/easy/CHEFHPAL.md +++ b/_problems/easy/CHEFHPAL.md @@ -116,6 +116,6 @@ All submissions for this problem are available.### Read problems statements in [ 1 codechef 3 aaababb - ### Explanation + **Example case 1.** There are multiple solutions. For example, "abaaa" is also correct. **Note that "abbaa" is not a correct solution, since "abba" is a palindromic substring of length 4, which is not optimal.** diff --git a/_problems/easy/CHEFIHG.md b/_problems/easy/CHEFIHG.md index 7fbf3fe3..5b6604e0 100644 --- a/_problems/easy/CHEFIHG.md +++ b/_problems/easy/CHEFIHG.md @@ -107,7 +107,6 @@ Output one non-empty string corresponding to the command with length ≤ **105** Output: LDUR -
Input:
 5 6
 ******
@@ -118,8 +117,8 @@ LDUR
 
 Output:
 RLLURUU
-
 
### Explanation + You can reach to capital city by feeding this command to robot starting from any city. We have shown one such application of the command for the city on the cell (2, 2). From cell (2, 2), you can go to following cells in order when you apply the command. diff --git a/_problems/easy/CHEFLCM.md b/_problems/easy/CHEFLCM.md index 92134cc4..0ee66122 100644 --- a/_problems/easy/CHEFLCM.md +++ b/_problems/easy/CHEFLCM.md @@ -112,7 +112,7 @@ For each test case, output a single line containing an integer corresponding to Output: 1 3 - ### Explanation + **Example 1 :** Only possible number is **1**, so the maximum sum of distinct numbers is exactly **1**. **Example 2 :** The distinct numbers you can have are just **1** and **2**, so the sum is **3**. If we consider any other number greater than **2**, then the least common multiple will be more than **2**. diff --git a/_problems/easy/CHEFLR.md b/_problems/easy/CHEFLR.md index 2c609591..5433affe 100644 --- a/_problems/easy/CHEFLR.md +++ b/_problems/easy/CHEFLR.md @@ -86,8 +86,8 @@ Chef has a nice _complete_ binary tree in his garden. _Complete_ means that each 3 5 7 9 / \ / \ / \ / \ 6 8 10 12 14 16 18 20 - Here you can see the visualization of the process. For example, in odd levels, the root was enumerated first, then, there were enumerated roots' left sons' sons and roots' right sons' sons. + You are given the string of symbols, let's call it **S**. Each symbol is either **l** or **r**. Naturally, this sequence denotes some path from the root, where **l** means going to the left son and **r** means going to the right son. Please, help Chef to determine the number of the last node in this path. @@ -122,6 +122,6 @@ lllr 4 13 - ### Explanation + See the example in the statement for better understanding the samples. diff --git a/_problems/easy/CHEFMATH.md b/_problems/easy/CHEFMATH.md index 16f797ce..17d955ee 100644 --- a/_problems/easy/CHEFMATH.md +++ b/_problems/easy/CHEFMATH.md @@ -140,8 +140,8 @@ For each question, output a separate line containing the answer of the question. 1 2 4 - ### Explanation + **Example case 1.** There is no way to create 12 by adding one Chefonacci number, as 12 is not a Chefonacci number. diff --git a/_problems/easy/CHEFMOVR.md b/_problems/easy/CHEFMOVR.md index 70d7846f..5d9ddb36 100644 --- a/_problems/easy/CHEFMOVR.md +++ b/_problems/easy/CHEFMOVR.md @@ -119,8 +119,8 @@ Chef wants to find the minimum number of times she needs to use the mover of siz 3 2 -1 - ### Explanation + **Testcase 1:** Here is a possible sequence of usages of the mover: diff --git a/_problems/easy/CHEFPATH.md b/_problems/easy/CHEFPATH.md index 02f89990..9d3ea0f8 100644 --- a/_problems/easy/CHEFPATH.md +++ b/_problems/easy/CHEFPATH.md @@ -112,7 +112,7 @@ Original Constraints Output: Yes - ### Explanation + **Example case 1.** Chef can start from (1,1), move down to (2,1), then move right to (2,2) and finally move upwards to reach (1,2). As, he is able to visit all the cells exactly once and sum of absolute differences of corresponding x and y dimension is 1, we can call this path a _magical_ path. diff --git a/_problems/easy/CHEFPDIG.md b/_problems/easy/CHEFPDIG.md index cc6d0f24..8d95aace 100644 --- a/_problems/easy/CHEFPDIG.md +++ b/_problems/easy/CHEFPDIG.md @@ -107,8 +107,8 @@ A AB ACDFGHIJKLNPQRSTUVW - ### Explanation + **Example case 1.** Chef can pick digits **6** and **5** and create integers 56 and 65. The integer 65 corresponds to 'A'. **Example case 2.** Chef can pick digits **6** and **5** and create **'A'** as it equals **65**. He can pick 6 and 6 (they are picked from position 2 and position 3, respectively) to create 'B' too. Hence answer is "AB". diff --git a/_problems/easy/CHEFQUE.md b/_problems/easy/CHEFQUE.md index 0ba71394..486a544b 100644 --- a/_problems/easy/CHEFQUE.md +++ b/_problems/easy/CHEFQUE.md @@ -69,8 +69,8 @@ Output a single line containing a single integer — sum of elements in the set Output: 5362358669068782 - ### Explanation: + The sequence {Si} is 1, 2, 3, 4, 5: Operation 1, 1 mod 2 = 1, add number \[1 / 2\] = 0 to set, sum is 0. diff --git a/_problems/easy/CHEFRP.md b/_problems/easy/CHEFRP.md index e6466ad5..15f2cc0c 100644 --- a/_problems/easy/CHEFRP.md +++ b/_problems/easy/CHEFRP.md @@ -111,7 +111,7 @@ She, being lazy, wants to know the maximum number of times she would need to pic Output: 4 2 - ### Explanation + - **In Example 1,** she need to pick up all items. - **In Example 2,** since there is only one type of ingredient, picking two items is enough. diff --git a/_problems/easy/CHEFRRUN.md b/_problems/easy/CHEFRRUN.md index cbc2edc9..7eb1e3fe 100644 --- a/_problems/easy/CHEFRRUN.md +++ b/_problems/easy/CHEFRRUN.md @@ -96,7 +96,7 @@ For each test case, output a single line containing number of magical boxes. ### Constraints - **1** ≤ sum of all **N** over all the test cases in a single test file ≤ **106** -- ≤ **Ai** ≤ **109** +- 0 ≤ **Ai** ≤ **109** ### Subtasks @@ -117,8 +117,8 @@ For each test case, output a single line containing number of magical boxes. 4 1 2 - ### Explanation + **Example case 1.** Here are Chef's paths if he starting from each the box: ``` @@ -127,13 +127,12 @@ Here are Chef's paths if he starting from each the box: ``` 2->4->2 3->1->3 4->2->4 -
As you see, all **4** boxes are magical. **Example case 2.**
+
 Here are Chef's paths if he starts from each box appropriately: ```
 
 1->1
 2->3->4->1->1
 3->4->1->1
 4->1->1
-
-
AS you see, only box **1** is magical. \ No newline at end of file +AS you see, only box **1** is magical. diff --git a/_problems/easy/CHEFSEG.md b/_problems/easy/CHEFSEG.md index 3dfd7ec4..01fd933a 100644 --- a/_problems/easy/CHEFSEG.md +++ b/_problems/easy/CHEFSEG.md @@ -108,6 +108,6 @@ Help Chef to define the coordinate of the point he will put on the **K**-th step 2.5000 7.5000 177375316.6198730500000000 - ### Explanation + You can see the points coordinates for the third sample from first two samples. diff --git a/_problems/easy/CHEFSETC.md b/_problems/easy/CHEFSETC.md index e6a82cf9..86a5c5f9 100644 --- a/_problems/easy/CHEFSETC.md +++ b/_problems/easy/CHEFSETC.md @@ -102,8 +102,8 @@ For each test case output "Yes", if possible to get 0 by choosing non-empty subs Yes Yes No - ### Explanation + **Example case 1.** We can choose subset {0} **Example case 2.** We can choose subset {-1, 1} diff --git a/_problems/easy/CHEFSIGN.md b/_problems/easy/CHEFSIGN.md index 91a60e0d..f3ef3ffe 100644 --- a/_problems/easy/CHEFSIGN.md +++ b/_problems/easy/CHEFSIGN.md @@ -115,8 +115,8 @@ Output: 2 2 3 - ### Explanation + Here are some possible valid sequences which can be formed with the minimum **P** for each of the test cases:
diff --git a/_problems/easy/CHEFSOC2.md b/_problems/easy/CHEFSOC2.md
index 43b71c83..e2e027a2 100644
--- a/_problems/easy/CHEFSOC2.md
+++ b/_problems/easy/CHEFSOC2.md
@@ -120,8 +120,8 @@ Dogs quickly found out that there can be lot of possible sequences of passes whi
 1 0 1
 0 2 0
 0 0 0
-
 
### Explanation + **Example case 1.** Possible sequence for dog **1** is **2->3->1**. Possible sequence for dog **3** is **2->1->3**. diff --git a/_problems/easy/CHEFSOCK.md b/_problems/easy/CHEFSOCK.md index dc08d26c..6c229cd3 100644 --- a/_problems/easy/CHEFSOCK.md +++ b/_problems/easy/CHEFSOCK.md @@ -104,8 +104,8 @@ Unlucky Chef Output: Lucky Chef - ### Subtasks + - **Subtask 1:** **jacketCost, money, sockCost** ≤ 103. **Points - 20** - **Subtask 2:** Original constraints. **Points - 80** diff --git a/_problems/easy/CHEFSPL.md b/_problems/easy/CHEFSPL.md index d7197af2..5f9be482 100644 --- a/_problems/easy/CHEFSPL.md +++ b/_problems/easy/CHEFSPL.md @@ -119,8 +119,8 @@ YES NO NO - ### Explanation + **Example case 1.** We can remove the character at position 1 (0-based index) to get "aa" which is a _double_ string. Hence, it is a _special_ dish. diff --git a/_problems/easy/CHEFSQUA.md b/_problems/easy/CHEFSQUA.md index 11843c13..a502c298 100644 --- a/_problems/easy/CHEFSQUA.md +++ b/_problems/easy/CHEFSQUA.md @@ -84,7 +84,7 @@ In a single line print single integer - the minimal number of points Chef need t ### Constraints -- ≤ **N** ≤ **2000** +- 0 ≤ **N** ≤ **2000** - **-10^6** ≤ **Xi, Yi** ≤ **10^6** - There are NO coincided points @@ -109,8 +109,8 @@ In a single line print single integer - the minimal number of points Chef need t Output: 0 - ### Explanation + For the first example Chef can add points **(2, 0), (0, 2)** or **(2, 3), (3, 2)** For the second example Chef already has square **(0, 0), (100, 0), (0, 100), (100, 100)**. diff --git a/_problems/easy/CHEFSSET.md b/_problems/easy/CHEFSSET.md index 6db122c6..edd24c01 100644 --- a/_problems/easy/CHEFSSET.md +++ b/_problems/easy/CHEFSSET.md @@ -132,8 +132,8 @@ For each test case, output a single integer corresponding to minimum number of o 0 1 2 - ### Explanation + **Example case 1.** If you multiply any pair of integers in the array, the product is 4, which is square. So, the array is _w0w_ already. **Example case 2.** You can multiply the first number by 2, then the array will become _w0w_. So the minimum number of operations required will be 1. diff --git a/_problems/easy/CHEFST.md b/_problems/easy/CHEFST.md index d76dd710..52004fc4 100644 --- a/_problems/easy/CHEFST.md +++ b/_problems/easy/CHEFST.md @@ -99,20 +99,20 @@ For each test case, output a single line containing the minimum sum of the numbe **Subtask 1** : (5 pts) - **1** ≤ **T** ≤ **100** -- ≤ **m** ≤ **18** -- ≤ **n1, n2** ≤ **100** +- 0 ≤ **m** ≤ **18** +- 0 ≤ **n1, n2** ≤ **100** **Subtask 2** : (25 pts) - **1** ≤ **T** ≤ **1000** -- ≤ **m** ≤ **10000** -- ≤ **n1, n2** ≤ **10000** +- 0 ≤ **m** ≤ **10000** +- 0 ≤ **n1, n2** ≤ **10000** **Subtask 3** : (70 pts) - **1** ≤ **T** ≤ **105** -- ≤ **m** ≤ **109** -- ≤ **n1, n2** ≤ **1018** +- 0 ≤ **m** ≤ **109** +- 0 ≤ **n1, n2** ≤ **1018** ### Example @@ -126,8 +126,8 @@ For each test case, output a single line containing the minimum sum of the numbe 0 1 3 - ### Explanation + **Example case 1.** : Remove 1 stone from each of the piles. Now 0 stones are remaining, so chef cannot remove any more stones from the piles. Hence, answer is 0+0 = 0 **Example case 2.** : Again, remove 1 stone from both the piles to get (0,1) stones. Now chef cannot remove any more stones from pile 1, so he stops. Hence, answer is 0+1 = 1. diff --git a/_problems/easy/CHEFSTON.md b/_problems/easy/CHEFSTON.md index f1daab4d..6b0aec9d 100644 --- a/_problems/easy/CHEFSTON.md +++ b/_problems/easy/CHEFSTON.md @@ -116,8 +116,8 @@ Please help Chef to find the maximal possible profit. Output: 12 - ### Explanation + If Chef picks stones of first kind he can pick **3** stones, he will get a profit of **3\*4 = 12** Rs. If Chef picks stones of second kind he can pick **2** stones, he will get a profit of **2\*4 = 8** Rs. If Chef picks stones of third kind he can pick **2** stones, he will get a profit of **2\*5 = 10** Rs. diff --git a/_problems/easy/CHEFSUBA.md b/_problems/easy/CHEFSUBA.md index a2703d6f..c4a0388e 100644 --- a/_problems/easy/CHEFSUBA.md +++ b/_problems/easy/CHEFSUBA.md @@ -112,8 +112,8 @@ For each Dog's question output a single line containing an integer corresponding Output: 2 3 - ### Explanation + **Example case 1.** For the first question , Chef can pick last **3** elements (or last two, no matter) for his frame, and will have **2** elements equal **1**. diff --git a/_problems/easy/CHEFTEAM.md b/_problems/easy/CHEFTEAM.md index e5bd65ab..b6a09800 100644 --- a/_problems/easy/CHEFTEAM.md +++ b/_problems/easy/CHEFTEAM.md @@ -34,5 +34,4 @@ Chef has **N** subordinates. In order to complete a very important order he will 2 1 252 - \ No newline at end of file diff --git a/_problems/easy/CHEFTET.md b/_problems/easy/CHEFTET.md index 364d1dad..14bf5bc9 100644 --- a/_problems/easy/CHEFTET.md +++ b/_problems/easy/CHEFTET.md @@ -124,8 +124,8 @@ Please help Chef in enjoying the game!! 30 21 -1 - ### Explanation + **Example case 1.** The only option in first example is to make **10** fall on **20**. As we have only one element condition of equality is satisfied. diff --git a/_problems/easy/CHEFTMA.md b/_problems/easy/CHEFTMA.md index 75e553b0..fba0cabb 100644 --- a/_problems/easy/CHEFTMA.md +++ b/_problems/easy/CHEFTMA.md @@ -124,8 +124,8 @@ Be careful! Time is sensitive! Chef **cannot** make a day when he completed more Output: 3 - ### Explanation +
Example case 1.
 In this example Chef goes through the following steps:
 Use black button 1 on the first day.
diff --git a/_problems/easy/CHEFTOWN.md b/_problems/easy/CHEFTOWN.md
index 268b8c4e..ad6652fb 100644
--- a/_problems/easy/CHEFTOWN.md
+++ b/_problems/easy/CHEFTOWN.md
@@ -96,5 +96,4 @@ All submissions for this problem are available.ChefTown is the biggest city and
   2
   Output for Input 2:
   3
-  
   ```
diff --git a/_problems/easy/CHEFTWOS.md b/_problems/easy/CHEFTWOS.md
index 9241256f..555d86f9 100644
--- a/_problems/easy/CHEFTWOS.md
+++ b/_problems/easy/CHEFTWOS.md
@@ -119,8 +119,8 @@ For each test case, output a single line containing answer of the problem.
 Output:
 8
 0
-
 
### Explanation + **Test case 1.**Possible subsets are: **{}**, **{1, 2}**, **{1, 2, 3}**, **{1, 2, 4}**, **{1, 2, 3, 4}**, **{3}**, **{4}**, **{3, 4}**. **Test case 2.** There are no possible sets **S** which can make both the strings good. diff --git a/_problems/easy/CHEFVOTE.md b/_problems/easy/CHEFVOTE.md index bf55f748..c04b5af5 100644 --- a/_problems/easy/CHEFVOTE.md +++ b/_problems/easy/CHEFVOTE.md @@ -112,8 +112,8 @@ For each test case, - If there is no real voting corresponding to given distribu 2 3 1 -1 -1 - ### Explanation + **Example 1:** In this example, each person has received one vote. One possible example of real voting leading to this distribution is {2, 3, 1}. In this distribution, number of votes of all three persons are equal to 1. Also it is real voting because no person votes himself as his best friend. You can also output another possible distribution {3, 1, 2} too. **Example 2:** There is no real voting corresponding to this voting distribution. diff --git a/_problems/easy/CHEFYODA.md b/_problems/easy/CHEFYODA.md index d8e04305..6323d118 100644 --- a/_problems/easy/CHEFYODA.md +++ b/_problems/easy/CHEFYODA.md @@ -93,19 +93,19 @@ For each test case, output a line containing the answer for task. The output mus **Subtask 1 : 10 points** - **2** ≤ **N, M** ≤ **5** -- ≤ **P** ≤ **K** ≤ **5** +- 0 ≤ **P** ≤ **K** ≤ **5** **Subtusk 2 : 10 points** - **2** ≤ **N, M** ≤ **10** -- ≤ **P** ≤ **K** ≤ **10^3** +- 0 ≤ **P** ≤ **K** ≤ **10^3** **Subtusk 3 : 20 points** - **2** ≤ **N, M** ≤ **100** -- ≤ **P** ≤ **K** ≤ **10^3** +- 0 ≤ **P** ≤ **K** ≤ **10^3** **Subtusk 4 : 60 points**- **2** ≤ **N, M** ≤ **100** -- ≤ **P** ≤ **K** ≤ **10^6** +- 0 ≤ **P** ≤ **K** ≤ **10^6** ### Example @@ -116,5 +116,4 @@ For each test case, output a line containing the answer for task. The output mus Output: 0.500000 1.000000 - \ No newline at end of file diff --git a/_problems/easy/CHEFZOT.md b/_problems/easy/CHEFZOT.md index 9540b171..1be0802b 100644 --- a/_problems/easy/CHEFZOT.md +++ b/_problems/easy/CHEFZOT.md @@ -90,7 +90,7 @@ Product of subarray **Aij** is product of all its elements (from **ith** to **jt ### Constraints - **1** ≤ **N** ≤ **100000** -- ≤ **Ai** ≤ **10000** +- 0 ≤ **Ai** ≤ **10000** ### Example @@ -114,8 +114,8 @@ Product of subarray **Aij** is product of all its elements (from **ith** to **jt Output: 1 - ### Explanation + For the first sample subarray is: {2, 3}. For the second sample there are no subbarays with non-zero product. diff --git a/_problems/easy/CHFANS.md b/_problems/easy/CHFANS.md index 29ada1e4..c503b95e 100644 --- a/_problems/easy/CHFANS.md +++ b/_problems/easy/CHFANS.md @@ -105,5 +105,4 @@ Print **T** lines with each containing the required answer. 1 1 3 - \ No newline at end of file diff --git a/_problems/easy/CHFNFRN.md b/_problems/easy/CHFNFRN.md index 58bc30a8..66c62866 100644 --- a/_problems/easy/CHFNFRN.md +++ b/_problems/easy/CHFNFRN.md @@ -93,7 +93,7 @@ For each test case, output a single line containing word "YES" (without quotes) - **1** ≤ **T** ≤ **103** - **1** ≤ **N** ≤ **103** -- ≤ **M** ≤ **106** +- 0 ≤ **M** ≤ **106** - **1** ≤ **ai, bi** ≤ **N** - The sum of **N** over all test cases in a single test file does not exceed **104** - The sum of **M** over all test cases in a single test file does not exceed **106** @@ -130,6 +130,7 @@ NO YES ### Explanation + **Example case 1.** Table 1: Person 1. Table 2: Persons 2 and 3. diff --git a/_problems/easy/CHINFL.md b/_problems/easy/CHINFL.md index 212eec13..50d82bf6 100644 --- a/_problems/easy/CHINFL.md +++ b/_problems/easy/CHINFL.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in A recent glut in Chefland's markets has caused the local currency _Peppercorn_ to devaluate sharply. (Peppercorns are getting cheaper on an average, though there could be ups and downs). -And Chef needs to rescue his wealth! Initially, he had **D** Peppercorns. There are **N** exchange kiosks in the city he lives in, where he can go and exchange his Peppercorns for a well-known stable currency, the Antarctican Dollar. For each kiosk, the exchange rate for the first **M** seconds of the day is known (both for buying and selling). All kiosks are arranged in a row, and to travel from the **ith** to the **jth** kiosk, you need to spend **|i-j|** seconds, and to exchange currency at any kiosk, you also need **1** second. So, starting at point of time at any of the kiosks (he can get there before trading starts for the day), Chef runs from one kiosk to another to buy and sell currency. You need to find the maximum amount of Peppercorns Chef could have after the **Mth** second. +And Chef needs to rescue his wealth! Initially, he had **D** Peppercorns. There are **N** exchange kiosks in the city he lives in, where he can go and exchange his Peppercorns for a well-known stable currency, the Antarctican Dollar. For each kiosk, the exchange rate for the first **M** seconds of the day is known (both for buying and selling). All kiosks are arranged in a row, and to travel from the **ith** to the **jth** kiosk, you need to spend **|i-j|** seconds, and to exchange currency at any kiosk, you also need **1** second. So, starting at point of time 0 at any of the kiosks (he can get there before trading starts for the day), Chef runs from one kiosk to another to buy and sell currency. You need to find the maximum amount of Peppercorns Chef could have after the **Mth** second. ### Note @@ -118,5 +118,4 @@ If the amount of money of any currency that Chef will own at any point of time e Output: 15.0000000000 - \ No newline at end of file diff --git a/_problems/easy/CHMOD.md b/_problems/easy/CHMOD.md index e44a6c25..c1ccef91 100644 --- a/_problems/easy/CHMOD.md +++ b/_problems/easy/CHMOD.md @@ -105,5 +105,4 @@ For each game, output a single line containing the answer for the respective seg 0 120 - \ No newline at end of file diff --git a/_problems/easy/CHN01.md b/_problems/easy/CHN01.md index e5c027de..2dc0a9b9 100644 --- a/_problems/easy/CHN01.md +++ b/_problems/easy/CHN01.md @@ -64,8 +64,8 @@ Can you please help them in finding out the maximum number of contests they can Output: 1 3 - ### Explanation + **In the first example**, they have 1 easy, 1 medium and 1 hard problem. They can conduct one contest of type 1. This is the maximum number of contests they can conduct. **In the second example**, they have 4 easy, 4 medium, and 4 hard problems. They can conduct 3 contests, one each of type 1, 2, and 3, which require a total of 4 easy, 4 med and 1 hard problems. This is the maximum number of contests they can conduct. Hence, the answer is 3. diff --git a/_problems/easy/CHN03.md b/_problems/easy/CHN03.md index cfc4ff21..11ae6b7a 100644 --- a/_problems/easy/CHN03.md +++ b/_problems/easy/CHN03.md @@ -67,8 +67,8 @@ Animesh has at max **time** hours before he gets frustrated by his noobness and Output: 6 11 - ### Explanation + **In the first example**, Malvika has prepared only one programming contest, its easy problem takes 1 hour and gives 5 units of pleasure. The medium one takes 2 hours and gives 3 units of pleasure whereas the same values for hard are 3 hours and 6 units of pleasure. Animesh has only 5 hours and can select at max one problems out of these to solve. The hard problem is the best candidate to choose for him, it will him give him 6 units of pleasure and take his 5 hours. So, the answer is 6. **In the second example**, Malvika has prepared two programming contests. diff --git a/_problems/easy/CHN05.md b/_problems/easy/CHN05.md index 153d0452..627ce3eb 100644 --- a/_problems/easy/CHN05.md +++ b/_problems/easy/CHN05.md @@ -54,8 +54,8 @@ Find out the minimum number of hours needed so that each person learns all the * Output: 1 4 - ### Explanation + **In the first example**, there are two people. Second person is Malvika and she has to teach only one topic to the first person. It will take only one hour to do so. **In the second example**, there are three people. The 3rd person is Malvika and she has to teach only two topics to 1st and 2nd person. In the 1st hour, she teaches the 1st topic to the 2nd person. Now, in the 2nd hour, the 2nd person will teach the 1st topic to the 1st person. In the 3rd hour, Malvika will teach the 2nd topic to the 2nd person. Now the 2nd person will teach that topic to the 1st in the 4th hour. So, it takes a total of 4 hours for all the people to know all the topics. diff --git a/_problems/easy/CHNGFUNC.md b/_problems/easy/CHNGFUNC.md index 9391f9fc..25acf1b3 100644 --- a/_problems/easy/CHNGFUNC.md +++ b/_problems/easy/CHNGFUNC.md @@ -101,6 +101,6 @@ Output a single integer indicating the output to the only test case. Output: 1 - ### Explanation + **Example case 1.**(1, 3) is the only pair such that x = 1, y = 3 satisfying x diff --git a/_problems/easy/CHNGSUM.md b/_problems/easy/CHNGSUM.md index 745833d2..1573be8b 100644 --- a/_problems/easy/CHNGSUM.md +++ b/_problems/easy/CHNGSUM.md @@ -103,8 +103,8 @@ Ouput an integer corresponding to the answer to the only test case in a line. Output: 19 - ### Explanation + The perfect Quadruples and their individual contribution is calculated as.
F(1, 1, 2, 2) = 2*1 = 2
@@ -112,5 +112,4 @@ The perfect Quadruples and their individual contribution is calculated as.
 F(1, 1, 3, 3) = 2*3 = 6
 F(1, 2, 3, 3) = 2*3 = 6
 F(2, 2, 3, 3) = 1*3 = 3
-
-
All these values sum up to **19**. \ No newline at end of file +All these values sum up to **19**. diff --git a/_problems/easy/CHODE.md b/_problems/easy/CHODE.md index 0d6e53a0..6afa06a1 100644 --- a/_problems/easy/CHODE.md +++ b/_problems/easy/CHODE.md @@ -116,5 +116,4 @@ hello! have a nice day! Hello! - \ No newline at end of file diff --git a/_problems/easy/CHPLGNS.md b/_problems/easy/CHPLGNS.md index 76463f92..9571463e 100644 --- a/_problems/easy/CHPLGNS.md +++ b/_problems/easy/CHPLGNS.md @@ -130,8 +130,8 @@ For each test case, output a single line containing **N** space-separated intege 3 3 -3 3 -3 -3 3 -3 Output: 1 0 2 - ### Explanation + In the picture the first polygon is marked in green, second - in red and third in blue color. ![explanation](http://www.codechef.com/download/JUNE15/CHPLGNS.jpg) diff --git a/_problems/easy/CHRECT.md b/_problems/easy/CHRECT.md index 205cbe99..5f200f75 100644 --- a/_problems/easy/CHRECT.md +++ b/_problems/easy/CHRECT.md @@ -106,8 +106,8 @@ For each test case, output the smallest value possible for **S**, if the Chef ch 1 12 - ### Explanation + **Test Case 1:** Chef may choose any way. The maximum value on any cell would be 1. **Test Case 2:** If Chef selects two paths that have a common cell, such as diff --git a/_problems/easy/CHSGMNTS.md b/_problems/easy/CHSGMNTS.md index c99bc07d..bf88da4d 100644 --- a/_problems/easy/CHSGMNTS.md +++ b/_problems/easy/CHSGMNTS.md @@ -118,8 +118,8 @@ Help Chef to find this number. Output: 5 4 - ### Explanation + **Example case 1.** All possible variants are correct: {\[1, 1\], \[2, 2\]}, {\[1, 1\], \[2, 3\]}, {\[1, 2\], \[3, 3\]}, {\[2, 2\], \[3, 3\]}, {\[1,1\], \[3, 3\]}. diff --git a/_problems/easy/CHSHIFU.md b/_problems/easy/CHSHIFU.md index 78313945..d2153f8d 100644 --- a/_problems/easy/CHSHIFU.md +++ b/_problems/easy/CHSHIFU.md @@ -128,13 +128,13 @@ For each testcase, print the **minimum** number of employees to be informed on a 1 2 2 3 3 4 - **Output** +
 1
 2
-
 
**Explanation** + In testcase 1, since every employee is a friend of every other employee, we just need to select 1 employee. In testcase 2, selecting employees 2 and 4 would ensure that all 4 employees are represented. diff --git a/_problems/easy/CHSQR.md b/_problems/easy/CHSQR.md index aadddf19..e04a0baf 100644 --- a/_problems/easy/CHSQR.md +++ b/_problems/easy/CHSQR.md @@ -115,5 +115,4 @@ For each test case, print **K** lines each consisting of **K** space separated i 1 3 2 2 1 3 - \ No newline at end of file diff --git a/_problems/easy/CHSTAMP.md b/_problems/easy/CHSTAMP.md index fe2def07..1760955f 100644 --- a/_problems/easy/CHSTAMP.md +++ b/_problems/easy/CHSTAMP.md @@ -129,6 +129,6 @@ For each test case, output a single line containing maximum possible value of Ch 16 - ### Explanation + **Example case 1.** Chef can use **2nd** offer to exchange the stamp of type **1** with an stamp of type **3**. After that he can use **1st** offer to exchange his 2 stamps of type **3** with 2 stamps of type **4**. Finally, on **3rd** day Chef uses the offer to exchange the stamp of type **5** with an stamp of type **8**. After this transaction, value of his collection becomes **4 + 4 + 8 = 16**. diff --git a/_problems/easy/CHSTR.md b/_problems/easy/CHSTR.md index 917ed1ac..4229ac34 100644 --- a/_problems/easy/CHSTR.md +++ b/_problems/easy/CHSTR.md @@ -126,8 +126,8 @@ ababa 15 1 0 - ### Explanation + **L** = {**"a", "b", "a", "b", "a", "ab", "ba", "ab", "ba", "aba", "bab", "aba", "abab", "baba", "ababa"**}. - **k1 = 2**: There are seven ways to choose two equal strings ("a", "a"), ("a", "a"), ("a", "a"), ("b", "b"), ("ab", "ab"), ("ba", "ba"), ("aba", "aba"). diff --git a/_problems/easy/CIELDIST.md b/_problems/easy/CIELDIST.md index 5f32d790..f7900805 100644 --- a/_problems/easy/CIELDIST.md +++ b/_problems/easy/CIELDIST.md @@ -82,7 +82,7 @@ The first line of the input contains an integer **T** denoting the number of tes For each test case, output a single line containing the minimum possible distance between Ciel's restaurants that could be achieved. The output must have an absolute or relative error at most **0.000001 (10−6)**. Please, note that your output should not have more than **1000** digits after the decimal point, otherwise you may (or may not) get _wrong answer_ or _runtime error (SIGXFSZ)_. -Note also that the answer could be , which means that two Ciel's restaurants should be located at the same building. +Note also that the answer could be 0, which means that two Ciel's restaurants should be located at the same building. ### Constraints @@ -104,8 +104,8 @@ Note also that the answer could be , which means that two Ciel's restaurants sho 0.0 69.00000 0 - ### Explanation + **Example case 1.** The distance between markets **S** and **T** is **50**. Assume for simplicity that **S** has coordinates **(0, 0)** and **T** has coordinates **(50, 0)**. Then Ciel could build her first restaurant **RS** at the point **(15, 0)** and the second restaurant **RT** at the point **(35, 0)**. This will ensure that the distance between **S** and **RS** is **DS = 15** and the distance between **T** and **RT** is **DT = 15**. The distance between restaurants appear to be **20** in this scenario. One can prove that this is the minimum possible distance. **Example case 2.** Here Ciel can locate both her restaurants at the same place. Indeed, if **S = (0, 0)** and **T = (18, 0)** then Ciel could locate both her restaurants at the point **R = (9, 12)**. To check this note that **Dist(R, S) = ((9 − 0)2 + (12 − 0)2)1/2 = (81 + 144)1/2 = 2251/2 = 15**. Similarly it can be verified that **Dist(R, T) = 15**. diff --git a/_problems/easy/CIELMAP.md b/_problems/easy/CIELMAP.md index 3c3eb8c3..fc83b760 100644 --- a/_problems/easy/CIELMAP.md +++ b/_problems/easy/CIELMAP.md @@ -100,6 +100,7 @@ No three points (**Xi**, **Yi**), (**Xj**, **Yj**), (**Xk**, **Yk**) lie in the 6 6 5 6 ### Sample Output + `5.8309518948`### Explanations The below figure denotes one of the valid tetragons for the sample input. The red segment is the longest segment which can be one of the sides in her tetragon. diff --git a/_problems/easy/CIELTOMY.md b/_problems/easy/CIELTOMY.md index 9b870ac2..8124ff3f 100644 --- a/_problems/easy/CIELTOMY.md +++ b/_problems/easy/CIELTOMY.md @@ -105,9 +105,11 @@ There is at least one path from Tomya's house to Ciel's restaurant. 2 3 6 1 3 9 ### Sample Output +
1
 2
 
### Explanations + In the first sample, only one shortest path exists, which is 1-3. In the second sample, both paths 1-2-3 and 1-3 are the shortest paths. diff --git a/_problems/easy/CIRCUITS.md b/_problems/easy/CIRCUITS.md index 573151f7..0f0a42d2 100644 --- a/_problems/easy/CIRCUITS.md +++ b/_problems/easy/CIRCUITS.md @@ -64,5 +64,4 @@ For each test case you are to output a single line containing the value p for wh 0.29289 0.70711 0.40303 - \ No newline at end of file diff --git a/_problems/easy/CIRKILL.md b/_problems/easy/CIRKILL.md index 19de743f..f85e32ca 100644 --- a/_problems/easy/CIRKILL.md +++ b/_problems/easy/CIRKILL.md @@ -117,8 +117,8 @@ For each test case, output a single line containing the probability that **Team 0.25 0.4 - ### Explanation + **Test 1:** There are 4 ways TR may be placed. Each one of them has the probability 0.25, of occuring. - { (-1,0), (0,0), (0,1) }, Ash is at (1,0). Ash cannot be killed even though TR has a valid and unique "kill circle". diff --git a/_problems/easy/CKISSHUG.md b/_problems/easy/CKISSHUG.md index 434f3aa1..3ec4efb4 100644 --- a/_problems/easy/CKISSHUG.md +++ b/_problems/easy/CKISSHUG.md @@ -93,6 +93,7 @@ First line of the input contains **T (T ≤ 1000)** denoting the number of test 3
 **Output**
+
  ```
 
 2
@@ -100,6 +101,7 @@ First line of the input contains **T (T ≤ 1000)** denoting the number of test
 6
    
 
**Explanation:** + In the first case the possible ways are K, H diff --git a/_problems/easy/CLEANUP.md b/_problems/easy/CLEANUP.md index 82fcb966..4db693f0 100644 --- a/_problems/easy/CLEANUP.md +++ b/_problems/easy/CLEANUP.md @@ -43,5 +43,4 @@ The output for each test case consists of two lines. The first line is a list of 1 4 6 2 5 7 - \ No newline at end of file diff --git a/_problems/easy/CLETAB.md b/_problems/easy/CLETAB.md index c3657b36..d633f576 100644 --- a/_problems/easy/CLETAB.md +++ b/_problems/easy/CLETAB.md @@ -114,8 +114,8 @@ For each test case output the minimum number of times Haku must clean the table( 2 4 4 - ### Explanation + **Example case 1.** In the starting all tables i.e. 2 tables are unoccupied. When customer 1 asks for table, he can be given any of the 2 tables. Haku has to clean either of the table. Next customer 2 can occupy the other free table. Haku must clean second time. When customer 3 comes Haku can ask either customer 1 or 2 to leave. Suppose he asks customer 1 to leave. Then he has to clean table for the third time. When customer 4 comes, Haku can ask customer 2 or 3 to leave. In either case Haku will have to clean the table for the fourth time. Phew!! **Example case 4.** Suppose the tables are listed as \[-, -, -\]. A possible optimal order of allocating tables can be \[1, -, -\] -> \[1, 2, -\] -> \[1, 2, -\] -> \[1, 2, 3\] -> \[4, 2, 3\]. So Haku will have to clean table for order no. 1, 2, 4 and 5. That is 4 times. diff --git a/_problems/easy/CLIQUED.md b/_problems/easy/CLIQUED.md index c9bacfab..e7cc1cd8 100644 --- a/_problems/easy/CLIQUED.md +++ b/_problems/easy/CLIQUED.md @@ -132,8 +132,8 @@ For each test case, output a single line containing **N** integers. The i-th of 100 100 0 100 150 100 100 0 100 140 17 32 30 20 0 10 1030 1080 - ### Explanation + **Test case 1.** There are **N** = 5 cities. The first **K** = 4 of them are all connected with each other with roads of length **X** = 100. There are **M** = 2 extra roads: - Cities 1 and 5 are connected with a road of length 50. diff --git a/_problems/easy/CLMBSTRS.md b/_problems/easy/CLMBSTRS.md index 3864edf8..1879c3d1 100644 --- a/_problems/easy/CLMBSTRS.md +++ b/_problems/easy/CLMBSTRS.md @@ -120,8 +120,8 @@ Your code will be judged against several input files. CORRECT INCORRECT (and 99998 more answers...) - ### Output Explanation: + On the first case, when there is only one step to climb, there is only one way to do it. 1 in binary is 1, and as the village's population guess is also 1 the answer is correct. On the second case, there are 21 ways of climbing the stairs altogether. 21 in binary is 10101, that contains three ones. As the village's population guess was 4, the answer is therefore incorrect. diff --git a/_problems/easy/CLOST.md b/_problems/easy/CLOST.md index 125c4d06..59fbad9f 100644 --- a/_problems/easy/CLOST.md +++ b/_problems/easy/CLOST.md @@ -107,6 +107,6 @@ Print **T** lines, with the **i**th one containing the solution string for the * Output: ()() (()) - ### Explanation + For the first sample case, "(())" are "()()" are two possible outputs. Printing anyone will do. diff --git a/_problems/easy/CLPERM.md b/_problems/easy/CLPERM.md index c2902bfc..40baa1bb 100644 --- a/_problems/easy/CLPERM.md +++ b/_problems/easy/CLPERM.md @@ -119,8 +119,8 @@ For each test case, print **"Chef"** if chef should move first otherwise print * Output Mom Chef - ### Explanation + For test case 1. - Mom can choose {1} to make 1. diff --git a/_problems/easy/CLRL.md b/_problems/easy/CLRL.md index 552b368d..cece58fb 100644 --- a/_problems/easy/CLRL.md +++ b/_problems/easy/CLRL.md @@ -127,6 +127,6 @@ Given the sequence that Chef wrote and Reziba's rating, find out whether this se Output: NO YES - ### Explanation + **Example case 1.**The first person that Chef asked has a rating of 600, which is more than 200 so he tells Chef to go to his left. The second person Chef meets has a rating of 300, also tells Chef to go to the left. The third person that chef asked has a rating of 100 so he tells Chef to go to the right. Then Chef asked a person with rating 350, that means Chef went beyond the person with rating of 300, which should never happen, so Chef must have made a mistake while writing this sequence. diff --git a/_problems/easy/CNOTE.md b/_problems/easy/CNOTE.md index f48951fd..9f036ef7 100644 --- a/_problems/easy/CNOTE.md +++ b/_problems/easy/CNOTE.md @@ -121,8 +121,8 @@ For each test case, Print "**LuckyChef**" if Chef can select such a notebook, ot LuckyChef UnluckyChef UnluckyChef - ### Explanation + **Example case 1.** In this case, Chef wants to write **X = 3** pages long poetry, but his notebook has only **Y = 1** page. And his budget is **K = 2** rubles, and there are **N = 2** notebooks in the shop. The first notebook has **P1 = 3** pages, but Chef cannot buy it, because its price is **C1 = 4** rubles. The second notebook has **P2 = 2** pages, and its price is **C2 = 2** rubles. Thus Chef can select the second notebook to accomplish the task. He will write **1** page of poetry in the old notebook, and **2** page of poetry in the new notebook. **Example case 2.** Chef cannot buy any notebook, because the prices exceed the Chef's budget. diff --git a/_problems/easy/CODECRCK.md b/_problems/easy/CODECRCK.md index d8d2dbd3..3625a091 100644 --- a/_problems/easy/CODECRCK.md +++ b/_problems/easy/CODECRCK.md @@ -125,6 +125,6 @@ It is guaranteed that -1010 ≤ Q ≤ 1010. Output: 0.28125 - ### Explanation + **Example case 1.** In this case, **a\_1** = 4, **b\_1** = 5, and **s** = 5. Cthulhu's code in this case is (**a\_1** + **b\_1**) / (2s) = 9/32 = 0.28125. diff --git a/_problems/easy/COLARR.md b/_problems/easy/COLARR.md index a3dce2d1..83d764b4 100644 --- a/_problems/easy/COLARR.md +++ b/_problems/easy/COLARR.md @@ -75,7 +75,7 @@ The kick was so strong that Chef suddenly understood the rules of the game. - Each cell is painted with a color. Here the colors are numbered from **1** to **M**. - For any cell **i**, Chef can repaint it with any color **q**, and the cost of such operation is **Ci,q** points. -- However Chef can do at most **K** repaintings ( repaintings is possible). +- However Chef can do at most **K** repaintings (0 repaintings is possible). - After performing all repaintings, each cell will have some color. For each cell **i**, if cell **i** has color **q** then Chef will receive **Bi,q** points. Now Chef is wondering how many points can he receive in total when he repaints optimally. @@ -119,8 +119,8 @@ For each test case, output a single line containing the maximal possible points. Output: 5 - **Explanation:** + For this sample, we can repaint only once, since **K = 1**. We should repaint **4**th cell with color **1**. We will pay **1** for this, and receive: **1** (**1**st cell - **1**st color) + diff --git a/_problems/easy/COLLIDE.md b/_problems/easy/COLLIDE.md index 1f3c6674..69e95d4f 100644 --- a/_problems/easy/COLLIDE.md +++ b/_problems/easy/COLLIDE.md @@ -51,8 +51,8 @@ DIRE, DIRA is one of 'U', 'R', 'D', 'L' 2.0 SAFE 1.5 - -**Explanation:**Case 1 : + +**Explanation:**Case 1 : Time 0 - Earth (0,0) Asteroids { (1,-2), (2,2) } Time 1 - Earth (1,0) Asteroids { (1,-1), (2,1) } Time 2 - Earth (2,0) Asteroids { (1,0 ), (2,0) } diff --git a/_problems/easy/COMM3.md b/_problems/easy/COMM3.md index d035dcbf..6560cea1 100644 --- a/_problems/easy/COMM3.md +++ b/_problems/easy/COMM3.md @@ -50,5 +50,4 @@ To be clear, we say that two transceivers are close enough to communicate direct yes yes no - \ No newline at end of file diff --git a/_problems/easy/COMMUTE.md b/_problems/easy/COMMUTE.md index c79acfe7..97494465 100644 --- a/_problems/easy/COMMUTE.md +++ b/_problems/easy/COMMUTE.md @@ -50,5 +50,4 @@ For each test case you are to output a single integer denoting the minimum time 11 8 5 - \ No newline at end of file diff --git a/_problems/easy/COMPCLUB.md b/_problems/easy/COMPCLUB.md index 4be37cb8..ed9628dd 100644 --- a/_problems/easy/COMPCLUB.md +++ b/_problems/easy/COMPCLUB.md @@ -74,7 +74,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [mandarin chinese](http://www.codechef.com/download/translated/LTIME49/mandarin/COMPCLUB.pdf), [russian](http://www.codechef.com/download/translated/LTIME49/russian/COMPCLUB.pdf) and [vietnamese](http://www.codechef.com/download/translated/LTIME49/vietnamese/COMPCLUB.pdf) as well. -You are working in a company with **N** employees numbered from to **N - 1**, and employee is the director. Each employee, except the director, has a supervisor. The director doesn't have a supervisor. Let's call employee **v**, an ancestor of employee **u** if and only if **v** is the supervisor of **u** or **v** is an ancestor of the supervisor of **u**. +You are working in a company with **N** employees numbered from 0 to **N - 1**, and employee 0 is the director. Each employee, except the director, has a supervisor. The director doesn't have a supervisor. Let's call employee **v**, an ancestor of employee **u** if and only if **v** is the supervisor of **u** or **v** is an ancestor of the supervisor of **u**. Also, each employee belongs to exactly one club. Employee **i** belongs to club number **Ci**. And each club has some internal levels, which are actually independent of the company hierarchy. Each member of a club has a Level Number. The Level Number of employee **i** is denoted by **Ki**. The higher the Level Number, the more important he is in the club. @@ -104,9 +104,9 @@ For each test case, you have to output **N** lines. Line number **i + 1** should - **1** ≤ **T** ≤ **100** - **1** ≤ **N** ≤ **500000** - **1** ≤ **X** ≤ **N** -- ≤ **Pi** i -- ≤ **Ci** N -- ≤ **Ki** X +- 0 ≤ **Pi** i +- 0 ≤ **Ci** N +- 0 ≤ **Ki** X - **1** ≤ Sum of **N** over all test cases ≤ **1000000** ### Subtasks @@ -146,8 +146,8 @@ For each test case, you have to output **N** lines. Line number **i + 1** should 1 1 - ### Explanation + - Good sequences starting at employee 0: (0, 1, 3), (0, 1, 4), (0, 2, 3), (0, 2, 4) - Good sequences starting at employee 1: (1, 3), (1, 4) - Good sequences starting at employee 2: (2, 3), (2, 4) diff --git a/_problems/easy/COMPILER.md b/_problems/easy/COMPILER.md index ecca9d56..08158bbe 100644 --- a/_problems/easy/COMPILER.md +++ b/_problems/easy/COMPILER.md @@ -104,7 +104,7 @@ are all valid. While: are not. -Given some expressions which represent some instructions to be analyzed by Lira's compiler, you should tell the length of the longest prefix of each of these expressions that is valid, or if there's no such a prefix. +Given some expressions which represent some instructions to be analyzed by Lira's compiler, you should tell the length of the longest prefix of each of these expressions that is valid, or 0 if there's no such a prefix. ### Input @@ -114,7 +114,7 @@ Then, **T** strings follow, each on a single line, representing a possible expre ### Output -For each expression you should output the length of the longest prefix that is valid or if there's no such a prefix. +For each expression you should output the length of the longest prefix that is valid or 0 if there's no such a prefix. ### Constraints @@ -133,5 +133,4 @@ For each expression you should output the length of the longest prefix that is v 0 2 - \ No newline at end of file diff --git a/_problems/easy/CONFLIP.md b/_problems/easy/CONFLIP.md index 281c4219..39f84001 100644 --- a/_problems/easy/CONFLIP.md +++ b/_problems/easy/CONFLIP.md @@ -102,8 +102,8 @@ For each game, output one integer denoting the total number of coins showing the Output: 2 3 - ### Explanation: + **In the 1st game in Example:****I=1**, so initial arrangement of coins are H H H H H, and now Elephant will play 5 rounds and coin faces will be changed as follows After the 1st Round: **T** H H H H After the 2nd Round: **H T** H H H diff --git a/_problems/easy/CONSESNK.md b/_problems/easy/CONSESNK.md index 603f7111..c39935ea 100644 --- a/_problems/easy/CONSESNK.md +++ b/_problems/easy/CONSESNK.md @@ -110,8 +110,8 @@ If a snake was initially at the position \[**X1, X1** + **L**\] and finally is a Output: 16 16 - ### Explanation + In the first testcase, the three snakes are initially at segments \[10, 14\], \[11, 15\], and \[30, 34\]. One optimal solution is to move the first snake which was at \[10, 14\] to \[15, 19\] and the third snake which was at \[30, 34\] to \[19, 23\]. After this, the snakes would form a valid parade because they will be from \[11, 15\], \[15, 19\] and \[19, 23\]. Hence they are all in a line without any gaps in between them, and they are all visible, because they all lie in the visible segment, which is \[11, 23\]. The distance traveled by the first snake is |15 - 10| = 5, by the second snake is |11 - 11| = 0 and by the third snake is |19 - 30| = 11. Hence the total distance traveled is 5 + 0 + 11 = 16. This is the best that you can do, and hence the answer is 16. diff --git a/_problems/easy/COOK82B.md b/_problems/easy/COOK82B.md index ec4100df..efd4ed71 100644 --- a/_problems/easy/COOK82B.md +++ b/_problems/easy/COOK82B.md @@ -111,16 +111,16 @@ In case there is no need to insert an additional number output "justdoit" (witho Output: 9261 - ### Example 2 +
Input:
 4
 25 15 5 27
 
 Output:
 justdoit
-
 
### Explanation + In the first Example, after inserting 9261, the array becomes {4, 6, 14, 9261}. We will show a series of moves through which Farah can make the array elements equal. We follow 1-based indexing. - (1, 4, 2). The array becomes {4/2, 6, 14, 9261\*2} = {2, 6, 14, 18522} diff --git a/_problems/easy/COOK82C.md b/_problems/easy/COOK82C.md index fee6a776..2eab9610 100644 --- a/_problems/easy/COOK82C.md +++ b/_problems/easy/COOK82C.md @@ -119,8 +119,8 @@ Can you help Hasan and answer the queries? 3 2 1 - ### Explanation + We show the multiset sorted at each step, for convenience. - Before any move, the multiset is (8, 5, 3, 1). diff --git a/_problems/easy/COOKGAME.md b/_problems/easy/COOKGAME.md index df6122e6..2a4c367b 100644 --- a/_problems/easy/COOKGAME.md +++ b/_problems/easy/COOKGAME.md @@ -108,6 +108,6 @@ Output the answer for each test-case in new line, the number of ways modulo **10 Output: 2 - ### Explanation + The only two valid fully filled arrays are (1,1,2,3,1,2) and (1,1,2,1,1,2). Hence the answer is 2. diff --git a/_problems/easy/COOLGUYS.md b/_problems/easy/COOLGUYS.md index 9aae1a02..785dc137 100644 --- a/_problems/easy/COOLGUYS.md +++ b/_problems/easy/COOLGUYS.md @@ -90,8 +90,8 @@ For each test case, output a single line containing probability as an irreducibl 1/1 3/4 5/9 - ### Constraints + 1<=**T**<=103 1<=**N**<=109 diff --git a/_problems/easy/COOLING.md b/_problems/easy/COOLING.md index 143a8f5b..adc919a8 100644 --- a/_problems/easy/COOLING.md +++ b/_problems/easy/COOLING.md @@ -32,6 +32,7 @@ For each test case, output on a line the maximum number of pies the chef can pla 8 3 14 10 10 ### Sample output: +
3
 4
  
diff --git a/_problems/easy/COUNTPAL.md b/_problems/easy/COUNTPAL.md
index 83b398e2..007c2e84 100644
--- a/_problems/easy/COUNTPAL.md
+++ b/_problems/easy/COUNTPAL.md
@@ -37,5 +37,4 @@ bobseesanna
 
 Output:
 18
-
 
\ No newline at end of file diff --git a/_problems/easy/COUNTREL.md b/_problems/easy/COUNTREL.md index 46dabd4a..823316ab 100644 --- a/_problems/easy/COUNTREL.md +++ b/_problems/easy/COUNTREL.md @@ -55,5 +55,4 @@ Phi=Empty Set So R1=Either {({1},{2})} or {({2},{1})} and R2=No relation exists So,there is 1 relation of kind R1 and 0 relation of kind R2. - \ No newline at end of file diff --git a/_problems/easy/COURSE.md b/_problems/easy/COURSE.md index 32ae5b43..14e4a419 100644 --- a/_problems/easy/COURSE.md +++ b/_problems/easy/COURSE.md @@ -33,6 +33,7 @@ For each input, output on a single line the diameter of the largest car that can 5 7 -2 -7 ### Sample output: + `2.720`### Explanation: The image below shows the course corresponding to the sample input. The black circles represent the boundaries of the racetrack, the small dots the cones, and the filled red circle the car. Also shown is one possible path of the car through the course. diff --git a/_problems/easy/CPERM.md b/_problems/easy/CPERM.md index 861b4222..ac13f57a 100644 --- a/_problems/easy/CPERM.md +++ b/_problems/easy/CPERM.md @@ -107,8 +107,8 @@ For each test case, output the answer modulo **109+7**. 0 2 - ### Explanation + Test case 1: No permutation satisfies. diff --git a/_problems/easy/CPLAY.md b/_problems/easy/CPLAY.md index d7c828b8..e021d323 100644 --- a/_problems/easy/CPLAY.md +++ b/_problems/easy/CPLAY.md @@ -130,8 +130,8 @@ On each line, print the winner of the corresponding match ("TEAM-A" or "TEAM-B") TEAM-A 12 TIE TEAM-B 7 - ### Explanation + **Example case 1:** After 5 turns, the result was a tie and after the 6th turn, the score was 4:3, so Chef's team was the winner and the number of shots required to decide the result was 12. **Example case 2:** Both teams didn't score any goal, so the match resulted in a tie after 10 turns (20 shots). diff --git a/_problems/easy/CPOINT.md b/_problems/easy/CPOINT.md index cdac6532..52933e0f 100644 --- a/_problems/easy/CPOINT.md +++ b/_problems/easy/CPOINT.md @@ -43,5 +43,4 @@ For each test case, output on a line a real number (with exactly 6 decimal place Output: 2.828427 9.640986 - \ No newline at end of file diff --git a/_problems/easy/CRAWA.md b/_problems/easy/CRAWA.md index 2f38e616..a6f57f9b 100644 --- a/_problems/easy/CRAWA.md +++ b/_problems/easy/CRAWA.md @@ -120,6 +120,6 @@ YES NO YES - **Explanation** + The points **(0, 0)** and **(3, 3)** will be having trace of oil while point **(3, 5)** will not have any trace of oil because point **(3, 5)** does not lie on the trajectory of robot. diff --git a/_problems/easy/CROWD.md b/_problems/easy/CROWD.md index 207275e6..a05877c1 100644 --- a/_problems/easy/CROWD.md +++ b/_problems/easy/CROWD.md @@ -87,18 +87,18 @@ The answer can get quite large. So output the total number of ways modulo 109+7.
 1TN15
 
-
 
### Example: + **Input:**``` 2 3 4 +
**Output:**```
 
-
**Output:**
 1
 3
 
-
-
**Explanation:**_Case 1:_ The only way he can go wrong is by inviting all the houses._Case 2:_ First way of getting wrong is by inviting houses (1,2,3). Second way to get wrong is by inviting houses (2,3,4). Third way of going wrong is by inviting all 4 houses i.e. (1,2,3,4). +
**Explanation:**_Case 1:_ The only way he can go wrong is by inviting all the houses. +_Case 2:_ First way of getting wrong is by inviting houses (1,2,3). Second way to get wrong is by inviting houses (2,3,4). Third way of going wrong is by inviting all 4 houses i.e. (1,2,3,4). diff --git a/_problems/easy/CSEQ.md b/_problems/easy/CSEQ.md index 57cb4557..bbeb3a6a 100644 --- a/_problems/easy/CSEQ.md +++ b/_problems/easy/CSEQ.md @@ -107,8 +107,8 @@ For each test case print the answer modulo **106+3** in a single line. Output: 2 5 -
### Explanation + **test #1:** \[4\] and \[5\] are the two sequences. **test #2:** \[4\], \[5\], \[4, 4\], \[4, 5\] and \[5, 5\] are the five sequences. diff --git a/_problems/easy/CSUB.md b/_problems/easy/CSUB.md index 8752064e..b2273860 100644 --- a/_problems/easy/CSUB.md +++ b/_problems/easy/CSUB.md @@ -99,7 +99,7 @@ For each testcase, print the required answer in one line. Output: 10 3 - ### Explanation + \#test1: All substrings satisfy. \#test2: Three substrings S\[1,1\], S\[5,5\] and S\[1,5\] satisfy. diff --git a/_problems/easy/CSUMD.md b/_problems/easy/CSUMD.md index 2d7752e5..cf40170c 100644 --- a/_problems/easy/CSUMD.md +++ b/_problems/easy/CSUMD.md @@ -100,11 +100,10 @@ For each case the output should be a single integer representing the number of s 1 2 3 - -**Sample Output** + +**Sample Output**
 1
 3
 8
-
 
\ No newline at end of file diff --git a/_problems/easy/CTEAMS.md b/_problems/easy/CTEAMS.md index 9b53b222..63136851 100644 --- a/_problems/easy/CTEAMS.md +++ b/_problems/easy/CTEAMS.md @@ -44,5 +44,4 @@ Every time a new chef joins the kitchen, output the absolute difference between 5 4 9 - \ No newline at end of file diff --git a/_problems/easy/CUBE.md b/_problems/easy/CUBE.md index 36e14215..434f472e 100644 --- a/_problems/easy/CUBE.md +++ b/_problems/easy/CUBE.md @@ -81,7 +81,7 @@ This winter our chef plans to unveil his latest creation - Cube Cakes. As the na The first line contains an integer **T** denoting the number of test cases. Then the descriptions of testcases follows. The first line of each testcase contains integers **N** (the size of the Cube Cakes **A** and **B** that are to be compared) and **P**. -The next line contains a string **SA** containing **N3** lowercase characters ('a'-'z'), where the **A\[i\]\[j\]\[k\]th** element of the Cube Cake **A** is given by **SA\[ i\*N\*N + j\*N + k \]** where ≤ **i, j, k** ≤ **N-1** . +The next line contains a string **SA** containing **N3** lowercase characters ('a'-'z'), where the **A\[i\]\[j\]\[k\]th** element of the Cube Cake **A** is given by **SA\[ i\*N\*N + j\*N + k \]** where 0 ≤ **i, j, k** ≤ **N-1** . The next line contains a string **SB** containing **N3** lowercase characters ('a'-'z'), **SB** is the description of the Cube Cake **B** in the way analogical to **A**. ### Output @@ -93,7 +93,7 @@ If there is no _common_ sub cube present, just print **-1** in a single line. - **1** ≤ **T** ≤ **40** - **1** ≤ **N** ≤ **40** -- ≤ **P** ≤ **100** +- 0 ≤ **P** ≤ **100** - **| SA |, |SB |** = **N3** ### Example @@ -114,8 +114,8 @@ b 2 1 1 2 -1 - ### Explanation + **Example case 1.** Since both the Cube Cakes are identical, the whole cube matches and hence the similarity is **2**. Also, there is only one sub-cube of size **2**. /> diff --git a/_problems/easy/CUBESUM.md b/_problems/easy/CUBESUM.md index 0d097c68..95b3fd8b 100644 --- a/_problems/easy/CUBESUM.md +++ b/_problems/easy/CUBESUM.md @@ -40,5 +40,4 @@ For each test case print the numbers of A in exactly the same fashion as the inp 14 0 9 4 18 18 2 - \ No newline at end of file diff --git a/_problems/easy/CVOTE.md b/_problems/easy/CVOTE.md index e68423b0..81c7320d 100644 --- a/_problems/easy/CVOTE.md +++ b/_problems/easy/CVOTE.md @@ -120,8 +120,8 @@ Leibniz Output: Germany Leibniz - ### Example 2 +
 Input:
 4 5
@@ -138,8 +138,8 @@ Lagrange
 Output:
 Italy
 Ramanujan
-
 
### Example 3 +
 Input:
 2 2
@@ -151,8 +151,8 @@ Euclid
 Output:
 England
 Euclid
-
 
### Explanation + **Example 1.** Here we have only one chef **Leibniz** and he is from **Germany**. Clearly, all votes are for him. So **Germany** is the country-winner and **Leibniz** is the **"Chef of the Year"**. **Example 2.** Here we have chefs **Torricelli** and **Lagrange** from **Italy**, chef **Ramanujan** from **India** and chef **Gauss** from **Germany**. **Torricelli** got 2 votes, while **Lagrange** got one vote. Hence the **Italy** got 3 votes in all. **Ramanujan** got also 2 votes. And so **India** got 2 votes in all. Finally **Gauss** got no votes leaving **Germany** without votes. So the country-winner is **Italy** without any ties. But we have two chefs with 2 votes: **Torricelli** and **Ramanujan**. But since the string **"Ramanujan"** is lexicographically smaller than **"Torricelli"**, then **Ramanujan** is the **"Chef of the Year"**. diff --git a/_problems/easy/D1.md b/_problems/easy/D1.md index 1ec33d64..a07a1281 100644 --- a/_problems/easy/D1.md +++ b/_problems/easy/D1.md @@ -45,5 +45,4 @@ For each test case, print a single line containing the corresponding result of t 5 7493 0000 - \ No newline at end of file diff --git a/_problems/easy/DAILY.md b/_problems/easy/DAILY.md index 5bc50209..4959892e 100644 --- a/_problems/easy/DAILY.md +++ b/_problems/easy/DAILY.md @@ -55,5 +55,4 @@ Output just one integer -- the requested number of ways. 360 Explanation: - -In the first test case, any of the free places can be sold. In the second test case, the only free compartment in the train is compartment 3 in the first car (places 9, 10, 11, 12, 49 and 50 are all free). In the third test case, the train is still absolutely free; as there are 20 ways to sell 3 tickets in an empty compartment, the answer is 2 \* 9 \* 20 = 360. \ No newline at end of file +In the first test case, any of the free places can be sold. In the second test case, the only free compartment in the train is compartment 3 in the first car (places 9, 10, 11, 12, 49 and 50 are all free). In the third test case, the train is still absolutely free; as there are 20 ways to sell 3 tickets in an empty compartment, the answer is 2 \* 9 \* 20 = 360. diff --git a/_problems/easy/DBOY.md b/_problems/easy/DBOY.md index 196a2e43..eb45e0aa 100644 --- a/_problems/easy/DBOY.md +++ b/_problems/easy/DBOY.md @@ -107,8 +107,8 @@ That is, the delivery boy always can fill a fuel tank exactly 2 \* **Hi** liters 7 - ### Explanation: + Here is one possible solution. For the first order, the delivery boy must ride 1 + 1 = 2 km long. Fill the tank twice in the first fuel station. diff --git a/_problems/easy/DCE03.md b/_problems/easy/DCE03.md index b868c617..352ee98a 100644 --- a/_problems/easy/DCE03.md +++ b/_problems/easy/DCE03.md @@ -23,8 +23,8 @@ For n=4, the different ways are (x1.((x2.x3).x4)) (x1.(x2.(x3.x4))) ((x1.(x2.x3)).x4) - -Hence the required answer would be 5.### Input +Hence the required answer would be 5. +### Input The first line contains the number of test cases t <=10. Each of the next t lines contain single integers <=1000 denoting n. @@ -44,5 +44,4 @@ Display t lines containg the number of ways to put parenthesis in the expression Output: 5 14 - \ No newline at end of file diff --git a/_problems/easy/DCE04.md b/_problems/easy/DCE04.md index 2bf01e82..c3c7ba3f 100644 --- a/_problems/easy/DCE04.md +++ b/_problems/easy/DCE04.md @@ -43,5 +43,4 @@ Display t lines, each line has three space separated integers denoting the numbe Explanation: Explanation for case 2: Since only 2 men are present, the number of women can not be more than 4. - \ No newline at end of file diff --git a/_problems/easy/DCE05.md b/_problems/easy/DCE05.md index ecb0f0bb..c18356e1 100644 --- a/_problems/easy/DCE05.md +++ b/_problems/easy/DCE05.md @@ -39,5 +39,4 @@ Display t lines, each containg a single integer, the place where you would stand Output: 4 8 - \ No newline at end of file diff --git a/_problems/easy/DCGAME.md b/_problems/easy/DCGAME.md index c3ba352e..dce79597 100644 --- a/_problems/easy/DCGAME.md +++ b/_problems/easy/DCGAME.md @@ -125,8 +125,8 @@ Output consists of a single line containing a string of length **M** made up fro Output: DCDDC - ### Explanation: + **Subarray List :** **1. \[1\]** **1. \[2\]** **1. \[3\]** **1. \[1,2\]** **1. \[2,3\]** **1. \[1,2,3\]** diff --git a/_problems/easy/DDISH.md b/_problems/easy/DDISH.md index 1a2b11bd..23e581ab 100644 --- a/_problems/easy/DDISH.md +++ b/_problems/easy/DDISH.md @@ -95,6 +95,6 @@ For every test case, output the answer on a separate line. 8 90 - ### Explanation + For the first test Ira can order every dish from 5 to 13 except 11. diff --git a/_problems/easy/DECSTR.md b/_problems/easy/DECSTR.md index 7a89d97a..dae4faed 100644 --- a/_problems/easy/DECSTR.md +++ b/_problems/easy/DECSTR.md @@ -28,9 +28,8 @@ Output T lines, one for each test case, containing the required string. Use only
2
 1
 2
-
 
### Sample Output +
ba
 cba
-
 
\ No newline at end of file diff --git a/_problems/easy/DEFACING.md b/_problems/easy/DEFACING.md index 32f61fd8..5aa48574 100644 --- a/_problems/easy/DEFACING.md +++ b/_problems/easy/DEFACING.md @@ -89,7 +89,7 @@ For each test case, output a single line containing the maximum possible score D ### Constraints - **1** ≤ **T** ≤ **201301** -- ≤ **S** ≤ **M** ≤ **20130120** +- 0 ≤ **S** ≤ **M** ≤ **20130120** - Each positive integer in the input will be given without leading zeros - If **S** or **M** is equal to zero, it will be given in the input as **"0"** (quotes for clarity) @@ -124,6 +124,6 @@ For each test case, output a single line containing the maximum possible score D 20130120 19889989 4 - ### Explanation + The first three example cases correspond to the figure in the problem statement. diff --git a/_problems/easy/DELISH.md b/_problems/easy/DELISH.md index c55ff529..5b70758c 100644 --- a/_problems/easy/DELISH.md +++ b/_problems/easy/DELISH.md @@ -113,8 +113,8 @@ Print the maximum delish value of the dish that the chef can get. Output: 13 4 - ### Explanation + **Example case 1.** Chef can choose **i = j = 1, k = 2, l = 5**. diff --git a/_problems/easy/DESTROY.md b/_problems/easy/DESTROY.md index 5c602a51..2a87b2f9 100644 --- a/_problems/easy/DESTROY.md +++ b/_problems/easy/DESTROY.md @@ -115,7 +115,7 @@ For each test case, output the required answer in a new line. 2 2 - ### Explanation + - Test 1: In an operation, Chef can choose **2** elements **X** and **Y** such that **X = 1** and **Y = 2** and can destroy them as **X != Y**. - Test 2: Chef cannot choose **2** elements **X** and **Y** such that **X != Y**. So, he has to use the second operation twice in order to destroy the array. diff --git a/_problems/easy/DEVCLASS.md b/_problems/easy/DEVCLASS.md index e0c69e7e..ae44ed5e 100644 --- a/_problems/easy/DEVCLASS.md +++ b/_problems/easy/DEVCLASS.md @@ -118,7 +118,7 @@ For each test case, print a single line containing the answer of the test case, - **1 ≤ T ≤ 102** - **1 ≤ n ≤ 103** -- **type** can be , **1** or **2**, that is **type ∈ {0, 1, 2}**. +- **type** can be 0, **1** or **2**, that is **type ∈ {0, 1, 2}**. ### Example @@ -150,21 +150,21 @@ BGB 3 1 0 - ### Explanation -Note **type** of the first **3** test cases is . So **c(i, j) = 1**. Hence we just have to count minimum number of swaps needed. + +Note **type** of the first **3** test cases is 0. So **c(i, j) = 1**. Hence we just have to count minimum number of swaps needed. **Example case 1.** There is no way to make sure that both the boys does not stand nearby. So answer is **-1**. -**Example case 2.** Arrangement is already valid. No swap is needed. So answer is . +**Example case 2.** Arrangement is already valid. No swap is needed. So answer is 0. **Example case 3.** Swap boy at position **1** with girl at position **2**. After swap the arrangement will be **BGBG** which is a valid arrangement. So answer is **1**. Now **type** of the next **3** test cases is **1**. So **c(i, j) = |j − i|**, that is, the absolute value of the difference between **i** and **j**. -**Example case 4.** Swap boy at position with girl at position **1**. After swap the arrangement will be **GBG** which is a valid arrangement. So answer is **|1 - 0| = 1**. +**Example case 4.** Swap boy at position 0 with girl at position **1**. After swap the arrangement will be **GBG** which is a valid arrangement. So answer is **|1 - 0| = 1**. -**Example case 5.** Swap boy at position with girl at position **1**. After swap the arrangement will be **GBGB** which is a valid arrangement. So answer is **|1 - 0| = 1**. +**Example case 5.** Swap boy at position 0 with girl at position **1**. After swap the arrangement will be **GBGB** which is a valid arrangement. So answer is **|1 - 0| = 1**. **Example case 6.** Swap boy at position **1** with girl at position **4**. After swap the arrangement will be **BGBGB** which is a valid arrangement. So answer is **|4 - 1| = 3**. @@ -172,4 +172,4 @@ Then **type** of the last **2** test cases is **2**. So **c(i, j) = (j − i)2** **Example case 7.** Swap boy at position **1** with girl at position **2**. After swap the arrangement will be **BGBG** which is a valid arrangement. So answer is **(2 - 1)2 = 1**. -**Example case 8.** Arrangement is already valid. No swap is needed. So answer is . +**Example case 8.** Arrangement is already valid. No swap is needed. So answer is 0. diff --git a/_problems/easy/DEVJERRY.md b/_problems/easy/DEVJERRY.md index 337c12f7..0f6bf73e 100644 --- a/_problems/easy/DEVJERRY.md +++ b/_problems/easy/DEVJERRY.md @@ -100,8 +100,8 @@ In a single move, Jerry can go either up, down, left or right in the grid such t Output: 2 4 - ### Explanation + **Example case 1.** ... Jerry will move directly (1, 1) to (2, 1) and then to (2, 2) in total 2 moves. **Example case 2.** ... diff --git a/_problems/easy/DEVLDISC.md b/_problems/easy/DEVLDISC.md index 89041739..20de082b 100644 --- a/_problems/easy/DEVLDISC.md +++ b/_problems/easy/DEVLDISC.md @@ -88,6 +88,7 @@ Algorithm (start_vertex): return ans; When Devu heard this algorithm, he exclaimed: "What, this does not seem to be correct!". Churu challenged him to give a counter example to disprove the algorithm. You have to help Devu come up with a graph as a counter example to the above algorithm, if one exists. + Formally, You will be given an integer **n** denoting the number of nodes of the expected graph (counter example Devu is producing). The graph should be undirected, unweighted and connected. The actual diameter of the graph should not be equal to the one returned by the Churu's proposed algorithm. If for the given **n**, there does not exist any such graph which could act as counter example, print -1. ### Input @@ -127,8 +128,8 @@ There is only a single subtask worth 100 points with above mentioned constraints 8 9 9 10 7 - ### Explanation + **Example case 1.** There can be only one connected graph of 2 nodes. (i.e. 1 is connected to 2). Diameter returned by algorithm for any start vertex will be 1 which is equal to the actual diameter. So answer is -1. **Example case 2.** Please note that example given for **n = 10** is **not a correct counter example**. It is only given so as to clarify the input output format. In the example, first line contains **9** denoting the number of edges in the graph. Then **9** edges of the graph are given. The graph is connected. Then the last line specifies the value of **start\_vertex** passed (that is, **7**) to Churu's algorithm. diff --git a/_problems/easy/DEVPERF.md b/_problems/easy/DEVPERF.md index 25d253e4..fcdd7c92 100644 --- a/_problems/easy/DEVPERF.md +++ b/_problems/easy/DEVPERF.md @@ -117,8 +117,8 @@ For each test case, output a single integer corresponding to the answer of the p Output: 1 2 - ### Explanation + **In the first example**, it will take Devu one second for putting the perfume at the only house. So, the answer is 1. **In the second example**, He will first put the perfume at the \* at cell (1, 1) (assuming 0-based indexing). diff --git a/_problems/easy/DEVSTR.md b/_problems/easy/DEVSTR.md index c5d85b4e..8686c71a 100644 --- a/_problems/easy/DEVSTR.md +++ b/_problems/easy/DEVSTR.md @@ -123,8 +123,8 @@ As Devu is always in hurry to meet his girlfriend, he wants you to help him in f 11 2 1010 - ### Explanation + **Example case 1:** As 1 is occurring twice consecutively, we can convert 11 to 10 in a single operation. **Example case 2:** You don't need to modify the string as it does not have more than 2 equal consecutive character. diff --git a/_problems/easy/DIAMOND.md b/_problems/easy/DIAMOND.md index 548f4366..acd68dcd 100644 --- a/_problems/easy/DIAMOND.md +++ b/_problems/easy/DIAMOND.md @@ -106,11 +106,11 @@ Output for each test case should contain a single real number in a separate line 21.000 9.500 10.000 - ### Explanation + **Case 1:** In the first move Alice has to take **100**, and this is the only move. Hence, the expected value Alice will get is **100**. -**Case 2:** It is quite clear that Alice will make only 1 move. As she can get **42** or with +**Case 2:** It is quite clear that Alice will make only 1 move. As she can get **42** or 0 with equal probability, the expected value she will get is equal to **0.5 ∙ 42 + 0.5 ∙ 0 = 21**. **Case 3:** Let's consider all possible scenarios how game can proceed: diff --git a/_problems/easy/DIGITSEP.md b/_problems/easy/DIGITSEP.md index 7607fac6..35af472b 100644 --- a/_problems/easy/DIGITSEP.md +++ b/_problems/easy/DIGITSEP.md @@ -79,7 +79,7 @@ All submissions for this problem are available.### Read problems statements in Mr. Wilson was planning to record his new Progressive Rock music album called "**Digits. Cannot. Separate**". Xenny and PowerShell, popular pseudo-number-theoreticists from the Land of Lazarus were called by him to devise a strategy to ensure the success of this new album. Xenny and Powershell took their Piano Lessons and arrived at the Studio in different Trains. -Mr. Wilson, creative as usual, had created one single, long music track **S**. The track consisted of **N** musical notes. The beauty of each musical note was represented by a decimal digit from to **9**. +Mr. Wilson, creative as usual, had created one single, long music track **S**. The track consisted of **N** musical notes. The beauty of each musical note was represented by a decimal digit from 0 to **9**. Mr. Wilson told them that he wanted to create multiple musical tracks out of this long song. Since Xenny and Powershell were more into the number theory part of music, they didn’t know much about their real workings. Mr. Wilson told them that a **separator** could be placed between 2 digits. After placing separators, the digits between 2 separators would be the constituents of this new track and the number formed by joining them together would represent the Quality Value of that track. He also wanted them to make sure that no number formed had greater than **M** digits. @@ -129,7 +129,7 @@ For both **Subtask 1 and Subtask 2:** - **1** ≤ **X** ≤ **Y** ≤ **(N - 1)** - **M**\***(Y+1)** ≥ **N** -- **S** may contain leading s. +- **S** may contain leading 0s. ### Example @@ -146,8 +146,8 @@ For both **Subtask 1 and Subtask 2:** Output: 2 1 - ### Explanation + **Test case 1.** Since only **1 separator** can be placed, we can only have 2 possibilities: diff --git a/_problems/easy/DIGJUMP.md b/_problems/easy/DIGJUMP.md index f8968e4e..b172d606 100644 --- a/_problems/easy/DIGJUMP.md +++ b/_problems/easy/DIGJUMP.md @@ -88,7 +88,7 @@ In a single line print single integer - the minimal number of jumps he needs. ### Constraints - **1** ≤ **N** ≤ **10^5** -- Each symbol of **S** is a digit from to **9**. +- Each symbol of **S** is a digit from 0 to **9**. ### Example @@ -103,11 +103,9 @@ In a single line print single integer - the minimal number of jumps he needs. Output: 4 -
 

 

Explanation

In the first case Chef can directly jump from the first digit (it is 0) to the last (as it is also 0).

In the second case Chef should jump in such sequence (the number of digits from 1: 1-2-4-5-15).

-
\ No newline at end of file diff --git a/_problems/easy/DIGROT.md b/_problems/easy/DIGROT.md index 9803ec1e..da4ec655 100644 --- a/_problems/easy/DIGROT.md +++ b/_problems/easy/DIGROT.md @@ -30,13 +30,12 @@ For each test case, print the largest integer that can result from performing on 211011 7 90 - ### Sample Output +
51234
 54321
 11090
 211011
 7
 9
-
 
\ No newline at end of file diff --git a/_problems/easy/DIRECTI.md b/_problems/easy/DIRECTI.md index 6df805f5..4f84dcde 100644 --- a/_problems/easy/DIRECTI.md +++ b/_problems/easy/DIRECTI.md @@ -103,8 +103,8 @@ Left on 100 Feet Road Right on Sarjapur Road Right on Hosur Road Right on Ganapathi Temple Road - ### Sample Output +
Begin on Road D
 Right on Road C
 Left on Road B
@@ -117,6 +117,6 @@ Left on 100 Feet Road
 Right on Domlur Flyover
 Right on Old Madras Road
 
-
 
### Explanation + In the first test case, the destination lies on Road D, hence the reversed route begins on Road D. The final turn in the original route is turning left from Road C onto Road D. The reverse of this, turning right from Road D onto Road C, is the first turn in the reversed route. diff --git a/_problems/easy/DISCHAR.md b/_problems/easy/DISCHAR.md index c4ce1c72..67c543d0 100644 --- a/_problems/easy/DISCHAR.md +++ b/_problems/easy/DISCHAR.md @@ -97,7 +97,7 @@ aba 3 2 - ### Explanation + For first testcase, the whole string is a subsequence which has all distinct characters. In second testcase, the we can delete last or first 'a' to get the required subsequence. diff --git a/_problems/easy/DISHLIFE.md b/_problems/easy/DISHLIFE.md index 35b414de..84fb231e 100644 --- a/_problems/easy/DISHLIFE.md +++ b/_problems/easy/DISHLIFE.md @@ -128,8 +128,8 @@ sad some all - ### Explanation + **Example 1**. The ingredient 4 is not available in any island, so Chef can't make the dish of life. Hence, the answer is "sad". **Example 2**. Chef can just go to the first island and collect all the three ingredients required. He does not need to visit the second island. So, the answer is "some". diff --git a/_problems/easy/DISHOWN.md b/_problems/easy/DISHOWN.md index afa23d52..40408a1a 100644 --- a/_problems/easy/DISHOWN.md +++ b/_problems/easy/DISHOWN.md @@ -96,7 +96,7 @@ First line of input contains an integer **T** denoting the number of test cases. - **1** ≤ **T** ≤ **25** - **1** ≤ **N** ≤ **10000(104)** -- ≤ **S\[i\]** ≤ **1000000(106)** +- 0 ≤ **S\[i\]** ≤ **1000000(106)** - **1** ≤ **Q** ≤ **10000(104)** - **1** ≤ **x, y** ≤ **N** @@ -114,8 +114,8 @@ First line of input contains an integer **T** denoting the number of test cases. 1 1 Output: 2 - ### Explanation + There are two chefs with scores of dishes **1** and **2** respectively. After the first query, chef **2** acquires dish **1** since **S\[2\] > S\[1\]** . Hence, the answer for the second query, i.e owner of the **first** dish is chef **2**. />/> diff --git a/_problems/easy/DISTCODE.md b/_problems/easy/DISTCODE.md index a65d7695..069dd8d4 100644 --- a/_problems/easy/DISTCODE.md +++ b/_problems/easy/DISTCODE.md @@ -105,8 +105,8 @@ BYBY Output: 3 2 - ### Explanation + **Example case 1.** The codes are **IN**, **NB** and **BY**. **Example case 2.** The codes are **BY** and **YB**. diff --git a/_problems/easy/DIVGOLD.md b/_problems/easy/DIVGOLD.md index c4117027..7466d455 100644 --- a/_problems/easy/DIVGOLD.md +++ b/_problems/easy/DIVGOLD.md @@ -107,8 +107,8 @@ XYZZYZZ Output: ADCB XYYZZZZ - ### Explanation + **Example case 1.** The optimal solution here is to choose the last character and put it in the beginning of the string. So the answer will be **ADCB** **Example case 2.** The optimal solution here is to choose the 5-th character (1-based index) and put it between the 2-nd and the 3-rd characters. So the answer will be **XYYZZZZ** diff --git a/_problems/easy/DIVIDING.md b/_problems/easy/DIVIDING.md index f89f48ec..c1d43ff3 100644 --- a/_problems/easy/DIVIDING.md +++ b/_problems/easy/DIVIDING.md @@ -100,12 +100,10 @@ The first line should contain **YES**, if we can obtain the required division, o Output: YES -
Input:
 5
 1 1 1 1 1
 
 Output:
 NO
-
 
\ No newline at end of file diff --git a/_problems/easy/DIVMAC.md b/_problems/easy/DIVMAC.md index 59d1bc4e..6a78442c 100644 --- a/_problems/easy/DIVMAC.md +++ b/_problems/easy/DIVMAC.md @@ -106,7 +106,7 @@ The first line of the input contains an integer **T** denoting the number of tes The first line of each test case contains two space-separated integers **N**, **M**, denoting the size of array **A** and the number of queries correspondingly. The second line of each test case contains **N** space-separated integers **A1**, **A2**, ..., **AN** denoting the initial array for dividing machine. -Each of following **M** lines contain three space-separated integers **type**, **L**, **R** - the type of operation ( - **Update** operation, **1** - **Get** operation), and the arguments of function, respectively +Each of following **M** lines contain three space-separated integers **type**, **L**, **R** - the type of operation (0 - **Update** operation, **1** - **Get** operation), and the arguments of function, respectively ### Output @@ -117,7 +117,7 @@ For each test case, output answer of each query of type 1 (**Get** query) separa - **1** ≤ **T** ≤ **100** - **1** ≤ **Ai** ≤ **106** - **1** ≤ **L** ≤ **R** ≤ **N** -- ≤ **type** ≤ **1** +- 0 ≤ **type** ≤ **1** - Sum of **M** over all test cases in a single test file does not exceed **106** ### Subtasks @@ -158,11 +158,11 @@ For each test case, output answer of each query of type 1 (**Get** query) separa 1 ### Explanation + **Example case 1.**The states of array A after each **Update**-operation:
 A: = [2 1 4 10 3 44]
 A: = [2 1 4 5 1 22]
 A: = [1 1 2 1 1 11]
-
 
\ No newline at end of file diff --git a/_problems/easy/DIVNINE.md b/_problems/easy/DIVNINE.md index 493d5310..7f940035 100644 --- a/_problems/easy/DIVNINE.md +++ b/_problems/easy/DIVNINE.md @@ -70,7 +70,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/SNCK15EL/mandarin/DIVNINE.pdf) , [Russian](http://www.codechef.com/download/translated/SNCK15EL/russian/DIVNINE.pdf) and [Vietnamese](http://www.codechef.com/download/translated/SNCK15EL/vietnamese/DIVNINE.pdf) -Chef Zidane likes the number **9**. He has a number **N**, and he wants to turn it into a multiple of **9**. He cannot add or remove digits, and he can only change one digit at a time. The only allowed operation is to increment or decrement a digit by one, and doing this takes exactly one second. Note that he cannot increase a digit **9** or decrease a digit , and the resulting number must not contain any leading zeroes unless **N** has a single digit. +Chef Zidane likes the number **9**. He has a number **N**, and he wants to turn it into a multiple of **9**. He cannot add or remove digits, and he can only change one digit at a time. The only allowed operation is to increment or decrement a digit by one, and doing this takes exactly one second. Note that he cannot increase a digit **9** or decrease a digit 0, and the resulting number must not contain any leading zeroes unless **N** has a single digit. Chef Zidane wants to know the minimum amount of time (in seconds) needed to accomplish this. Please help him, before his kitchen gets overwhelmed with mist! @@ -107,8 +107,8 @@ For each test case, output a single line containing the answer. 3 2 -
-
### Explanation +
### Explanation
+
 **Example case 1.** 1989 is already divisible by 9, so no operations are needed to be performed.
 
 **Example case 2.** 86236 can be turned into a multiple of 9 by incrementing the first and third digit (from the left), to get 96336. This takes 2 seconds.
diff --git a/_problems/easy/DIVQUERY.md b/_problems/easy/DIVQUERY.md
index eea52b71..443eda79 100644
--- a/_problems/easy/DIVQUERY.md
+++ b/_problems/easy/DIVQUERY.md
@@ -106,5 +106,4 @@ For each query output the result in one line.
 4
 0
 1
-
 
\ No newline at end of file
diff --git a/_problems/easy/DONUTS.md b/_problems/easy/DONUTS.md
index 3af39114..9270cfd5 100644
--- a/_problems/easy/DONUTS.md
+++ b/_problems/easy/DONUTS.md
@@ -127,8 +127,8 @@ For each test case, output a single line containing an integer corresponding to
 2
 1
 
-
 ### Explanation
+
 **Example 1:** We could cut 2 doughnut from any "chain" and use them to connect chains to the one. 
  For example, let's cut it from the first chain. After this we will have chains of sizes 2, 3, 4 and two doughnuts that have been cut. So we could connect the first chain with second and second with third using these two doughnuts./>
 
diff --git a/_problems/easy/DOWNLOAD.md b/_problems/easy/DOWNLOAD.md
index ecb24c17..891b79ab 100644
--- a/_problems/easy/DOWNLOAD.md
+++ b/_problems/easy/DOWNLOAD.md
@@ -105,8 +105,8 @@ For each of the **Q** groups, output the number of different recipes that group
 3
 4
 2
-
-**Explanation:**
+
+**Explanation:**
 Given videos of 4 recipes in the following closed intervals.
 1. \[ 1 , 4 \]
 2. \[ 3 , 10 \]
diff --git a/_problems/easy/DRAGNXOR.md b/_problems/easy/DRAGNXOR.md
index f7920511..52d6fcf7 100644
--- a/_problems/easy/DRAGNXOR.md
+++ b/_problems/easy/DRAGNXOR.md
@@ -44,8 +44,8 @@ For each case, output the maximum possible value of (shuffle-A xor shuffle-B) in
 7
 16
 14
-
- **Explanation:**
+
+ **Explanation:**
 
 Case 1: 5 and 4 as 3-bit binary strings are (101)2 and (100)2 respectively. After shuffling, xor can be maximum for (110)2 ^ (001)2 = (111)2 = 7
  Case 2: Maximum Possible result can be for (00000)2 ^ (10000)2 = (10000)2 = 16
diff --git a/_problems/easy/DRANGE.md b/_problems/easy/DRANGE.md
index 29dae2fc..c169e470 100644
--- a/_problems/easy/DRANGE.md
+++ b/_problems/easy/DRANGE.md
@@ -88,6 +88,7 @@ For each test case output a single line containing the range of the new data set
 1 ≤ x ≤ y ≤ N
 0 ≤ z ≤ 100000
 ### Example:
+
 
 Input
 1
@@ -98,5 +99,4 @@ For each test case output a single line containing the range of the new data set
 Output:
 11
 
-
-
**Explanation:** Initially the papers are as follows: 1 2 3 4 5 6 7 8 9 10. First operation decreases the numbers on paper number 3,4,5 and 6 by 4. Now, the papers look like: 1 2 -1 0 1 2 7 8 9 10. The second operation increases the numbers on papers 5 to 9 by 1. The numbers will now be 1 2 -1 0 2 3 8 9 10 10. Thus, the range is 10 - (-1) = 11. \ No newline at end of file +**Explanation:** Initially the papers are as follows: 1 2 3 4 5 6 7 8 9 10. First operation decreases the numbers on paper number 3,4,5 and 6 by 4. Now, the papers look like: 1 2 -1 0 1 2 7 8 9 10. The second operation increases the numbers on papers 5 to 9 by 1. The numbers will now be 1 2 -1 0 2 3 8 9 10 10. Thus, the range is 10 - (-1) = 11. diff --git a/_problems/easy/DREAM.md b/_problems/easy/DREAM.md index 8c85a3db..7b93933c 100644 --- a/_problems/easy/DREAM.md +++ b/_problems/easy/DREAM.md @@ -93,8 +93,8 @@ Print minimum number of assistans which can cook all the meals in one line. Output: 3 - -**Explanation:** + +**Explanation:** 3 assistants are enough to cook all the meals. They can work in following schedule: 1st assistant chooses interval \[2,4\] and cooks meals 2 and 4. 2nd assistant chooses interval \[1,3\] and cooks meals 1 and 3. diff --git a/_problems/easy/DRGHTS.md b/_problems/easy/DRGHTS.md index 5f21704a..b31e4f00 100644 --- a/_problems/easy/DRGHTS.md +++ b/_problems/easy/DRGHTS.md @@ -75,7 +75,7 @@ Furik is interested in one question: what is the number of pairs of rooms, which ### Input -The first line contains two space-separated integers **N** and **M**. The next line contains **N** integers, where the **i**th number is equal to **1**, if the window in the room number **i** is opened, otherwise . Then the next **M** lines contain pairs of integers, where the **i**th pair denotes the numbers of the connected rooms by **i**th passageway. Consider that the rooms are numerated by different integers from **1** to **N**. +The first line contains two space-separated integers **N** and **M**. The next line contains **N** integers, where the **i**th number is equal to **1**, if the window in the room number **i** is opened, otherwise 0. Then the next **M** lines contain pairs of integers, where the **i**th pair denotes the numbers of the connected rooms by **i**th passageway. Consider that the rooms are numerated by different integers from **1** to **N**. ### Output @@ -84,7 +84,7 @@ In a single line print two numbers, denoting the answers to Furik and Rubik ques ### Constraints - **1** ≤ **N** ≤ **50000 (5 × 104)** -- ≤ **M** ≤ **N − 1** +- 0 ≤ **M** ≤ **N − 1** - There is at most one way to move between each pair of rooms, that is, the given graph is a forest ### Example @@ -109,5 +109,4 @@ In a single line print two numbers, denoting the answers to Furik and Rubik ques Output: 0 0 - \ No newline at end of file diff --git a/_problems/easy/DRGNBOOL.md b/_problems/easy/DRGNBOOL.md index 2ead706c..2465b3b9 100644 --- a/_problems/easy/DRGNBOOL.md +++ b/_problems/easy/DRGNBOOL.md @@ -130,8 +130,8 @@ For every **Soint** of level **L** there exists at least one **Sofloat** of the Output: 8 89 - ### Explanation + **Case 1.**The warriors are **I1 = (I, 10, 1), I2 = (I, 20, 2), F1 = (F, 5, 2), F2 = (F, 5, 2), F3 = (F, 18, 1)**. Without the **SoChef** help the battle can proceed as follows. - **I2** fights with **F1**, **F1** dies, **I2** becomes **(I, 15, 2)**. diff --git a/_problems/easy/DUMPLING.md b/_problems/easy/DUMPLING.md index 0658c30e..7408873e 100644 --- a/_problems/easy/DUMPLING.md +++ b/_problems/easy/DUMPLING.md @@ -114,5 +114,4 @@ Thus, there are three different positions at most 1 unit away from the center that are reachable by both the chefs in one or more moves. - \ No newline at end of file diff --git a/_problems/easy/E1.md b/_problems/easy/E1.md index 6ac3022c..87686344 100644 --- a/_problems/easy/E1.md +++ b/_problems/easy/E1.md @@ -45,5 +45,4 @@ K.... Output: 2 - \ No newline at end of file diff --git a/_problems/easy/EASYPROB.md b/_problems/easy/EASYPROB.md index 420a282f..6b15a6e0 100644 --- a/_problems/easy/EASYPROB.md +++ b/_problems/easy/EASYPROB.md @@ -29,5 +29,4 @@ The first two lines of the CORRECT output file are: 1315=2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0) The correct output file should contain 7 lines. - \ No newline at end of file diff --git a/_problems/easy/EGBOBRD.md b/_problems/easy/EGBOBRD.md index 91137290..fa3ca4d3 100644 --- a/_problems/easy/EGBOBRD.md +++ b/_problems/easy/EGBOBRD.md @@ -126,8 +126,8 @@ For each of the **T** test cases, output a single line - minimum number of packa 2 1 4 - ### Explanation + Test case **1** has already been explained in the statement. In test case **2**, we have one day tour and packages with one piece each. In the first day, we have to eat one piece of bread, so we open a package and eat one piece. Tour ended, and our answer is 1. diff --git a/_problems/easy/EGRCAKE.md b/_problems/easy/EGRCAKE.md index 971dfa8a..026f712e 100644 --- a/_problems/easy/EGRCAKE.md +++ b/_problems/easy/EGRCAKE.md @@ -93,7 +93,7 @@ For each of the **T** test cases, output a single line: ### Constraints and Subtasks - **1** ≤ **T** ≤ **10** -- ≤ **M** < **N** +- 0 ≤ **M** < **N** **Subtask 1: 25 points** @@ -116,8 +116,8 @@ No 1 Yes No 2 - ### Explanation + In test case 1, we have two robots indexed 1 and 2. They are arranged as (1 2). Chef goes to the first robot, gives him a cake, and moves to position 1. In the next step, he sees that robot at this position already has a has cake. So Chef stops moving, and our **answer** is **"No 1"**. In test case 2, we again have two robots indexed 1 and 2. Initially, they are arranged as (1 2). Then, Chef moves robot#1 to the end of the row, and thus the arrangement becomes (2 1). Chef goes to the robot at the first position, which is robot#2. Chef hands him a cake, and moves to position 2. Then, he hands a cake to robot#1 at position 2, and moves back to the first position. Since, robot#2 at the first position already ahs a cake, Chef stops moving. All **N** robots have cakes, so Chef is satisfied, and our **answer** is **"Yes"**. diff --git a/_problems/easy/EMITL.md b/_problems/easy/EMITL.md index c3ba64eb..7a2a55b5 100644 --- a/_problems/easy/EMITL.md +++ b/_problems/easy/EMITL.md @@ -106,8 +106,8 @@ LTIMEM YES NO - ### Explanation + **Test case 1**: we can permute the last 5 letters and get LTIMEAZAZAEMITL **Test case 2**: we have 3 copies of each of the letters 'L', 'T', 'I', 'M', 'E' so we can leave 5 of them in the beginning and move 5 of them to the end. diff --git a/_problems/easy/EQIDLIS.md b/_problems/easy/EQIDLIS.md index b5e1c28d..198830e6 100644 --- a/_problems/easy/EQIDLIS.md +++ b/_problems/easy/EQIDLIS.md @@ -45,8 +45,8 @@ For each case, output the number of times Dexter has to repeat the given step to 1 -1 3 - -**Explanation:** + +**Explanation:** Case 1 : { 1, 2, 2, 3}. Maximum 3, Minimum 1. R = ceil((3-1)/2) = 1. Transfer 1 idli from person having 3 idlis to the person having 1 idli. Each of them has 2 idlis now, so just 1 step is enough. diff --git a/_problems/easy/EQUALITY.md b/_problems/easy/EQUALITY.md index e6a0fb8c..9e2f24aa 100644 --- a/_problems/easy/EQUALITY.md +++ b/_problems/easy/EQUALITY.md @@ -121,8 +121,8 @@ For each test case, output a single line containing **N** integers: a sequence * 1 4 5 1 3 4 6 - ### Explanation + In the first test case, we can simply replace the variables with the values from the correct output to make sure, that all the conditions are satisfied: - **x2** + **x3** = 4 + 5 = 9 = **a1** diff --git a/_problems/easy/EQUALIZ.md b/_problems/easy/EQUALIZ.md index dfd8dbb1..497eba65 100644 --- a/_problems/easy/EQUALIZ.md +++ b/_problems/easy/EQUALIZ.md @@ -93,8 +93,8 @@ For each test case output a line containing a single integer **K** (0 ≤ **K** 3 1 4 7 3 2 5 8 3 3 6 9 - ### Explanation + In the first test case, the initial array is (5, 6, 7, 8). The array after the first operation is (5, 6.5, 6.5, 8). The array after the second operation is (6.5, 6.5, 6.5, 6.5). In the second test case, all the elements of the array become equal to 44/7 after the only operation. diff --git a/_problems/easy/EQUALIZE.md b/_problems/easy/EQUALIZE.md index b8aa74b4..ebe0b9d2 100644 --- a/_problems/easy/EQUALIZE.md +++ b/_problems/easy/EQUALIZE.md @@ -79,6 +79,7 @@ Before creating the map, Chef first wants to make the heights of all the tiles e 7 7 7 7 7 7 8 8 8 Suppose the dimensions of the equalize tool is **3 × 7**, and we apply it in the middle **3 × 7** region. The median of the values in that region is **3**, so after application, the grid becomes: +
9 8 8 8 7 7 7 8 7
 1 3 3 3 3 3 3 3 4
 2 3 3 3 3 3 3 3 9
@@ -86,6 +87,7 @@ Before creating the map, Chef first wants to make the heights of all the tiles e
 7 7 7 7 7 7 8 8 8
 
 
Note that **K** and **L** are odd integers, so that the median is always an integer. + Chef wants to make all height values equal by repeatedly applying the equalize tool. Furthermore, he also wants the final (common) height to be as large as possible. What is the maximum final (common) height that he can obtain? Furthermore, you have to answer **Q** queries, where each query denotes a different set of values for **K** and **L**. @@ -106,7 +108,7 @@ For each query, output a single integer, the maximum final (common) height that - **3** ≤ **N**, **M** ≤ **1000** - **1** ≤ **Q** ≤ **25** -- ≤ **Hi,j** ≤ **107** +- 0 ≤ **Hi,j** ≤ **107** - **3** ≤ **Kj** ≤ **N** - **3** ≤ **Lj** ≤ **M** - **Kj** and **Lj** are odd. @@ -126,8 +128,8 @@ For each query, output a single integer, the maximum final (common) height that 8 5 6 - ### Explanation + In the first query, Chef can obtain a final height of **8** by first applying the equalizer on the leftmost **3 × 3** region:
8 8 8 5 8 6 8
@@ -135,13 +137,15 @@ In the first query, Chef can obtain a final height of **8** by first applying th
 8 8 8 5 5 5 8
 
 
then the rightmost **3 × 3** region: +
8 8 8 5 8 8 8
 8 8 8 5 8 8 8
 8 8 8 5 8 8 8
 
 
and then finally the middlemost **3 × 3** region: +
8 8 8 8 8 8 8
 8 8 8 8 8 8 8
 8 8 8 8 8 8 8
 
-
It can be shown that this is the largest final height that can be obtained. \ No newline at end of file +It can be shown that this is the largest final height that can be obtained. diff --git a/_problems/easy/EQUATION.md b/_problems/easy/EQUATION.md index 9e6bff38..93766afa 100644 --- a/_problems/easy/EQUATION.md +++ b/_problems/easy/EQUATION.md @@ -28,9 +28,8 @@ Output T lines, one for each test case.
2
 4 3 2 1
 1 1 1 1
-
 
### Sample Output +
20
 4
-
 
\ No newline at end of file diff --git a/_problems/easy/ERROR.md b/_problems/easy/ERROR.md index 1730530b..1f1a5b64 100644 --- a/_problems/easy/ERROR.md +++ b/_problems/easy/ERROR.md @@ -114,6 +114,7 @@ Good

/>/> ### Explanation + **Example case 1.** The string doesn't contain **010** or **101** as substrings. /> diff --git a/_problems/easy/EXPTREE.md b/_problems/easy/EXPTREE.md index 8c4bdc53..56821381 100644 --- a/_problems/easy/EXPTREE.md +++ b/_problems/easy/EXPTREE.md @@ -125,8 +125,8 @@ Consider the answer to be a proper fraction **P**/**Q**, where gcd(**P**, **Q**) 1 1 400000004 200000003 - ### Explanation + You can see every possible tree with 1, 2, 3 or 4 vertices on the diagram below. ![](https://codechef_shared.s3.amazonaws.com/download/upload/JULY17/exptree.jpg)From this you can see that answers for these inputs are 0/1 = 0, 1/1 = 1, (2+0)/2 = 1 and (3+1+1+1+0)/5 = 6/5 correspondingly. diff --git a/_problems/easy/EXTRAN.md b/_problems/easy/EXTRAN.md index fd21e12c..5fafeb81 100644 --- a/_problems/easy/EXTRAN.md +++ b/_problems/easy/EXTRAN.md @@ -121,8 +121,8 @@ For each test case, output a single line containing one integer — a number tha 7 12 10 - ### Explanation + **Test case 1.** The sequence **A** is (45, 42, 46, 48, 47). We should remove the number 42, and the remaining numbers will form a nice sequence (45, 46, 48, 47). **Test case 2.** We should remove one of two 7's to get the sequence (7, 8), which is nice. diff --git a/_problems/easy/EZNO.md b/_problems/easy/EZNO.md index a1dffb0a..146f3c1f 100644 --- a/_problems/easy/EZNO.md +++ b/_problems/easy/EZNO.md @@ -111,6 +111,6 @@ For each test case, output a single integer denoting the number of _easy_ number Output: 1 150 - ### Explanation + **Example case 1.** There are 2 numbers in base 2 consisting of 2 digits. Those are 2 (represented as 10 in base 2) and 3 (represented as 11 in base 2). 2 is an easy number, whereas 3 is not (see the explanation about it in the problem statement). Hence the number of easy numbers consisting of 2 digits in base 2 are 1. diff --git a/_problems/easy/F1.md b/_problems/easy/F1.md index d6486c6b..3e99b434 100644 --- a/_problems/easy/F1.md +++ b/_problems/easy/F1.md @@ -58,5 +58,4 @@ Case 2: 5 7 8 8(2) - \ No newline at end of file diff --git a/_problems/easy/FATCHEF.md b/_problems/easy/FATCHEF.md index 81e59c8f..5b75a562 100644 --- a/_problems/easy/FATCHEF.md +++ b/_problems/easy/FATCHEF.md @@ -120,5 +120,4 @@ B 6 1 1 4 - \ No newline at end of file diff --git a/_problems/easy/FCBARCA.md b/_problems/easy/FCBARCA.md index 043224cf..30f3bb2b 100644 --- a/_problems/easy/FCBARCA.md +++ b/_problems/easy/FCBARCA.md @@ -105,8 +105,8 @@ For each test case, output a single integer, the number of ways the winning play Output: 4 6 - ### Explanation + In the first test case, say four players with Messi are Xavi, Busquets, Iniesta and Jordi Alba. Then the ways of the winning play to happen when **exactly** 2 passes are to be performed are: 1\) Messi - Xavi - Messi 2\) Messi - Busquets - Messi diff --git a/_problems/easy/FCTRL2.md b/_problems/easy/FCTRL2.md index 9ef6965b..594bdb3f 100644 --- a/_problems/easy/FCTRL2.md +++ b/_problems/easy/FCTRL2.md @@ -31,11 +31,10 @@ Sample input: ``` 2 5 3 -
Sample output:
+
 
1 2 120 6 -
\ No newline at end of file
diff --git a/_problems/easy/FENWITER.md b/_problems/easy/FENWITER.md
index 653210bf..0fc8cd96 100644
--- a/_problems/easy/FENWITER.md
+++ b/_problems/easy/FENWITER.md
@@ -79,7 +79,7 @@ Chef has just learned a new data structure - [Fenwick tree](https://en.wikipedia
 
 Both operations take O(log N) time. This data structure is also well known for its low memory usage. To be more precise, it needs exactly the same amount of memory as that of array. Given some array **A**, first we build data structure in some other array **T**. **Ti** stores the sum of the elements **Astart**, **Astart + 1**, ..., **Ai**. Index **start** is calculated with formula **start = Fdown(i) = (i & (i + 1))**. Here "&" denotes [bitwise **AND** operation](https://en.wikipedia.org/wiki/Bitwise_operation).
 
-So, in order to find a sum of elements **A0**, **A1**, ..., **AL** you start with index **L** and calculate sum of **TL + TFdown(L)-1 + TFdown(Fdown(L)-1)-1 + ... + TFdown(Fdown(...(Fdown(L)-1)-1)-1**. Usually it is performed with cycle that goes from **L** down to  with function Fdown and sums some elements from T. Chef wants to verify that the time complexity to calculate sum of **A0**, **A1**, **A2**, ..., **AL** is **O(log L)**. In order to do so, he wonders how many times he has to access array **T** to calculate this sum. Help him to find this out.
+So, in order to find a sum of elements **A0**, **A1**, ..., **AL** you start with index **L** and calculate sum of **TL + TFdown(L)-1 + TFdown(Fdown(L)-1)-1 + ... + TFdown(Fdown(...(Fdown(L)-1)-1)-1**. Usually it is performed with cycle that goes from **L** down to 0 with function Fdown and sums some elements from T. Chef wants to verify that the time complexity to calculate sum of **A0**, **A1**, **A2**, ..., **AL** is **O(log L)**. In order to do so, he wonders how many times he has to access array **T** to calculate this sum. Help him to find this out.
 
 Since Chef works with really big indices. The value of **L** can be very large and is provided to you in binary representation as concatenation of strings **L1**, **L2** repeated **N** times and string **L3**.
 
@@ -87,7 +87,7 @@ Since Chef works with really big indices. The value of **L** can be very large a
 
 The first line of the input contains an integer **T** denoting the number of test cases. The description of **T** test cases follows.
 
-The only line of each test case contains three non-empty strings **L1**, **L2**, **L3** and an integer **N**. Strings will contain only characters  and **1**. To obtain binary representation of index **L** concatenate **L1** with **L2** repeated **N** times and with **L3**. You are guaranteed that the index will be positive.
+The only line of each test case contains three non-empty strings **L1**, **L2**, **L3** and an integer **N**. Strings will contain only characters 0 and **1**. To obtain binary representation of index **L** concatenate **L1** with **L2** repeated **N** times and with **L3**. You are guaranteed that the index will be positive.
 
 ### Output
 
@@ -119,5 +119,4 @@ For each test case, output a single line containing number of times Fenwick tree
 12
 8
 10
-
 
\ No newline at end of file diff --git a/_problems/easy/FFCOMB.md b/_problems/easy/FFCOMB.md index 725ae70d..b0fbbef8 100644 --- a/_problems/easy/FFCOMB.md +++ b/_problems/easy/FFCOMB.md @@ -115,6 +115,6 @@ For each test case, output a single line containing the minimal total amount of Output: 10 - ### Explanation + **Example case 1.** If Sergey buys all the meals separately, it would cost him **3 + 5 + 6 = 14** rubles. He can buy all of them at once by buying the first meal set, which costs for **11** rubles, but the optimal strategy would be either to buy the second and the third meal set, thus, paying **5 + 5 = 10** rubles, or to buy the third meal set and the second meal separately by paying the same amount of **10** rubles. diff --git a/_problems/easy/FGFS.md b/_problems/easy/FGFS.md index 716f0730..18927203 100644 --- a/_problems/easy/FGFS.md +++ b/_problems/easy/FGFS.md @@ -90,9 +90,9 @@ Note that the **ith** customer wants to occupy the **pith** compartment from **\ ### Constraints - **1** ≤ **T** ≤ **30** -- ≤ **N** ≤ **105** +- 0 ≤ **N** ≤ **105** - **1** ≤ **K** ≤ **109** -- ≤ **si** < **fi** ≤ **109** +- 0 ≤ **si** < **fi** ≤ **109** - **1** ≤ **pi** ≤ **K** ### Example @@ -112,8 +112,8 @@ Note that the **ith** customer wants to occupy the **pith** compartment from **\ Output: 3 3 - ### Explanation + **Example case 1.** All three customers want different compartments and hence all 3 can be accommodated. /> diff --git a/_problems/easy/FIBQ.md b/_problems/easy/FIBQ.md index c03bb16f..dc8bb599 100644 --- a/_problems/easy/FIBQ.md +++ b/_problems/easy/FIBQ.md @@ -127,15 +127,15 @@ C 1 2 Q 1 2 Q 1 3 - **Output** +
 4
 8
 5
 30
-
 
### Explanation: + - **Q1** : F = Fibonacci(1) + Fibonacci(2) + Fibonacci(1+2) = 4 % 1000000007 = 4 - **Q2** : F = Fibonacci(2) + Fibonacci(3) + Fibonacci(2+3) = 8 % 1000000007 = 8 - **Q3** : A = {2, 2, 3} diff --git a/_problems/easy/FILLMTR.md b/_problems/easy/FILLMTR.md index 88b2abd6..047b3766 100644 --- a/_problems/easy/FILLMTR.md +++ b/_problems/easy/FILLMTR.md @@ -130,12 +130,11 @@ yes no yes no - ### Explanation + **Example 1**. You can fill the entries of matrix **B** as follows.
 0 1
 1 0
-
-
This matrix corresponds to the array A = \[1, 2\]. **Example 2**. It is impossible to fill the remaining entries of matrix B such that the resulting matrix is good, as **B**\[1\]\[2\] = 1 and **B**\[2\]\[1\] = 0, which is impossible. \ No newline at end of file +This matrix corresponds to the array A = \[1, 2\]. **Example 2**. It is impossible to fill the remaining entries of matrix B such that the resulting matrix is good, as **B**\[1\]\[2\] = 1 and **B**\[2\]\[1\] = 0, which is impossible. diff --git a/_problems/easy/FIRE.md b/_problems/easy/FIRE.md index 4ca89a43..46c0d470 100644 --- a/_problems/easy/FIRE.md +++ b/_problems/easy/FIRE.md @@ -67,5 +67,4 @@ For each test case, you are to output a single line consisting of either "yes" o no yes yes - \ No newline at end of file diff --git a/_problems/easy/FIRESC.md b/_problems/easy/FIRESC.md index 8e55f05c..ad784da0 100644 --- a/_problems/easy/FIRESC.md +++ b/_problems/easy/FIRESC.md @@ -91,7 +91,7 @@ For each test case, output a single line containing two space separated integers - **1** ≤ **T** ≤ **5** - **1** ≤ **N** ≤ **100000** (**105**) -- ≤ **M** ≤ **100000** (**105**) +- 0 ≤ **M** ≤ **100000** (**105**) - **1** ≤ **i**, **j** ≤ **N** - **i** ≠ **j** - For any pair of employees **_i_** and **_j_** such that **1** ≤ **i** < **j** ≤ **N**, at most one pair among (**i**, **j**) and (**j**, **i**) will appear in the input @@ -117,8 +117,8 @@ For each test case, output a single line containing two space separated integers 2 3 3 3 3 8 - ### Explanation + **Example case 1.** Here employees 1 and 2 are friends and should share the same fire escape. Also employees 2 and 3 share the same fire escape. This means employees 1, 2 and 3 will have a common route. But to maximize number of routes Chef could assign another route to employee 4 since it is not a friend of other employee. So we have two escape routes with the following distribution of employees by routes: {1, 2, 3}, {4}. Therefore, there are 3 ways to chose drill captains: (1, 4), (2, 4), (3, 4), where first element in the pair denotes the captain for the first route and second element denotes the captain for the second route. **Example case 2.** Here the optimal distribution of employees by routes is {1, 2, 3}, {4}, {5}. Therefore, there are 3 ways to chose drill captains: (1, 4, 5), (2, 4, 5), (3, 4, 5). diff --git a/_problems/easy/FLAGS.md b/_problems/easy/FLAGS.md index 89e2ecbc..15610a55 100644 --- a/_problems/easy/FLAGS.md +++ b/_problems/easy/FLAGS.md @@ -114,8 +114,8 @@ For each testcase, output a single line containing an integer - the answer for t 0 4 42 - ### Explanations: + There are **four** different well-painted flags for **N** = 2 different colors : ![](/download/extimages/57c2f54761cda108c18bd840f4638fda.jpg) diff --git a/_problems/easy/FLOORI4.md b/_problems/easy/FLOORI4.md index 18e055f9..3fac7280 100644 --- a/_problems/easy/FLOORI4.md +++ b/_problems/easy/FLOORI4.md @@ -107,6 +107,6 @@ There are two types of datasets: Output: 373 - ### Explanation + 14\*4 + 24\*2 + 34\*1 + 44\*1 = 373 diff --git a/_problems/easy/FLUSHOT.md b/_problems/easy/FLUSHOT.md index fc5b121a..79089217 100644 --- a/_problems/easy/FLUSHOT.md +++ b/_problems/easy/FLUSHOT.md @@ -49,6 +49,6 @@ For each test case, you should output the minimum value of D with exactly 4 deci 0.5000 1.4000 - ### Explanation of Sample Data + In the first test case, the first person can move to location 0 and the second to location 4 with the maximum distance moved being 2. In the second case, person 1 can move to location 0.5 and person 2 can move to location 2.5 for a maximum distance moved being 0.5. Finally, in the last output the first person does not move, the second moves to location 1, the third to location 2, and the fourth to location 3. The maximum distance moved by any person was done by the third person who moved 1.4 meters to their destination. diff --git a/_problems/easy/FLYMODE.md b/_problems/easy/FLYMODE.md index 047327fb..45077179 100644 --- a/_problems/easy/FLYMODE.md +++ b/_problems/easy/FLYMODE.md @@ -112,13 +112,12 @@ Output a single maximum integer **K** in one line, such that the plane was at so Output: 3 - ### Explanation + The flight can be draw as:
 3  /\/
 2 /
 1
-
-
There are infinitely many heights at which the plane was 3 times during the flight, for example 2.5, 2.1. Notice that the plane was only 2 times at height 2. Moreover, there are no height at which the plane was more than 3 times, so the answer is 3. \ No newline at end of file +There are infinitely many heights at which the plane was 3 times during the flight, for example 2.5, 2.1. Notice that the plane was only 2 times at height 2. Moreover, there are no height at which the plane was more than 3 times, so the answer is 3. diff --git a/_problems/easy/FORESTGA.md b/_problems/easy/FORESTGA.md index 2d74a39b..ac7ea745 100644 --- a/_problems/easy/FORESTGA.md +++ b/_problems/easy/FORESTGA.md @@ -111,8 +111,8 @@ Output a single integer denoting the number of months that have to pass before C Output: 7 - ### Explanation + After **6** months, heights of each tree will be **14**, **47** and **56** respectively. Chef is allowed to cut only the third tree, sadly it is not enough to fulfill an order of 74 meters of wood. After **7** months, heights of each tree will be **16**, **54** and **65** respectively. Now Chef is allowed to cut second and third trees. Cutting both of them would provide him **119** meters of wood, which is enough to fulfill the order. diff --git a/_problems/easy/FORGETPW.md b/_problems/easy/FORGETPW.md index 56e92374..07f0a72b 100644 --- a/_problems/easy/FORGETPW.md +++ b/_problems/easy/FORGETPW.md @@ -129,5 +129,4 @@ d 3 1800 .001 321.33098 - \ No newline at end of file diff --git a/_problems/easy/FRIEMEET.md b/_problems/easy/FRIEMEET.md index 77ad2759..f1e70e76 100644 --- a/_problems/easy/FRIEMEET.md +++ b/_problems/easy/FRIEMEET.md @@ -132,5 +132,4 @@ For each test case, output a single line containing two integers **numer** and * Output: 4 1 29 6 - \ No newline at end of file diff --git a/_problems/easy/FRNDMTNG.md b/_problems/easy/FRNDMTNG.md index 01063356..4d971efa 100644 --- a/_problems/easy/FRNDMTNG.md +++ b/_problems/easy/FRNDMTNG.md @@ -123,5 +123,4 @@ For each test case, output one the single real number - probability of meeting C Output: 0.750000 1.000000 - \ No newline at end of file diff --git a/_problems/easy/FROGV.md b/_problems/easy/FROGV.md index a130fea5..fc6b96e1 100644 --- a/_problems/easy/FROGV.md +++ b/_problems/easy/FROGV.md @@ -91,7 +91,7 @@ Chef knows all **P** pairs of frogs, which want to send messages. Help him to de ### Constraints - **1** ≤ **N, P** ≤ **10^5** -- ≤ **Ai, K** ≤ **10^9** +- 0 ≤ **Ai, K** ≤ **10^9** - **1** ≤ **A, B** ≤ **N** ### Example @@ -108,11 +108,9 @@ Yes Yes No -
 

Explanation

For pair (1, 2) frog 1 can directly speak to the frog 2 as the distance between them is 3 - 0 = 3 <= K .

For pair (1, 3) frog 1 can send a message to frog 2, frog 2 can send it to frog 4 and it can send it to frog 3.

For pair (2, 5) frogs can't send a message under current constraints.

-
\ No newline at end of file diff --git a/_problems/easy/FSTSQ.md b/_problems/easy/FSTSQ.md index 79394958..05c959ce 100644 --- a/_problems/easy/FSTSQ.md +++ b/_problems/easy/FSTSQ.md @@ -115,6 +115,6 @@ where **M** is the length of the array representation of **Y** and **p** equals 40079781 32745632 - ### Explanation + In the first test case, **X = 4** and **Y = 16**. Its hash equals **1\*1 + 23\*6 = 139**. diff --git a/_problems/easy/FTRIP.md b/_problems/easy/FTRIP.md index c91243b5..e82fb0b9 100644 --- a/_problems/easy/FTRIP.md +++ b/_problems/easy/FTRIP.md @@ -93,8 +93,8 @@ For each test case, output a line containing the required probability. The answe 1 ≤ MS 0 ≤ K < M - ### Example: + **Input:**
@@ -104,14 +104,14 @@ For each test case, output a line containing the required probability. The answe
 3 2 2 1
 
 
-
 
**Output:** +
 1.000000
 0.000000
 0.500000
-
 
### Explanation: + **Case #1:** Every student will be taken to the trip. So all her 4 friends will accompany her to the trip no matter what. diff --git a/_problems/easy/GALACTIK.md b/_problems/easy/GALACTIK.md index 4900203c..e9f414a4 100644 --- a/_problems/easy/GALACTIK.md +++ b/_problems/easy/GALACTIK.md @@ -135,5 +135,4 @@ Print the minimum amount needed for the GFA to fulfill their plan if it can be f Output 2 -1 - \ No newline at end of file diff --git a/_problems/easy/GAMEAAM.md b/_problems/easy/GAMEAAM.md index 00a40613..4a1da7d9 100644 --- a/_problems/easy/GAMEAAM.md +++ b/_problems/easy/GAMEAAM.md @@ -107,8 +107,8 @@ NO NO YES - ### Explanation + **Example case 1.** The first player don't have any choice other subtracting 2 from 3. So during the turn of the second player integer pair will be (2,1). The second player will win by subtracting 1 from 2. **Example case 2.** If the first player choose to move (4,5) to (4,1) the second player will make it to (1,1). If the first player choose to move (5,6) to (5,1) the second player will make it to (1,1). So regardless of the move of the first player, the second will always win. diff --git a/_problems/easy/GAMEBALL.md b/_problems/easy/GAMEBALL.md index ce5a49b0..fd493af0 100644 --- a/_problems/easy/GAMEBALL.md +++ b/_problems/easy/GAMEBALL.md @@ -118,66 +118,65 @@ If it is possible to achieve the objective, then each of the next X lines should 2 1 2 2 2 2 1 2 1 1 1 3 - ### Explanation +
 
 ***
 **.
 
-
 
In first move, you can take the ball at (2, 1) and move it to cell (2, 3), and the ball at cell (2, 2) will be destroyed. The resulting grid will be +
 
 ***
 ..*
 
-
 
In second move, you can move the ball at cell (1, 1) to cell (2, 1). The resulting grid will be +
 
 .**
 *.*
 
-
 
Now, you can move the ball (1, 3) to (1, 1) and destroying the ball at (1, 2), we get. +
 *..
 *.*
-
 
Now, move the ball at cell (2, 1) to (2, 2) +
 
 *..
 .**
 
-
 
Move the ball at cell (2, 3) to (2, 1) by destroying the ball at cell (2, 2). +
 
 *..
 *..
 
-
 
Move the ball at cell (2, 1) to (2, 2) +
 
 *..
 .*.
 
-
 
Move the ball at cell (2, 2) to (1, 2) +
 
 **.
 ...
 
-
 
Now, move the ball cell (1, 1) to (1, 3), thus destroying the ball at (1, 2). +
 
 ..*
 ...
 
-
-
And you are done :) \ No newline at end of file +And you are done :) diff --git a/_problems/easy/GARDENSQ.md b/_problems/easy/GARDENSQ.md index d17d5aad..010a707a 100644 --- a/_problems/easy/GARDENSQ.md +++ b/_problems/easy/GARDENSQ.md @@ -48,14 +48,14 @@ aabb bbaa bbaa - **Sample output** +
0
 1
 4
 
-
 
**Explanation** + In the first case the only avaliable square does not conform to the definition in the problem statement because 'a' and 'A' describes different colors. In the second case, you can select the 4 a's at the corners of the garden. diff --git a/_problems/easy/GCAC.md b/_problems/easy/GCAC.md index 65f9da38..ac83f452 100644 --- a/_problems/easy/GCAC.md +++ b/_problems/easy/GCAC.md @@ -130,8 +130,8 @@ You have to find the number of the candidates that will end up with a job, the t Output: 3 22000 4 - ### Explanation + There are 5 candidates and 6 companies. The first candidate wants a job that pays at least 5000 Rs. He has qualified in all the companies, so he will choose the 1st company that provides him the maximum money, 10000 Rs. The second candidate will get a job offer of 10000 Rs from 1st company. diff --git a/_problems/easy/GCD2.md b/_problems/easy/GCD2.md index 0ecd58a2..66bea97d 100644 --- a/_problems/easy/GCD2.md +++ b/_problems/easy/GCD2.md @@ -21,8 +21,8 @@ int gcd(int a, int b) else return gcd(b,a%b); } - and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 digits. Your task is to help Frank programming an efficient code for the challenge of Felman. + ### Input The first line of the input file contains a number representing the number of lines to follow. Each line consists of two number A and B (0 <= A <= 40000 and A <= B < 10^250). @@ -44,5 +44,4 @@ Print for each pair (A,B) in the input one integer representing the GCD of A and 2 1 - \ No newline at end of file diff --git a/_problems/easy/GENARSEQ.md b/_problems/easy/GENARSEQ.md index 404c69da..8499d1e3 100644 --- a/_problems/easy/GENARSEQ.md +++ b/_problems/easy/GENARSEQ.md @@ -47,5 +47,4 @@ For each test case, output a single line containing the numbers **x\[1\], x\[2\] 1 2 4 5 10 11 13 14 28 29 1 2 3 4 5 1 3 4 5 - -- - - - - - \ No newline at end of file +- - - - - - diff --git a/_problems/easy/GERALD03.md b/_problems/easy/GERALD03.md index 4e3c52ea..74bc4e82 100644 --- a/_problems/easy/GERALD03.md +++ b/_problems/easy/GERALD03.md @@ -129,5 +129,4 @@ R+L+R+L+R+L+R+L+R+ R+ 13 L-R-L-L-L-L-R-R-R-R-L+R+L+ - \ No newline at end of file diff --git a/_problems/easy/GERALD04.md b/_problems/easy/GERALD04.md index ceeab861..65ee18c3 100644 --- a/_problems/easy/GERALD04.md +++ b/_problems/easy/GERALD04.md @@ -116,5 +116,4 @@ For each test case output a single line containing two real numbers - the time f 70.0 60.0 90.0 60.0 120.0 90.0 - \ No newline at end of file diff --git a/_problems/easy/GERALD05.md b/_problems/easy/GERALD05.md index ff6a784d..a220d64a 100644 --- a/_problems/easy/GERALD05.md +++ b/_problems/easy/GERALD05.md @@ -95,7 +95,7 @@ For each test case, output a single line containing a single integer - the answe - **1** ≤ **T** ≤ **500** - **1** ≤ **S** ≤ **100** -- ≤ **Ai** ≤ **1000** +- 0 ≤ **Ai** ≤ **1000** - Sum of all **S** for all test cases is not greater than 500. It's guaranteed that at least one **Ai** is non-zero. ### Example @@ -116,8 +116,8 @@ For each test case, output a single line containing a single integer - the answe 3 3 213986343 - ### Explanation + **Example case 2.** In the second example function looks as follows **F(N) = 1**. So for each _rang_ there is a single object of the _rang_. To get multiset with sum of _rang_s equal to 3, you can pick: three objects of _rang_ 1, or one object of _rang_ 1 and one of _rang_ 2, or only one object of _rang_ 3. diff --git a/_problems/easy/GERMANDE.md b/_problems/easy/GERMANDE.md index 31e4d752..d0258053 100644 --- a/_problems/easy/GERMANDE.md +++ b/_problems/easy/GERMANDE.md @@ -83,11 +83,11 @@ But the state boundaries have not been fixed yet. Given just the district-wise d - The first line contains one integer, **T**, which is the number of testcases. - The first line of each testcase contains two space separated integers, **o1** and **o2**, which are the number of states, and number of districts in each state, respectively. -- The next line of each testcase contains **N = o1 \* o2** space separated integers: **d1, d2, .., dN**. If **di** is **1**, then it signifies that District **i** has chosen a One representative. If **di** is , then they have a Zero representative. +- The next line of each testcase contains **N = o1 \* o2** space separated integers: **d1, d2, .., dN**. If **di** is **1**, then it signifies that District **i** has chosen a One representative. If **di** is 0, then they have a Zero representative. ### Output -- Each testcase should be in a new line, and should contain **1**, if the President can be a One, and otherwise. +- Each testcase should be in a new line, and should contain **1**, if the President can be a One, and 0 otherwise. ### Constraints @@ -129,8 +129,8 @@ For all subtasks you may assume that: 1 1 0 - ### Explanation + In the first testcase, each state should have only 1 district, and hence, there is no actual choice in constructing the states. There will be three One Governors, and two Zero Governors, and hence the President will be a One. In the second testcase, each of the three states should should have 3 districts each. Consider the following partitioning of the districts into states: {2,3,4}, {5,6,7} and {8,9,1}. So, the first state consists of the districts {2,3,4}, and the representatives of these correspond to {0,1,1}. The majority is One, and hence the first state will have a One Governor. The representatives corresponding to the second state are {0,1,1}, and so again, this will have a One Governor. The third state has representatives {0,0,0}, and hence will have a Zero Governor. On the whole, there are two One Governors, and one Zero Governor, and hence the President will be a One. And since there is a way to partition the districts into states, in which the President is a One, the answer is 1. diff --git a/_problems/easy/GIFTCHEF.md b/_problems/easy/GIFTCHEF.md index dceb68b3..a863690c 100644 --- a/_problems/easy/GIFTCHEF.md +++ b/_problems/easy/GIFTCHEF.md @@ -113,8 +113,8 @@ aa 1 3 7 - ### Explanation + **Example case 1.** chefand|**charliethebest**| 1 way to cut 1 string "charliethebest" from the string S: diff --git a/_problems/easy/GOODNUMB.md b/_problems/easy/GOODNUMB.md index 3aef1a25..005af2bf 100644 --- a/_problems/easy/GOODNUMB.md +++ b/_problems/easy/GOODNUMB.md @@ -75,7 +75,7 @@ A number **n** is called a _good number_ if following properties hold. You will two numbers **L, R**, you have to find sum of divisors (including non-trivial) of all the good numbers in the range **L** to **R**, both inclusive. -Please note that is not considered a prime number. +Please note that 0 is not considered a prime number. ### Input @@ -109,8 +109,8 @@ For each test case, output a single line corresponding to answer of the test cas Output: 6 30 - ### Explanation + - Following number in the range 1 to 10 are square free numbers : 1, 2, 3, 5, 6, 7, 10. - Sum of their divisors will be 1, 3, 4, 6, 12, 8, 18 respectively. - Number of prime divisors of their sum of divisors will be 0, 1, 1, 2, 2, 1, 2 respectively. diff --git a/_problems/easy/GRANAMA.md b/_problems/easy/GRANAMA.md index 8dc48290..271ced26 100644 --- a/_problems/easy/GRANAMA.md +++ b/_problems/easy/GRANAMA.md @@ -100,16 +100,16 @@ alex axle paradise diapers alice bob - -**Output:**/> +**Output:** +/>
 YES
 NO
 YES
 
-
-
**Explanation:**/> +**Explanation:** +/> Example case 1: Chef declared them as granama recipes. They are actually granama because the sets of ingredients and the number of times each ingredient has been used are equal. The Chef got it right! diff --git a/_problems/easy/GRAYSC.md b/_problems/easy/GRAYSC.md index be3a9993..b7a161f2 100644 --- a/_problems/easy/GRAYSC.md +++ b/_problems/easy/GRAYSC.md @@ -95,5 +95,4 @@ Output “Yes” (quotes exclusive) if there exist four distinct indices **i1, i Output: Yes - \ No newline at end of file diff --git a/_problems/easy/GRGUY.md b/_problems/easy/GRGUY.md index bdb89978..dc12604d 100644 --- a/_problems/easy/GRGUY.md +++ b/_problems/easy/GRGUY.md @@ -143,8 +143,8 @@ Yes Yes 5 No - ### Explanation + - **Test 1:** Chef will start his journey from **L2**, switch from **L2** to **L1** and finally land up at last block of **L2** by switching from **L1** to **L2**. Therefore, he requires total 2 gravity switches to reach the destination. - **Test 3:** Chef cannot start his journey as starting block of both the lanes **L1 & L2** are dirty and he cannot step over them. @@ -158,5 +158,4 @@ Yes 8 No - -is considered as a correct output for the example input. \ No newline at end of file +is considered as a correct output for the example input. diff --git a/_problems/easy/GRID.md b/_problems/easy/GRID.md index a5a33857..23a4d7f2 100644 --- a/_problems/easy/GRID.md +++ b/_problems/easy/GRID.md @@ -108,8 +108,8 @@ For each testcase, print the number of possible options where mirror can be plac Output: 6 0 - ### Explanation + **Example case 1.** All places where rock are not there are valid positions. **Example case 2.** No valid positions./> diff --git a/_problems/easy/GROWGOLD.md b/_problems/easy/GROWGOLD.md index f5ffcd3b..7317da1d 100644 --- a/_problems/easy/GROWGOLD.md +++ b/_problems/easy/GROWGOLD.md @@ -103,8 +103,8 @@ For each test case, output the tax in units of gold to be paid in the **N**th ye 4 1536 18811834 - -**Explanation:** + +**Explanation:** Let tax\[i\] be the tax paid in ith year. diff --git a/_problems/easy/H1.md b/_problems/easy/H1.md index 80e9d53c..00b008bf 100644 --- a/_problems/easy/H1.md +++ b/_problems/easy/H1.md @@ -18,8 +18,8 @@ The puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of th
1 2 3
 4 5 6
 7 8 9
-
 
At each step, Johnny may swap two adjacent tiles **if their sum is a prime number.** Two tiles are considered adjacent if they have a common edge. + Help Johnny to find the shortest number of steps needed to reach the goal state. ### Input @@ -48,8 +48,8 @@ For each test case print a single line containing the shortest number of steps n Output: 6 -1 - ### Output details + The possible 6 steps in the first test case are described in the following figure: ![](/themes/abessive/images/contests/h1.png) diff --git a/_problems/easy/HAREJUMP.md b/_problems/easy/HAREJUMP.md index c0ac05c9..872b360a 100644 --- a/_problems/easy/HAREJUMP.md +++ b/_problems/easy/HAREJUMP.md @@ -38,5 +38,4 @@ Print T integers each denoting the number of ways the rabbit can perform jumps o 1 415 13624 - \ No newline at end of file diff --git a/_problems/easy/HDELIVER.md b/_problems/easy/HDELIVER.md index ac0ddb88..c2fda3f7 100644 --- a/_problems/easy/HDELIVER.md +++ b/_problems/easy/HDELIVER.md @@ -89,8 +89,8 @@ For each test case print **Q** lines - one for each query. Output "YO" if the or 1 ≤ M ≤ 1000 0 ≤ A, B, X, YN-1 1 ≤ Q ≤ 3000 - ### Example +
 Input:
 1
@@ -106,6 +106,6 @@ For each test case print **Q** lines - one for each query. Output "YO" if the or
 YO
 NO
 YO
-
 
### Warning! + **There are large input and output files in this problem. Make sure you use fast enough I/O methods.** diff --git a/_problems/easy/HELLO.md b/_problems/easy/HELLO.md index 8b0e34cd..5d97d725 100644 --- a/_problems/easy/HELLO.md +++ b/_problems/easy/HELLO.md @@ -83,11 +83,11 @@ For each test case, output one integer- the number of the best plan (from 1 to N ### Constraints 1 ≤ **T** ≤ 100 -0\.5 ≤ **D** ≤ 10.0 (exactly 2 digits after the decimal point) +0.5 ≤ **D** ≤ 10.0 (exactly 2 digits after the decimal point) 1 ≤ **U** ≤ 10000 1 ≤ **N** ≤ 100 1 ≤ **M** ≤ 36 -0\.05 ≤ **R** < **D** (exactly 2 digits after the decimal point) +0.05 ≤ **R** < **D** (exactly 2 digits after the decimal point) 1 ≤ **C** ≤ 1000 ### Example @@ -112,8 +112,8 @@ For each test case, output one integer- the number of the best plan (from 1 to N 2 0 2 - ### Explanation + **Test Case 1:** This test case is same as the example in the problem statement. **Test Case 2:** This is for you to work out! **Test Case 3:** Chef's monthly usage is only 50 Rokdas and none of the 2 plans are advantageous, hence the answer is zero '0'. diff --git a/_problems/easy/HELPLIRA.md b/_problems/easy/HELPLIRA.md index 35e94732..a24466fd 100644 --- a/_problems/easy/HELPLIRA.md +++ b/_problems/easy/HELPLIRA.md @@ -115,5 +115,4 @@ If there are multiple triangles with the same area, then the last index should b Output: 2 1 - \ No newline at end of file diff --git a/_problems/easy/HHAL.md b/_problems/easy/HHAL.md index 2e2f0871..9723202e 100644 --- a/_problems/easy/HHAL.md +++ b/_problems/easy/HHAL.md @@ -117,8 +117,8 @@ abbabaab Output: 2 - ### Explanation + There're multiple ways to ruin Harrenhal in the example test. Let's consider one of them. The first troop can delete **S** = _'ababa'_(_'**ab**b**ab**a**a**b'_). After that, **H** = _'bab'_. diff --git a/_problems/easy/HOLES.md b/_problems/easy/HOLES.md index 26a819a4..0eac11ff 100644 --- a/_problems/easy/HOLES.md +++ b/_problems/easy/HOLES.md @@ -32,5 +32,4 @@ DRINKEATCODE Output: 2 5 - \ No newline at end of file diff --git a/_problems/easy/HOMDEL.md b/_problems/easy/HOMDEL.md index fa99b783..cb456b68 100644 --- a/_problems/easy/HOMDEL.md +++ b/_problems/easy/HOMDEL.md @@ -69,7 +69,7 @@ layout: problem --- All submissions for this problem are available.Chef has started Home Delivery scheme in one of his restaurants. As the scheme is new , Chef appoints only one employee to deliver food to various locations. The delivery boy who has been appointed is an absent-minded chap. He always forgets to fill fuel in his delivery scooter. So what he does is that whenever Chef sends him for delivery, he goes to the gas station from the restaurant first. He gets his tank filled and then he heads towards his destination. He will do this every single time _irrespective of the destination_. The delivery boy tries his best to be on time. And to do this, he will choose those paths(from restaurant to gas station AND gas station to destinaion) which cost him the _least_ amount of time. Your task is to tell the Chef how much time can the delivery boy save if he had enough fuel in his scooter i.e. if he went to the destination directly without stopping for fuel (taking the path which costs him least amount of time). -The city has **N** streets numbered from to **N-1**. The restaurant is on street number **S**, the gas station is on street number **G** and the food has to be delivered to street **D** . Note that **S, G** and **D** need **not** be distinct. +The city has **N** streets numbered from 0 to **N-1**. The restaurant is on street number **S**, the gas station is on street number **G** and the food has to be delivered to street **D** . Note that **S, G** and **D** need **not** be distinct. ### Input: @@ -92,8 +92,8 @@ Both these values must be on the same line separated by a single space. 0 ≤ T[i][j] ≤ 100000 0 ≤ S,G,DN-1 - ### Example: + **Input:**``` 4 @@ -107,12 +107,11 @@ Both these values must be on the same line separated by a single space. 3 1 2 3 0 1 +
**Output:**```
 
-
**Output:**
 2 0
 1 0
 3 2
 3 2
 
-
 
\ No newline at end of file diff --git a/_problems/easy/HORSES.md b/_problems/easy/HORSES.md index 3b6fc202..b38b16f2 100644 --- a/_problems/easy/HORSES.md +++ b/_problems/easy/HORSES.md @@ -85,17 +85,16 @@ For each test case, output a single line containing the minimum difference that 2 ≤ N ≤ 5000 1 ≤ S[i] ≤ 1000000000 -
### Example: + **Input:**``` 1 5 4 9 1 32 13 +
**Output:**```
 
-
**Output:**
 3
 
-
-
**Explanation:** The minimum difference can be achieved if we pick horses with skills 1 and 4 for the race. \ No newline at end of file +
**Explanation:** The minimum difference can be achieved if we pick horses with skills 1 and 4 for the race. diff --git a/_problems/easy/HOTEL.md b/_problems/easy/HOTEL.md index b8c2e111..bfda9cf9 100644 --- a/_problems/easy/HOTEL.md +++ b/_problems/easy/HOTEL.md @@ -33,13 +33,13 @@ For each test case, print the maximum number of guests that are simultaneously a 7 13 6 5 8 2 10 12 19 18 6 9 9 11 15 -
### Sample Output +
3
 1
 3
-
 
### Constraints + - T≤100 - N≤100 - All arrival/departure times will be between 1 and 1000, inclusive diff --git a/_problems/easy/HS08TEST.md b/_problems/easy/HS08TEST.md index 9d15639a..85405f52 100644 --- a/_problems/easy/HS08TEST.md +++ b/_problems/easy/HS08TEST.md @@ -33,21 +33,20 @@ Output the account balance after the attempted transaction, given as a number wi Output: 89.50 -
### Example - Incorrect Withdrawal Amount (not multiple of 5) +
 Input:
 42 120.00
 
 Output:
 120.00
-
 
### Example - Insufficient Funds +
 Input:
 300 120.00
 
 Output:
 120.00
-
 
\ No newline at end of file diff --git a/_problems/easy/HULLSUM.md b/_problems/easy/HULLSUM.md index d94278d7..9f5bb70f 100644 --- a/_problems/easy/HULLSUM.md +++ b/_problems/easy/HULLSUM.md @@ -102,8 +102,8 @@ Note: Remember that you don't print **N** in the first line. -150 -150 150 -150 11 13 - ### Explanation + Let's analyze sizes of convex hulls for the provided output. There are 25-1 non-empty sets of points. - There are 5 sets of points that consist of only 1 point each. The convex hull of each of those sets has size 1. diff --git a/_problems/easy/ICPC16C.md b/_problems/easy/ICPC16C.md index dd65432d..50379a2b 100644 --- a/_problems/easy/ICPC16C.md +++ b/_problems/easy/ICPC16C.md @@ -52,6 +52,6 @@ For each test case output the required answer in one line. Output: 6 - ### Explanation + Possible value of **N** in given case are: 32,23,113,131 and so on, in each case digit sum of **(N+1)** would be **6**. diff --git a/_problems/easy/ICPC16D.md b/_problems/easy/ICPC16D.md index 3ba9f88f..07cd0fc1 100644 --- a/_problems/easy/ICPC16D.md +++ b/_problems/easy/ICPC16D.md @@ -60,8 +60,8 @@ For each test case, output a single line containing the corresponding answer. Output: 3 5 - ### Explanation + **Test case 1.** There are three sets which are good **{1}**, **{2}**, **{1, 2}**. **Test case 2.** There are five sets which are good **{6}**, **{2}**, **{3}**, **{6 2}**, **{6, 3}**. diff --git a/_problems/easy/ICPC16E.md b/_problems/easy/ICPC16E.md index 47d097b1..c71da7ee 100644 --- a/_problems/easy/ICPC16E.md +++ b/_problems/easy/ICPC16E.md @@ -54,8 +54,8 @@ For each test case, output a single line containing the required answer modulo * 1 12 - ### Explanation + **Example case 1.** The only way is to fill all cells with same color. **Example case 2.** Assume that the two colors are 1 and 2. The 12 distinct ways are: @@ -120,5 +120,4 @@ _______ 1 1 1 1 - \ No newline at end of file diff --git a/_problems/easy/IGAME.md b/_problems/easy/IGAME.md index faf4c686..b4b6a85c 100644 --- a/_problems/easy/IGAME.md +++ b/_problems/easy/IGAME.md @@ -40,11 +40,11 @@ For each test case print a string - either "Alice" or "Bob" (without the quotes) 1 1 0 0 2 4 1 2 - ### Sample Output +
Alice
 Bob
 
-
 
### Explanation + In the second test case, initially the vehicle is at co-ordinate (2, 4). Alice now has four possible moves. Alice can move the vehicle to position (1, 4), (1, 3), (2, 3) and (2, 2). For all moves that Alice can do, Bob can move the vehicle to the position (1, 2), winning the game. diff --git a/_problems/easy/INSOMB1.md b/_problems/easy/INSOMB1.md index 9dbe52d5..f23aa711 100644 --- a/_problems/easy/INSOMB1.md +++ b/_problems/easy/INSOMB1.md @@ -29,5 +29,4 @@ Line 1: PRIME or COMPOSITE Output: PRIME - \ No newline at end of file diff --git a/_problems/easy/INSOMB6.md b/_problems/easy/INSOMB6.md index a53ba3f8..acf3bde3 100644 --- a/_problems/easy/INSOMB6.md +++ b/_problems/easy/INSOMB6.md @@ -49,11 +49,10 @@ Chevrolet 1 Ford 2 Scorpio Chevrolet 1 Ford - + **Sample Output:**/>
 No
-
 
\ No newline at end of file diff --git a/_problems/easy/INTEG.md b/_problems/easy/INTEG.md index 3d4a7dbd..649d0590 100644 --- a/_problems/easy/INTEG.md +++ b/_problems/easy/INTEG.md @@ -67,9 +67,9 @@ time: current: 1493558153 layout: problem --- -All submissions for this problem are available. Chef has an array of **N** integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to . +All submissions for this problem are available. Chef has an array of **N** integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0. -Chef can use two types of operations. The first type is to increase all the integers of the given array by **1**, but it costs **X** coins. The operation of the second type is to add **1** to only one integer of the given array and to use this operation you need to pay **1** coin. You need to calculate the minimal cost to win this game (to make all integers greater than or equal to ) +Chef can use two types of operations. The first type is to increase all the integers of the given array by **1**, but it costs **X** coins. The operation of the second type is to add **1** to only one integer of the given array and to use this operation you need to pay **1** coin. You need to calculate the minimal cost to win this game (to make all integers greater than or equal to 0) ### Input @@ -83,7 +83,7 @@ For each test case, output a single line containing minimal cost required to mak - **1** ≤ **N** ≤ **105** - **-109** ≤ **Ai** ≤ **109** -- ≤ **X** ≤ **109** +- 0 ≤ **X** ≤ **109** ### Example @@ -94,6 +94,6 @@ For each test case, output a single line containing minimal cost required to mak Output: 5 - ### Explanation + **Example case 1:** Use the first type operation twice and the second type once. diff --git a/_problems/easy/INTERVAL.md b/_problems/easy/INTERVAL.md index 7999d6c5..43ff0c4a 100644 --- a/_problems/easy/INTERVAL.md +++ b/_problems/easy/INTERVAL.md @@ -115,8 +115,8 @@ For each test case, output a single integer in a separate line corresponding to Output: 20 - ### Explanation + **Example case 1.** Chef chooses the interval **\[1, 6\]** (i.e. **(3, 7, 5, 4, 9, 6)**). The score now is 34 points. In the next turn, Chefu chooses the interval **\[3, 5\]** (i.e. **(5, 4, 9)**). The score now is 34 - 18 = 16 points. diff --git a/_problems/easy/INTEST.md b/_problems/easy/INTEST.md index 46adf6b3..2607950a 100644 --- a/_problems/easy/INTEST.md +++ b/_problems/easy/INTEST.md @@ -36,5 +36,4 @@ Write a single integer to output, denoting how many integers ti are divisible by Output: 4 - \ No newline at end of file diff --git a/_problems/easy/IPCTRAIN.md b/_problems/easy/IPCTRAIN.md index ed54fb2a..03bde9fe 100644 --- a/_problems/easy/IPCTRAIN.md +++ b/_problems/easy/IPCTRAIN.md @@ -129,8 +129,8 @@ For each test case, output a single integer corresponding to the minimum total s 100 0 150 - ### Explanation + **Example case 1**. Both the first and second trainer want to take exactly two lectures. The first trainer arrives on the 1st day and the second trainer arrives on the 2nd day. Consider a schedule where the first trainer takes the first two lectures, and the second trainer takes the last lecture on the day 3. This way the second trainer will take only one lecture but wanted to take two. Thus, his sadness will be 100. The first trainer took all the lectures that he wanted to take (ie. two lectures). Thus the total sadness is 100 + 0 = 100. You can check that no other way of assigning trainers to the days will give a better answer than this. **Example case 2**. In this case, the trainers can all take all their ideal number of lectures. diff --git a/_problems/easy/ISSNAKE.md b/_problems/easy/ISSNAKE.md index f2985815..6fde88b5 100644 --- a/_problems/easy/ISSNAKE.md +++ b/_problems/easy/ISSNAKE.md @@ -81,16 +81,19 @@ Usually, I am skeptical of such legends. So, I want to check for myself whether ## ## -Now, the legend could be true. A snake can be on it, and one possible configuration is as follows. The head of the snake is at (1, 1), then the next portion at (1, 2), then at (2, 2) and then the finally the tail at (2, 1). Notice that the parts of the snake can be adjacent only if the corresponding cells have a common side. +Now, the legend could be true. A snake can be on it, and one possible configuration is as follows. The head of the snake is at (1, 1), then the next portion at (1, 2), then at (2, 2) and then the finally the tail at (2, 1). Notice that the parts of the snake can be adjacent only if the corresponding cells have a common side. ``` + ##.#.. .###..
There can be a snake on the plate above.
+
 
##.## .#.#.
The legend is surely false if the plate is as above. These are not marks of a single snake. There could be more than one possible snakes here. But not a single snake.
+
 Given the description of the plate, figure out if the legend could be true, or if it is definitely false.
 
 ### Input
diff --git a/_problems/easy/J7.md b/_problems/easy/J7.md
index 00fdd21c..b84dbdbb 100644
--- a/_problems/easy/J7.md
+++ b/_problems/easy/J7.md
@@ -39,5 +39,4 @@ For each test case, print a real number that is the largest volume of the box th
 Output details
 First case: the dimensions of the largest box may be 3, 1 and 1.
 Second case: the dimensions of the largest box may be 7/3, 4/3 and 4/3.
-
 
\ No newline at end of file diff --git a/_problems/easy/JOHNY.md b/_problems/easy/JOHNY.md index 2f37ad25..053061c7 100644 --- a/_problems/easy/JOHNY.md +++ b/_problems/easy/JOHNY.md @@ -101,8 +101,8 @@ For each test case, output a single line containing the position of "Uncle Johny 3 4 1 - ### Explanation + In the example test there are **T**=3 test cases. **Test case 1** diff --git a/_problems/easy/K1.md b/_problems/easy/K1.md index 162628b8..772b4b54 100644 --- a/_problems/easy/K1.md +++ b/_problems/easy/K1.md @@ -49,8 +49,8 @@ For each test case, print in a single line the minimum total distance between th Output: 26.232349 - ### Output details + The line equation of Highway 1 is 3x-5x-7=0. Ingoo have 5 warehouses: A(1,3), B(-2,4), C(4,-7), D(7,6), and E(3,3). The optimum location of the new plant is P as shown in the figure below: ![](/themes/abessive/images/contests/plant.png) diff --git a/_problems/easy/KBIGNUMB.md b/_problems/easy/KBIGNUMB.md index 291722c5..6536bb52 100644 --- a/_problems/easy/KBIGNUMB.md +++ b/_problems/easy/KBIGNUMB.md @@ -85,7 +85,7 @@ For each test case, output a single line containing an integer denoting the valu ### Constraints - **1** ≤ **T** ≤ **105** -- ≤ **A** ≤ **109** +- 0 ≤ **A** ≤ **109** - **1** ≤ **N** ≤ **1012** - **2** ≤ **M** ≤ **109** @@ -114,8 +114,8 @@ For each test case, output a single line containing an integer denoting the valu Output: 5 6 - ### Explanation + **Example 1:** As **A = 12, N = 2, X = 1212**, **1212 modulo 17 = 5** **Example 2.** As **A = 523, N = 3, X = 523523523**, **523523523 modulo 11 = 6** diff --git a/_problems/easy/KFUNC.md b/_problems/easy/KFUNC.md index c93d8cfd..9d8f804e 100644 --- a/_problems/easy/KFUNC.md +++ b/_problems/easy/KFUNC.md @@ -104,7 +104,7 @@ Example: - **1** ≤ **T** ≤ **105** - **1** ≤ **A1** ≤ **109** -- ≤ **D** ≤ **10**9 +- 0 ≤ **D** ≤ **10**9 - **1** ≤ **R** ≤ **1018** - **1** ≤ **L** ≤ **R** @@ -125,8 +125,8 @@ Example: 6 12 - ### Explanation + **Example case 1.** **A** = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...} diff --git a/_problems/easy/KGOOD.md b/_problems/easy/KGOOD.md index e13c92ff..128c2dd8 100644 --- a/_problems/easy/KGOOD.md +++ b/_problems/easy/KGOOD.md @@ -93,7 +93,7 @@ For each test case, output a single line containing a single integer: the minimu - **1** ≤ **T** ≤ **30** - **1** ≤ **|w|** ≤ **105** -- ≤ **K** ≤ **105** +- 0 ≤ **K** ≤ **105** - **w** contains only lowercase English letters. ### Example @@ -110,8 +110,8 @@ defenselessness 3 0 1 2 - ### Explanation + **Example case 1.** The word “**glaciological**” is already 1-good, so the Chef doesn't have to remove any letter. **Example case 2.** Similarly, “**teammate**” is already 0-good. diff --git a/_problems/easy/KINGCON.md b/_problems/easy/KINGCON.md index 7d2170dc..ea97a20d 100644 --- a/_problems/easy/KINGCON.md +++ b/_problems/easy/KINGCON.md @@ -69,7 +69,7 @@ time: current: 1493558156 layout: problem --- -All submissions for this problem are available.The Kingdom of Bytelandia has **N** cities, numbered from to **N**−**1**. There are **M** bidirectional roads, each of which connects two different cities. The road network in the kingdom is such that people of any city can reach any other city they desired through the road network. This is called having _unity_ in the kingdom. Bytelandia is very famous for its unity. The people are united and familiar with each other. The king of Bytelandia is also very proud of this fact. +All submissions for this problem are available.The Kingdom of Bytelandia has **N** cities, numbered from 0 to **N**−**1**. There are **M** bidirectional roads, each of which connects two different cities. The road network in the kingdom is such that people of any city can reach any other city they desired through the road network. This is called having _unity_ in the kingdom. Bytelandia is very famous for its unity. The people are united and familiar with each other. The king of Bytelandia is also very proud of this fact. But, **some people just want to watch the world burn**. Dr. Bobo is one of such people. He is very wicked. He doesn't like _unity_ of Bytelandia. He has a chemical missile to spread diseases. He plans to attack one of the cities of Bytelandia. @@ -96,7 +96,7 @@ For each test case, output the minimum amount of money required to fulfill the k - **1** ≤ **T** ≤ **1500** - **2** ≤ **N** ≤ **3000** - **N**−**1** ≤ **M** ≤ **N**\*(**N**−**1**)/**2**) -- ≤ **A**, **B** ≤ **N**−**1**, **A** ≠ **B** +- 0 ≤ **A**, **B** ≤ **N**−**1**, **A** ≠ **B** - **1** ≤ **K** ≤ **1000** - The road network has _unity_ - No two roads connect the same pair of cities @@ -117,6 +117,6 @@ For each test case, output the minimum amount of money required to fulfill the k Output: 15 - ### Explanation + In the sample, the cities **1**, **2**, and **4** must be protected by the shields. diff --git a/_problems/easy/KINGSHIP.md b/_problems/easy/KINGSHIP.md index 8ad1d32f..62a64fb9 100644 --- a/_problems/easy/KINGSHIP.md +++ b/_problems/easy/KINGSHIP.md @@ -103,5 +103,4 @@ For each test case, print a single integer, the minimum cost to build the new ro Output: 50 266 - \ No newline at end of file diff --git a/_problems/easy/KIRLAB.md b/_problems/easy/KIRLAB.md index 16145a42..e3b12cb7 100644 --- a/_problems/easy/KIRLAB.md +++ b/_problems/easy/KIRLAB.md @@ -106,8 +106,8 @@ For each test case, output the maximum number of rooms he could clear. (Kirito s Output: 5 2 - ### Explanation + **Example 1**. Kirito can clear the monsters in the rooms 2, 3, 4, 5, 7 in that order. These rooms consist of 2, 8, 6, 3, and 9 monsters, respectively. You can check that gcd(2, 8), gcd(8, 6), gcd(6, 3) and gcd(3, 9), all are greater than 1. **Example 2**. Kirito can clear the monsters in the rooms numbered 2, 3. Each of these two rooms contains two monsters. And we know that gcd(2, 2) = 2 > 1. diff --git a/_problems/easy/KNICOV.md b/_problems/easy/KNICOV.md index 79967a9a..59c8201b 100644 --- a/_problems/easy/KNICOV.md +++ b/_problems/easy/KNICOV.md @@ -99,8 +99,8 @@ For each test case print the minimum number of knights required to cover every c Output: 4 - ### Explanation + One optimal configuration is: ![](https://codechef_shared.s3.amazonaws.com/download/upload/COOK83/KNICOV.png)Cells (1, 1), (1, 2), (4, 1) and (4, 2) contain knights. Cell (2, 1) is attacked by the knight in cell (4, 2). Cell (2, 2) is attacked by the knight in cell (4, 1). Cell (3, 1) is attacked by the knight in cell (1, 2). And cell (3, 2) is attacked by the knight in cell (1, 1). diff --git a/_problems/easy/KNIGHTMV.md b/_problems/easy/KNIGHTMV.md index 0b25489d..cf197658 100644 --- a/_problems/easy/KNIGHTMV.md +++ b/_problems/easy/KNIGHTMV.md @@ -36,5 +36,4 @@ Yes No Error Error - \ No newline at end of file diff --git a/_problems/easy/KOL1502.md b/_problems/easy/KOL1502.md index 703ffe21..95a24431 100644 --- a/_problems/easy/KOL1502.md +++ b/_problems/easy/KOL1502.md @@ -61,8 +61,8 @@ For each test case, output the value as asked in a separate line. 1 2 Output: 8 - ### Explanation + **Example case 1.** The dishes made by CodeChef and the amounts collected: - Dish 1: Contains both ingredients: Sold to Planet A for 3 Alterian dollars. diff --git a/_problems/easy/KOL1504.md b/_problems/easy/KOL1504.md index f81f94e7..9a3a1757 100644 --- a/_problems/easy/KOL1504.md +++ b/_problems/easy/KOL1504.md @@ -82,8 +82,8 @@ No Yes No - ### Explanation + **Example case 1.** Swap layer 'y' with 'q'. **Example case 2.** Follow the following swap order: diff --git a/_problems/easy/KOL1506.md b/_problems/easy/KOL1506.md index a2ebb3ca..e80ac4a1 100644 --- a/_problems/easy/KOL1506.md +++ b/_problems/easy/KOL1506.md @@ -45,8 +45,8 @@ Everyone chose Samosa Bhai's company because of Aloo uncle and Kachori aunty. So - **1** ≤ **T** ≤ **104** - **2** ≤ **N** ≤ **105** -- ≤ **k** ≤ **100** -- ≤ **Ai** ≤ **1000000006** +- 0 ≤ **k** ≤ **100** +- 0 ≤ **Ai** ≤ **1000000006** - The sum of **N** over all test cases will be at most **100000** - 2 houses **can** be at the same position @@ -72,8 +72,8 @@ Everyone chose Samosa Bhai's company because of Aloo uncle and Kachori aunty. So 1650 558199159 - ### Explanation + **Example case 1.** House 1 sends a gift to House 2 with cost (|2 - 7|)2 and house 2 sends a gift to house 1 with cost (|7-2|)2, for a total cost of 50 **Example case 3.** The cost for gift from house with index 1 to house with index 2 is 22 = 4, from houses 1 to 3 is 1, from houses 2 to 3 is 1. Taking into account the gifts sent the other way (from 2 to 1, 3 to 1 and 3 to 2), the total cost is 4 + 1 + 1 + 4 + 1 + 1 = 12 diff --git a/_problems/easy/KOL1509.md b/_problems/easy/KOL1509.md index 2c56fed8..587639e4 100644 --- a/_problems/easy/KOL1509.md +++ b/_problems/easy/KOL1509.md @@ -59,8 +59,8 @@ For each test case, output the value equal to **two times the area**, rounded to Output: 6 13 - ### Explanation + **Example case 1.** Covered portion is a right angled triangle with vertices (2,4), (2,1) and (4,1). Area = (1/2)\*2\*3 = 3. diff --git a/_problems/easy/KOL16F.md b/_problems/easy/KOL16F.md index 48553eae..d267816b 100644 --- a/_problems/easy/KOL16F.md +++ b/_problems/easy/KOL16F.md @@ -23,7 +23,7 @@ time: current: 1493558158 layout: problem --- -All submissions for this problem are available.Nemo went to the shop to buy a chain for his girlfriend. The shopkeeper has shown him a chain made of some expensive stones. The chain has **n** stones marked from to **n-1**. The **ith** stone is connected with **((i+1)%n)th** stone for each **0 ≤ i < n**. Each stone can be either Ruby or Amber. +All submissions for this problem are available.Nemo went to the shop to buy a chain for his girlfriend. The shopkeeper has shown him a chain made of some expensive stones. The chain has **n** stones marked from 0 to **n-1**. The **ith** stone is connected with **((i+1)%n)th** stone for each **0 ≤ i < n**. Each stone can be either Ruby or Amber. Nemo defines beauty factor **B** of a chain as the maximum number of consecutive stones of same type. @@ -54,6 +54,7 @@ ARRRRAAA Case 2: 4

### Explanation:
+
 Case **1** represents the figure in the problem statement. Nemo can exchange one Amber with a Ruby and reduce **B** to **3**.
 
 ![](https://www.codechef.com/download/upload/ACM16KOL/F2.png)
diff --git a/_problems/easy/KOL16H.md b/_problems/easy/KOL16H.md
index 3ff9b6e9..5dbf2eac 100644
--- a/_problems/easy/KOL16H.md
+++ b/_problems/easy/KOL16H.md
@@ -52,5 +52,4 @@ For every test-case, output a single containing test-case number and the minimum
 Output
 Case 1: 1
 Case 2: 3
-
 
\ No newline at end of file
diff --git a/_problems/easy/KPRIME.md b/_problems/easy/KPRIME.md
index c40ada2f..389e64ab 100644
--- a/_problems/easy/KPRIME.md
+++ b/_problems/easy/KPRIME.md
@@ -105,5 +105,4 @@ For each game, output on a separate line the number of **K**-primes between **A*
 2
 0
 
-
 
\ No newline at end of file diff --git a/_problems/easy/KSPHERES.md b/_problems/easy/KSPHERES.md index 6e62bd86..254d00d4 100644 --- a/_problems/easy/KSPHERES.md +++ b/_problems/easy/KSPHERES.md @@ -123,8 +123,8 @@ Output a single line containing **C** space-separated integers **D1**, **D2**, . Output: 5 2 0 -
### Explanation + We can build spheres with such radii: **R**=1 and there are 2 ways to do it. (We can choose any of 2 lower hemispheres with **R**=1) diff --git a/_problems/easy/KSUBSUM.md b/_problems/easy/KSUBSUM.md index d77b1e39..7fac7357 100644 --- a/_problems/easy/KSUBSUM.md +++ b/_problems/easy/KSUBSUM.md @@ -45,8 +45,8 @@ K3 ≤ N\*(N+1)/2 60 50 30 30 30 10 15 -5 -20 - -**Explanation:** + +**Explanation:** Case 1 & 2 : A = { 10, 20, 30 }. All possible sums of sub-arrays in non-increasing order, S\[1..6\] = { 60, 50, 30, 30, 20, 10 } diff --git a/_problems/easy/KSUM.md b/_problems/easy/KSUM.md index b5f4f99f..d422060a 100644 --- a/_problems/easy/KSUM.md +++ b/_problems/easy/KSUM.md @@ -115,8 +115,8 @@ Output **K** space separated integers where the **ith** integer denotes the **it Output 2 19 12 10 - ### Explanation + **Test 1:** ![](https://s3.amazonaws.com/hr-challenge-images/15909/1461161918-8d79d8843c-B.png "B.png") diff --git a/_problems/easy/KTHMAX.md b/_problems/easy/KTHMAX.md index 800bbcd6..abe27c90 100644 --- a/_problems/easy/KTHMAX.md +++ b/_problems/easy/KTHMAX.md @@ -130,5 +130,4 @@ Output a single integer corresponding to the maximum element in the **pth** suba Output: 4 3 - \ No newline at end of file diff --git a/_problems/easy/L3.md b/_problems/easy/L3.md index 5673af1f..e0586543 100644 --- a/_problems/easy/L3.md +++ b/_problems/easy/L3.md @@ -40,5 +40,4 @@ You can assume that there is at least one solution for each test case. 5 23 101 - \ No newline at end of file diff --git a/_problems/easy/LAPIN.md b/_problems/easy/LAPIN.md index b6b35bd9..633015ee 100644 --- a/_problems/easy/LAPIN.md +++ b/_problems/easy/LAPIN.md @@ -96,8 +96,8 @@ abbaab ababc +
**Output:**```
 
-
**Output:**
 YES
 NO
 YES
@@ -105,5 +105,4 @@ YES
 NO
 NO
 
-
 
\ No newline at end of file diff --git a/_problems/easy/LASTDIG.md b/_problems/easy/LASTDIG.md index eb73782c..e08515bb 100644 --- a/_problems/easy/LASTDIG.md +++ b/_problems/easy/LASTDIG.md @@ -27,12 +27,12 @@ For each test case, output a single integer indicating the corresponding sum. 1 8 28 138 314159 314159 -
### Sample Output +
36
 495
 7
-
 
### Constraints + - T ≤ 1000 - 0 ≤ A ≤ B ≤ 400,000,000 diff --git a/_problems/easy/LCKYST.md b/_problems/easy/LCKYST.md index 52f713d6..4480f813 100644 --- a/_problems/easy/LCKYST.md +++ b/_problems/easy/LCKYST.md @@ -122,8 +122,8 @@ Na2a has **N** numbers in his bag which are denoted by array **A**. For each num Output: 2 60 -
### Explanation
+
 **Example case 1.** You can't get any number having zeros at the end multiplying 2 by lucky numbers.
 
 **Example case 2.** You can multiply 15 by 4 and get 60, which has one trailing zero.
diff --git a/_problems/easy/LCPESY.md b/_problems/easy/LCPESY.md
index 8bc78d46..abd09b18 100644
--- a/_problems/easy/LCPESY.md
+++ b/_problems/easy/LCPESY.md
@@ -107,8 +107,8 @@ elfedcc
 4
 3
 5
-
 
### Explanation + **Example case 1.** There is no common character. **Example case 2.** All the characters are same. diff --git a/_problems/easy/LEALCO.md b/_problems/easy/LEALCO.md index f99dec87..ed81d6d6 100644 --- a/_problems/easy/LEALCO.md +++ b/_problems/easy/LEALCO.md @@ -71,11 +71,11 @@ layout: problem --- All submissions for this problem are available.The Little Elephant and his friends from the Zoo of Lviv were returning from the party. But suddenly they were stopped by the policeman Big Hippo, who wanted to make an alcohol test for elephants. -There were **N** elephants ordered from the left to the right in a row and numbered from to **N-1**. Let **R\[i\]** to be the result of breathalyzer test of **i**-th elephant. +There were **N** elephants ordered from the left to the right in a row and numbered from 0 to **N-1**. Let **R\[i\]** to be the result of breathalyzer test of **i**-th elephant. Considering current laws in the Zoo, elephants would be arrested if there exists **K** consecutive elephants among them for which at least **M** of these **K** elephants have the maximal test result among these **K** elephants. -Using poor math notations we can alternatively define this as follows. The elephants would be arrested if there exists **i** from to **N-K**, inclusive, such that for at least **M** different values of **j** from **i** to **i+K-1**, inclusive, we have **R\[j\] = max{R\[i\], R\[i+1\], ..., R\[i+K-1\]}**. +Using poor math notations we can alternatively define this as follows. The elephants would be arrested if there exists **i** from 0 to **N-K**, inclusive, such that for at least **M** different values of **j** from **i** to **i+K-1**, inclusive, we have **R\[j\] = max{R\[i\], R\[i+1\], ..., R\[i+K-1\]}**. The Big Hippo is very old and the Little Elephant can change some of the results. In a single operation he can add **1** to the result of any elephant. But for each of the elephants he can apply this operation at most once. @@ -114,9 +114,9 @@ For each test case, output a single line containing the minimum number of operat 1 1 -1 -
### Explanation -**Example case 1.** Let's follow the poor math definition of arrest. We will consider all values of **i** from to **N-K = 2**, inclusive, and should count the number of values of **j** described in the definition. If it less than **M = 2** then this value of **i** does not cause the arrest, otherwise causes. + +**Example case 1.** Let's follow the poor math definition of arrest. We will consider all values of **i** from 0 to **N-K = 2**, inclusive, and should count the number of values of **j** described in the definition. If it less than **M = 2** then this value of **i** does not cause the arrest, otherwise causes. **i****{R\[i\],...,R\[i+K-1\]}****max{R\[i\],...,R\[i+K-1\]}**For which **j = i, ..., i+K-1** we have **R\[j\] = max**Conclusion**i=0****{1, 3, 1}****max = 3****R\[j\] = 3** for **j = 1**does not cause the arrest**i=1****{3, 1, 2}****max = 3****R\[j\] = 3** for **j = 1**does not cause the arrest**i=2****{1, 2, 1}****max = 2****R\[j\] = 2** for **j = 3**does not cause the arrestSo we see that initial test results of the elephants do not cause their arrest. Hence the Little Elephant does not need to apply any operations. Therefore, the answer is 0. @@ -137,4 +137,4 @@ For each test case, output a single line containing the minimum number of operat **i****{R\[i\],...,R\[i+K-1\]}****max{R\[i\],...,R\[i+K-1\]}**For which **j = i, ..., i+K-1** we have **R\[j\] = max**Conclusion**i=0****{7, 8, 7}****max = 8****R\[j\] = 8** for **j = 1**does not cause the arrest**i=1****{8, 7, 8}****max = 8****R\[j\] = 8** for **j = 1, 3**does not cause the arrest**i=2****{7, 8, 8}****max = 8****R\[j\] = 8** for **j = 3, 4**does not cause the arrestSo we see that now test results of the elephants do not cause their arrest. Thus we see that using 0 operations we can't avoid the arrest but using 1 operation can. Hence the answer is 1. Note that if we increase by 1 the result **R\[2\]** instead of **R\[1\]** then the value **i = 2** will cause the arrest since **{R\[2\], R\[3\], R\[4\]}** will be **{8, 8, 8}** after this operation and we will have 3 values of **j** from **2** to **4**, inclusive, for which **R\[j\] = max{R\[2\], R\[3\], R\[4\]}**, namely, **j = 2, 3, 4**. -**Example case 4.** When **M = 1** the Little Elephant can't reach the goal since for each value of **i** from to **N-K** we have at least one value of **j** for which **R\[j\] = max{R\[i\], R\[i+1\], ..., R\[i+K-1\]}**. +**Example case 4.** When **M = 1** the Little Elephant can't reach the goal since for each value of **i** from 0 to **N-K** we have at least one value of **j** for which **R\[j\] = max{R\[i\], R\[i+1\], ..., R\[i+K-1\]}**. diff --git a/_problems/easy/LEBALONS.md b/_problems/easy/LEBALONS.md index 049056bd..d3f44329 100644 --- a/_problems/easy/LEBALONS.md +++ b/_problems/easy/LEBALONS.md @@ -89,7 +89,7 @@ In **T** lines print **T** real numbers - the answers for the corresponding test 11. **1** ≤ **T** ≤ **40** 12. **1** ≤ **N**, **Ci**≤ **40** 13. **1** ≤ **Pi** ≤ **1000000** -14. ≤ **M** ≤ **K**, where **K** is the number of different colors in the test case. +14. 0 ≤ **M** ≤ **K**, where **K** is the number of different colors in the test case. ### Example
@@ -106,5 +106,4 @@ In **T** lines print **T** real numbers - the answers for the corresponding test
 11.000000000
 7.333333333
 
-
 
\ No newline at end of file diff --git a/_problems/easy/LEBAMBOO.md b/_problems/easy/LEBAMBOO.md index a66696df..bdc93568 100644 --- a/_problems/easy/LEBAMBOO.md +++ b/_problems/easy/LEBAMBOO.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in Little Elephant from Zoo of Lviv likes bamboo very much. He currently has **n** stems of bamboo, **Hi** - height of **i-th** stem of bamboo (0-based numeration). -Today inspector Andrii from World Bamboo Association is visiting the plantation. He doesn't like current situation. He wants the height of **i-th** stem to be **Di**, for each **i** from to **n-1**, inclusive. +Today inspector Andrii from World Bamboo Association is visiting the plantation. He doesn't like current situation. He wants the height of **i-th** stem to be **Di**, for each **i** from 0 to **n-1**, inclusive. Little Elephant is going to buy some special substance. One bottle of such substance he can use to single stem of bamboo. After using substance for stem **i**, the height of **i-th** stem is decrased by **1** and the height of **j-th** stem is increased by **1** for each **j** not equal to **i**. Note that it is possible for some of the stems to have negative height, but after all transformations all stems should have positive height. @@ -117,5 +117,4 @@ In **T** lines print **T** integers - the answers for the corresponding test cas 1 5 - \ No newline at end of file diff --git a/_problems/easy/LEBOMBS.md b/_problems/easy/LEBOMBS.md index 500e81a9..21618e05 100644 --- a/_problems/easy/LEBOMBS.md +++ b/_problems/easy/LEBOMBS.md @@ -68,15 +68,15 @@ time: current: 1493558160 layout: problem --- -All submissions for this problem are available.The Little Elephant from the Zoo of Lviv currently is on the military mission. There are **N** enemy buildings placed in a row and numbered from left to right strating from . Each building **i** (except the first and the last) has exactly two adjacent buildings with indices **i-1** and **i+1**. The first and the last buildings have just a single adjacent building. +All submissions for this problem are available.The Little Elephant from the Zoo of Lviv currently is on the military mission. There are **N** enemy buildings placed in a row and numbered from left to right strating from 0. Each building **i** (except the first and the last) has exactly two adjacent buildings with indices **i-1** and **i+1**. The first and the last buildings have just a single adjacent building. Some of the buildings contain bombs. When bomb explodes in some building it destroys it and all adjacent to it buildings. -You are given the string **S** of length **N**, where **Si** is **1** if the **i**-th building contains bomb, otherwise. Find for the Little Elephant the number of buildings that will not be destroyed after all bombs explode. Please note that all bombs explode simultaneously. +You are given the string **S** of length **N**, where **Si** is **1** if the **i**-th building contains bomb, 0 otherwise. Find for the Little Elephant the number of buildings that will not be destroyed after all bombs explode. Please note that all bombs explode simultaneously. ### Input -The first line contains single integer **T** - the number of test cases. **T** test cases follow. The first line of each test case contains the single integer **N** - the number of buildings. The next line contains the string **S** of length **N** consisted only of digits and **1**. +The first line contains single integer **T** - the number of test cases. **T** test cases follow. The first line of each test case contains the single integer **N** - the number of buildings. The next line contains the string **S** of length **N** consisted only of digits 0 and **1**. ### Output @@ -101,5 +101,4 @@ In **T** lines print **T** inetgers - the answers for the corresponding test cas 1 7 - \ No newline at end of file diff --git a/_problems/easy/LECARDS.md b/_problems/easy/LECARDS.md index 9538513e..8d9666b0 100644 --- a/_problems/easy/LECARDS.md +++ b/_problems/easy/LECARDS.md @@ -106,5 +106,4 @@ For each test case, print the answer in one line. 4 5 - \ No newline at end of file diff --git a/_problems/easy/LEDIV.md b/_problems/easy/LEDIV.md index fbac2adc..a991a4cd 100644 --- a/_problems/easy/LEDIV.md +++ b/_problems/easy/LEDIV.md @@ -108,8 +108,8 @@ The sum of values of **N** in each test file does not exceed **100000** 2 -1 - ### Explanation + **Case 1.** Clearly 2 is a divisor of each of the numbers 2, 4 and 8. Since 2 is the least number greater than 1 then it is the answer. **Case 2.** Let's perform check for several first values of **x**. diff --git a/_problems/easy/LEEXAMS.md b/_problems/easy/LEEXAMS.md index b1f916d4..d6bdf14b 100644 --- a/_problems/easy/LEEXAMS.md +++ b/_problems/easy/LEEXAMS.md @@ -110,5 +110,4 @@ Output **T** lines, each containing a single real number - answer for the corres 0.500000000 0.347800000 - \ No newline at end of file diff --git a/_problems/easy/LELEMON.md b/_problems/easy/LELEMON.md index e32c186e..e0cd845b 100644 --- a/_problems/easy/LELEMON.md +++ b/_problems/easy/LELEMON.md @@ -73,7 +73,7 @@ All submissions for this problem are available.Little Elephant likes lemonade. When Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all. -There are **n** rooms (numbered from to **n-1**), each contains **Ci** bottles. Each bottle has a volume (in litres). The first room visited by Little Elephant was **P0-th**, the second - **P1-th**, ..., the **m-th** - **Pm-1-th** room. Note that Little Elephant may visit a room more than once. +There are **n** rooms (numbered from 0 to **n-1**), each contains **Ci** bottles. Each bottle has a volume (in litres). The first room visited by Little Elephant was **P0-th**, the second - **P1-th**, ..., the **m-th** - **Pm-1-th** room. Note that Little Elephant may visit a room more than once. Find for Little Elephant the total volume of lemonade he has drunk. @@ -118,5 +118,4 @@ In **T** lines print **T** integers - the answers for the corresponding test cas 17 22 - \ No newline at end of file diff --git a/_problems/easy/LEMAGIC.md b/_problems/easy/LEMAGIC.md index a6bdf09a..a5c3458d 100644 --- a/_problems/easy/LEMAGIC.md +++ b/_problems/easy/LEMAGIC.md @@ -69,7 +69,7 @@ layout: problem --- All submissions for this problem are available.The Little Elephant from the Zoo of Lviv believes in magic. -He has a magic board **A** that consists of **N** rows and **M** columns. Each cell of the board contains an integer from to **9** inclusive. The cell at the intersection of the **i**-th row and the **j**-th column is denoted as **(i; j)**, where **1** ≤ **i** ≤ **N** and **1** ≤ **j** ≤ **M**. The number in the cell **(i; j)** is denoted as **A\[i\]\[j\]**. +He has a magic board **A** that consists of **N** rows and **M** columns. Each cell of the board contains an integer from 0 to **9** inclusive. The cell at the intersection of the **i**-th row and the **j**-th column is denoted as **(i; j)**, where **1** ≤ **i** ≤ **N** and **1** ≤ **j** ≤ **M**. The number in the cell **(i; j)** is denoted as **A\[i\]\[j\]**. The Little Elephant owns the only magic operation which can be described as follows. He chooses some integer **P** and some row or column, after that for each cell in the chosen row or column he adds number **P** to the number in this cell and take the result modulo **10** in order to keep numbers in the range **{0, 1, ..., 9}**. Our Little Magician wants to perform series of such operations to achieve some board for which certain characteristic called _level of the board_ is maximal possible. @@ -103,7 +103,7 @@ For each test case output a single line containing a single integer, the maximal **1** ≤ **T** ≤ **10** **1** ≤ **N** ≤ **100** **1** ≤ **M** ≤ **100** - ≤ **A\[i\]\[j\]** ≤ **9** +0 ≤ **A\[i\]\[j\]** ≤ **9** ### Example @@ -121,38 +121,37 @@ For each test case output a single line containing a single integer, the maximal Output: 3 5 - ### Explanation + **Case 1.** The board already has a sequence of **3** cells that satisfies all required constraints (without applying any operation). For example, one can choose, the sequence **(1; 1), (1; 2), (2; 2)**. It is also shown in the figure below (chosen cells are made bold):
 11
 10
+
Let's formally validate this sequence of cells. Inequality **1** ≤ **i1** ≤ ... ≤ **iK** ≤ **N** takes the form **1** ≤ **1** ≤ **2**. Inequality **1** ≤ **j1** ≤ ... ≤ **jK** ≤ **M** takes the form **1** ≤ **2** ≤ **2**. Finally, inequality **A\[i1\]\[j1\]** ≥ **A\[i2\]\[j2\]** ≥ ... ≥ **A\[iK\]\[jK\]** takes the form **1** ≥ **1** ≥ 0. So all of them is satisfied, which means that the level of this board is at least **3**. But clearly, we can't have the required sequence of cells of length more than **3**. So **3** is the actual level of this board. -Let's formally validate this sequence of cells. Inequality **1** ≤ **i1** ≤ ... ≤ **iK** ≤ **N** takes the form **1** ≤ **1** ≤ **2**. Inequality **1** ≤ **j1** ≤ ... ≤ **jK** ≤ **M** takes the form **1** ≤ **2** ≤ **2**. Finally, inequality **A\[i1\]\[j1\]** ≥ **A\[i2\]\[j2\]** ≥ ... ≥ **A\[iK\]\[jK\]** takes the form **1** ≥ **1** ≥ . So all of them is satisfied, which means that the level of this board is at least **3**. But clearly, we can't have the required sequence of cells of length more than **3**. So **3** is the actual level of this board. **Case 2.** The desired sequence of length **5** can be achieved by several values of **P**. Consider, for example, **P = 3**. At first let's apply the magic operation to the 1st row. We get the following transformation:
 3478  →  6701
 4268  →  4268
 7173  →  7173
-
 
Now let's transform the 1st column by the magic operation. We get: +
 6701  →  9701
 4268  →  7268
 7173  →  0173
-
 
Finally we modify the 2nd column: +
 9701  →  9001
 7268  →  7568
 0173  →  0473
-
 
Now we can take the following sequence of 5 cells to satisfy all needed constraints: **(1; 1), (2; 1), (2; 2), (3; 2), (3; 4)** (see the figure below): +
 9001
 7568
 0473
-
-
Just to reiterate we note that the inequality **A\[i1\]\[j1\]** ≥ **A\[i2\]\[j2\]** ≥ ... ≥ **A\[iK\]\[jK\]** takes the form **9 ≥ 7 ≥ 5 ≥ 4 ≥ 3** for this sequence. One can check (for example, by brute force), that sequences of length more than **5** can't be achieved. So **5** is the answer. \ No newline at end of file +Just to reiterate we note that the inequality **A\[i1\]\[j1\]** ≥ **A\[i2\]\[j2\]** ≥ ... ≥ **A\[iK\]\[jK\]** takes the form **9 ≥ 7 ≥ 5 ≥ 4 ≥ 3** for this sequence. One can check (for example, by brute force), that sequences of length more than **5** can't be achieved. So **5** is the answer. diff --git a/_problems/easy/LEMOUSE.md b/_problems/easy/LEMOUSE.md index 2aac8df3..3cb641b4 100644 --- a/_problems/easy/LEMOUSE.md +++ b/_problems/easy/LEMOUSE.md @@ -72,13 +72,13 @@ All submissions for this problem are available.It is well-known that the elephan The Little Elephant is on a board **A** of **n** rows and **m** columns (0-based numeration). At the beginning he is in cell with coordinates **(0; 0)** and he wants to go to cell with coordinates **(n-1; m-1)**. From cell **(x; y)** Little Elephant can go either to **(x+1; y)** or **(x; y+1)**. -Each cell of the board contains either **1** or . If **A\[i\]\[j\] = 1**, then there is a single mouse in cell **(i; j)**. Mouse at cell **(i; j)** scared Little Elephants if and only if during the path there was at least one such cell **(x; y)** (which belongs to that path) and **|i-x| + |j-y| .** +Each cell of the board contains either **1** or 0. If **A\[i\]\[j\] = 1**, then there is a single mouse in cell **(i; j)**. Mouse at cell **(i; j)** scared Little Elephants if and only if during the path there was at least one such cell **(x; y)** (which belongs to that path) and **|i-x| + |j-y| .** Little Elephant wants to find some correct path from **(0; 0)** to **(n-1; m-1)** such that the number of mouses that have scared the Little Elephant is minimal possible. Print that number. ### Input -First line contains single integer **T** - the number of test cases. Then **T** test cases follow. First line of each test case contain pair of integers **n** and **m** - the size of the board. Next **n** lines contain **n** strings, each of size **m** and consisted of digits and **1**. +First line contains single integer **T** - the number of test cases. Then **T** test cases follow. First line of each test case contain pair of integers **n** and **m** - the size of the board. Next **n** lines contain **n** strings, each of size **m** and consisted of digits 0 and **1**. ### Output @@ -112,8 +112,8 @@ In **T** lines print **T** integer - the answers for the corresponding test. 9 10 - ### Explanation + **Example case 1:** The optimized path is: (0, 0) -> (0, 1) -> (0, 2) -> (0, 3) -> (0, 4) -> (0, 5) -> (0, 6) -> (0, 7) -> (0, 8) -> (1, 8) -> (2, 8). The mouses that scared the Little Elephant are at the following cells: (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 7), (0, 2), (0, 8). **Example case 2:** The optimized path is: (0, 0) -> (1, 0) -> (1, 1) -> (2, 1) -> (2, 2) -> (3, 2) -> (3, 3) -> (4, 3) -> (4, 4) -> (5, 4) -> (5, 5) -> (6, 5) -> (6, 6) -> (6, 7) -> (6, 8). The 10 mouses that scared the Little Elephant are at the following cells: (0, 1), (1, 0), (1, 1), (2, 1), (3, 3), (4, 4), (5, 4), (5, 5), (6, 6), (6, 8). diff --git a/_problems/easy/LEMUSIC.md b/_problems/easy/LEMUSIC.md index 60e1f225..3ac0aed0 100644 --- a/_problems/easy/LEMUSIC.md +++ b/_problems/easy/LEMUSIC.md @@ -108,8 +108,8 @@ For each test, output the maximum total sweetness. Output: 12 16 - ### Explanation + In the first sample: if he listens the songs in given order, then **B1=1, L1=2**: the sweetness = **2** \* **1** = **2** **B2=2, L2=2**: the sweetness = **2** \* **2** = **4** diff --git a/_problems/easy/LEPERMUT.md b/_problems/easy/LEPERMUT.md index 3289eb1a..7d287f2b 100644 --- a/_problems/easy/LEPERMUT.md +++ b/_problems/easy/LEPERMUT.md @@ -108,8 +108,8 @@ YES YES NO YES - ### Explanation + **Case 1.** Here **N = 1**, so we have no pairs **(i; j)** with **1 ≤ i < j ≤ N**. So the number of inversions is equal to zero. The number of local inversion is also equal to zero. Hence this permutation is good. **Case 2.** Here **N = 2**, and we have one pair **(i; j)** with **1 ≤ i < j ≤ N**, the pair **(1; 2)**. Since **A\[1\] = 2** and **A\[2\] = 1** then **A\[1\] > A\[2\]** and the number of inversions is equal to **1**. The number of local inversion is also equal to **1** since we have one value of **i** for which **1 ≤ i < N** (the value **i = 1**) and **A\[i\] > A\[i+1\]** for this value of **i** since **A\[1\] > A\[2\]**. Hence this permutation is also good. diff --git a/_problems/easy/LEVY.md b/_problems/easy/LEVY.md index e3da1d07..02ea713a 100644 --- a/_problems/easy/LEVY.md +++ b/_problems/easy/LEVY.md @@ -102,8 +102,8 @@ For each test case, output the number of ordered pairs **(p, q)** of primes such 0 1 2 - ### Explanation + **Case #1:** There are no ordered pairs **(p, q)** such that **p + 2q = 2**. **Case #2:** There is only one ordered pair **(p, q) = (3, 2)** such that **p + 2q = 7**. diff --git a/_problems/easy/LEXOPAL.md b/_problems/easy/LEXOPAL.md index b20283fd..92e67b57 100644 --- a/_problems/easy/LEXOPAL.md +++ b/_problems/easy/LEXOPAL.md @@ -108,13 +108,13 @@ a.ba cb.bc a.b +
**Output**```
 
-
**Output**
 abba
 cbabc
 -1
-
 
### Explanation + **In example 1**, you can create a palindrome by filling the faded character by 'b'. **In example 2**, you can replace the faded character by any character from 'a' to 'z'. We fill it by 'a', as it will generate the lexicographically smallest palindrome. diff --git a/_problems/easy/LFEB14B.md b/_problems/easy/LFEB14B.md index f7238390..bc050405 100644 --- a/_problems/easy/LFEB14B.md +++ b/_problems/easy/LFEB14B.md @@ -101,8 +101,8 @@ For each testcase print the answer modulo **10^9+7**. 1 3 -
### Note + **Test #0-1(25 points) n ≤** 20 **Test #2(25 points) n ≤** 1000 diff --git a/_problems/easy/LFSTACK.md b/_problems/easy/LFSTACK.md index 6d0bf5b7..b71e70ec 100644 --- a/_problems/easy/LFSTACK.md +++ b/_problems/easy/LFSTACK.md @@ -141,8 +141,8 @@ For each test case, output a single line containing **Yes**, if Sergey could hav Output: Yes No -
### Explanation + **Example case 1.** First, the integers of the first thread were added: **1, 2**. Then, the integers of the second thread were added: **3, 4**. So the sequence of the additions is **1, 2, 3, 4**. Since it is a LIFO stack, when we pop, we get **4, 3, 2, 1**. This way, the given sequence is reachable. **Example case 2.** We need to get the following sequence of pushes to the stack: **3, 2, 1, 4**. So, **2** should be added before **1**. But only the first thread in the example can add these integers, and it will add **2** only **after** it has added **1**. So, the given configuration is impossible to obtain. diff --git a/_problems/easy/LIFE.md b/_problems/easy/LIFE.md index 1b845c7e..4d72b05d 100644 --- a/_problems/easy/LIFE.md +++ b/_problems/easy/LIFE.md @@ -37,11 +37,10 @@ For each test case, output the state of the game that precedes the given state. 000 000001 11110 - ### Sample Output +
01100101
 Multiple solutions
 No solution
 10010
-
 
\ No newline at end of file diff --git a/_problems/easy/LIGHTHSE.md b/_problems/easy/LIGHTHSE.md index 86cc467e..d1836f47 100644 --- a/_problems/easy/LIGHTHSE.md +++ b/_problems/easy/LIGHTHSE.md @@ -136,8 +136,8 @@ If there are many possible placements, output any one of them. 4 NE 2 NE - ### Explanation + **Example case 1.** Also we can place lighthouse on **1st** or **5th** island. **Example case 2.** Notice that some islands can be illuminated by more than 1 lighthouse. diff --git a/_problems/easy/LIKECS02.md b/_problems/easy/LIKECS02.md index bed822c3..3d527a7f 100644 --- a/_problems/easy/LIKECS02.md +++ b/_problems/easy/LIKECS02.md @@ -103,21 +103,21 @@ If the solution exists, output **N** space separated integers denoting the eleme
 1 ≤ T ≤ 20
 1 ≤ N ≤ 100
-
 
### Sample Input +
 3
 1
 2
 3
-
 
### Sample Output +
 1
 1 2
 1 2 3
-
 
### Explanation + For test case **3**, the subarrays and their median are as follows: 1. **{1}**, median = **1** diff --git a/_problems/easy/LIKECS03.md b/_problems/easy/LIKECS03.md index 2e45e23c..51155ad6 100644 --- a/_problems/easy/LIKECS03.md +++ b/_problems/easy/LIKECS03.md @@ -116,18 +116,18 @@ Output the minimum number of elements that need to be inserted so that inifinite 1 ≤ Sum of N over all test cases ≤ 105 1 ≤ K ≤ 20 0 ≤ A[i] ≤ 2K-1, where A[i] denotes the ith element of the array. - ### Sample Input - 1 +
 1
 2 2
 3 1
-
 
### Sample Output - 1 +
 1
-
 
### Explanation - 1 + You can win the game by inserting the element **2** into the array. ### Sample Input - 2 @@ -136,10 +136,10 @@ You can win the game by inserting the element **2** into the array. 1 7 3 3 7 5 4 6 2 1 - ### Sample Output - 2 +
 0
-
 
### Explanation - 2 + The initial array will result will terminate in the first step of algorithm only. Thus there is no need to insert any new element. diff --git a/_problems/easy/LNGHW.md b/_problems/easy/LNGHW.md index fe7e7584..5f7d3bf2 100644 --- a/_problems/easy/LNGHW.md +++ b/_problems/easy/LNGHW.md @@ -34,7 +34,7 @@ The first line of each test case contains three integer **N**, **Q** and **M** d For each query output one integer, **j**(1-indexed), which is the index such that a\[j\] is the ith smallest element for which **a\[j\]%M = R**. If it doesn't exist then print **-1**### Constraints 35. **1** ≤ **N, Q, M** ≤ **2\*105** -36. ≤ **R** ≤ **M** +36. 0 ≤ **R** ≤ **M** 37. **1** ≤ **A\[i\]** ≤ **2\*108** ### Subtasks @@ -57,7 +57,7 @@ For each query output one integer, **j**(1-indexed), which is the index such tha 5 4 -1 - - ```### Explanation + ``` + ### Explanation **Example case 1.** For the first query the answer is 1 because a\[1\] is 1, which is the smallest element in the array with remainder 1. diff --git a/_problems/easy/LOKBIL.md b/_problems/easy/LOKBIL.md index 5ce18001..49355007 100644 --- a/_problems/easy/LOKBIL.md +++ b/_problems/easy/LOKBIL.md @@ -64,5 +64,4 @@ There are atmost 100 groups. Output: 4 1.166667 - \ No newline at end of file diff --git a/_problems/easy/LRQUER.md b/_problems/easy/LRQUER.md index 76db8aec..ecb33228 100644 --- a/_problems/easy/LRQUER.md +++ b/_problems/easy/LRQUER.md @@ -112,6 +112,6 @@ For every Chuwi's performed operation output the maximal value in a single line. 0 1 - ### Explanation + **Example case 1.** For Chuwi's subarray \[2, 1, 4, 3\] there are 4 possible values of (**A**\[**M**\] - **A**\[**L**\]) \* (**A**\[**R**\] - **A**\[**M**\]) - {0, -2, -2, 0} correspondingly, maximal value will be 0. After the second operation array will be \[2, 3, 4, 3\]. And for Chuwi's subarray \[2, 3, 4\] possible 3 values - {0, 1, 0}, hence answer is 1. diff --git a/_problems/easy/LTM40CD.md b/_problems/easy/LTM40CD.md index 6a843369..5942e36c 100644 --- a/_problems/easy/LTM40CD.md +++ b/_problems/easy/LTM40CD.md @@ -113,5 +113,4 @@ Order the sides of triangles in non-decreasing order. Output all triangles in no 6 25 29 7 15 20 9 10 17
- \ No newline at end of file diff --git a/_problems/easy/LUCKY1.md b/_problems/easy/LUCKY1.md index ffae3472..d407c6c9 100644 --- a/_problems/easy/LUCKY1.md +++ b/_problems/easy/LUCKY1.md @@ -42,5 +42,4 @@ layout: problem 6 31 1266 - \ No newline at end of file diff --git a/_problems/easy/LUCKY10.md b/_problems/easy/LUCKY10.md index fbef2a8c..c6f4b9c8 100644 --- a/_problems/easy/LUCKY10.md +++ b/_problems/easy/LUCKY10.md @@ -112,8 +112,8 @@ Sum of |**A**| across all the tests in the input does not exceed **200000**. 74 777744 - ### Explanation + **Case 1.** In this case the only possible string **C** we can get is **"7"** and it is the lucky string. **Case 2.** If we reorder **A** and **B** as **A = "543"** and **B = "749"** the string **C** will be at first **"749"** and then becomes **"74"**. It can be shown that this is the lexicographically greatest string for the given **A** and **B**. diff --git a/_problems/easy/LUCKY2.md b/_problems/easy/LUCKY2.md index c84a3ff8..d4100f4d 100644 --- a/_problems/easy/LUCKY2.md +++ b/_problems/easy/LUCKY2.md @@ -100,8 +100,8 @@ For each of the **T** test cases print one integer, the number of such **X**, th 16 640 2 - ### Notes + First test case: of course, any number of less than 4 digits can't contain lucky number of lucky digits, so the answer is 0. Second test case: 16 required numbers are **4444 4447 4474 4477 4744 4747 4774 4777 7444 7447 7474 7477 7744 7747 7774 7777**. diff --git a/_problems/easy/LUCKY5.md b/_problems/easy/LUCKY5.md index 9179cd96..a6ef4bd1 100644 --- a/_problems/easy/LUCKY5.md +++ b/_problems/easy/LUCKY5.md @@ -49,5 +49,4 @@ For each **T** test cases print one integer, the minimum number of operations th 1 2 - \ No newline at end of file diff --git a/_problems/easy/LUCKYBAL.md b/_problems/easy/LUCKYBAL.md index f9042916..326fa595 100644 --- a/_problems/easy/LUCKYBAL.md +++ b/_problems/easy/LUCKYBAL.md @@ -109,8 +109,8 @@ For each test case output a single line containing the answer for this test case 3 23 - ### Explanation + In the first test case balance substrings are **S\[1, 1\] = 4** and **S\[1, 2\] = 47**. In the second test case balance substrings are **S\[2, 2\] = 4** and **S\[1, 2\] = 74**. diff --git a/_problems/easy/LUCKYSTR.md b/_problems/easy/LUCKYSTR.md index b05f5825..65bd4c5b 100644 --- a/_problems/easy/LUCKYSTR.md +++ b/_problems/easy/LUCKYSTR.md @@ -77,7 +77,7 @@ The Little Elephant has found **N** lucky strings **B1, B2, ..., BN** under the Let **S** be some lucky string. Then - **|S|** denotes the length of the string **S**; - **S\[i\]** (**1 ≤ i ≤ |S|**) denotes the **i**th character of **S** (the numeration of characters starts from **1**); -- The string **T** of the length **M** is called a _substring_ of **S** if for some **k** from to **|S| - M** we have +- The string **T** of the length **M** is called a _substring_ of **S** if for some **k** from 0 to **|S| - M** we have **T\[1\] = S\[k + 1\], T\[2\] = S\[k + 2\], ..., T\[M\] = S\[k + M\]**. ### Input @@ -115,8 +115,8 @@ Good Bad Good - ### Explanation + The string **S = 7444** is good since the favorite string **744** is its substring. The string **S = 447** is good since the favorite string **47** is its substring. diff --git a/_problems/easy/LUMPYBUS.md b/_problems/easy/LUMPYBUS.md index fb13b6ef..01bc4274 100644 --- a/_problems/easy/LUMPYBUS.md +++ b/_problems/easy/LUMPYBUS.md @@ -95,7 +95,7 @@ For each test case, output a single line containing an integer corresponding to - **1** ≤ **T** ≤ **106** - **1** ≤ **N** ≤ **105** - **1** ≤ **Ai** ≤ **109** -- ≤ **P, Q** ≤ **1014** +- 0 ≤ **P, Q** ≤ **1014** - Sum of **N** over all the cases does not exceed **106** ### Subtasks @@ -121,8 +121,8 @@ For each test case, output a single line containing an integer corresponding to 2 3 3 - ### Explanation + In Test **1**, Lumpy has just **3** one rupee coins. He can pay creatures numbered **{1, 2}** or creatures numbered **{1, 3}** with these coins. Thus, answer is 2. In Test **2**, Lumpy has **2** one rupee coins and **1** two rupee coin. In the optimal solution, Lumpy can give the two rupee coin to creature **2** and the one rupee coins to creatures **1** and **3**. Thus, answer is 3. diff --git a/_problems/easy/LWS.md b/_problems/easy/LWS.md index ad0b52ec..e0f20ffa 100644 --- a/_problems/easy/LWS.md +++ b/_problems/easy/LWS.md @@ -87,8 +87,8 @@ For every test case, output the length of the LWS of the given string. 1 ≤ T ≤ 10 1 ≤ length of S ≤ 2000 - ### Example +
 Input
 3
@@ -101,8 +101,8 @@ ddaabbaacc
 6
 10
 
-
 
### Explanation + **First case:** The string itself is LWS since it can be split into non-decreasing subsequence **"abc"** and non-increasing empty subsequence. **Second case:** One of the possible LWS is **"cbaabc"** since it can be split as **"cbaABC"**. Here we indicate by capital letters non-decreasing subsequence and by lowercase letters non-increasing one. Other possible LWS's are **"cbaZZa", "AzyaBC"**. diff --git a/_problems/easy/MAANDI.md b/_problems/easy/MAANDI.md index 19e6555c..d3d1efa5 100644 --- a/_problems/easy/MAANDI.md +++ b/_problems/easy/MAANDI.md @@ -112,5 +112,4 @@ For each test case on different lines print the answer to the problem. 0 0 - \ No newline at end of file diff --git a/_problems/easy/MAKEART.md b/_problems/easy/MAKEART.md index b34ac327..2b7e95e5 100644 --- a/_problems/easy/MAKEART.md +++ b/_problems/easy/MAKEART.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in [ Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only. -Chef's canvas is **N** millimeters long and is initially all white. For simplicity, colors will be represented by an integer between and **105**. indicates white. The picture he is envisioning is also **N** millimeters long and the **i**th millimeter consists purely of the color **Ci**. Unfortunately, his brush isn't fine enough to paint every millimeter one by one. The brush is 3 millimeters wide and so it can only paint three millimeters at a time _with the same color._ Painting over the same place completely replaces the color by the new one. Also, Chef has lots of bottles of paints of each color, so he will never run out of paint of any color. +Chef's canvas is **N** millimeters long and is initially all white. For simplicity, colors will be represented by an integer between 0 and **105**. 0 indicates white. The picture he is envisioning is also **N** millimeters long and the **i**th millimeter consists purely of the color **Ci**. Unfortunately, his brush isn't fine enough to paint every millimeter one by one. The brush is 3 millimeters wide and so it can only paint three millimeters at a time _with the same color._ Painting over the same place completely replaces the color by the new one. Also, Chef has lots of bottles of paints of each color, so he will never run out of paint of any color. Chef also doesn't want to ruin the edges of the canvas, so he doesn't want to paint any part beyond the painting. This means, for example, Chef cannot paint just the first millimeter of the canvas, or just the last two millimeters, etc. @@ -115,6 +115,7 @@ Yes No
### Explanation
+
 **Example case 1.** Chef's canvas initially contains the colors \[0,0,0,0\]. Chef can finish the painting by first painting the first three millimeters with color 1, so the colors become \[1,1,1,0\], and then the last three millimeters with color 5 so that it becomes \[1,5,5,5\].
 
 **Example case 2.** Chef's canvas initially contains the colors \[0,0,0,0\]. Chef can finish the painting by first painting the last three millimeters by color 5 so the colors become \[0,5,5,5\], and then the first three millimeters by color 1 so it becomes \[1,1,1,5\].
diff --git a/_problems/easy/MAKETRI.md b/_problems/easy/MAKETRI.md
index 85493fa0..becee5a4 100644
--- a/_problems/easy/MAKETRI.md
+++ b/_problems/easy/MAKETRI.md
@@ -119,6 +119,6 @@ Output a single line corresponding to the answer of the problem.
 
 Output:
 3
-
 
### Explanation + If Chef chooses the strand of length 1, he can't form a triangle using this strand and the any of the pair of strands of length 1, 2, 3, 4, 5. However, for each of the extra strand of length 2, 3, 4, one can find at least one pair of strands such that those pair of strands and the extra strand makes a triangle. So, the answer will be 3. diff --git a/_problems/easy/MANYCHEF.md b/_problems/easy/MANYCHEF.md index 82f328f3..996e0f8a 100644 --- a/_problems/easy/MANYCHEF.md +++ b/_problems/easy/MANYCHEF.md @@ -107,8 +107,8 @@ CHEFCIELISOURCHEF TAKEITEASY CHEFCHEF AAACHEF - ### Explanation + **Example Case 1.** Here the resulting string can have at most 2 substrings equal to **"CHEF"**. For example, some possible such strings are: - **CHEF**CIELISA**CHEF** diff --git a/_problems/easy/MARBLEGF.md b/_problems/easy/MARBLEGF.md index fcd7c385..ac8c7954 100644 --- a/_problems/easy/MARBLEGF.md +++ b/_problems/easy/MARBLEGF.md @@ -121,7 +121,7 @@ The output should contain as many lines as the number of queries S and it should - **The array is 0-indexed.** - **1000** ≤ **A\[i\]** ≤ **2000** - **A student can never have a negative value of marbles. (i.e. there's no data which can cause a student to have a negative value of marbles)** -- ≤ **i, j** ≤ **N-1**, and **i** ≤ **j** for the sum query +- 0 ≤ **i, j** ≤ **N-1**, and **i** ≤ **j** for the sum query - **At any given time, it is assured that the maximum number of marbles each student can have (**num\_marbles**) never exceeds the size of the int data type.** ### Example diff --git a/_problems/easy/MARCHA1.md b/_problems/easy/MARCHA1.md index 36da00e6..94ec2cc3 100644 --- a/_problems/easy/MARCHA1.md +++ b/_problems/easy/MARCHA1.md @@ -83,5 +83,4 @@ Yes Yes No Yes - -**Explanation:** For example, in the last case you have to pay up, since: 6+3+123=132. \ No newline at end of file +**Explanation:** For example, in the last case you have to pay up, since: 6+3+123=132. diff --git a/_problems/easy/MARCHA2.md b/_problems/easy/MARCHA2.md index ec4ce9d4..51b4a81b 100644 --- a/_problems/easy/MARCHA2.md +++ b/_problems/easy/MARCHA2.md @@ -41,5 +41,4 @@ For each test case, output a line containing exactly one of the words 'Yes' or ' Output: Yes No - \ No newline at end of file diff --git a/_problems/easy/MATDYS.md b/_problems/easy/MATDYS.md index 6bcf548a..3b7971e6 100644 --- a/_problems/easy/MATDYS.md +++ b/_problems/easy/MATDYS.md @@ -125,15 +125,15 @@ The output file will contain **Q** lines, each one representing the answer to on 1 6 2 - -
Input:
+
+
Input:
 1
 64 11047805202224836936
 
 Output:
 1337369305470044825
-
 
### Explanation +
 In all questions, we have N = 3. Therefore, we have a deck with 8 cards.
 The shuffling is done in three steps:
@@ -152,5 +152,4 @@ Step 2: We divide {0, 4, 2, 6, 1, 5, 3, 7} in 22 decks. We get four d
 The card labelled 4 is on position 1.
 The card labelled 3 is on position 6.
 The card labelled 2 is on position 2.
-
 
\ No newline at end of file diff --git a/_problems/easy/MATTEG.md b/_problems/easy/MATTEG.md index 802c9b4f..b36a7ec0 100644 --- a/_problems/easy/MATTEG.md +++ b/_problems/easy/MATTEG.md @@ -179,8 +179,8 @@ All submissions for this problem are available.### Read problems statements in [ 188 24 3 - ### Explanation +
 First test
 Mathison starts at (2, 2).
@@ -196,5 +196,4 @@ Third test
 Mathison starts at (1, 1).
 Mathison has one tel-pair, (2, 2).
 He can't use the tel-pair so the answer is 3 (the value of the starting cell).
-
 
\ No newline at end of file diff --git a/_problems/easy/MAXCOMP.md b/_problems/easy/MAXCOMP.md index 1e1c10ae..1f90ccac 100644 --- a/_problems/easy/MAXCOMP.md +++ b/_problems/easy/MAXCOMP.md @@ -104,8 +104,8 @@ Output for each test case should contain a single integer in a separate line, th Output: 3700 2000 - ### Explanation + **Case 1.** The best choice here is to conduct **3**rd and **4**th events. The total compensation is equal to **1600 + 2100 = 3700**. These events do not overlap since **3**rd event starts just after the finish of the **4**th one. Alternatively we can conduct first three events that also do not overlap. But in this case compensation will be only **100 + 200 + 1600 = 1900**. **Case 2.** Note that first event overlaps with both second and third events, while the last two events do not overlap. Hence there are two reasonable choices available for Chef. One is to take just the first order with total compensation **2000** and the second one is to take the last two orders with total compensation **100 + 400 = 500**. Clearly the first choice is better. Hence the answer is **2000**. diff --git a/_problems/easy/MAXCOUNT.md b/_problems/easy/MAXCOUNT.md index 42ba666e..697b2897 100644 --- a/_problems/easy/MAXCOUNT.md +++ b/_problems/easy/MAXCOUNT.md @@ -38,5 +38,4 @@ For each test case, output two space separated integers V & C. V is the value wh Description: In first case 2 occurs twice whereas all other elements occur only once. In second case, both 1 and 2 occur 3 times but 1 is smaller than 2. - \ No newline at end of file diff --git a/_problems/easy/MAXDIFF.md b/_problems/easy/MAXDIFF.md index a9b8ac23..92727fe0 100644 --- a/_problems/easy/MAXDIFF.md +++ b/_problems/easy/MAXDIFF.md @@ -104,8 +104,8 @@ For each test case, output the maximum possible difference between the weights c Output: 17 2 - ### Explanation: + **Case #1:** The optimal way is that Chef gives his son **K=2** items with weights **2** and **4**. Chef carries the rest of the items himself. Thus the difference is: **(8+5+10) − (4+2) = 23 − 6 = 17**. **Case #2:** Chef gives his son **3** items and he carries **5** items himself. diff --git a/_problems/easy/MAXDIST.md b/_problems/easy/MAXDIST.md index a5fcbde6..b46cb9ca 100644 --- a/_problems/easy/MAXDIST.md +++ b/_problems/easy/MAXDIST.md @@ -105,8 +105,8 @@ For each test case, output a single line print "YES" if it is possible to add a NO YES YES - ### Explanation + **Example case 1.** In this example, we can use just cycle edges, or a parallel edge but these edges don't change the distance of the 1-2 nodes. ![HTML5 Icon](https://dl.dropboxusercontent.com/u/61869957/example1.bmp) **Example case 2.**The original graph diameter is two because distance(1,3)=2, distance(1,2)=1 and distance(2,3)=1, if we connect 1,3 nodes then distance(1,3) will be 1 so the diameter decrease to 1. ![HTML5 Icon](https://dl.dropboxusercontent.com/u/61869957/example2.bmp) diff --git a/_problems/easy/MAXIEDGE.md b/_problems/easy/MAXIEDGE.md index ca6438a0..3efb3c60 100644 --- a/_problems/easy/MAXIEDGE.md +++ b/_problems/easy/MAXIEDGE.md @@ -107,8 +107,8 @@ aa bb bbac bbac - ### Explanation + Let (r, c) denote the cell on the r-th row and c-th column. **Example case 1**: The score of the new grid is 2. The two unordered pairs of cells are {(1, 1), (1, 2)} (these two cells share a side, and have the same letter 'a' in them) and {(2, 1), (2, 2)} (these two cells share a side, and have the same letter 'b' in them). This is the maximum score that we can obtain. diff --git a/_problems/easy/MAXISUM.md b/_problems/easy/MAXISUM.md index 8056b1a8..507a72d0 100644 --- a/_problems/easy/MAXISUM.md +++ b/_problems/easy/MAXISUM.md @@ -130,7 +130,7 @@ Find out the maximum value of _interaction_ of the arrays that you can get. Output: 10 44 - ### Explanation + **In the first example**, you can increase value **A\[2\]** using two two operations. Now, **A** would be \[1, 4\]. The value of _interaction_ will be 1 \* -2 + 4 \* 3 = -2 + 12 = 10. diff --git a/_problems/easy/MAXNUM3.md b/_problems/easy/MAXNUM3.md index 36c5517a..53769583 100644 --- a/_problems/easy/MAXNUM3.md +++ b/_problems/easy/MAXNUM3.md @@ -110,5 +110,4 @@ Subtasks: 12 00222 -1 - \ No newline at end of file diff --git a/_problems/easy/MAXPR.md b/_problems/easy/MAXPR.md index 1fce9505..252c95c1 100644 --- a/_problems/easy/MAXPR.md +++ b/_problems/easy/MAXPR.md @@ -114,5 +114,4 @@ For each test case print the remainder of the division the answer on **100000000 0 1 - \ No newline at end of file diff --git a/_problems/easy/MAXSEGM.md b/_problems/easy/MAXSEGM.md index 4dd9f561..842647dc 100644 --- a/_problems/easy/MAXSEGM.md +++ b/_problems/easy/MAXSEGM.md @@ -91,8 +91,8 @@ For each testcase, output a single integer in a new line, which should be the ma - **1** ≤ **T** ≤ **100** - **1** ≤ **N** ≤ **1000000** -- ≤ **Ci** N -- ≤ **Wi** ≤ **1000000000** +- 0 ≤ **Ci** N +- 0 ≤ **Wi** ≤ **1000000000** - **1** ≤ Sum of **N** over all test cases ≤ **1000000** ### Subtasks @@ -110,6 +110,6 @@ For each testcase, output a single integer in a new line, which should be the ma Output: 21 - ### Explanation + The range \[2, 4\] is an _unique_ range because (1, 2, 0) has no duplicates. Its _sum_ is 6 + 7 + 8 = 21. This is the maximum possible, and hence is the answer. diff --git a/_problems/easy/MCHAIRS.md b/_problems/easy/MCHAIRS.md index b76de466..4afe85b3 100644 --- a/_problems/easy/MCHAIRS.md +++ b/_problems/easy/MCHAIRS.md @@ -105,5 +105,4 @@ For each test case, you should output an integer, denoting the sum of the number Output: 1 3 - \ No newline at end of file diff --git a/_problems/easy/MCHEF.md b/_problems/easy/MCHEF.md index ef7183ee..7f2511cb 100644 --- a/_problems/easy/MCHEF.md +++ b/_problems/easy/MCHEF.md @@ -121,6 +121,6 @@ For each test case, print a single integer in a line corresponding to the answer output 5 - ### Explanation + - Chef can drop dish numbered 3rd with rating -5 by paying 10 rupees to the 4th judge, and get the maximum possible total rating of 5. diff --git a/_problems/easy/MEX.md b/_problems/easy/MEX.md index 2d64d3d2..53c9ebf0 100644 --- a/_problems/easy/MEX.md +++ b/_problems/easy/MEX.md @@ -96,8 +96,8 @@ For each testcase, output the answer in a single line. - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **105** -- ≤ **K** ≤ **105** -- ≤ **Si** ≤ **2 \* 105** +- 0 ≤ **K** ≤ **105** +- 0 ≤ **Si** ≤ **2 \* 105** ### Subtasks @@ -122,8 +122,8 @@ For each testcase, output the answer in a single line. 4 6 0 - ### Explanation + **Example case 1.** As **K** = 0, so we can't add any element to the multi-set. Elements of the set are {1, 0, 2}. The MEX value of this set is 3. **Example case 2.** As **K** = 1, you are allowed to add at most 1 element to the multi-set. The multi-set are {1, 0, 2}. You can add element 3 to the multi-set, and it becomes {1, 0, 2, 3}. The MEX value of this multi-set is 4. There is no other way to have higher value of MEX of the set by adding at most one element to the multi-set. diff --git a/_problems/easy/MEXDIV.md b/_problems/easy/MEXDIV.md index 7ddd4ac8..dd492075 100644 --- a/_problems/easy/MEXDIV.md +++ b/_problems/easy/MEXDIV.md @@ -93,13 +93,12 @@ Given an array **A** of **n** non-negative integers. Find the number of ways to Output: 2 -
Input:
 10 3
 0 1 2 3 4 0 1 2 5 3
 
 Output:
 379
-
 
### Explanation + **Example 1**. The valid ways of partitioning will be \[\[0\], \[1, 2\]\] (mex of first subarray is 1, while that of the second is zero), and \[\[0\], \[1\], \[2\]\] (mex of first subarray is 1, and that of others is 0). There is no other way to partition the array such that mex is less than or equal to 1. For example, \[\[0, 1\], \[2\]\] is not a valid partitioning as mex of first subarray is 2 which is more than 1. diff --git a/_problems/easy/MFREQ.md b/_problems/easy/MFREQ.md index 2a4059ad..b06cdf46 100644 --- a/_problems/easy/MFREQ.md +++ b/_problems/easy/MFREQ.md @@ -88,7 +88,7 @@ Output M lines where each line contains the answer to the **i**-th query. - **1** ≤ **N, M** **≤ 105** - **1** ≤ **L** ≤ **R** ≤ **N** - **floor((R-L+1)/2)** k ≤ **R-L+1** -- ≤ **Ai** ≤ **109** +- 0 ≤ **Ai** ≤ **109** ### Subtasks @@ -115,6 +115,6 @@ Output M lines where each line contains the answer to the **i**-th query. Output: 2 - ### Explanation + The element 2 occurs more than 3 times in the range \[1,5\]. diff --git a/_problems/easy/MGCRNK.md b/_problems/easy/MGCRNK.md index 42027799..110685fa 100644 --- a/_problems/easy/MGCRNK.md +++ b/_problems/easy/MGCRNK.md @@ -115,5 +115,4 @@ Your code will be judged against several input files. Output: 8.000000 Bad Judges - \ No newline at end of file diff --git a/_problems/easy/MIKE1.md b/_problems/easy/MIKE1.md index fdc8a0c2..c0a135b3 100644 --- a/_problems/easy/MIKE1.md +++ b/_problems/easy/MIKE1.md @@ -104,7 +104,6 @@ The first line should contain an integer, denoting **max(**E1**, **E2**)**. 2 2 Output: 9 -
Input:
 1 3
 1 2 3
@@ -113,7 +112,6 @@ The first line should contain an integer, denoting **max(**E1**, **E2**)**.
 3 1
 Output:
 -1
-
 
Input:
 1 3
 1 2 3
@@ -122,8 +120,8 @@ The first line should contain an integer, denoting **max(**E1**, **E2**)**.
 3 1
 Output:
 4
-
 
### Explanation + In the first test case **N** equals to 3, **M** equals to 2, **L** equals to 2. **E1** = 2 + 5 = 7, **E2** = 4 + 5 = 9. The answer is **max(**E1**, **E2**)** = **max(**7**,** 9**)** = 9; In the second test case **N** equals to 1, **M** equals to 3, **L** equals to 2. It is impossible to calculate **E1** and **E2**, because **A3, 1** doesn't exist. So the answer is **max(**E1**, **E2**)** = **max(**-1**,** -1**)** = -1; diff --git a/_problems/easy/MIKE3.md b/_problems/easy/MIKE3.md index d8331cc3..4fda2985 100644 --- a/_problems/easy/MIKE3.md +++ b/_problems/easy/MIKE3.md @@ -106,6 +106,6 @@ Output should contain the only integer, denoting the maximal number of the offer Output: 2 - ### Explanation + In the example test Mike should accept the first and the third offer. diff --git a/_problems/easy/MIME2.md b/_problems/easy/MIME2.md index 2c62ec2f..df30c2f5 100644 --- a/_problems/easy/MIME2.md +++ b/_problems/easy/MIME2.md @@ -39,13 +39,12 @@ nodotsatall virus.exe dont.let.the.png.fool.you case.matters.TXT - ### Sample Output +
text/html
 text/plain
 unknown
 unknown
 unknown
 unknown
-
 
\ No newline at end of file diff --git a/_problems/easy/MINIMAX.md b/_problems/easy/MINIMAX.md index 07db607e..aa2a95e4 100644 --- a/_problems/easy/MINIMAX.md +++ b/_problems/easy/MINIMAX.md @@ -122,8 +122,8 @@ Print one integer, denoting the minimum number of changes required to make the g Output3: 2 - ### Explanation + **Example #1.** In the first example, initially we have r1 = 10, r2 = 10 and r3 = 5. For columns, we have C1 = 20, C2 = 20 and C3 = 35. max(r1, r2, r3) = 10 and min(C1, C2, C3) = 20, and so the given grid isn't nice. Chef can change the second number in the first row from 20 to 10, to get the following nice grid: @@ -132,4 +132,5 @@ max(r1, r2, r3) = 10 and min(C1, C2, C3) = 20, and so the given grid isn't nice. 20 10 30 10 5 35 The answer is 1 because we must change at least 1 number. + **Example #2.** The provided grid is already nice, so the answer is 0. diff --git a/_problems/easy/MINPERM.md b/_problems/easy/MINPERM.md index 959908f5..7190ee0d 100644 --- a/_problems/easy/MINPERM.md +++ b/_problems/easy/MINPERM.md @@ -124,8 +124,8 @@ For each test case, output the lexicographically smallest _good_ permutation of 2 3 1 2 1 4 5 3 2 1 4 3 6 5 - ### Explanation + **Example case 1.** The only _good_ permutation of length 2 is (2, 1). **Example case 2.** Consider all permutations of length 3, they are(in lexicographically order): diff --git a/_problems/easy/MINSUBAR.md b/_problems/easy/MINSUBAR.md index f976d285..0c48fb58 100644 --- a/_problems/easy/MINSUBAR.md +++ b/_problems/easy/MINSUBAR.md @@ -115,5 +115,4 @@ For each test case, print a single line containing one integer — the length of 2 1 - \ No newline at end of file diff --git a/_problems/easy/MISINTER.md b/_problems/easy/MISINTER.md index ace39568..cbedb79c 100644 --- a/_problems/easy/MISINTER.md +++ b/_problems/easy/MISINTER.md @@ -37,11 +37,10 @@ For each test case, print the number of words of length N that Chef can use; tha 14 45 - **Sample output** +
26
 456976
 827063120
 
-
 
\ No newline at end of file diff --git a/_problems/easy/MKSQR.md b/_problems/easy/MKSQR.md index ad19e6fb..1eb10071 100644 --- a/_problems/easy/MKSQR.md +++ b/_problems/easy/MKSQR.md @@ -43,12 +43,12 @@ Output should contain exactly t lines, with "YES" or "NO" ( without the quotes - 10 -6 -5 -1 1 -1 - ### Sample Output +
 YES
 YES
-
 
### Explanation + Test case 1 : a1 = 0 , a2 = 1, a3 = 1. Test case 2 : a1 = 2 , a2 = 0 , a3 = 1, a4 = 3. diff --git a/_problems/easy/MMSUM.md b/_problems/easy/MMSUM.md index 983431ef..57a6e211 100644 --- a/_problems/easy/MMSUM.md +++ b/_problems/easy/MMSUM.md @@ -108,6 +108,6 @@ For each test case, output a single line containing the maximal possible maximal Output: 8 -1 - ### Explanation + **Example case 1.** As shown in the statement, the maximal sum of the initial array is **6**, but if you remove the fourth element (i.e. **-2**), then the array **\[1, -2, 3, 5\]** will have subarray **\[3, 5\]** and the value of the maximal sum will be equal to **8**. diff --git a/_problems/easy/MONTRANS.md b/_problems/easy/MONTRANS.md index 91c874f6..0230a030 100644 --- a/_problems/easy/MONTRANS.md +++ b/_problems/easy/MONTRANS.md @@ -34,6 +34,6 @@ Of course, you want to do this to maximize your profit. For example if **C=69** Output: 4 0 - ### Explanation + In the first test we have the following sequence: **9.77, 8.09, 40.07, 38.39, 70.37, 68.69, 0.68**. After last step we have not enough money for further transformations. The maximal profit will be after **4** transformations. diff --git a/_problems/easy/MOVES.md b/_problems/easy/MOVES.md index 2f5e1daa..383c8687 100644 --- a/_problems/easy/MOVES.md +++ b/_problems/easy/MOVES.md @@ -34,5 +34,4 @@ For each test case, output on a line an integer which is the result calculated. 4 8 18 - -Explanation for the first sample test case: 4 ways are **RRDDDR, RDDDRR, DRRRDD, DDRRRD** ('R' or 'D' represents a right or down move respectively). \ No newline at end of file +Explanation for the first sample test case: 4 ways are **RRDDDR, RDDDRR, DRRRDD, DDRRRD** ('R' or 'D' represents a right or down move respectively). diff --git a/_problems/easy/MTRNSFRM.md b/_problems/easy/MTRNSFRM.md index 6706ccb9..b673cf9d 100644 --- a/_problems/easy/MTRNSFRM.md +++ b/_problems/easy/MTRNSFRM.md @@ -128,9 +128,9 @@ For each test case, output a single integer ― the minimal number of moves Chef 3 -1 9 - ### Explanation + **Example case 1.** We can transform the matrix **A** into **B** in three moves: ``` 1 1 -> 1 2 -> 1 2 -> 1 2 1 1 -> 1 2 -> 2 3 -> 3 4 -
**Example case 2.** It is impossible to make these matrices equal using only the allowed moves. **Example case 3.** We can transform matrix **A** into **4 5 7 7** in six moves and matrix **B** into the same **4 5 7 7** in three moves.
\ No newline at end of file
+
**Example case 2.** It is impossible to make these matrices equal using only the allowed moves. **Example case 3.** We can transform matrix **A** into **4 5 7 7** in six moves and matrix **B** into the same **4 5 7 7** in three moves.
diff --git a/_problems/easy/MTRWY.md b/_problems/easy/MTRWY.md
index 704d62fc..3b9ffac8 100644
--- a/_problems/easy/MTRWY.md
+++ b/_problems/easy/MTRWY.md
@@ -78,7 +78,7 @@ Now you are given **Q** queries, each of whom is of following four types.
 
 - **1 x y** - build the wall between cells **(x, y)** and **(x, y+1)**. If there is already exist a wall between them, this query is ignored.
 - **2 x y** - build the wall between cells **(x, y)** and **(x+1, y)**. If there is already exist a wall between them, this query is ignored.
-- **3 x1 y1 x2 y2** - check if cells **(x1, y1)** and **(x2, y2)** are connected. You must answer **1** if they are connected,  otherwise.
+- **3 x1 y1 x2 y2** - check if cells **(x1, y1)** and **(x2, y2)** are connected. You must answer **1** if they are connected, 0 otherwise.
 - **4** - You must answer the size of the largest connected component. A connected component is a set of sells wherein each two cells are connected. The size of a connected component is a number of the cells in it.
 
 You must assume that there are no walls on the grid before the queries.
@@ -133,8 +133,8 @@ For each test case, output an integer, denoting the sum of answers for queries o
 
 Output:
 21
-
 
### Explanation + **Query 1.** There are a lot of ways from **(1,1)** to **(3,4)**. One of them is marked in red in the picture #1. So these are connected, then **Answer = 1** in this query. **Query 2.** In the picture #2 you can see the grid after second query. diff --git a/_problems/easy/MTRXMOD.md b/_problems/easy/MTRXMOD.md index d0589913..3d09365e 100644 --- a/_problems/easy/MTRXMOD.md +++ b/_problems/easy/MTRXMOD.md @@ -99,9 +99,9 @@ Print **Q + 1** lines which contain **N** space-separated integers, Miron's init - **3** ≤ **N** ≤ **1000** - **1** ≤ **Q** ≤ **1000** -- ≤ **Bi,j** ≤ **5000** +- 0 ≤ **Bi,j** ≤ **5000** - **1** ≤ **p** ≤ **n** -- ≤ **Fi** ≤ **5000** +- 0 ≤ **Fi** ≤ **5000** - it's guaranteed there's always an answer ### Example @@ -119,6 +119,6 @@ Print **Q + 1** lines which contain **N** space-separated integers, Miron's init 0 -1 -2 0 -4 -3 0 -4 3 -
### Explanation + **Example case 1.** Initially, sequence **{0, 1, 2}** is also suitable, but **{0, -1, -2}** is lexicografically smaller. diff --git a/_problems/easy/MVCOIN.md b/_problems/easy/MVCOIN.md index c78cb9bd..7f0d7550 100644 --- a/_problems/easy/MVCOIN.md +++ b/_problems/easy/MVCOIN.md @@ -44,5 +44,4 @@ For each test case output one line containing the requested minimal time for Bob 0 Explanation: - -In the first example Bob can move the coin from cell 7 consequently to cells 6, 5, 3 and 1, then move the coin from cell 4 to cell 3. In the second example there is nothing to move. \ No newline at end of file +In the first example Bob can move the coin from cell 7 consequently to cells 6, 5, 3 and 1, then move the coin from cell 4 to cell 3. In the second example there is nothing to move. diff --git a/_problems/easy/MXMEDIAN.md b/_problems/easy/MXMEDIAN.md index 38efb6d0..8c86f39b 100644 --- a/_problems/easy/MXMEDIAN.md +++ b/_problems/easy/MXMEDIAN.md @@ -124,8 +124,8 @@ In the second line, print **2 \* N** integers in a single line denoting any perm 1 3 2 5 4 6 3 1 3 3 3 2 2 - ### Explanation + **Example case 1.** There are only two possible permutations of **A**, for both of those B will be 2. The median of B is 2. **Example case 2.** For following permutation of A: 1 3 2 5 4 6, the corresponding B will be: 3 5 6, whose median is 5, which is the maximum that you can achieve. diff --git a/_problems/easy/MXSUBARR.md b/_problems/easy/MXSUBARR.md index c2860e61..35ab5898 100644 --- a/_problems/easy/MXSUBARR.md +++ b/_problems/easy/MXSUBARR.md @@ -121,8 +121,8 @@ For each test case, output a single line corresponding to maximum number of grou 1 3 18 - ### Explanation + **Example case 1.** **M** will be equal to 2. The subarrays will be {\[1, 1\], \[2, 2\]}. **Example case 2.** **M** will be equal to 3. The subarrays will be {\[1, 1\], \[2, 2\]}, {\[1, 1\], \[3, 3\]} and {\[1, 1\], \[2, 3\]}. Note that {\[2, 2\], \[3, 3\]} won't be a non-intersecting subarray as A\[2\] = 2 and A\[3\] = 2. So, 2 is common in both these subarrays. diff --git a/_problems/easy/N1.md b/_problems/easy/N1.md index 8b3e95c9..8a2e367a 100644 --- a/_problems/easy/N1.md +++ b/_problems/easy/N1.md @@ -77,5 +77,4 @@ For each test case, print in a single line the earliest time that Dave can reach 4 6 16 - \ No newline at end of file diff --git a/_problems/easy/NAME1.md b/_problems/easy/NAME1.md index e2cf98e1..42f0bc5b 100644 --- a/_problems/easy/NAME1.md +++ b/_problems/easy/NAME1.md @@ -110,8 +110,8 @@ man YES YES NO - ### Explanation: + Let **Y** denote the concatenation of names of all the children, and **X** denote the concatenation of the names of the parents. **Case 1:** Here **X = "tommarvoloriddle"**, and **Y = "lordvoldemort"**. Consider **Z = "iamlordvoldemort"**. It is not difficult to see that **Z** is a permutation of **X** and **Y** is a substring of **Z**. Hence **Y** is a substring of a permutation of **X**, so the answer is "YES". diff --git a/_problems/easy/NAME2.md b/_problems/easy/NAME2.md index 32ce8add..d3c16b5d 100644 --- a/_problems/easy/NAME2.md +++ b/_problems/easy/NAME2.md @@ -103,8 +103,8 @@ kayla jayla YES YES NO - ### Explanation + **Case 1:** Consider **S = "johanna"**. So, **S\[0\] = 'j', S\[1\] = 'o', S\[2\] = 'h'** and so on. If we remove the indices \[3, 4, 6\] or \[3, 5, 6\] from S, it becomes **"john"**. Hence **"john"** is a subsequence of **S**, so the answer is "YES". **Case 2:** Any string is a subsequence of it self, as it is formed after removing **"0"** characters. Hence the answer is **"YES"**. diff --git a/_problems/easy/NDIFFPAL.md b/_problems/easy/NDIFFPAL.md index b33f72f6..735960f9 100644 --- a/_problems/easy/NDIFFPAL.md +++ b/_problems/easy/NDIFFPAL.md @@ -111,6 +111,7 @@ If such string **S** doesn't exist, output **-1** instead of it. radar ab ### Explanation + **Example case 1.** In the string "noon", the pairs that denote a palindrome are (1-indexed): **(1, 1), (1, 4), (2, 2), (2, 3), (3, 3), (4, 4)**. **Example case 2.** In the string "radar", the pairs that denote a palindrome are (1-indexed): **(1, 1), (1, 5), (2, 2), (2, 4), (3, 3), (4, 4), (5, 5)**. diff --git a/_problems/easy/NDLVOTE.md b/_problems/easy/NDLVOTE.md index 3d7f2f5e..68f044bd 100644 --- a/_problems/easy/NDLVOTE.md +++ b/_problems/easy/NDLVOTE.md @@ -40,8 +40,8 @@ M -2 Output: 1 1 - + **Explanation:** Case 1 : diff --git a/_problems/easy/NDUNGEON.md b/_problems/easy/NDUNGEON.md index 07af38ce..f7e16948 100644 --- a/_problems/easy/NDUNGEON.md +++ b/_problems/easy/NDUNGEON.md @@ -23,8 +23,8 @@ The wazir, knowing that the prince is on his way, has set a time bomb that will 2 5 1 5 3 1 3 1 1 - The number at position _(i,j)_ indicates the time taken for the prince to overpower the guards in room _(i,j)_. Suppose the princess is in the room at position (4,2). If _T_ = 10. there is no way the prince can reach the princess in time. However, if _M_ = 15, the prince can reach the princess with 4 seconds to spare, as follows. Starting from (1,1), he moves right to (1,2) and then (1,3), comes down all the way to (4,3) and then moves (4,2). This takes 11 seconds (note that he must also overpower the guard in the room where the princess is incarcerated). You can check that he cannot reach the princess with more than 4 seconds to spare by any route. + ### Input The first line contains two integers M and N indicating the number of rows and columns in the rectangular dungeon. Lines 2,3, ,M+1 contain N positive integers. The jth integer on line i+1 is the time taken to overpower the guards at room (i,j). The last line in the input, line M+2, contains three integers a, b and T, where (a,b) is the position of the cell where the princess is held and T is the amount of time before the bomb goes off. @@ -51,5 +51,4 @@ You may assume that 1 N,K 70. Output: YES 4 - \ No newline at end of file diff --git a/_problems/easy/NEO01.md b/_problems/easy/NEO01.md index d9937f7f..b060aca3 100644 --- a/_problems/easy/NEO01.md +++ b/_problems/easy/NEO01.md @@ -90,7 +90,7 @@ Output a single number denoting the maximum happiness you can get from the feast ### Subtasks -- Subtask #1: **Ai** ≤ (30 points) +- Subtask #1: **Ai** ≤ 0 (30 points) - Subtask #2: Original Constraints (70 points) ### Example 1 @@ -102,8 +102,8 @@ Output a single number denoting the maximum happiness you can get from the feast Output: -10 - ### Example 2 +
Input:
 1
 3
@@ -111,6 +111,6 @@ Output a single number denoting the maximum happiness you can get from the feast
 
 Output:
 18
-
 
### Explanation + **Example case 1.** You can eat the first dish in the first step, the second dish in the second step and the third dish in the third step. total happiness = 1\*(-8) + 1\*0 + 1\*(-2) = -10 diff --git a/_problems/easy/NEWSCH.md b/_problems/easy/NEWSCH.md index 47bd38eb..142ab5fa 100644 --- a/_problems/easy/NEWSCH.md +++ b/_problems/easy/NEWSCH.md @@ -96,8 +96,8 @@ For each test case output a single integer in a separate line, the answer for th 12 24 240 - ### Explanation + **Case 1.** For **N = 2** days we have the following **12** schedules: First daySecond day salo borsch salo varenyky salo galushky borsch salo borsch varenyky borsch galushky varenyky salo varenyky borsch varenyky galushky galushky salo galushky borsch galushky varenyky **Case 2.** For **N = 3** we have the following **24** schedules: diff --git a/_problems/easy/NI01.md b/_problems/easy/NI01.md index d3b8b04f..c56ea21d 100644 --- a/_problems/easy/NI01.md +++ b/_problems/easy/NI01.md @@ -60,5 +60,4 @@ The output parameters should be in the above order with one space gap. 1 5 27 0 1 12 6 0 - \ No newline at end of file diff --git a/_problems/easy/NI02.md b/_problems/easy/NI02.md index 3e1fbbef..af996860 100644 --- a/_problems/easy/NI02.md +++ b/_problems/easy/NI02.md @@ -68,5 +68,4 @@ Print a single integer for each test case on a line by itself, the minimum amoun 20 4 - \ No newline at end of file diff --git a/_problems/easy/NICEQUAD.md b/_problems/easy/NICEQUAD.md index 2300f289..20e7a35b 100644 --- a/_problems/easy/NICEQUAD.md +++ b/_problems/easy/NICEQUAD.md @@ -52,5 +52,4 @@ For each test case print the number of nice quadrangles that can be formed using Output: 2 - \ No newline at end of file diff --git a/_problems/easy/NOCODING.md b/_problems/easy/NOCODING.md index fcbb7d9c..df4b7d15 100644 --- a/_problems/easy/NOCODING.md +++ b/_problems/easy/NOCODING.md @@ -96,15 +96,15 @@ Assuming Chef writes the shortest code (with minimum instructions) to print the
1 ≤ T ≤ 100
 1 ≤ length of word ≤ 1000
-
 
### Sample Input +
2
 helloworld
 mississippi
-
 
### Sample Output +
NO
 YES
-
 
### Explanation + The optimal program length for mississippi is 112 instructions and that is smaller than 121 (length of 'mississippi' \* 11) diff --git a/_problems/easy/NOLOGIC.md b/_problems/easy/NOLOGIC.md index 5a74d5e2..b18fbec3 100644 --- a/_problems/easy/NOLOGIC.md +++ b/_problems/easy/NOLOGIC.md @@ -69,8 +69,8 @@ Bunny Day ~ You Can output aLoMsT anytihng HERE - ### Explanation + Example cases 1 and 2 correspond to the dialog in the problem statement. Note that we don't print dots since it is allowed to have only spaces and letters in the answer. In example case 3 each letter of English alphabet is used in the question. Hence we can't produce the answer that has no logic. diff --git a/_problems/easy/NOTATRI.md b/_problems/easy/NOTATRI.md index 86c5c65e..2f435d7a 100644 --- a/_problems/easy/NOTATRI.md +++ b/_problems/easy/NOTATRI.md @@ -39,5 +39,4 @@ For each test case, output a single line containing the number of triples. 0 2 - -For the first test case, 4 + 2 < 10, so you will win with the one available triple. For the second case, 1 + 2 is equal to 3; since degenerate triangles are allowed, the answer is 0. \ No newline at end of file +For the first test case, 4 + 2 < 10, so you will win with the one available triple. For the second case, 1 + 2 is equal to 3; since degenerate triangles are allowed, the answer is 0. diff --git a/_problems/easy/NUKES.md b/_problems/easy/NUKES.md index 9ae0bce3..3fe183e0 100644 --- a/_problems/easy/NUKES.md +++ b/_problems/easy/NUKES.md @@ -28,5 +28,4 @@ Consists of K numbers on one line followed by a newline. The first number is the 3 1 3 Output: 1 1 0 - -**Explanation**Total of 3 particles are bombarded. After particle 1 is bombarded, the chambers have particle distribution as "1 0 0". After second particle is bombarded, number of particles in chamber 0 becomes 2 which is greater than 1. So, num of particles in chamber 0 becomes 0 and in chamber 1 becomes 1. So now distribution is "0 1 0". After the 3rd particle is bombarded, chamber 0 gets 1 particle and so distribution is "1 1 0" after all particles are bombarded one by one. \ No newline at end of file +**Explanation**Total of 3 particles are bombarded. After particle 1 is bombarded, the chambers have particle distribution as "1 0 0". After second particle is bombarded, number of particles in chamber 0 becomes 2 which is greater than 1. So, num of particles in chamber 0 becomes 0 and in chamber 1 becomes 1. So now distribution is "0 1 0". After the 3rd particle is bombarded, chamber 0 gets 1 particle and so distribution is "1 1 0" after all particles are bombarded one by one. diff --git a/_problems/easy/NUMBERS.md b/_problems/easy/NUMBERS.md index 240fa3c9..d2aebca1 100644 --- a/_problems/easy/NUMBERS.md +++ b/_problems/easy/NUMBERS.md @@ -103,8 +103,8 @@ Nana 2 Output: Lucy Nobody wins. - ### Scoring + Subtask 1 (17 points): **T** = 10000, 1 <= **N** <= 10, 1 <= **Ai** <= 10 Subtask 2 (19 points): **T** = 10000, 1 <= **N** <= 10, 1 <= **Ai** <= 2\*109 diff --git a/_problems/easy/NUMGAME.md b/_problems/easy/NUMGAME.md index 141cd5cc..faed7e09 100644 --- a/_problems/easy/NUMGAME.md +++ b/_problems/easy/NUMGAME.md @@ -33,17 +33,14 @@ Sample Input : 1 2 -
 Sample Output :
 BOB
 ALICE
 
-
 
 Constraints :
 1 <= T <= 10000
 1 <= N <= 1000000000
 
-
-
Note : For the first test case, Alice cannot make any move and hence Bob wins the game. For the second test case, Alice subtracts 1 from N. Now, Bob cannot make a move and loses the game. \ No newline at end of file +Note : For the first test case, Alice cannot make any move and hence Bob wins the game. For the second test case, Alice subtracts 1 from N. Now, Bob cannot make a move and loses the game. diff --git a/_problems/easy/NUMGAME2.md b/_problems/easy/NUMGAME2.md index 9498e923..6a564045 100644 --- a/_problems/easy/NUMGAME2.md +++ b/_problems/easy/NUMGAME2.md @@ -13,11 +13,11 @@ layout: problem Alice and Bob play the following game.They choose a number N to play with.The runs are as follows : -1\.Bob plays first and the two players alternate. +1.Bob plays first and the two players alternate. -2\.In his/her turn ,a player can subtract from N any prime number(including 1) less than N.The number thus obtained is the new N. +2.In his/her turn ,a player can subtract from N any prime number(including 1) less than N.The number thus obtained is the new N. -3\.The person who cannot make a move in his/her turn loses the game. +3.The person who cannot make a move in his/her turn loses the game. Assuming both play optimally,who wins the game ? @@ -44,5 +44,5 @@ BOB Constraints: 1 <= T <= 1000000 1 <= N <= 1000000000 - -Note : For the first test case, Bob cannot make any move and hence Alice wins the game. For the second test case, Bob subtracts 1 from N. Now, Alice cannot make a move and loses the game. + +Note : For the first test case, Bob cannot make any move and hence Alice wins the game. For the second test case, Bob subtracts 1 from N. Now, Alice cannot make a move and loses the game. diff --git a/_problems/easy/OBTTRNGL.md b/_problems/easy/OBTTRNGL.md index ef89d3ea..13462971 100644 --- a/_problems/easy/OBTTRNGL.md +++ b/_problems/easy/OBTTRNGL.md @@ -107,8 +107,8 @@ For each test case, output a single line containing one integer: the answer for 1 0 3 - ### Explanation + **Example case 1.** Only candle with number **2** is suitable. **Example case 2.** No matter how we choose **C** the angle would have **90** degrees. diff --git a/_problems/easy/ODDDIV.md b/_problems/easy/ODDDIV.md index d005ef0e..d659fd8b 100644 --- a/_problems/easy/ODDDIV.md +++ b/_problems/easy/ODDDIV.md @@ -104,8 +104,8 @@ For each test case, output the required sum on a separate line. Output: 45 32 - ### Explanation + In the first example case, **f(1) + f(2) + ... + f(10) = 1 + 1 + 4 + 1 + 6 + 4 + 8 + 1 + 13 + 6 = 45** In the second example case, **f(42) = 32**. diff --git a/_problems/easy/OJUMPS.md b/_problems/easy/OJUMPS.md index 82ae9b0c..d553edc9 100644 --- a/_problems/easy/OJUMPS.md +++ b/_problems/easy/OJUMPS.md @@ -70,7 +70,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/MAY14/mandarin/OJUMPS.pdf) and [Russian](http://www.codechef.com/download/translated/MAY14/russian/OJUMPS.pdf). -This morning Chef wants to jump a little. In a few minutes he will arrive at the point . Then he will perform a lot of jumps in such a sequence: **1**-jump, **2**-jump, **3**-jump, **1**-jump, **2**-jump, **3**-jump, **1**-jump, and so on. +This morning Chef wants to jump a little. In a few minutes he will arrive at the point 0. Then he will perform a lot of jumps in such a sequence: **1**-jump, **2**-jump, **3**-jump, **1**-jump, **2**-jump, **3**-jump, **1**-jump, and so on. **1**-jump means that if Chef is at the point **x**, he will jump to the point **x+1**. @@ -90,7 +90,7 @@ Output "yes" without a quotes if Chef can arrive at point **a** or "no" without ### Constraints -- ≤ **a** ≤ **1018** +- 0 ≤ **a** ≤ **1018** ### Example @@ -136,6 +136,6 @@ yes Output: no - ### Explanation + The first reached points are: 0 (+1) 1 (+2) 3 (+3) 6 (+1) 7, and so on. diff --git a/_problems/easy/OMAX.md b/_problems/easy/OMAX.md index 8fdd4fae..b063f752 100644 --- a/_problems/easy/OMAX.md +++ b/_problems/easy/OMAX.md @@ -43,5 +43,4 @@ For each test case, output on a line an integer which is the respective maximal Output: 6 19 - \ No newline at end of file diff --git a/_problems/easy/ONCHESS.md b/_problems/easy/ONCHESS.md index df66ab4d..6762152c 100644 --- a/_problems/easy/ONCHESS.md +++ b/_problems/easy/ONCHESS.md @@ -152,8 +152,8 @@ wait wait 5 - ### Explanation + **Example case 1.** - player 1 has to wait because there are no other players yet diff --git a/_problems/easy/ONOZ.md b/_problems/easy/ONOZ.md index 31a6ac0c..0f17ac48 100644 --- a/_problems/easy/ONOZ.md +++ b/_problems/easy/ONOZ.md @@ -76,7 +76,7 @@ _3:33_ It's possible for all the digits displayed on a digital clock in the _hours:minutes_ format to be identical. The time shown above (_3:33_) is an example of such a situation. Other examples are _2:2_ and _1:11_. Note that the digits of _33:33_ are identical, but it is not a valid time on a usual digital clock. -The above example was for a usual 24-hour format digital clock. Let's consider a more general clock, where an hour lasts **M** minutes and a day lasts **H** hours (therefore, the clock can show any number of hours between and **H-1**, inclusive, and any number of minutes between and **M-1**, inclusive). Both the hours and the minutes are shown **without leading zeroes** in decimal notation and their separator (e.g., ':') doesn't matter. +The above example was for a usual 24-hour format digital clock. Let's consider a more general clock, where an hour lasts **M** minutes and a day lasts **H** hours (therefore, the clock can show any number of hours between 0 and **H-1**, inclusive, and any number of minutes between 0 and **M-1**, inclusive). Both the hours and the minutes are shown **without leading zeroes** in decimal notation and their separator (e.g., ':') doesn't matter. Can you tell how many minutes during a day will the digital clock have identical digits displayed on it? @@ -112,8 +112,8 @@ For each test case, output a single line corresponding to the answer of the prob 11 10 1 - ### Explanation + **Example case 1.** A clock shows two identical digits at times _0:0_, _1:1_, .., _9:9_, three identical digits at times _11:1_, _22:2_, _1:11_, _2:22_, _3:33_, _4:44_, _5:55_, and four identical digits at times _11:11_ and _22:22_. So, there are 19 minutes during which the time displayed by the clock will have identical digits. **Example case 2.** Compared to the previous case, the clock doesn't show _5:55_, but can show _33:3_ and _33:33_. diff --git a/_problems/easy/ONP.md b/_problems/easy/ONP.md index c63280ef..db86416a 100644 --- a/_problems/easy/ONP.md +++ b/_problems/easy/ONP.md @@ -27,8 +27,8 @@ Followed by t lines, containing an expression to be translated to RPN form, wher
 The expressions in RPN form, one per line.
-
 
### Example +
 Input:
 3
@@ -40,5 +40,4 @@ Output:
 abc*+
 ab+zx+*
 at+bac++cd+^*
-
 
\ No newline at end of file diff --git a/_problems/easy/ORACLCS.md b/_problems/easy/ORACLCS.md index 74b171ea..fd208212 100644 --- a/_problems/easy/ORACLCS.md +++ b/_problems/easy/ORACLCS.md @@ -119,8 +119,8 @@ baab 1 0 2 - ### Explanation + **In the first example**, the minimum value of LCS of all the strings is 1, the string by oracle can be one of these {aa, ab, ba, bb}. **In the second example**, whatever string oracle has does not matter, LCS will always be zero. diff --git a/_problems/easy/PACKBAND.md b/_problems/easy/PACKBAND.md index 0340fadc..0cd3c422 100644 --- a/_problems/easy/PACKBAND.md +++ b/_problems/easy/PACKBAND.md @@ -41,5 +41,5 @@ For each test case, output the maximum number of boxes you can pack, in a new li Output: 2 - - **Explanation:** Only 1 test case here, and a possible answer can be, using (7,14) rubber band to pack box L = **20**, and using (7,35) rubber band to pack box L = 55. We cannot pack more than 2 boxes. + + **Explanation:** Only 1 test case here, and a possible answer can be, using (7,14) rubber band to pack box L = **20**, and using (7,35) rubber band to pack box L = 55. We cannot pack more than 2 boxes. diff --git a/_problems/easy/PAIRING.md b/_problems/easy/PAIRING.md index c8f3f527..3414fad4 100644 --- a/_problems/easy/PAIRING.md +++ b/_problems/easy/PAIRING.md @@ -43,5 +43,4 @@ The output for each test case consists of the indices of the pairs of employees Output: 1 4 2 - \ No newline at end of file diff --git a/_problems/easy/PAIRSUM.md b/_problems/easy/PAIRSUM.md index b96f091f..15bd2a78 100644 --- a/_problems/easy/PAIRSUM.md +++ b/_problems/easy/PAIRSUM.md @@ -33,5 +33,4 @@ One number which is the size of the greatest subset as mentioned in the problem Explanation: The array {1,4,2,3} is good, since you can form p1[] = {1,2} and p2[] = {4,3}. (satisfying 1 + 4 = 2 + 3) - \ No newline at end of file diff --git a/_problems/easy/PALHAM.md b/_problems/easy/PALHAM.md index cdf38709..4b4da64e 100644 --- a/_problems/easy/PALHAM.md +++ b/_problems/easy/PALHAM.md @@ -98,7 +98,7 @@ For each test case, output a single line containing the answer to the test-case. - **1** ≤ **T** ≤ **10,000** - **1** ≤ **N** ≤ **300,000** - **1** ≤ sum of **N** in all test-cases ≤ **1,000,000** -- ≤ **K** ≤ **N** +- 0 ≤ **K** ≤ **N** - String S will consist of English lower letters. ### Example @@ -114,6 +114,6 @@ abc 76 2 - ### Explanation + in second test-case the only possible strings are "aba" and "cbc" diff --git a/_problems/easy/PALINGAM.md b/_problems/easy/PALINGAM.md index ef2db553..09d4b1f7 100644 --- a/_problems/easy/PALINGAM.md +++ b/_problems/easy/PALINGAM.md @@ -113,8 +113,8 @@ cd B A B - ### Explanation + **Testcase 1**: If A adds 'a' to w in the first move, B can add 'a' and make the string w = "aa", which is a palindrome, and hence win. Similarly, you can show that no matter what A plays, B can win. Hence the answer is B. **Testcase 2**: Player A moves with 'a', player B can put any of the character 'c', 'd' or 'e', Now Player A can create a palindrome by adding 'a'. diff --git a/_problems/easy/PANSTACK.md b/_problems/easy/PANSTACK.md index 70050799..05f2e02e 100644 --- a/_problems/easy/PANSTACK.md +++ b/_problems/easy/PANSTACK.md @@ -89,10 +89,9 @@ For each case the output should be a single integer representing the number of w 2 1 2 - **Output** +
 1
 2
-
 
\ No newline at end of file diff --git a/_problems/easy/PCYCLE.md b/_problems/easy/PCYCLE.md index b1bf63b3..1260597e 100644 --- a/_problems/easy/PCYCLE.md +++ b/_problems/easy/PCYCLE.md @@ -15,12 +15,12 @@ layout: problem
 2  4  5  1  7  6  3  8
-
 
is a permutation of 1,2,...,8. Of course, +
 1  2  3  4  5  6  7  8
-
 
is also a permutation of 1,2,...,8. + We can "walk around" a permutation in a interesting way and here is how it is done for the permutation above: Start at position 1. At position 1 we have 2 and so we go to position 2. Here we find 4 and so we go to position 4. Here we find 1, which is a position that we have already visited. This completes the first part of our walk and we denote this walk by (1 2 4 1). Such a walk is called a _cycle_. An interesting property of such walks, that you may take for granted, is that the position we revisit will always be the one we started from! @@ -46,21 +46,21 @@ Sample input 1:
 8
 2 4 5 1 7 6 3 8
-
 
Sample output 1: +
 4
 1 2 4 1
 3 5 7 3
 6 6
 8 8 
-
 
Sample input 2: +
 8
 1 2 3 4 5 6 7 8
-
 
Sample output 2: +
 8
 1 1
@@ -71,5 +71,4 @@ Sample input 1:
 6 6
 7 7
 8 8
-
 
\ No newline at end of file diff --git a/_problems/easy/PERMEXIS.md b/_problems/easy/PERMEXIS.md index cc30fc0d..1a094855 100644 --- a/_problems/easy/PERMEXIS.md +++ b/_problems/easy/PERMEXIS.md @@ -105,8 +105,8 @@ For each test case, output in one line **YES** or **NO** denoting if array **A** Output: YES NO - ### Explanation + Test case 1: No need to reorganise. diff --git a/_problems/easy/PERMSUFF.md b/_problems/easy/PERMSUFF.md index 2aa84ba6..ff33c9a0 100644 --- a/_problems/easy/PERMSUFF.md +++ b/_problems/easy/PERMSUFF.md @@ -116,5 +116,4 @@ For each test case, output a single line containing the answer to the correspond Possible Impossible - \ No newline at end of file diff --git a/_problems/easy/PERMUT2.md b/_problems/easy/PERMUT2.md index 7ef4713b..90a4738b 100644 --- a/_problems/easy/PERMUT2.md +++ b/_problems/easy/PERMUT2.md @@ -35,10 +35,9 @@ For each test case output whether the permutation is ambiguous or not. Adhere to 1 1 0 - ### Sample Output +
ambiguous
 not ambiguous
 ambiguous
-
 
\ No newline at end of file diff --git a/_problems/easy/PERPALIN.md b/_problems/easy/PERPALIN.md index a92a7a5c..4ed043cf 100644 --- a/_problems/easy/PERPALIN.md +++ b/_problems/easy/PERPALIN.md @@ -117,8 +117,8 @@ impossible aba abba abaaba - ### Explanation + **Example 1**: The only strings possible are either aaa or bbb, which Chef doesn't like. So, the answer is impossible. **Example 2**: There are four possible strings, aa, ab, ba, bb. Only aa and bb are palindromic, but Chef doesn't like these strings. Hence, the answer is impossible. diff --git a/_problems/easy/PETERSEN.md b/_problems/easy/PETERSEN.md index 1b9e3ff6..967d3b15 100644 --- a/_problems/easy/PETERSEN.md +++ b/_problems/easy/PETERSEN.md @@ -72,7 +72,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/COOK52/mandarin/PETERSEN.pdf) and [Russian](http://www.codechef.com/download/translated/COOK52/russian/PETERSEN.pdf) as well. - The following graph **G** is called a [Petersen graph](http://en.wikipedia.org/wiki/Petersen_graph) and its vertices have been numbered from to **9**. Some letters have also been assigned to vertices of **G**, as can be seen from the following picture: + The following graph **G** is called a [Petersen graph](http://en.wikipedia.org/wiki/Petersen_graph) and its vertices have been numbered from 0 to **9**. Some letters have also been assigned to vertices of **G**, as can be seen from the following picture: ![](//www.codechef.com//download/Petersen1tinysvg.png) @@ -90,7 +90,7 @@ Your task is to determine whether there is a walk **W** which realizes a given s ### Output - The output should contain exactly **T** lines, one line per each testcase in the order of their appearance. For each testcase, if there is no walk **W** which realizes **S**, then output **-1**. Otherwise, you should output the least lexicographical walk **W** which realizes **S**. Since all of the vertices are numbered from to **9**, then it can be encoded as a string consisting of symbols **'0'-'9'** (see the "Examples" section for more details). + The output should contain exactly **T** lines, one line per each testcase in the order of their appearance. For each testcase, if there is no walk **W** which realizes **S**, then output **-1**. Otherwise, you should output the least lexicographical walk **W** which realizes **S**. Since all of the vertices are numbered from 0 to **9**, then it can be encoded as a string consisting of symbols **'0'-'9'** (see the "Examples" section for more details). ### Constraints @@ -108,5 +108,4 @@ AABE Output: 501 -1 - \ No newline at end of file diff --git a/_problems/easy/PIANO1.md b/_problems/easy/PIANO1.md index 284bdb0c..0928559b 100644 --- a/_problems/easy/PIANO1.md +++ b/_problems/easy/PIANO1.md @@ -127,6 +127,6 @@ TTSTTTS 4 36 - ### Explanation + **Example case 1.** In the first case there is only one octave and Chef can play scale (not in cycle each time) starting with notes _C, C#, D, D#_ - four together. diff --git a/_problems/easy/PIZPAR.md b/_problems/easy/PIZPAR.md index 9b7849f5..622970fe 100644 --- a/_problems/easy/PIZPAR.md +++ b/_problems/easy/PIZPAR.md @@ -57,6 +57,6 @@ Output a single integer - the maximum number of slices chef can get. 1 2 3 4 5 Output: 31 - ### Explanation + **Example case 1. One of the optimal way to cut would be to do {0, 1, 0, 4, 5} cuts.** diff --git a/_problems/easy/PLANEDIV.md b/_problems/easy/PLANEDIV.md index 04c28961..177de0ed 100644 --- a/_problems/easy/PLANEDIV.md +++ b/_problems/easy/PLANEDIV.md @@ -121,6 +121,6 @@ For each test case output the cardinality of the largest perfect subset in a sin Output: 2 - ### Explanation + Lines **3\*x + 4\*y + 5 = 0** and **30\*x + 40\*y + 0 = 0** form a biggest perfect subset. diff --git a/_problems/easy/PLUSMUL.md b/_problems/easy/PLUSMUL.md index 69582477..ac4dd0b0 100644 --- a/_problems/easy/PLUSMUL.md +++ b/_problems/easy/PLUSMUL.md @@ -105,8 +105,8 @@ For each testcase, output a single line containing the sum of results of all pos Output: 30 20 - ### Explanation + **Example case 1.** There can be following four expressions.
@@ -114,5 +114,4 @@ For each testcase, output a single line containing the sum of results of all pos
 1 + 2 * 4 = 9
 1 * 2 + 4 = 6
 1 * 2 * 4 = 8
-
-
Total sum of results = 30 \ No newline at end of file +Total sum of results = 30 diff --git a/_problems/easy/PLZLYKME.md b/_problems/easy/PLZLYKME.md index 29183456..7dc2230f 100644 --- a/_problems/easy/PLZLYKME.md +++ b/_problems/easy/PLZLYKME.md @@ -108,8 +108,8 @@ For each test case, print a single line containing “**ALIVE AND KICKING**” i Output ALIVE AND KICKING DEAD AND ROTTING - **Explanation** + In the first case by the end of Day-1 we would be having **S** that is **5** number of likes, as it is ≥ **L**, the answer is **ALIVE AND KICKING**. In the second case, **D2 =S + C\*S**, therefore **D2 = 2 + 2 \* 2 = 6**, as 6 is less than 10, the answer is **DEAD AND ROTTING**. /> diff --git a/_problems/easy/PNTNG.md b/_problems/easy/PNTNG.md index 24e847d9..6c04fdc4 100644 --- a/_problems/easy/PNTNG.md +++ b/_problems/easy/PNTNG.md @@ -106,8 +106,8 @@ The output should contain the minimum cost of the painting if there is one, othe Output: 18 - ### Example 2 +
Input:
 2 2 3
 1 1
@@ -116,8 +116,8 @@ The output should contain the minimum cost of the painting if there is one, othe
 
 Output:
 Impossible
-
 
### Explanations + In the first example, we should paint 6 cells on the first layer and 6 cells on the second layer. In the second example, there are not enough cells to paint the table properly. diff --git a/_problems/easy/POINTS.md b/_problems/easy/POINTS.md index 361b20a6..dbaf9d7d 100644 --- a/_problems/easy/POINTS.md +++ b/_problems/easy/POINTS.md @@ -52,5 +52,4 @@ For the third test case above, the following is the path you must take: 1,10 -> 1,5 1,5 -> 2,2 = 18.21 - \ No newline at end of file diff --git a/_problems/easy/POKER.md b/_problems/easy/POKER.md index 3179a9cd..9ff60565 100644 --- a/_problems/easy/POKER.md +++ b/_problems/easy/POKER.md @@ -49,5 +49,4 @@ QH QD 2S QC 2C royal flush pair full house - \ No newline at end of file diff --git a/_problems/easy/POSTTREE.md b/_problems/easy/POSTTREE.md index 09644961..d0321eb5 100644 --- a/_problems/easy/POSTTREE.md +++ b/_problems/easy/POSTTREE.md @@ -108,8 +108,8 @@ Output a single line containing **N** integers, the i-th of which should be the Output: 1 3 4 5 6 21 96 26 - ### Explanation + For example, take a look at the path from vertex 7: The path is 7 -> 8 -> 6 -> 5 -> 1. Cost(7) has no choice but to be **A7**. So Cost(7) = 70. diff --git a/_problems/easy/POTATOES.md b/_problems/easy/POTATOES.md index 5f5bbcd2..6ea9f28c 100644 --- a/_problems/easy/POTATOES.md +++ b/_problems/easy/POTATOES.md @@ -96,6 +96,6 @@ For each test case, output a single line containing the answer. Output: 1 4 - ### Explanation + In example case 1: the farmer harvested a potato from the first field and 3 potatoes from the second field. The sum is 4. If he is able to harvest a potato from the third field, that will make the sum 5, which is prime. Hence the answer is 1(he needs one more potato to make the sum of harvested potatoes prime.) diff --git a/_problems/easy/PPCTS.md b/_problems/easy/PPCTS.md index d4f9decc..d8e87f7a 100644 --- a/_problems/easy/PPCTS.md +++ b/_problems/easy/PPCTS.md @@ -115,8 +115,8 @@ RDL 4 6 6 - ### Explanation + Initially Tuzik stays at cell **(0, 0)**. Let's consider his path: - Move **'R'** to the cell (1, 0). Distance to the catcher **(1, 2)** equals 2, distance to the catcher **(0, 1)** equals 2, so the total distance equals 4 diff --git a/_problems/easy/PPNUM.md b/_problems/easy/PPNUM.md index ccefb35e..69fd1058 100644 --- a/_problems/easy/PPNUM.md +++ b/_problems/easy/PPNUM.md @@ -96,6 +96,6 @@ For each test case, output a single line containing the answer to the correspond Output: 75 - ### Explanation + **Example case 1.** The answer is **9\*1 + 10\*2 + 11\*2 + 12\*2 = 75**. diff --git a/_problems/easy/PPTEST.md b/_problems/easy/PPTEST.md index e88a6eb5..1453497f 100644 --- a/_problems/easy/PPTEST.md +++ b/_problems/easy/PPTEST.md @@ -102,6 +102,6 @@ For each test case, output a single line containing the answer to the correspond Output: 11 - ### Explanation + **Example case 1.** The best choice is to learn the first and the third questions and get **1\*2 + 3\*3 = 11** points. diff --git a/_problems/easy/PREDICT.md b/_problems/easy/PREDICT.md index d94c6e79..fe58951c 100644 --- a/_problems/easy/PREDICT.md +++ b/_problems/easy/PREDICT.md @@ -103,8 +103,8 @@ For each test case output single line containing the expected amount of money Da Output: 10098 - ### Example bet: + Look at the following situation: diff --git a/_problems/easy/PREFINVS.md b/_problems/easy/PREFINVS.md index 1f48c275..dc7178e9 100644 --- a/_problems/easy/PREFINVS.md +++ b/_problems/easy/PREFINVS.md @@ -102,8 +102,8 @@ Output a single line containing one integer, the minimum number of operations th Output: 6 -
### Explanation
+
 For the given sample case, let us look at the way where we achieved minimum number of operations.
 
   **Operation 1:** You flip values in the prefix of length 8 and transform the string into 10110110
diff --git a/_problems/easy/PRETNUM.md b/_problems/easy/PRETNUM.md
index 8666b5ba..3be1a94e 100644
--- a/_problems/easy/PRETNUM.md
+++ b/_problems/easy/PRETNUM.md
@@ -92,7 +92,7 @@ For each test case, output a single line containing answer for corresponding tes
 
 - **1** ≤ **T** ≤ **5**
 - **1** ≤ **L** ≤ **R** ≤ **1012**
-- ≤ **R-L** ≤ **106**
+- 0 ≤ **R-L** ≤ **106**
 
 ### Example
 
@@ -102,6 +102,6 @@ For each test case, output a single line containing answer for corresponding tes
 
 Output:
 6
-
 
### Explanation + **Example case 1.** Numbers 2,3,4,5,7,9 are special. diff --git a/_problems/easy/PRGIFT.md b/_problems/easy/PRGIFT.md index 12024b3f..b704f0db 100644 --- a/_problems/easy/PRGIFT.md +++ b/_problems/easy/PRGIFT.md @@ -49,7 +49,7 @@ For each test case, print a single line containing "YES" or "NO" (without quotes - **1** ≤ **T** ≤ **10** - **1** ≤ **n** ≤ **50** -- ≤ **k** ≤ **n** +- 0 ≤ **k** ≤ **n** - **1** ≤ **a i** ≤ **100** ### Example @@ -70,7 +70,6 @@ YES YES NO YES -


for (int i = 0; i < n; i++)

if (i > 0) {

diff --git a/_problems/easy/PRIMES2.md b/_problems/easy/PRIMES2.md index 9ce692a4..e02b20cf 100644 --- a/_problems/easy/PRIMES2.md +++ b/_problems/easy/PRIMES2.md @@ -29,10 +29,9 @@ For each odd number in the input, print 3 primes P1, P2, P3 on a line, where P1 85 155 0 -
### Sample Output +
5 7 3
 73 2 2
 5 5 5
-
 
\ No newline at end of file diff --git a/_problems/easy/PRLADDU.md b/_problems/easy/PRLADDU.md index e12979b3..67bbde23 100644 --- a/_problems/easy/PRLADDU.md +++ b/_problems/easy/PRLADDU.md @@ -126,8 +126,8 @@ For each test case, print a single line containing the integer corresponding to 5 5 4 - ### Explanation + **Example case 1.** Each villager in village 1, need to walk 1 km to reach to the dinosaur in 2nd village. **Example case 2.** Each villager in village 2, need to walk 1 km to reach to the dinosaur 1st village. diff --git a/_problems/easy/PROB.md b/_problems/easy/PROB.md index f2526ca6..60a8946b 100644 --- a/_problems/easy/PROB.md +++ b/_problems/easy/PROB.md @@ -121,11 +121,11 @@ For each test case, output a single line containing the probability that Artem w 0.5 0.4 - ### Explanation + **In the first test case**, the **5** possible outcomes after Chef discards 2 tickets is -- **(0,2,1)** with probability **(1/10)**. Probability of winning is - since there are no winning tickets! +- **(0,2,1)** with probability **(1/10)**. Probability of winning is 0 - since there are no winning tickets! - **(2,0,1)** with probability **(1/10)**. Probability of winning is **1** - since there are no losing tickets! - **(2,1,0)** with probability **(1/5)**. Probability of winning is **(2/3)** - there are no second chances! - **(1,2,0)** with probability **(1/5)**. Probability of winning is **(1/3)** - there are no second chances! diff --git a/_problems/easy/PROSUM.md b/_problems/easy/PROSUM.md index 166a8ed5..5461d1f3 100644 --- a/_problems/easy/PROSUM.md +++ b/_problems/easy/PROSUM.md @@ -90,7 +90,7 @@ For each test, print the required number of pairs in a single line. - **1** ≤ **T** ≤ **10** - **2** ≤ **N** ≤ **100000 (105)** -- ≤ **A\[i\]** ≤ **1000000 (106)** +- 0 ≤ **A\[i\]** ≤ **1000000 (106)** /> @@ -107,8 +107,8 @@ For each test, print the required number of pairs in a single line. Output: 3 0 - ### Explanation + /> **Example case 1.** All pairs of numbers satisfy the criteria. Total number of pairs equals **3**. /> diff --git a/_problems/easy/PROTEPOI.md b/_problems/easy/PROTEPOI.md index 535c362a..962f4eb6 100644 --- a/_problems/easy/PROTEPOI.md +++ b/_problems/easy/PROTEPOI.md @@ -128,8 +128,8 @@ The King has other duties for the snakes, and hence wants to remove as many snak Output: 3 -1 - ### Explanation + The first example corresponds to: ![](https://puu.sh/vUwp7/33aaeb020d.png)Note that the top-left corner cell of the **N**x**N** grid is by definition, (1,1). The inner square contains the poison, and the seven snakes are shown in different colours. The green snake is the 1st snake in the input. diff --git a/_problems/easy/PRPALIN.md b/_problems/easy/PRPALIN.md index 6a62d505..7a4bc65e 100644 --- a/_problems/easy/PRPALIN.md +++ b/_problems/easy/PRPALIN.md @@ -30,5 +30,4 @@ Your output must consist of a single integer, the smallest prime palindrome grea 31 Output: 101 - \ No newline at end of file diff --git a/_problems/easy/PRPALN.md b/_problems/easy/PRPALN.md index 7448976f..098504b8 100644 --- a/_problems/easy/PRPALN.md +++ b/_problems/easy/PRPALN.md @@ -110,8 +110,8 @@ YES NO YES YES - ### Explanation + **Example case 1.** Delete any one 'a', resulting string is "aa" which is a palindrome. **Example case 2.** It is not possible to delete exactly one character and having a palindrome. diff --git a/_problems/easy/PRPOTION.md b/_problems/easy/PRPOTION.md index 5d7be9ff..6ef809f1 100644 --- a/_problems/easy/PRPOTION.md +++ b/_problems/easy/PRPOTION.md @@ -122,6 +122,6 @@ For each test case, print a single integer denoting the answer of the problem. 2 4 4 - ### Explanation + **Example case 1.** Magical girl can pick the blue potion and make its liquid amount half. So the potions will now have amounts 1 2 1. Maximum of these values is 2. Hence answer is 2. diff --git a/_problems/easy/PUPPYGM.md b/_problems/easy/PUPPYGM.md index 379f005c..c00ca610 100644 --- a/_problems/easy/PUPPYGM.md +++ b/_problems/easy/PUPPYGM.md @@ -104,8 +104,8 @@ For each test case, output a single line containing the word "Tuzik" or "Vanka" Output: Vanka Tuzik - ### Explanation + In the **first test case** Tuzik can't finish even the first move, so Vanka wins. In the **second test case** Tuzik eats the first stack (with 1 nut), then splits the second stack (with 2 nuts) into two stacks, and Vanka loses. diff --git a/_problems/easy/QMAXTRIX.md b/_problems/easy/QMAXTRIX.md index 8ac0c67d..9aff3202 100644 --- a/_problems/easy/QMAXTRIX.md +++ b/_problems/easy/QMAXTRIX.md @@ -111,8 +111,8 @@ Now you will be given an integer **Q**, followed by **Q** operations: Each query Output: E E - ### Explanation + The given array is: 1 1 1 0 1 0 diff --git a/_problems/easy/RACELANE.md b/_problems/easy/RACELANE.md index 5ef15911..ce381e57 100644 --- a/_problems/easy/RACELANE.md +++ b/_problems/easy/RACELANE.md @@ -55,5 +55,4 @@ The output for each test case consists of a single integer on a single line. Thi 498 500 497 - \ No newline at end of file diff --git a/_problems/easy/RAINBOW.md b/_problems/easy/RAINBOW.md index 6238a73c..364b6003 100644 --- a/_problems/easy/RAINBOW.md +++ b/_problems/easy/RAINBOW.md @@ -131,8 +131,8 @@ For each test case, output the maximum possible size of an interesting subset, i 0 0 4 - ### Explanation + In the first case, the set of all nodes is an interesting subset. In the second and third cases, no non-empty subset of nodes is interesting. diff --git a/_problems/easy/RAINBOWB.md b/_problems/easy/RAINBOWB.md index ebbfb0d8..4c17360f 100644 --- a/_problems/easy/RAINBOWB.md +++ b/_problems/easy/RAINBOWB.md @@ -135,5 +135,4 @@ Output the number of different Rainbow Arrays with **N** elements, modulo **10^9 7

 

- \ No newline at end of file diff --git a/_problems/easy/RANKLIST.md b/_problems/easy/RANKLIST.md index 7950b491..3abb8f3f 100644 --- a/_problems/easy/RANKLIST.md +++ b/_problems/easy/RANKLIST.md @@ -114,8 +114,8 @@ For each test case, print a single line containing a single integer correspondin 1 2 - ### Explanation + **Example case 1.** Only possible rank list in this case is {1}, As it is already an ideal rank list, hence you need zero operations. diff --git a/_problems/easy/RDF.md b/_problems/easy/RDF.md index c316a57c..6a566857 100644 --- a/_problems/easy/RDF.md +++ b/_problems/easy/RDF.md @@ -89,7 +89,7 @@ For each test case, output a single line containing the expected result of **RDF - **1** ≤ **T** ≤ **500000** (**5 \* 105**) - **1** ≤ **N** < **100000** (**105**) -- ≤ **K** < **100000** (**105**) +- 0 ≤ **K** < **100000** (**105**) ### Example @@ -104,8 +104,8 @@ For each test case, output a single line containing the expected result of **RDF 2.5 0.3750 0.0416667 - ### Explanation + **Example case 1.** **RDF(6, 1)** returns each of the numbers **0, 1, 2, 3, 4, 5** with probability **1/6**. Hence the expected value is **(0 + 1 + 2 + 3 + 4 + 5) / 6 = 2.5**./> diff --git a/_problems/easy/REARRSTR.md b/_problems/easy/REARRSTR.md index f7605d56..8bda53a6 100644 --- a/_problems/easy/REARRSTR.md +++ b/_problems/easy/REARRSTR.md @@ -104,8 +104,8 @@ aa aba ab -1 - ### Explanation + **Example case 1.** He can arrange the balloons in the order given by the following string "aba". **Example case 2.** He can arrange the balloons in the order given by the following string "ab" diff --git a/_problems/easy/RECIPE.md b/_problems/easy/RECIPE.md index 584d4b02..2646e213 100644 --- a/_problems/easy/RECIPE.md +++ b/_problems/easy/RECIPE.md @@ -27,13 +27,13 @@ For each test case, output exactly N space-separated integers on a line, giving 2 4 4 3 2 3 4 4 3 15 9 6 - ### Sample Output +
1 1
 2 3 4
 1 5 3 2
-
 
### Constraints + T≤100 2≤N≤50 All ingredient quantities are between 1 and 1000, inclusive. diff --git a/_problems/easy/RECRECOV.md b/_problems/easy/RECRECOV.md index 0e535869..79a1e0f2 100644 --- a/_problems/easy/RECRECOV.md +++ b/_problems/easy/RECRECOV.md @@ -119,5 +119,4 @@ For each test case, output a single line containing the minimum number of lines 1 2 2 - \ No newline at end of file diff --git a/_problems/easy/RECTCNT.md b/_problems/easy/RECTCNT.md index e9275503..995b970b 100644 --- a/_problems/easy/RECTCNT.md +++ b/_problems/easy/RECTCNT.md @@ -39,5 +39,4 @@ For each test case, output on a line an integer which is the respective number o Output: 3 - \ No newline at end of file diff --git a/_problems/easy/RECTLOVE.md b/_problems/easy/RECTLOVE.md index 1918eabf..e7b94576 100644 --- a/_problems/easy/RECTLOVE.md +++ b/_problems/easy/RECTLOVE.md @@ -113,6 +113,6 @@ Output **T** lines, each containing a single real number, containing the expecte Output: 0.8888888888888888 - ### Explanation + There are a total of 9 possible rectangles Thik could draw, shown in the figure above, and grid squares 1 and 2 are painted with a heart. The top row of possible selections (shown in the figure) contain 1, 0, 1, 2, and 2 hearts (from left to right), and the bottom row of possible selections (in the figure) contain 1, 0, 1, and 0 hearts. Therefore, 3/9 of the time 0 hearts are contained in the rectangle, 4/9 of the times 1 heart is contained in the rectangle, and 2/9 of the time 2 hearts are contained in the rectangle. The expected value is then 0 \* 3/9 + 1 \* 4/9 + 2 \* 2/9 = 8/9. diff --git a/_problems/easy/RECTQUER.md b/_problems/easy/RECTQUER.md index be5059e9..fa6bbff5 100644 --- a/_problems/easy/RECTQUER.md +++ b/_problems/easy/RECTQUER.md @@ -104,5 +104,4 @@ Output **Q** integers, each in a separate line - answers for the queries. 3 1 5 - \ No newline at end of file diff --git a/_problems/easy/REIGN.md b/_problems/easy/REIGN.md index d801049e..02379409 100644 --- a/_problems/easy/REIGN.md +++ b/_problems/easy/REIGN.md @@ -121,8 +121,8 @@ For each test case, output a single line containing the required integer. -2 12 18 - ### Explanation + There are **T** = 3 test cases the input. The first test case: **N** equals to 5, **K** equals to 3, A\[\] equals to {-1, 1, 2, 3, -1}. There is the only option: we have to choose \[1, 1\] and \[5, 5\] periods. diff --git a/_problems/easy/RESCALC.md b/_problems/easy/RESCALC.md index 2fbf3449..3820af2d 100644 --- a/_problems/easy/RESCALC.md +++ b/_problems/easy/RESCALC.md @@ -130,8 +130,8 @@ For each test case, output a single line containing the answer as specified in t chef 2 tie - ### Explanation + **Example case 1**. Chef has total 6 cookie, so he gets 6 points for that. Also, he can put all his cookies (as they are all distinct) in a bag of size 6. It will fetch him additional 4 points. So, Chef's total points will be 10. diff --git a/_problems/easy/RESERVOI.md b/_problems/easy/RESERVOI.md index 6704c8a2..1c01bb40 100644 --- a/_problems/easy/RESERVOI.md +++ b/_problems/easy/RESERVOI.md @@ -81,35 +81,35 @@ For example, let the reservoir be
 WW
 BB
+
This is not stable, as the water in the block (1, 1) can overflow to the left, similarly water in block (1, 2) can overflow to the right too. ``` -This is not stable, as the water in the block (1, 1) can overflow to the left, similarly water in block (1, 2) can overflow to the right too. BWB BBB +
This is stable, as the water at block (1, 2) is entrapped between bricks from all sides. ```
 
-
This is stable, as the water at block (1, 2) is entrapped between bricks from all sides. 
 AWA
 BBB
+
This is not stable, as the water at block (1, 2) might overflow to the left or the right. ``` -
This is not stable, as the water at block (1, 2) might overflow to the left or the right.
BAA ABB +
This is not stable, as there is a brick at block (1, 1) and air at (2, 1). The brick will go down and air will come up, so its not stable too. ```
 
-
This is not stable, as there is a brick at block (1, 1) and air at (2, 1). The brick will go down and air will come up, so its not stable too. 
 BWAAB
 BWBWB
 BBBBB
+
This is not stable too, as there is water at block (1, 2) and air at (1, 3), and (1, 4). The water will move towards those blocks. ``` -
This is not stable too, as there is water at block (1, 2) and air at (1, 3), and (1, 4). The water will move towards those blocks.
BBB BAB BBB +
So brick at (1, 2) is loose and without support, and hence will fill the space beneath it, which is right now filled with air. That is, the brick will go down and replace the air ```
 
-
So brick at (1, 2) is loose and without support, and hence will fill the space beneath it, which is right now filled with air. That is, the brick will go down and replace the air 
 BBB
 BWB
 BBB
-
 
This is also unstable due to the same reason as the above. Now, you are given description of reservoir. Can you tell whether the current state of reservoir is stable or not? + ### Input The first line of input contains an integer **T** denoting number of test cases. Description of **T** test cases follows. @@ -173,6 +173,6 @@ no no no no -
### Explanation + All the examples are explained in the problem statement itself. diff --git a/_problems/easy/RESN04.md b/_problems/easy/RESN04.md index 1398dbe8..75e4a4ad 100644 --- a/_problems/easy/RESN04.md +++ b/_problems/easy/RESN04.md @@ -34,5 +34,4 @@ Output T lines, one per test case. For each test case, output "ALICE" if Alice w Output: ALICE ALICE -
\ No newline at end of file diff --git a/_problems/easy/RESN05.md b/_problems/easy/RESN05.md index 8f039be1..a366a92e 100644 --- a/_problems/easy/RESN05.md +++ b/_problems/easy/RESN05.md @@ -33,5 +33,4 @@ Output T lines, one corresponding to each test case. Since the answers can get v 1 7 31 - \ No newline at end of file diff --git a/_problems/easy/RESQ.md b/_problems/easy/RESQ.md index 5abe721e..48d3d80c 100644 --- a/_problems/easy/RESQ.md +++ b/_problems/easy/RESQ.md @@ -104,8 +104,8 @@ Output **T** lines, each indicating the minimum possible difference between the 12 2 0 - ### Explanation + **Case 1**: 20 cupcakes can be arranged in 6 possible ways - 1 x 20, 2 x 10, 4 x 5, 5 x 4, 10 x 2 and 20 x 1. The corresponding differences between the length and the width are 19, 8, 1, 1, 8 and 19 respectively. Hence, 1 is the answer. **Case 4**: 4 cupcakes can be arranged as a 2 x 2 square. Difference between the length and the width is 0. You can't do anything better than 0. diff --git a/_problems/easy/RETPO.md b/_problems/easy/RETPO.md index 4824452b..4fab4940 100644 --- a/_problems/easy/RETPO.md +++ b/_problems/easy/RETPO.md @@ -95,6 +95,6 @@ For each test case, output a single line containing number of moves that robot w Output: 6 7 - ### Explanation + **Example case 1.** Sequence of moves would be LRLRLR diff --git a/_problems/easy/REVERSE.md b/_problems/easy/REVERSE.md index 95fc6a12..f53fa39c 100644 --- a/_problems/easy/REVERSE.md +++ b/_problems/easy/REVERSE.md @@ -105,8 +105,8 @@ In a single line, print the minimum number of edges we need to revert. If there Output: 2 - ### Explanation + We can consider two paths from **1** to **7**: - **1-2-3-4-7** diff --git a/_problems/easy/RHOUSE.md b/_problems/easy/RHOUSE.md index 86bf4d17..b59ed8de 100644 --- a/_problems/easy/RHOUSE.md +++ b/_problems/easy/RHOUSE.md @@ -59,5 +59,4 @@ HRR 2 0 1 - \ No newline at end of file diff --git a/_problems/easy/RIGHTRI.md b/_problems/easy/RIGHTRI.md index 7a92d506..2c5051d6 100644 --- a/_problems/easy/RIGHTRI.md +++ b/_problems/easy/RIGHTRI.md @@ -77,7 +77,7 @@ The first line of the input contains an integer **N** denoting the number of tri Output one integer, the number of right triangles among the given triangles. ### Constraints - **1** ≤ **N** ≤ **100000 (105)** -- ≤ **x1, y1, x2, y2, x3, y3** ≤ **20** +- 0 ≤ **x1, y1, x2, y2, x3, y3** ≤ **20** ### Example @@ -91,6 +91,6 @@ Output one integer, the number of right triangles among the given triangles. ### Output: 3 - ### Explanation + The first triangle and the last two triangles of the example are right triangles. diff --git a/_problems/easy/RIGHTTRI.md b/_problems/easy/RIGHTTRI.md index d2fb37f2..b22f775e 100644 --- a/_problems/easy/RIGHTTRI.md +++ b/_problems/easy/RIGHTTRI.md @@ -107,5 +107,4 @@ Output the answer for each test-case in a single line. If it is not possible to -1 285168.817674 546189.769984 616153.000000 - \ No newline at end of file diff --git a/_problems/easy/RNUM.md b/_problems/easy/RNUM.md index a92482e4..71f0bdce 100644 --- a/_problems/easy/RNUM.md +++ b/_problems/easy/RNUM.md @@ -100,7 +100,7 @@ Princess Rupsa wants to find out the minimum and maximum number of moves that ca Output: 1 2 - ### Explanation + - For minimum moves, you could aim for **2**, killing **1**, **2** and **3** in the same move. - For maximum moves, you could aim for **1**, killing **1** and **2** in the first move and then aim for **3** in the second move. diff --git a/_problems/easy/ROBOTG.md b/_problems/easy/ROBOTG.md index 31dad668..4cf5cb60 100644 --- a/_problems/easy/ROBOTG.md +++ b/_problems/easy/ROBOTG.md @@ -119,8 +119,8 @@ safe unsafe safe safe - ### Explanation + For the first case, there is only one grid square, so we must place our robot there. When the robot follows the command, it'll fall off, so it is unsafe. For the second case, we can place the robot on the bottom right grid square. Here is an image denoting the moves that the robot will make. ![](https://snag.gy/l4krZU.jpg) diff --git a/_problems/easy/ROTATION.md b/_problems/easy/ROTATION.md index 4672c56c..f7c4ca9f 100644 --- a/_problems/easy/ROTATION.md +++ b/_problems/easy/ROTATION.md @@ -110,8 +110,8 @@ R 2 5 3 3 - ### Explanation + The initial array : 5 4 3 3 9 The answer for **R 1** : 5 diff --git a/_problems/easy/ROWCOLOP.md b/_problems/easy/ROWCOLOP.md index 423e03e7..2622aa78 100644 --- a/_problems/easy/ROWCOLOP.md +++ b/_problems/easy/ROWCOLOP.md @@ -60,8 +60,8 @@ RowAdd 2 1 Output: 7 - ### Explanation + The grid changes as follows:
00  33  34  74  74
diff --git a/_problems/easy/ROWSOLD.md b/_problems/easy/ROWSOLD.md
index b7784173..e28af266 100644
--- a/_problems/easy/ROWSOLD.md
+++ b/_problems/easy/ROWSOLD.md
@@ -114,8 +114,8 @@ For each test case, output a single line containing one integer — the maximum
 10
 0
 48
-
 
### Explanation + **Test case 1.**The initial string is 10100. There are N = 5 cells. There is one soldier in the first cell, and one soldier in the third cell. The following scenario maximizes the total time: - Limak chooses the soldier in the first cell. This soldier can move only one cell to the right. It takes 1 second to choose a soldier and 1 second for a soldier to move to the next cell (2 seconds in total). The string is 01100 now. diff --git a/_problems/easy/RRCODE.md b/_problems/easy/RRCODE.md index cc7606fb..16e66ed3 100644 --- a/_problems/easy/RRCODE.md +++ b/_problems/easy/RRCODE.md @@ -114,8 +114,8 @@ OR 0 0 3 - ### Explanation + 0 xor 1 xor 2 xor 3 = 0 0 and 1 and 2 and 3 = 0 diff --git a/_problems/easy/RRCOPY.md b/_problems/easy/RRCOPY.md index beb7c90c..4636e247 100644 --- a/_problems/easy/RRCOPY.md +++ b/_problems/easy/RRCOPY.md @@ -93,6 +93,6 @@ For each test case, output a single line containing the answer. ### Constraints Output: 1 3 - ### Explanation + In the first case we could have only array **\[1\]** in the beginning and then obtain **\[1, 1\]**, then **\[1, 1, 1, 1\]** and finally **\[1, 1, 1, 1, 1\]**. In the second one we could obtain **A** from **\[1, 2, 3\]** by copying it's first two elements to the end. diff --git a/_problems/easy/RRECIPE.md b/_problems/easy/RRECIPE.md index 1c0546a7..c37b7c1d 100644 --- a/_problems/easy/RRECIPE.md +++ b/_problems/easy/RRECIPE.md @@ -99,8 +99,8 @@ aba 1 0 1 - ### Constraints + 1 ≤ T ≤ 20 1 ≤ sum of length of all input strings ≤ 1,000,000 diff --git a/_problems/easy/RRGAME.md b/_problems/easy/RRGAME.md index b506ca97..c9838edb 100644 --- a/_problems/easy/RRGAME.md +++ b/_problems/easy/RRGAME.md @@ -92,8 +92,8 @@ Output single integer - answer for the given problem modulo **109+7**. 1 2 3 Output: 2 - - ```### Explanation + ``` + ### Explanation All possible sums are 14 and 10. You can get them by, for example, these arrays: diff --git a/_problems/easy/RRSTONE.md b/_problems/easy/RRSTONE.md index 657faab0..df29179c 100644 --- a/_problems/easy/RRSTONE.md +++ b/_problems/easy/RRSTONE.md @@ -84,7 +84,7 @@ Output **N** numbers on a single line. It should be the array **A** after **K** ### Constraints - **1** <= **N** <= **105** -- <= **K** <= **109** +- 0 <= **K** <= **109** - **Ai** does not exceed **2 \* 109** by it's absolute value. ### Example @@ -95,5 +95,4 @@ Output **N** numbers on a single line. It should be the array **A** after **K** Output: 2 8 0 7 - \ No newline at end of file diff --git a/_problems/easy/RRSUM.md b/_problems/easy/RRSUM.md index b621ec49..924c6a7c 100644 --- a/_problems/easy/RRSUM.md +++ b/_problems/easy/RRSUM.md @@ -101,5 +101,4 @@ Output the answer for each query in separate lines as in example. 1 3 1 - \ No newline at end of file diff --git a/_problems/easy/SAD.md b/_problems/easy/SAD.md index 4cfe34ad..289d39c3 100644 --- a/_problems/easy/SAD.md +++ b/_problems/easy/SAD.md @@ -100,8 +100,8 @@ First line contains two integers **R** and **C**, the number of rows and columns Output: 8 - ### Example 2 +
 Input:
 3 3
@@ -111,8 +111,8 @@ First line contains two integers **R** and **C**, the number of rows and columns
 
 Output:
 GUESS
-
 
### Example 3 +
 Input:
 2 2
@@ -121,8 +121,8 @@ GUESS
 
 Output:
 10
-
 
### Explanation of Sample Cases + **Example 1**: The first row contains 9, 8, 8. Observe that both 8 are the minimum. Considering the first 8, look at the corresponding column (containing 8 and 6). Here, 8 is the largest element in that column. So it will be chosen. **Example 2**: There is no value in the matrix that is smallest in its row but largest in its column. diff --git a/_problems/easy/SALARY.md b/_problems/easy/SALARY.md index 375df37f..7e2de1fe 100644 --- a/_problems/easy/SALARY.md +++ b/_problems/easy/SALARY.md @@ -82,7 +82,7 @@ For each test case, output a single line containing the minimum number of operat - **1** ≤ **T** ≤ **100** - **1** ≤ **N** ≤ **100** -- ≤ **Wi** ≤ **10000** (**104**) +- 0 ≤ **Wi** ≤ **10000** (**104**) ### Example @@ -97,8 +97,8 @@ For each test case, output a single line containing the minimum number of operat Output: 3 0 - ### Explanation + **Example Case 1.** Chief can equalize all salaries in 3 turns: Turn IDIDs of involved workersSalaries after the move1 1 2 2 3 32 1 2 3 4 33 1 3 4 4 4**Example Case 2.** All salaries are already equal. He doesn't need to do anything. diff --git a/_problems/easy/SAMESNAK.md b/_problems/easy/SAMESNAK.md index f7655e16..11960458 100644 --- a/_problems/easy/SAMESNAK.md +++ b/_problems/easy/SAMESNAK.md @@ -113,8 +113,8 @@ yes no no yes - ### Explanation + In the images, the first snake is red, the second snake is yellow, and the intersections, if any, are in orange. The first test case corresponds to: diff --git a/_problems/easy/SANSKAR.md b/_problems/easy/SANSKAR.md index 752198d7..895916f4 100644 --- a/_problems/easy/SANSKAR.md +++ b/_problems/easy/SANSKAR.md @@ -90,8 +90,8 @@ For each test case, output "yes" if it is possible to divide his sanskars equall - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **21** - **1** ≤ **K** ≤ **8** -- Subtask #1 (20 points) : ≤ **intensity of sanskar** ≤ **10^5** -- Subtask #2 (80 points) : ≤ **intensity of sanskar** ≤ **10^10** +- Subtask #1 (20 points) : 0 ≤ **intensity of sanskar** ≤ **10^5** +- Subtask #2 (80 points) : 0 ≤ **intensity of sanskar** ≤ **10^10** ### Example @@ -105,6 +105,6 @@ For each test case, output "yes" if it is possible to divide his sanskars equall Output: yes no - ### Explanation + In the first case, sanskars can be allocated as follows, each follower receiving a total intensity of 6: {1,5}, {2,4}, {6}. diff --git a/_problems/easy/SCHEDULE.md b/_problems/easy/SCHEDULE.md index 99ddc29f..59e7f5b3 100644 --- a/_problems/easy/SCHEDULE.md +++ b/_problems/easy/SCHEDULE.md @@ -76,11 +76,11 @@ Chef is a well-known chef, and everyone wishes to taste his dishes. As you might know, cooking is not an easy job at all and cooking everyday makes the chef very tired. So, Chef has decided to give himself some days off. -Chef has made a schedule for the next **N** days: On **i**-th day if **A**i is equal to **1** then Chef is going to cook a delicious dish on that day, if **A**i is equal to then Chef is going to rest on that day. +Chef has made a schedule for the next **N** days: On **i**-th day if **A**i is equal to **1** then Chef is going to cook a delicious dish on that day, if **A**i is equal to 0 then Chef is going to rest on that day. After Chef made his schedule he discovered that it's not the best schedule, because there are some big blocks of consecutive days where Chef will cook which means it's still tiring for Chef, and some big blocks of consecutive days where Chef is going to rest which means chef will be bored doing nothing during these days. -Which is why Chef has decided to make changes to this schedule, but since he doesn't want to change it a lot, he will flip the status of at most **K** days. So for each day which Chef chooses, he will make it **1** if it was or he will make it if it was **1**. +Which is why Chef has decided to make changes to this schedule, but since he doesn't want to change it a lot, he will flip the status of at most **K** days. So for each day which Chef chooses, he will make it **1** if it was 0 or he will make it 0 if it was **1**. Help Chef by writing a program which flips the status of at most **K** days so that the size of the maximum consecutive block of days of the same status is minimized. @@ -90,7 +90,7 @@ The first line of the input contains an integer **T** denoting the number of tes The first line of each test case contains two integers: **N** denoting the number of days and **K** denoting maximum number of days to change. -The second line contains a string of length **N** , of which the **i**-th character is if chef is going to rest on that day, or **1** if chef is going to work on that day +The second line contains a string of length **N** , of which the **i**-th character is 0 if chef is going to rest on that day, or **1** if chef is going to work on that day ### Output @@ -101,8 +101,8 @@ For each test case, output a single line containing a single integer, which is t - **1** ≤ **T** ≤ **11,000** - **1** ≤ **N** ≤ **106** - The sum of **N** in all test-cases won't exceed **106**. -- ≤ **K** ≤ **106** -- ≤ **Ai** ≤ **1** +- 0 ≤ **K** ≤ **106** +- 0 ≤ **Ai** ≤ **1** ### Subtasks @@ -125,8 +125,8 @@ For each test case, output a single line containing a single integer, which is t 2 2 - ### Explanation + **Example case 1:** The answer is 2 because we can change the string to: 110101011 **Example case 2:** If we don't change the input string at all, the answer will be 2. It is the best value we can achieve under the given conditions. diff --git a/_problems/easy/SEAARASU.md b/_problems/easy/SEAARASU.md index d434e2fd..a22fe22e 100644 --- a/_problems/easy/SEAARASU.md +++ b/_problems/easy/SEAARASU.md @@ -111,8 +111,8 @@ For each test case, output a single line with the answer. ### Constraints Output: 1 6 - ### Explanation + **Example case 2.** In this case, one possible way in which Sereja can perform the operations could be as follows. - Pick **i = 2, j = 1. A\[2\] -= A\[1\]**. Now the resulting array would be **\[2, 2, 6\]**. diff --git a/_problems/easy/SEACO.md b/_problems/easy/SEACO.md index 67ff9d1d..b1103fd2 100644 --- a/_problems/easy/SEACO.md +++ b/_problems/easy/SEACO.md @@ -128,8 +128,8 @@ For each test case on different lines print an array **a**, after executing all 7 7 0 7 7 2 512 512 512 512 512 512 512 512 512 512 - ### Explanation: + **Example case 1.**. After the first command, the resulting array is \[1 1 0 0 0\], after second \[1 1 0 1 1\]. diff --git a/_problems/easy/SEAGRP.md b/_problems/easy/SEAGRP.md index 1cb43c39..021dc142 100644 --- a/_problems/easy/SEAGRP.md +++ b/_problems/easy/SEAGRP.md @@ -109,5 +109,4 @@ For each test case print **"YES"**, if you can remove the edges so that the degr YES NO YES - \ No newline at end of file diff --git a/_problems/easy/SEALINE.md b/_problems/easy/SEALINE.md index d6ad802e..914b1fdf 100644 --- a/_problems/easy/SEALINE.md +++ b/_problems/easy/SEALINE.md @@ -93,7 +93,7 @@ For each test case, output a single line with the answer — the minimal number - **1** ≤ **T** ≤ **100** - **1** ≤ **N** ≤ **100** -- ≤ **A\[i\]** i +- 0 ≤ **A\[i\]** i ### Example @@ -110,8 +110,8 @@ For each test case, output a single line with the answer — the minimal number 0 0 3 - ### Explanation + **Example case 3.** - First three persons don't need any steps to sit. The line after the arrangement of these persons will look like **\[1, 2, 3\]**. diff --git a/_problems/easy/SEALUP.md b/_problems/easy/SEALUP.md index f7bf0235..e2819188 100644 --- a/_problems/easy/SEALUP.md +++ b/_problems/easy/SEALUP.md @@ -104,7 +104,7 @@ For each test case, output a single line containing the minimum cost of sealing - **1** ≤ **T** ≤ **10** - The coordinates of the window are given either in clockwise or in a counter-clockwise order. - No three or more vertices lie on the same line (i.e. are collinear). -- ≤ **Xi**, **Yi** ≤ **106** +- 0 ≤ **Xi**, **Yi** ≤ **106** - **1** ≤ **Li**, **Ci** ≤ **106** ### Subtasks @@ -128,6 +128,6 @@ For each test case, output a single line containing the minimum cost of sealing Output: 50 - ### Explanation + **Example case 1.** In this case, Sergey's window is a rectangle with the side lengths of **1000** and **2000**. There are two types of the sticky stripes in the shop - the one of the length 1000 with the cost of 10 rubles and with the length of 2000 and the cost of 15 rubles. The optimal solution would be to buy **2** stripes of the first type **2** stripes of the second type. The cost will be **2 × 15 + 2 × 10 = 50** rubles. diff --git a/_problems/easy/SEATL.md b/_problems/easy/SEATL.md index c916321f..d03e16ae 100644 --- a/_problems/easy/SEATL.md +++ b/_problems/easy/SEATL.md @@ -79,15 +79,15 @@ For example, for the matrix 3 4 1 2 1 1 1 1 2 2 2 2 - The matrix **F** is +
 3 3 4 4
 3 3 3 3
 5 4 6 4
 4 5 4 6
-
 
Your task is to find the value of the maximum element of **F**. + ### Input The first line of input contains a single integer **T**, the number of test cases. **T** tests follow. First line of each test case contains two integers, **N** and **M**. Each of the next **N** lines contain **M** numbers, representing the matrix **A**. ### Output @@ -110,8 +110,8 @@ For each test case, output a line containing a single integer, the answer to the Output: 6 - ### Sub tasks + - Sub task #1: **1 ≤ N, M ≤ 10** (10 points) - Sub task #2: **1 ≤ N, M ≤ 100** (20 points) - Sub task #3: **original constraints** (70 points) diff --git a/_problems/easy/SEATRSF.md b/_problems/easy/SEATRSF.md index 236812e2..18577257 100644 --- a/_problems/easy/SEATRSF.md +++ b/_problems/easy/SEATRSF.md @@ -104,5 +104,4 @@ In a single line print the remainder of division the answer of the problem on nu 2 4 - \ No newline at end of file diff --git a/_problems/easy/SEATSTR2.md b/_problems/easy/SEATSTR2.md index 47e89497..ad9a4f54 100644 --- a/_problems/easy/SEATSTR2.md +++ b/_problems/easy/SEATSTR2.md @@ -115,5 +115,4 @@ abcd Output: 0 144 - \ No newline at end of file diff --git a/_problems/easy/SECUBE.md b/_problems/easy/SECUBE.md index c43ee801..301549f9 100644 --- a/_problems/easy/SECUBE.md +++ b/_problems/easy/SECUBE.md @@ -96,7 +96,7 @@ For each test case, output a single line containing "YES" or "NO" (without quote ### Constraints - **1** ≤ **T** ≤ **105** -- ≤ **C** ≤ **K3** +- 0 ≤ **C** ≤ **K3** - **2** ≤ **K** ≤ **100** ### Example @@ -109,6 +109,6 @@ For each test case, output a single line containing "YES" or "NO" (without quote Output: YES NO - ### Explanation + **Example case 1.** In this case Sebi bought a Rubik's of size 2 \* 2 \* 2. His sisters wanted 5 units of cube. He disassembled the cube into 8 units immediately and gave 5 of them to his sisters. Now he is left with 3 units. He buys 3 cubes at the shop. Now, after disassembling, he has 3 + 3 \* 8 = 27 cubes. By making use of these 27 cubes, he can make a Rubik's cube of size 3 \* 3 \* 3. diff --git a/_problems/easy/SETDIFF.md b/_problems/easy/SETDIFF.md index a8adedf0..1e56d369 100644 --- a/_problems/easy/SETDIFF.md +++ b/_problems/easy/SETDIFF.md @@ -129,8 +129,8 @@ Two subsets will be called different if there exists an index **i** such that ** 6 23 3 - ### Explanation + For first case answer will be 2-1 = 1. For the second case: diff --git a/_problems/easy/SETELE.md b/_problems/easy/SETELE.md index aa0118e6..7f6b384f 100644 --- a/_problems/easy/SETELE.md +++ b/_problems/easy/SETELE.md @@ -91,7 +91,7 @@ Output a single line containing the expected toll tax a tourist has to pay for v - **2** ≤ **N** ≤ **105** - **1** ≤ **u, v** ≤ **N** -- ≤ **c** ≤ **106** +- 0 ≤ **c** ≤ **106** ### Example @@ -102,8 +102,8 @@ Output a single line containing the expected toll tax a tourist has to pay for v Output: 2.333333 - ### Explanation + Assume that the citizens construct the high class road between city 1 and 2. A tourist can visit all the places by just paying a toll tax of 2 Rs. If the high class road is constructed between city 1 and 3. All the places then can be visited by just paying a toll tax of 3 Rs. diff --git a/_problems/easy/SGARDEN.md b/_problems/easy/SGARDEN.md index 3f430bc7..49abb75f 100644 --- a/_problems/easy/SGARDEN.md +++ b/_problems/easy/SGARDEN.md @@ -109,8 +109,8 @@ Now the Sheriff asks the question: How many times has he whistled? 1 6

- ### Explanation +
 

Example case 2. the bandits positions are: diff --git a/_problems/easy/SHIRO.md b/_problems/easy/SHIRO.md index 7d65f0c1..aa973a45 100644 --- a/_problems/easy/SHIRO.md +++ b/_problems/easy/SHIRO.md @@ -97,8 +97,8 @@ For each test case, output a line containing the required probability. The answe 1 ≤ ai ≤ 100 0 ≤ pi ≤ 100 -

### Example: + **Input:**
@@ -110,13 +110,13 @@ For each test case, output a line containing the required probability. The answe
 5 5
 50 60
 
-
 
**Output:** +
 0.5000000
 0.8000000
 
 
-
 
**Update:** + Difference in answer upto 1e-6 will be ignored. diff --git a/_problems/easy/SHOPTRIP.md b/_problems/easy/SHOPTRIP.md index 0d87ec5a..022a3201 100644 --- a/_problems/easy/SHOPTRIP.md +++ b/_problems/easy/SHOPTRIP.md @@ -163,8 +163,8 @@ For each test case, output a single line containing the answer: a number -1 if L 403.2247551123 -1 6652.7837723893 - ### Explanation + **Test case 1.** There are 3 shops, located at points (100, 100), (-50, 100) and (0, -100). The first shop is described by a string "111110", which means that ingredients 1 through 5 are available in this shop, but ingredient 6 isn't. The other two shops are described by strings "110011" and "001111" respectively. Any two shops are enough to get all 6 ingredients (because, for every two shops it's true that each of 6 ingredients is available in at least one of those two shops). To minimize the total distance, Limak should visit the first and the second shop (in any order). For example, his journey can look as follows: diff --git a/_problems/easy/SIGNWAVE.md b/_problems/easy/SIGNWAVE.md index 32088889..d277bf5b 100644 --- a/_problems/easy/SIGNWAVE.md +++ b/_problems/easy/SIGNWAVE.md @@ -144,8 +144,8 @@ For each test case, print the number of the points on the **x**-axis such that a 3 9 5 - ### Explanation + **Example 1.** This is the case of **S = 2, C = 0**. So the situation is the same as the first figure in the statement. There are **5** points on the **x**-axis such that at least **1** function through the points. That is, **x = 0, π/2, π, 3π/2, 2π**. **Example 2.** This is also the case of **S = 2, C = 0**. So the situation is the same as the first figure in the statement. There are **3** points on the **x**-axis such that at least **2** functions through the points. That is, **x = 0, π, 2π**. diff --git a/_problems/easy/SKYSCR.md b/_problems/easy/SKYSCR.md index c19fe95e..b3205984 100644 --- a/_problems/easy/SKYSCR.md +++ b/_problems/easy/SKYSCR.md @@ -118,9 +118,8 @@ For each testcase, print the minimum number of moves on a new line.
 1
 2 3
-
 
**Sample Output** +
 1
-
 
\ No newline at end of file diff --git a/_problems/easy/SNACKUP.md b/_problems/easy/SNACKUP.md index d35d1fae..71badcdc 100644 --- a/_problems/easy/SNACKUP.md +++ b/_problems/easy/SNACKUP.md @@ -118,5 +118,4 @@ In the next **k** lines, print the invitation letters as three space separated i 2 1 1 2 2 1 2 - \ No newline at end of file diff --git a/_problems/easy/SNAKEEAT.md b/_problems/easy/SNAKEEAT.md index 9b60f1b8..5835cb26 100644 --- a/_problems/easy/SNAKEEAT.md +++ b/_problems/easy/SNAKEEAT.md @@ -110,8 +110,8 @@ The Chef doesn't care about snakes eating each other. All he wants is to have as 3 1 0 - ### Explanation + In the first testcase, first query, the second snake (length 9) can eat the fourth snake (length 8), and hence make its length 10. Now, there are four snakes left, and their lengths are {21, 10, 5, 10}. So, we have three snakes with length ≥ 10: Two snakes of length 10 and one snake of length 21. This is the best you can do. In the second query, no matter what happens, you cannot get more than one snake of length ≥ 15. diff --git a/_problems/easy/SNAKY.md b/_problems/easy/SNAKY.md index 08562130..a8fef9f0 100644 --- a/_problems/easy/SNAKY.md +++ b/_problems/easy/SNAKY.md @@ -39,5 +39,4 @@ RRRRRDDDLLLU WALL 2 BODY 1 - \ No newline at end of file diff --git a/_problems/easy/SNCK04.md b/_problems/easy/SNCK04.md index 8b3efa13..1d356f88 100644 --- a/_problems/easy/SNCK04.md +++ b/_problems/easy/SNCK04.md @@ -37,5 +37,4 @@ For each test case print the output on a single line. 0 1 3 - \ No newline at end of file diff --git a/_problems/easy/SNCOUP.md b/_problems/easy/SNCOUP.md index 3492f19f..403e3173 100644 --- a/_problems/easy/SNCOUP.md +++ b/_problems/easy/SNCOUP.md @@ -114,6 +114,6 @@ For each test case, output a single integer corresponding to the minimum number 2 3 1 - ### Explanation + ![](https://discuss.codechef.com/upfiles/fences.png)All the examples are shown in the pictures. The fences built are shown by red colored horizontal or vertical segments. You can see that after putting these borders no snake can talk with any another snake. diff --git a/_problems/easy/SNSOCIAL.md b/_problems/easy/SNSOCIAL.md index efdee475..34ed7ca5 100644 --- a/_problems/easy/SNSOCIAL.md +++ b/_problems/easy/SNSOCIAL.md @@ -115,8 +115,8 @@ For each test case output a single integer corresponding to the minimum number o 0 1 2 - ### Explanation + **Example 1**. The wealth of all the snakes is already equal. So, no time is required for the transition. **Example 2**. At the end of the first hour, the wealth of snakes at cells (1, 1), (2,1) and (1, 2) will change from 1 to 2. Then, the wealth of all the snakes becomes equal, and hence it required a total of 1 hour. @@ -127,5 +127,4 @@ For each test case output a single integer corresponding to the minimum number o 2 2 2 2 2 2 2 2 1 2 2 2 - -After the end of the second hour, the wealth of all the snakes will be equal. So, the answer is 2. \ No newline at end of file +After the end of the second hour, the wealth of all the snakes will be equal. So, the answer is 2. diff --git a/_problems/easy/SNTEMPLE.md b/_problems/easy/SNTEMPLE.md index 8ec2b4ff..0745e767 100644 --- a/_problems/easy/SNTEMPLE.md +++ b/_problems/easy/SNTEMPLE.md @@ -112,8 +112,8 @@ For each test case, output a new line with an integer corresponding to the answe 0 1 3 - ### Explanation + **Example 1**. The entire mountain range is already a temple. So, there is no need to make any operation. **Example 2**. If you reduce the height of the first block to 0. You get 0 1 2 1. The blocks 1, 2, 1 form a temple. So, the answer is 1. diff --git a/_problems/easy/SPCANDY.md b/_problems/easy/SPCANDY.md index 41ae11a1..601a7c5c 100644 --- a/_problems/easy/SPCANDY.md +++ b/_problems/easy/SPCANDY.md @@ -100,13 +100,13 @@ For each test case, output a single line containing two space separated integers 2 10 2 100 3 - **Output:** +
 5 0
 33 1
-
 
### Explanation + For the first test case, all students can get an equal number of candies and teacher receives no candies at all For the second test case, teacher can give 33 candies to each student and keep 1 candy to herself diff --git a/_problems/easy/SPECIES.md b/_problems/easy/SPECIES.md index 2dffb254..8ac05401 100644 --- a/_problems/easy/SPECIES.md +++ b/_problems/easy/SPECIES.md @@ -147,8 +147,8 @@ PP 0 288603514 1 - ### Explanation + **Test case 1.** We are given the grid of size 3 × 3. One of the already fixed cells is inhabited by brown bears. They would fight with bears of any species other than brown bears, so adjacent cells with question marks must by inhabited by brown bears as well. Hence, there is only 1 way to replace question marks (both of them must be replaced by 'B'). **Test case 2.** In the given grid, there are two adjacent cells both inhabited by grizzly bears. They will fight with each other, so the answer is 0 — it's impossible to replace question marks so that there would be no fights (it doesn't matter that there are no question marks at all). diff --git a/_problems/easy/SPOON.md b/_problems/easy/SPOON.md index abe91389..8b173aa0 100644 --- a/_problems/easy/SPOON.md +++ b/_problems/easy/SPOON.md @@ -105,12 +105,12 @@ opqrs ddddd india yucky - ### Sample Output +
 There is a spoon!
 There is a spoon!
 There is indeed no spoon!
-
 
### Explanation + In the first test case, "Spoon" occurs in the second row. In the second test case, "spOon" occurs in the last column. diff --git a/_problems/easy/SPOTWO.md b/_problems/easy/SPOTWO.md index 32e3697e..a88178c7 100644 --- a/_problems/easy/SPOTWO.md +++ b/_problems/easy/SPOTWO.md @@ -124,5 +124,4 @@ For each test case, output a single line containing the required value: the **Nt 4 1048576 (and 99998 more answers...) - \ No newline at end of file diff --git a/_problems/easy/SPREAD.md b/_problems/easy/SPREAD.md index c251699a..0edf5ea7 100644 --- a/_problems/easy/SPREAD.md +++ b/_problems/easy/SPREAD.md @@ -42,13 +42,13 @@ S 1 7 1 Q 3 S 1 3 1 Q 3 +
**Output:**```
 
-
**Output:**
 0
 1
 2
-
 
### Limitations + - 0### Explanation + **In the first example**, 2 is a super number while 3 is not (as explained in the statement). So, the number of super numbers in the range \[2, 3\] will be equal to 1. diff --git a/_problems/easy/STACKS.md b/_problems/easy/STACKS.md index 24dc6530..43ba875d 100644 --- a/_problems/easy/STACKS.md +++ b/_problems/easy/STACKS.md @@ -131,6 +131,6 @@ If there are multiple correct answers, you are allowed to output any of them. 3 1 1 2 5 2 2 4 7 10 4 5 10 12 18 -
### Explanation + **Example 1** is already explained in the problem statement. diff --git a/_problems/easy/STDYTAB.md b/_problems/easy/STDYTAB.md index 34caae31..56f858fe 100644 --- a/_problems/easy/STDYTAB.md +++ b/_problems/easy/STDYTAB.md @@ -104,6 +104,6 @@ For each test case, print a single integer corresponding to the answer. 2 25 273 -
### Explanation + Test case 1 : There are only 2 such grids possible 0 and 1. diff --git a/_problems/easy/STEM.md b/_problems/easy/STEM.md index 61b268b6..38a8f4e1 100644 --- a/_problems/easy/STEM.md +++ b/_problems/easy/STEM.md @@ -99,6 +99,6 @@ For each test case, output the stem in a new line. grace graceful disgraceful gracefully Output: grace - ### Explanation + The stem is grace. diff --git a/_problems/easy/STEPUP.md b/_problems/easy/STEPUP.md index a5ba6367..77a0b1cd 100644 --- a/_problems/easy/STEPUP.md +++ b/_problems/easy/STEPUP.md @@ -41,20 +41,20 @@ For each testcase output the maximum value m or "IMPOSSIBLE" if no assignment is 3 2 1 2 1 3 - ### SAMPLE OUTPUT +
 IMPOSSIBLE
 2
-
 
### CONSTRAINTS +
 t <= 20
 N <= 10000
 M <= 20000
 1 <= a,b <= N
-
 
### EXPLANATION +
 A feasible assignment for the second testcase is: 
 
@@ -64,5 +64,4 @@ Vertex	             Number
 3			2
 
 So the maximum value is 2
-
 
\ No newline at end of file diff --git a/_problems/easy/STFM.md b/_problems/easy/STFM.md index 8ca7aaa4..bc2ac747 100644 --- a/_problems/easy/STFM.md +++ b/_problems/easy/STFM.md @@ -108,8 +108,8 @@ As answer could be large, help him, calculate value modulo **m**. 6

Explanation

- -18. F(1) = 1 \* (1! + 1) = 219. F(2) = 1 \* (1! + 2) + 2 \* (2! + 2) = 3 + 8 = 11 +18. F(1) = 1 \* (1! + 1) = 2 +19. F(2) = 1 \* (1! + 2) + 2 \* (2! + 2) = 3 + 8 = 11 20. F(3) = 1 \* (1! + 3) + 2 \* (2! + 3) + 3 \* (3! + 3) = 4 + 10 + 27 = 41 21. F(4) = 1 \* (1! + 4) + 2 \* (2! + 4) + 3 \* (3! + 4) + 4 \* (4! + 4) = 5 + 12 + 30 + 112 = 159 22. F(5) = 1 \* (1! + 5) + 2 \* (2! + 5) + 3 \* (3! + 5) + 4 \* (4! + 5) + 5 \* (5! + 5) = 794 diff --git a/_problems/easy/STONES.md b/_problems/easy/STONES.md index a82158ba..57a47dc5 100644 --- a/_problems/easy/STONES.md +++ b/_problems/easy/STONES.md @@ -94,5 +94,4 @@ none 2 1 0 - \ No newline at end of file diff --git a/_problems/easy/STRBIT.md b/_problems/easy/STRBIT.md index c9808d43..f57b7d96 100644 --- a/_problems/easy/STRBIT.md +++ b/_problems/easy/STRBIT.md @@ -110,8 +110,8 @@ RGGRGRG Output: 4 - ### Explanation + **Example case 1.** One optimal solution (with 4 steps) looks like this: - Choose the 1-st character (1-based index) and get "GRRRGRG". diff --git a/_problems/easy/STROPR.md b/_problems/easy/STROPR.md index 0960837b..ef5718b2 100644 --- a/_problems/easy/STROPR.md +++ b/_problems/easy/STROPR.md @@ -117,8 +117,8 @@ For each test case, output a single line containing one integer: **Ax** modulo 1 Output: 5 15 - ### Explanation + Values in the array **A**: - Before the operations: **\[1, 2, 3\]** diff --git a/_problems/easy/STRQ.md b/_problems/easy/STRQ.md index a2bf749d..badbc71b 100644 --- a/_problems/easy/STRQ.md +++ b/_problems/easy/STRQ.md @@ -121,8 +121,8 @@ c f 6 10 2 2 2 - ### Explanation + - Q1 : good strings are **ch** , **checfch** , **cfch** , **ch** - Q2 : good strings are **checf** , **checfchef** , **checfcheff** , **cf** , **cfchef** , **cfcheff** , **chef** , **cheff** diff --git a/_problems/easy/STRSUB.md b/_problems/easy/STRSUB.md index 3be8b93d..70b2d4a2 100644 --- a/_problems/easy/STRSUB.md +++ b/_problems/easy/STRSUB.md @@ -71,9 +71,9 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/MARCH15/mandarin/STRSUB.pdf) and [Russian](http://www.codechef.com/download/translated/MARCH15/russian/STRSUB.pdf). -You are given a string **S** of length **N** consisting only of s and **1**s. You are also given an integer **K**. +You are given a string **S** of length **N** consisting only of 0s and **1**s. You are also given an integer **K**. -You have to answer **Q** queries. In the **i**th query, two integers **Li** and **Ri** are given. Then you should print the number of substrings of **S\[L, R\]** which contain at most **K** s and at most **K** **1**s where **S\[L, R\]** denotes the substring from **L**th to **R**th characters of the string **S**. +You have to answer **Q** queries. In the **i**th query, two integers **Li** and **Ri** are given. Then you should print the number of substrings of **S\[L, R\]** which contain at most **K** 0s and at most **K** **1**s where **S\[L, R\]** denotes the substring from **L**th to **R**th characters of the string **S**. In other words, you have to count number of pairs **(i, j)** of integers such that **L ≤ i ≤ j ≤ R** such that no character in substring **S\[i, j\]** occurs more than **K** times. ### Input @@ -94,7 +94,7 @@ For each query, print the required answer in a single line. - **1 ≤ Li ≤ Ri ≤ N** - Sum of **N** over all test cases in one test file does not exceed **105** - Sum of **Q** over all test cases in one test file does not exceed **105** -- **S** consists only of s and **1**s. +- **S** consists only of 0s and **1**s. **Subtask 1: 10 points** @@ -127,14 +127,14 @@ For each query, print the required answer in a single line. 8 5 7 - ### Explanation + **Query 1:** Consider substring **P = S\[1, 4\] = "0111"**. Out of **10** total substrings of **P**, substrings **P\[1, 4\]** and **P\[2, 4\]** are not valid because both contain more than two **1**s. - Other substrings contains at most two s and at most two **1**s, thus the answer is **8**./>/> + Other substrings contains at most two 0s and at most two **1**s, thus the answer is **8**./>/> **Query 2:** Consider substring **P = S\[2, 4\] = "111"**. Out of **6** total substrings of **P**, substrings **P\[1, 3\]** is not valid because it contains more than two 1s./> **Query 3:** Consider substring **P = S\[5, 8\] = "0000"**. -Out of **10** total substrings of **P**, substrings **P\[1, 3\]**, **P\[1, 4\]** and **P\[2, 4\]** are not valid because all contain more than two s./> +Out of **10** total substrings of **P**, substrings **P\[1, 3\]**, **P\[1, 4\]** and **P\[2, 4\]** are not valid because all contain more than two 0s./> diff --git a/_problems/easy/SUBANAGR.md b/_problems/easy/SUBANAGR.md index 6bfabe44..d3b38c9a 100644 --- a/_problems/easy/SUBANAGR.md +++ b/_problems/easy/SUBANAGR.md @@ -52,6 +52,6 @@ step no such string Explanation: - In the first test case the longest string appears to be two characters long. String 'hp' satisfies the requirements as it's an anagram of 'hp' which is a subsequence of 'hope' and an anagram of 'ph' which is a subsequence of both 'elephant' and 'path'. Note that string 'ph' also satisfies the requirements, but 'hp' is lexicographically smaller. + In the second test case there is no such string. diff --git a/_problems/easy/SUBGCD.md b/_problems/easy/SUBGCD.md index 8062ebbd..8f324486 100644 --- a/_problems/easy/SUBGCD.md +++ b/_problems/easy/SUBGCD.md @@ -106,8 +106,8 @@ For each testcase, print the required answer in one line. Output: 2 -1 - ### Explanation + **Example case 1.**GCD(2,7)=1. So the subarray **\[A1,A2\]** is valid. **Example case 2.**No subarray satisfies. diff --git a/_problems/easy/SUBMIN.md b/_problems/easy/SUBMIN.md index a6dfd9c8..d95e8746 100644 --- a/_problems/easy/SUBMIN.md +++ b/_problems/easy/SUBMIN.md @@ -102,8 +102,8 @@ For each query, print the required number of subarrays. 2 0 8 - ### Explanation + **Query 1.** Only the two subarrays **\[3, 4\]** and **\[3\]** satisfy. **Query 2.** Again only the two subarrays **\[4\]** and **\[4\]** satisfy. Please note that these subarrays (**A0** and **A4**) are considered different. diff --git a/_problems/easy/SUMPAIR.md b/_problems/easy/SUMPAIR.md index fb9767ef..0a88b66d 100644 --- a/_problems/easy/SUMPAIR.md +++ b/_problems/easy/SUMPAIR.md @@ -109,8 +109,8 @@ For each test case, output the answer in a separate line. 8 22 37 - ### Explanation: + Test Case 1: You can only take 1 pair out of 3 numbers. So pair(3,5) is only valid pair whose difference is 2. Test Case 3: You can take pairs(3,2) and (15,17) as the answer. diff --git a/_problems/easy/SUMQ.md b/_problems/easy/SUMQ.md index 23b2eff8..eac81be9 100644 --- a/_problems/easy/SUMQ.md +++ b/_problems/easy/SUMQ.md @@ -110,8 +110,8 @@ Your task is to find the sum of f(X , Y , Z) over all triplets (X, Y , Z) where Output: 399 - ### Explanation: + As there is only one choice for Y which equals to 5, to get a non-zero function value,we can choose any element for X from the set { 1 , 2 , 3 } and for Z from the set { 4 , 5 } So triplets which give non-zero function values are: diff --git a/_problems/easy/SUMTRIAN.md b/_problems/easy/SUMTRIAN.md index c02f9931..87a75788 100644 --- a/_problems/easy/SUMTRIAN.md +++ b/_problems/easy/SUMTRIAN.md @@ -44,6 +44,6 @@ For each test case write the determined value in a separate line. Output: 5 9 - + **Warning: large Input/Output data, be careful with certain languages** /> diff --git a/_problems/easy/SUPERPLN.md b/_problems/easy/SUPERPLN.md index 154e2c3b..8a0213c9 100644 --- a/_problems/easy/SUPERPLN.md +++ b/_problems/easy/SUPERPLN.md @@ -47,5 +47,4 @@ For each test case, output a single line containing the word **"Yes"** followed Yes 3 No No - \ No newline at end of file diff --git a/_problems/easy/SUPVIL.md b/_problems/easy/SUPVIL.md index 360f9d51..500ef4f6 100644 --- a/_problems/easy/SUPVIL.md +++ b/_problems/easy/SUPVIL.md @@ -127,8 +127,8 @@ tinythief superheroes villains draw - ### Explanation + **Example case 1.** As you know that initially a superhero is fighting with a villain. After that, superhero "kittywoman" joins the fight. At this point, there are two superheros and one villain. After that "wingman" joins the fight too. As this point of time, there are three superheros and one villain, so the number of superheros are two more than number of villains, so superheros will win the fight. **Example case 2.** Other than first two peoople, six more people join the fight. The moment when the fight is decided is after **watersnake** joins the fight, because there are two superheroes fighting five villains, so villains will win. diff --git a/_problems/easy/TAAPLUSB.md b/_problems/easy/TAAPLUSB.md index 09d85576..c7501580 100644 --- a/_problems/easy/TAAPLUSB.md +++ b/_problems/easy/TAAPLUSB.md @@ -104,8 +104,8 @@ Your answer will be accepted if the error is less than 10 -6. 0.945 1.4445 - ### Explanation + **Example case 1.** We have 10\*10 = 100 cases of adding two 1-digit number. The carry appears when adding 1 and 9, 2 and 9, 3 and 9 ... and so on, diff --git a/_problems/easy/TAASEQ.md b/_problems/easy/TAASEQ.md index b1f57463..fd694d5d 100644 --- a/_problems/easy/TAASEQ.md +++ b/_problems/easy/TAASEQ.md @@ -114,8 +114,8 @@ For each test case print out single integer which is the number you will remove 3 -1 7 - ### Explaination + **test 1:** an array contain a single integer is considered to be an arithmetic progression so you can remove any number in the array. But note that we must print out the **smallest result** which is 3. **test 2:** there is no solution since none of \[1, 3, 4\], \[1, 5, 3\], \[1, 5, 4\], \[5, 3, 4\] is an arithmetic progressions. diff --git a/_problems/easy/TACHSTCK.md b/_problems/easy/TACHSTCK.md index 935f3418..8bdbf888 100644 --- a/_problems/easy/TACHSTCK.md +++ b/_problems/easy/TACHSTCK.md @@ -86,7 +86,7 @@ Output a single line containing the maximum number of pairs of chopsticks the Ch ### Constraints - **1** ≤ **N** ≤ **100,000 (10 5 )** -- ≤ **D** ≤ **1,000,000,000 (10 9 )** +- 0 ≤ **D** ≤ **1,000,000,000 (10 9 )** - **1** ≤ **L\[i\]** ≤ **1,000,000,000 (10 9 )** for all integers **i** from **1** to **N** ### Example @@ -102,8 +102,8 @@ Output a single line containing the maximum number of pairs of chopsticks the Ch Output: 2 - ### Explanation + The 5 sticks have lengths 1, 3, 3, 9 and 4 respectively. The maximum allowed difference in the lengths of two sticks forming a pair is at most 2. It is clear that the 4th stick (length 9) cannot be used with any other stick. The remaining 4 sticks can can be paired as (1st and 3rd) and (2nd and 5th) to form 2 pairs of usable chopsticks. diff --git a/_problems/easy/TAPALIN.md b/_problems/easy/TAPALIN.md index b6b5850c..f80a2346 100644 --- a/_problems/easy/TAPALIN.md +++ b/_problems/easy/TAPALIN.md @@ -121,6 +121,6 @@ For each test case, output a single line containing the answer for the correspon 728 1404 508533804 - ### Explanation + The first three examples are explained in the problem statement above. diff --git a/_problems/easy/TAVISUAL.md b/_problems/easy/TAVISUAL.md index f926538f..899aa531 100644 --- a/_problems/easy/TAVISUAL.md +++ b/_problems/easy/TAVISUAL.md @@ -102,8 +102,8 @@ For each test case output on a separate line the final position of the ball. Output: 1 - ### Explanation + The row of cups at the beginning of the game and after each flip is shown below. Here **'-'** means an empty cup and **'B'** is the cup that hides the ball, the segment of flip is marked bold.
diff --git a/_problems/easy/TEST.md b/_problems/easy/TEST.md
index b2ed0d3f..8883887a 100644
--- a/_problems/easy/TEST.md
+++ b/_problems/easy/TEST.md
@@ -29,5 +29,4 @@ Your program is to use the brute-force approach in order to _find the Answer to
 1
 2
 88
-
 
\ No newline at end of file diff --git a/_problems/easy/THREEDIF.md b/_problems/easy/THREEDIF.md index 93bb2ff3..67156376 100644 --- a/_problems/easy/THREEDIF.md +++ b/_problems/easy/THREEDIF.md @@ -105,8 +105,8 @@ For each test case, output a single line containing the number of required tripl 1 578880 0 - ### Explanation + **Example case 1.** We have the following triples composed of different numbers up to 3: (1, 2, 3) (1, 3, 2) diff --git a/_problems/easy/TIDRICE.md b/_problems/easy/TIDRICE.md index f354dcc9..a2ab8632 100644 --- a/_problems/easy/TIDRICE.md +++ b/_problems/easy/TIDRICE.md @@ -46,13 +46,12 @@ bhavani - 1 -2 -1 - -**Explanation** + +**Explanation**
Case 1 : Initially score = 0. Updation of scores in the order of user tilak's votes is as follows,

( + ): +1 is added to the final score. This is the 1st vote by this user, so no previous vote to nullify. score = 1 ( + ): 0 should be added ( -1 to nullify previous (+) vote, +1 to count the current (+) vote ). score = 1 ( - ) : -2 should be added ( -1 to nullify previous (+) vote, -1 to count the current (-) vote ). score = -1 ( + ): +2 should be added ( +1 to nullify previous (-) vote, +1 to count the current (+) vote ). score = 1

-
\ No newline at end of file diff --git a/_problems/easy/TIMEASR.md b/_problems/easy/TIMEASR.md index 4ad9a0ce..47708722 100644 --- a/_problems/easy/TIMEASR.md +++ b/_problems/easy/TIMEASR.md @@ -91,12 +91,12 @@ For each test case print all valid values of time as described in the statement ### Constraints and Subtasks - **1** ≤ **T** ≤ **105** -- ≤ **A** ≤ **180** +- 0 ≤ **A** ≤ **180** - Output won't exceed **1 MB**. **Subtask 1: (30 points)** -- **A** is an integer from the set {, **90**, **180**}. +- **A** is an integer from the set {0, **90**, **180**}. **Subtask 2: (30 points)** diff --git a/_problems/easy/TLG.md b/_problems/easy/TLG.md index db0da080..2c7d0386 100644 --- a/_problems/easy/TLG.md +++ b/_problems/easy/TLG.md @@ -26,8 +26,8 @@ Consider the following score sheet for a game with 5 rounds: 3 90 110 4 112 106 5 88 90 - The total scores of both players, the leader and the lead after each round for this game is given below: +
    Round      Player 1       Player 2     Leader     Lead
 
       1               140           	 82        Player 1     58
@@ -35,8 +35,8 @@ Consider the following score sheet for a game with 5 rounds:
       3               319           	326       Player 2      7
       4               431           	432       Player 2      1
       5               519           	522       Player 2      3
-
 
The winner of this game is Player 1 as he had the maximum lead (58 at the end of round 1) during the game. + Your task is to help the Manager find the winner and the winning lead. You may assume that the scores will be such that there will always be a single winner. That is, there are no ties. Input @@ -57,8 +57,7 @@ Input: 90 110 112 106 88 90 - Output: -
1 58
 
+
1 58
 
\ No newline at end of file diff --git a/_problems/easy/TMSLT.md b/_problems/easy/TMSLT.md index 8f6d4b0b..e6f391ee 100644 --- a/_problems/easy/TMSLT.md +++ b/_problems/easy/TMSLT.md @@ -82,7 +82,7 @@ But Chef does not know exact strengths of each player. He knows some parameter * Si = (a \* Si-12 + b \* Si-1 + c) mod 1000000, for i = 1 to N - 1** -There are **N** players numbering to **N-1** and **Si** is the strength of player **i**. +There are **N** players numbering 0 to **N-1** and **Si** is the strength of player **i**. ### Input @@ -111,5 +111,4 @@ For each test case, you have to print a single line containing the absolute stre 2 763 74896 -
\ No newline at end of file diff --git a/_problems/easy/TOTR.md b/_problems/easy/TOTR.md index bbcb1093..94aba494 100644 --- a/_problems/easy/TOTR.md +++ b/_problems/easy/TOTR.md @@ -108,8 +108,8 @@ Hello What are these people doing? They are solving TOTR in Codechef March long contest. Ohh! - ### Explanation + The string "qwertyuiopasdfghjklzxcvbnm" means that 'a' in Bytelandian is 'q' in English, 'b' in Bytelandian is 'w' in English, 'c' in Bytelandian is 'e' in English and so on. Thus to translate "Ph" (first sentence in example) to English: 1\) We find that 'p' in Bytelandian means 'h' in English. So we replace 'P' with 'H'. diff --git a/_problems/easy/TOURISTS.md b/_problems/easy/TOURISTS.md index 1219d02c..a4b1b0f4 100644 --- a/_problems/easy/TOURISTS.md +++ b/_problems/easy/TOURISTS.md @@ -125,8 +125,8 @@ YES 1 2 2 3 3 1 - ### Example 2 +
Input:
 3 2
 1 2
@@ -134,8 +134,8 @@ YES
 
 Output:
 NO
-
 
### Example 3 +
Input:
 5 6
 1 2
@@ -153,5 +153,4 @@ YES
 4 2
 2 5
 5 1
-
 
\ No newline at end of file diff --git a/_problems/easy/TOURMAP.md b/_problems/easy/TOURMAP.md index 2e333416..fbad2da6 100644 --- a/_problems/easy/TOURMAP.md +++ b/_problems/easy/TOURMAP.md @@ -78,12 +78,12 @@ Madrid Paris 100$ Paris Munich 200$ Munich Warsaw 150$ Warsaw Kiev 120$ - More formally, if he wanted to go from **A** to **B** directly and the price is **C** dollars, then he would write -
A B C$
 
+
A B C$
 
-
on a card.Each move was written on a different card. Sridhar was a great planner, so he would never visit the same place twice. Just before starting his journey, the cards got shuffled. Help Sridhar figure out the actual order of the cards and the total cost of his journey. +
on a card. +Each move was written on a different card. Sridhar was a great planner, so he would never visit the same place twice. Just before starting his journey, the cards got shuffled. Help Sridhar figure out the actual order of the cards and the total cost of his journey. ### Input @@ -92,8 +92,8 @@ The first line of the input contains an integer **T**, the number of test cases.
 Ai Bi Ci$
 
-
 
where the **i-th** line refers to the **i-th** card after getting shuffled. + ### Output For each case the output contains **N** lines, the first **N-1** lines should contain the **N-1** cards in their proper original order, the **N-th** line should contain the total cost of the travel. @@ -126,5 +126,4 @@ Paris Munich 200$ Munich Warsaw 150$ Warsaw Kiev 120$ 570$ - \ No newline at end of file diff --git a/_problems/easy/TOURNAM.md b/_problems/easy/TOURNAM.md index 80c5d4d0..889f64e7 100644 --- a/_problems/easy/TOURNAM.md +++ b/_problems/easy/TOURNAM.md @@ -66,5 +66,4 @@ For each test case output exactly one line containing the required probability i 66.00000000000000 73.18080000000000 75.47784648840000 - \ No newline at end of file diff --git a/_problems/easy/TPRODUCT.md b/_problems/easy/TPRODUCT.md index 6494f46b..35647f2d 100644 --- a/_problems/easy/TPRODUCT.md +++ b/_problems/easy/TPRODUCT.md @@ -38,8 +38,8 @@ For each test case, output on a line an integer which is the respective value of 3 105 - -Explanation:The second test case is constructed as follows: ``` +Explanation: +The second test case is constructed as follows: ``` 3 / \ diff --git a/_problems/easy/TRAVELER.md b/_problems/easy/TRAVELER.md index c667ea9a..fc743916 100644 --- a/_problems/easy/TRAVELER.md +++ b/_problems/easy/TRAVELER.md @@ -82,8 +82,8 @@ ERROR ERROR ERROR ERROR - ### Explanation + The 2nd route is incorrect since there is no road from **New-York** to **Kiev**. Note however that inverse road from **Kiev** to **New-York** exists. The 3rd route is incorrect since the first city coincides with the last one. The 4th route is incorrect since there is no city with name **Kyiv** (Probably Chef means **Kiev** but he misspells this word). diff --git a/_problems/easy/TREECAKE.md b/_problems/easy/TREECAKE.md index 242695f5..f529fe78 100644 --- a/_problems/easy/TREECAKE.md +++ b/_problems/easy/TREECAKE.md @@ -101,8 +101,8 @@ For each test case, output a single integer in a separate line denoting the mini Output: 1 2 - ### Explanation + **Example case 1.** The rooted tree will consist of only 1 node. So, Chef can cut the entire cake into 1 vertex-disjoint path consisting of the single node itself. **Example case 2.** This case is already explained in the problem description. diff --git a/_problems/easy/TREEGAME.md b/_problems/easy/TREEGAME.md index 0df4ce1b..2affb579 100644 --- a/_problems/easy/TREEGAME.md +++ b/_problems/easy/TREEGAME.md @@ -117,5 +117,4 @@ For each test case, output a single line containing the answer to the correspond 2 5 1 - \ No newline at end of file diff --git a/_problems/easy/TRIP.md b/_problems/easy/TRIP.md index 51aad500..add63e37 100644 --- a/_problems/easy/TRIP.md +++ b/_problems/easy/TRIP.md @@ -27,16 +27,15 @@ Output two space seperated integers : The least number of stops, and the number 4 7 10 - ### Sample Output : +
 3 2
-
 
### Constraints : +
 2 <= N <= 1000000
 1 <= M <= 1000
 a_1 < a_2 < .. < a_N
 
-
 
\ No newline at end of file diff --git a/_problems/easy/TRMAG.md b/_problems/easy/TRMAG.md index 62a901a0..57b6629f 100644 --- a/_problems/easy/TRMAG.md +++ b/_problems/easy/TRMAG.md @@ -42,5 +42,4 @@ Number of printed Sides<=2000. All other values abide by the number of printed s Output: 31.2000 47.0000 - \ No newline at end of file diff --git a/_problems/easy/TSORT.md b/_problems/easy/TSORT.md index 0f262656..2466b739 100644 --- a/_problems/easy/TSORT.md +++ b/_problems/easy/TSORT.md @@ -34,13 +34,12 @@ Output given numbers in non decreasing order. 6 7 1 - **Output:** +
 1
 3
 5
 6
 7
-
 
\ No newline at end of file diff --git a/_problems/easy/TUZGMBR.md b/_problems/easy/TUZGMBR.md index f1f1286b..77805430 100644 --- a/_problems/easy/TUZGMBR.md +++ b/_problems/easy/TUZGMBR.md @@ -105,7 +105,7 @@ For each test output "Tuzik" or "Vanya" on a separate line, indicating who will Tuzik Vanya - ### Explanation + **Test case 1:** On his first turn Tuzik moves chip 3 cells up to the cell **(4, 1)**. On his turn Vanya can move chip only right to the cell **(4, 2)** or to the cell **(4, 3)** and after that Tuzik moves it to **(4, 4)** and finishes the game. **Test case 2:** On his first Turn Tuzik can move chip to the cell **(2, 1)** or **(1, 2)**, but on his next turn Vanya moves it to **(2, 2)** and wins the game. diff --git a/_problems/easy/TWODOGS.md b/_problems/easy/TWODOGS.md index 8c76f490..d03581d0 100644 --- a/_problems/easy/TWODOGS.md +++ b/_problems/easy/TWODOGS.md @@ -104,8 +104,8 @@ Print one integer describing the minimum number of seconds that Chef needs to wa Sample Output 2: -1 - ### Explanation + In the first example, if Chef leaves the first dog from left and gives it integer **4**, and the second dog from right and gives it integer **1**, then the first dog takes **2** seconds and the second dog takes **1** second to get the apples. Thus Chef needs to wait **2** seconds. In any other way, Chef can't get the desired apples in less than **2** seconds. In the second example, Chef cannot get two apples such that the sum of their types is **5** so the answer is "-1". diff --git a/_problems/easy/TWSTR.md b/_problems/easy/TWSTR.md index 4df085e3..17da412b 100644 --- a/_problems/easy/TWSTR.md +++ b/_problems/easy/TWSTR.md @@ -122,5 +122,4 @@ chicken-ham flour-without-eggs NO - \ No newline at end of file diff --git a/_problems/easy/UASEQ.md b/_problems/easy/UASEQ.md index fb6f7677..5bcf1fa1 100644 --- a/_problems/easy/UASEQ.md +++ b/_problems/easy/UASEQ.md @@ -89,7 +89,7 @@ In the given test data, it is always possible to recover at least one arithmetic ### Constraints - **2** ≤ **N** ≤ **100000** -- ≤ **K** ≤ **min(10, N-2)** +- 0 ≤ **K** ≤ **min(10, N-2)** - **-109** ≤ **Ai** ≤ **109** ### Example @@ -100,5 +100,4 @@ In the given test data, it is always possible to recover at least one arithmetic Output: -5 -2 1 4 - \ No newline at end of file diff --git a/_problems/easy/UGLYF.md b/_problems/easy/UGLYF.md index bf17b81b..0ac56512 100644 --- a/_problems/easy/UGLYF.md +++ b/_problems/easy/UGLYF.md @@ -85,8 +85,8 @@ X X B C Z Q E F -
Length of petals in the above flower are 2, 2, 3 and 3.
+
 A flower's ugliness is sum of absolute difference of adjacent petal lengths _i.e._ _i.e._ if adjacent petal lengths are **L1, L2, L3, L4**, then ugliness of flower is **|L1 - L2| + |L2 - L3| + |L3 - L4| + |L4 - L1|.**
 
 Sherlock wants to find minimum value of ugliness if we consider all possible flower configurations. Note that a configuration is valid even if any of the petal length is 0.
@@ -116,8 +116,8 @@ BBBBBB
 Output: 
 2
 6
-
 
### Explanation
+
 Test case 1:
 If we keep the configuration shown in statement, the ugliness is 2, which is minimum possible. 
 
@@ -131,5 +131,4 @@ B B B  B  B B
        B
 
 where petal lengths are 1, 3, 1, 2.
-
 
\ No newline at end of file
diff --git a/_problems/easy/UNICOURS.md b/_problems/easy/UNICOURS.md
index 1542f65b..8f442c7e 100644
--- a/_problems/easy/UNICOURS.md
+++ b/_problems/easy/UNICOURS.md
@@ -110,8 +110,8 @@ For each test case, output a single line containing an integer corresponding to
 Output:
 2
 1
-
 
### Explanation + **Example case 1.** Both the courses 2 and 3 can have course 1 as a prerequisite. In this case, course 2 and course 3 are not prerequisites for any course. So, we have two such courses. Other possibility could be following. Course 2 has course 1 as a prerequisite, and course 3 has course 2 as a prerequisite. Thus only course 3 is the only course that is not the prerequisite of any other course. diff --git a/_problems/easy/UNIONSET.md b/_problems/easy/UNIONSET.md index a49e6709..af0fb964 100644 --- a/_problems/easy/UNIONSET.md +++ b/_problems/easy/UNIONSET.md @@ -123,8 +123,8 @@ For each test case, output a single integer corresponding to the answer. 0 3 3 -
### Explanation + **Example 1**. No pair of sets is there with its union = 2. For **example 2 and 3**, all the pairs are valid. diff --git a/_problems/easy/UNIVERSE.md b/_problems/easy/UNIVERSE.md index 94c53550..9738942c 100644 --- a/_problems/easy/UNIVERSE.md +++ b/_problems/easy/UNIVERSE.md @@ -121,8 +121,8 @@ For each query output its answer in a new line. If it's possible to reach one pl 4 2 -
**Explanation 1**: There are **N** = 3 planets in each universe. And they are connected by the edges (1, 2) and (2, 3) in each universe, as described by the 2nd and 3rd lines of the input. There are **M** = 3 special teleports, which are described by the 4th, 5th and 6th lines of the input. For example, the fourth line is "1 1 1 2", which means that there is a special teleport between the first planet of the first universe and the first planet of the second universe. The next **Q** = 3 lines denote the queries. For example, the 7th line is "2 1 2 2", which asks for the shortest distance between the second planet of the first universe and the second planet of the second universe. + The map of the multi-verse would look like this: ![](https://codechef_shared.s3.amazonaws.com/download/upload/SNCKFL17/universe.png)The solid lines correspond to tunnels, and the dotted lines correspond to the special teleports. @@ -158,5 +158,4 @@ impossible 3 2 - -**Explanation 2**: Note that there can be teleports between two planets of the same universe. As example, the only teleport in this testcase is between the first and fourth planets of the 30th universe. \ No newline at end of file +**Explanation 2**: Note that there can be teleports between two planets of the same universe. As example, the only teleport in this testcase is between the first and fourth planets of the 30th universe. diff --git a/_problems/easy/VK18.md b/_problems/easy/VK18.md index b8dd5120..6750b099 100644 --- a/_problems/easy/VK18.md +++ b/_problems/easy/VK18.md @@ -121,6 +121,6 @@ For each test case, print the answer on a separate line. 2 12 36 - ### Explanation + **Example case 3:** There are 9 rooms. Room (1,1) has number 2, room (1,2) has number 3, etc. For each room, the number of diamonds in it is equal to the room number, so the total number of diamonds present is (2+3+4+3+4+5+4+5+6) = 36. diff --git a/_problems/easy/VOTERS.md b/_problems/easy/VOTERS.md index 73840fb8..943e8ed3 100644 --- a/_problems/easy/VOTERS.md +++ b/_problems/easy/VOTERS.md @@ -21,12 +21,12 @@ layout: problem 23 30 42 57 90 21 23 35 57 90 92 21 23 30 57 90 - then the final list compiled by the collector would be: +
 21  23  30  57  90
-
 
The ID numbers 35, 42 and 92 which appeared in only one list each do not figure in the final list. + Your task is to help the collector by writing a program that produces the final list from the three given lists. Input format @@ -63,8 +63,8 @@ Sample input: 30 57 90 - Sample output: +
 5
 21 
@@ -72,5 +72,4 @@ Sample input:
 30 
 57 
 90
-
 
\ No newline at end of file diff --git a/_problems/easy/WALK.md b/_problems/easy/WALK.md index 4fc80bd3..bced65eb 100644 --- a/_problems/easy/WALK.md +++ b/_problems/easy/WALK.md @@ -109,8 +109,8 @@ There are few problems: 6 5 - ### Explanation + **Example case 1.** If we choose velocity 6, on the first step we have 6 >= 6 everything is OK, then we should decrease the velocity to 5 and on the 2nd segment we'll receive 5 >= 5, again OK, and so on. diff --git a/_problems/easy/WCOUNT.md b/_problems/easy/WCOUNT.md index 1bcbe777..784769dd 100644 --- a/_problems/easy/WCOUNT.md +++ b/_problems/easy/WCOUNT.md @@ -35,5 +35,4 @@ AAbaz 1 2 60 - -**Description:** In first case "ab" & "ba" are two different words. In third case, note that A & a are different alphabets and hence "Aa" & "aA" are different words. \ No newline at end of file +**Description:** In first case "ab" & "ba" are two different words. In third case, note that A & a are different alphabets and hence "Aa" & "aA" are different words. diff --git a/_problems/easy/WEICOM.md b/_problems/easy/WEICOM.md index 2a17da6e..7a15c845 100644 --- a/_problems/easy/WEICOM.md +++ b/_problems/easy/WEICOM.md @@ -116,5 +116,4 @@ Subtasks: 0011 1001 1000 - \ No newline at end of file diff --git a/_problems/easy/WEIGHT.md b/_problems/easy/WEIGHT.md index 88f698eb..71069557 100644 --- a/_problems/easy/WEIGHT.md +++ b/_problems/easy/WEIGHT.md @@ -21,8 +21,8 @@ Let us denote an **n** digit decimal number by a1a2a3...an with the condition th weight = weight + ABS(ai+1 - ai) - -Here ABS is the absolute value of the argument.Given _n_ and a weight _w_, find all the _n_ digit numbers having a weight _w_. Since the answer could be very large, print the answer modulo 1000007. +Here ABS is the absolute value of the argument. +Given _n_ and a weight _w_, find all the _n_ digit numbers having a weight _w_. Since the answer could be very large, print the answer modulo 1000007. ### Input Format: @@ -34,7 +34,7 @@ This will be followed by **t** lines each consisting of numbers **n** and **w**. - 2 <= **n** <= 20 -- <= **w** <= 200 +- 0 <= **w** <= 200 ### Output Format: @@ -49,11 +49,10 @@ For each test case print the answer modulo 1000007 in a separate line. 2 10 0 2 1 - ### Sample Output: +
 9
 17
-
 
\ No newline at end of file diff --git a/_problems/easy/WINDOW2.md b/_problems/easy/WINDOW2.md index 0bf123ce..ad4dc75a 100644 --- a/_problems/easy/WINDOW2.md +++ b/_problems/easy/WINDOW2.md @@ -42,8 +42,8 @@ Now Chef considers some particular **N x M** grid and wants to calculate the tot Output: 2 5 - ### Explanation + In the first case it is just the number of pairs of cells with value 1 that have the same column number. In the second case we have the following **(2, 2)**-windows: diff --git a/_problems/easy/WITMATH.md b/_problems/easy/WITMATH.md index 8d12ef94..efea460e 100644 --- a/_problems/easy/WITMATH.md +++ b/_problems/easy/WITMATH.md @@ -103,5 +103,4 @@ The first line contains single integer **T** - the number of test cases. Each of φ(2)/2=1/2 φ(3)/3=2/3 φ(4)/4=2/4 - \ No newline at end of file diff --git a/_problems/easy/WORLDCUP.md b/_problems/easy/WORLDCUP.md index 0e376e70..ee0c742c 100644 --- a/_problems/easy/WORLDCUP.md +++ b/_problems/easy/WORLDCUP.md @@ -121,8 +121,8 @@ For each test cases output the number of ways modulo 1e9+7 (i.e. 1000000007) 1 0 12 - ### Explanation +
 Explanation for the sample input 1:
 
@@ -150,5 +150,4 @@ Only possible ways to win the match are 46 and 64. Hence answer is 2.
 You need to consider all sample space i.e. 4^B
 
 Note that the answer to R = 0 , B = 2 , W =1 is 3  [ 00 , 0W , W0 ]
-
 
\ No newline at end of file diff --git a/_problems/easy/WOUT.md b/_problems/easy/WOUT.md index 7debbaeb..916f986e 100644 --- a/_problems/easy/WOUT.md +++ b/_problems/easy/WOUT.md @@ -94,7 +94,7 @@ One integer – minimum energy required. - **1** ≤ **N** ≤ **106** - **1** ≤ sum of **N** over all test cases ≤ **106** - **1** ≤ **H** ≤ **N** -- ≤ **li** ≤ **hi** < **N** +- 0 ≤ **li** ≤ **hi** < **N** ### Subtasks @@ -122,8 +122,8 @@ Subtask 2 (75 points): No additional constraints 4 2 - ### Explanation + In the second case, the figure describes the initial map, where white cells denote empty cells and brown cells denote soil cells. ![](http://www.codechef.com/download/AUG15/bef.png) diff --git a/_problems/easy/WSITES01.md b/_problems/easy/WSITES01.md index 94980f11..24f2000d 100644 --- a/_problems/easy/WSITES01.md +++ b/_problems/easy/WSITES01.md @@ -113,6 +113,6 @@ Otherwise, in the first line print the number of filters K in the firewall. Then 2 codef y - ### Explanation + You can see that the filter "codef" is a prefix of the blocked site "codeforces", but not a prefix of approved sites "codechef" and "google". Similarly, filter "y" is also a prefix of blocked site "youtube", but not a prefix of the approved sites. You can also see that there exists at least one filter for both the blocked sites "codeforces" and "youtube". diff --git a/_problems/easy/WSTRING.md b/_problems/easy/WSTRING.md index b709b87a..49f57bfe 100644 --- a/_problems/easy/WSTRING.md +++ b/_problems/easy/WSTRING.md @@ -79,11 +79,11 @@ For example, the _W string_ can be formed from "aaaaa#bb#cc#dddd" such as: a b c d a b c d # # - He also call the strings which can generate a 'W' shape (satisfying the above conditions) _W strings_. + More formally, a string **S** is a _W string_ if and only if it satisfies the following conditions (some terms and notations are explained in **Note**, please see it if you cannot understand): -- The string **S** contains **exactly** **3** '#' characters. Let the indexes of all '#' be **P1 < P2 < P3** (indexes are -origin). +- The string **S** contains **exactly** **3** '#' characters. Let the indexes of all '#' be **P1 < P2 < P3** (indexes are 0-origin). - Each substring of **S\[0, P1−1\], S\[P1+1, P2−1\], S\[P2+1, P3−1\], S\[P3+1, |S|−1\]** contains exactly one kind of characters, where **S\[a, b\]** denotes the non-empty substring from **a+1**th character to **b+1**th character, and **|S|** denotes the length of string **S** (See **Note** for details). Now, his friend Ryuk gives him a string **S** and asks him to find the length of the longest _W string_ which is a subsequence of **S**, with only one condition that there must not be any '#' symbols between the positions of the first and the second '#' symbol he chooses, nor between the second and the third (here the "positions" we are looking at are in **S**), i.e. suppose the index of the '#'s he chooses to make the _W string_ are **P1, P2, P3** (in increasing order) in the original string **S**, then there must be no index **i** such that **S\[i\]** = '#' where **P1 < i < P2 or P2 < i < P3**. @@ -104,7 +104,7 @@ First line of input contains an integer **T**, denoting the number of test cases ### Output -Output an integer, denoting the length of the longest _W string_ as explained before. If **S** has no _W string_ as its subsequence, then output . +Output an integer, denoting the length of the longest _W string_ as explained before. If **S** has no _W string_ as its subsequence, then output 0. ### Constraints @@ -125,8 +125,8 @@ abc#dda#bb#bb#aca 16 10 11 - ### Explanation + In the first case: the whole string forms a _W String_. In the second case: acb#aab#bab#accba, the longest _W string_ is ac**b#aa**b**\#b**a**b#a**ccb**a** diff --git a/_problems/easy/XORNUBER.md b/_problems/easy/XORNUBER.md index 248ed83c..e3b42c06 100644 --- a/_problems/easy/XORNUBER.md +++ b/_problems/easy/XORNUBER.md @@ -96,6 +96,6 @@ For each test case, output a single line containing the number **M** or **-1** a Output: 1 - ### Explanation + **First Example :** **M** desired in the problem would be 1. As bitwise XOR of 1 and 2 is equal to 3. diff --git a/_problems/easy/XORSUB.md b/_problems/easy/XORSUB.md index 4e92912e..799abadd 100644 --- a/_problems/easy/XORSUB.md +++ b/_problems/easy/XORSUB.md @@ -100,8 +100,8 @@ For each test case, print the required answer in one line. Output: 7 -
### Explanation
+
 Considering all subsets:
 
  F({}) = 0 ⇒ 4 **⊕** 0 = 4
diff --git a/_problems/easy/YNOUTPUT.md b/_problems/easy/YNOUTPUT.md
index 54f6c545..f92d9d03 100644
--- a/_problems/easy/YNOUTPUT.md
+++ b/_problems/easy/YNOUTPUT.md
@@ -80,17 +80,17 @@ only if it is different, print "NO". The output for each case must be on a singl
 
 
1 ≤ T ≤ 100
 There is only one unique valid output that you can print
-
 
### Sample Input +
2
 NO
 NO
 NO
 YES
-
 
### Sample Output +
NO
 YES
-
 
### Explanation + Your output clearly matches the input for the second case. No other output can be valid for this file. diff --git a/_problems/hard/A5.md b/_problems/hard/A5.md index fcaf6d68..7dd23b1a 100644 --- a/_problems/hard/A5.md +++ b/_problems/hard/A5.md @@ -36,8 +36,8 @@ Print to output exactly 2 numbers separated by spaces: the cost of the optimal s Output: 31 3 -
+ **Explanation:** The three solutions leading to cost 31 are as follows:/> diff --git a/_problems/hard/A7.md b/_problems/hard/A7.md index ae237a32..7ab49695 100644 --- a/_problems/hard/A7.md +++ b/_problems/hard/A7.md @@ -55,8 +55,8 @@ The output should contain a single integer value - the code that opens the safe. Output: 2 - ### Notes + a) This should not surprise anyone. As the IT sector is extremely well-developed in Byteland, pizza network owners are among the richest people there. b) For some inscrutable reasons such streets are called squares. Not to be mixed up with the squares you draw! diff --git a/_problems/hard/A8.md b/_problems/hard/A8.md index b30487f0..cf9dd7c1 100644 --- a/_problems/hard/A8.md +++ b/_problems/hard/A8.md @@ -45,5 +45,4 @@ For each test case, output a separate line containing one number, equal to the m 2 4 5 - -a) Some conspiracy theorists claim that this task has in fact nothing to do with unification, and that it was proposed by pizza parlour lobbyists simply to boost their direct revenue at your expense. But don't worry, in any case, you are helping Byteland out of depression! \ No newline at end of file +a) Some conspiracy theorists claim that this task has in fact nothing to do with unification, and that it was proposed by pizza parlour lobbyists simply to boost their direct revenue at your expense. But don't worry, in any case, you are helping Byteland out of depression! diff --git a/_problems/hard/ADADET.md b/_problems/hard/ADADET.md index b0c9b9cd..d7c11a3d 100644 --- a/_problems/hard/ADADET.md +++ b/_problems/hard/ADADET.md @@ -112,8 +112,8 @@ For each testcase print **n** integers: **ai**, the rightmost building shot at, Output: 5 5 -1 -1 7 7 -1 - ### Explanation + ![](https://codechef_shared.s3.amazonaws.com/download/upload/COOK83/detective.png)The lines of shooting are shown in the figure above. From building 1, buildings 2 and 5 are shot. As the rightmost is building 5, that is the answer for building 1. Note that from building 1 is not possible to shoot at building 4 (dotted line) because building 2 obstructs the line of sight. diff --git a/_problems/hard/ADJLEAF.md b/_problems/hard/ADJLEAF.md index 08b52e14..bd3998bf 100644 --- a/_problems/hard/ADJLEAF.md +++ b/_problems/hard/ADJLEAF.md @@ -137,8 +137,8 @@ For each test-case output **N** lines, in i-th line output a single integer deno 27 27 27 - ### Explanation + **Example case 1.** all subsets of leaves are good whatever the root is, so the answer is 7 when there are 3 leaves and 3 when there are 2 leaves **Example case 2.** when the root is node 1 all subsets of leaves are good except: diff --git a/_problems/hard/ALICE.md b/_problems/hard/ALICE.md index c57c97f4..d715b2b3 100644 --- a/_problems/hard/ALICE.md +++ b/_problems/hard/ALICE.md @@ -109,6 +109,7 @@ If there are multiple passwords that satisfies the information, print any of the 0 3 3 2 ### Explanation + One of the possible passwords is depicted in the above figure. Every cell is cut by at least one line, for example the green cell is cut by the blue and purple lines, but not by the yellow one. The integer points on the perimeter of the board are drawn as small black circles. diff --git a/_problems/hard/ALLPOLY.md b/_problems/hard/ALLPOLY.md index 2fbb8539..bcbde901 100644 --- a/_problems/hard/ALLPOLY.md +++ b/_problems/hard/ALLPOLY.md @@ -72,7 +72,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/JULY16/mandarin/ALLPOLY.pdf), [Russian](http://www.codechef.com/download/translated/JULY16/russian/ALLPOLY.pdf) and [Vietnamese](http://www.codechef.com/download/translated/JULY16/vietnamese/ALLPOLY.pdf) as well. -Chef holds all his secret recipes inside his house. For this reason, Chef's house is closed off by walls, thus it is very secure. You can think of the walls as a **simple polygon** in the 2D plane, and you can consider the thickness of the walls to be negligible, i.e., . +Chef holds all his secret recipes inside his house. For this reason, Chef's house is closed off by walls, thus it is very secure. You can think of the walls as a **simple polygon** in the 2D plane, and you can consider the thickness of the walls to be negligible, i.e., 0. Unfortunately, bad guys plan to steal his recipes. To do so, they plan to send a single agent to parachute in a uniformly-chosen random point in the region **\[-107,107\] × \[-107,107\]**. (This point need not be a lattice point.) Once the agent parachutes down that point, he then deploys in his exact location a special weapon called the **pulverizer**, which is designed to destroy walls. The pulverizer works by firing a laser that rotates 360 degrees clockwise, initially pointing north. This laser beam completely destroys the part of the wall it hits. @@ -138,6 +138,6 @@ For each test case, output a single real number denoting the probability of a su Output: 0.25 0.00045 - ### Explanation + The second example is depicted by the image above. diff --git a/_problems/hard/ALMROW.md b/_problems/hard/ALMROW.md index 1edee871..b1579a02 100644 --- a/_problems/hard/ALMROW.md +++ b/_problems/hard/ALMROW.md @@ -134,8 +134,8 @@ For each test case, output a single line containing one integer — the sum of f 16 891 166666666666500000 - ### Explanation + The provided example test contains **T** = 4 test cases. The following drawings show the situation for the first two test cases (extra roads are red): ![](https://codechef_shared.s3.amazonaws.com/uploads/2017/03/LTIME46/ALMROW.png) diff --git a/_problems/hard/AMR15E.md b/_problems/hard/AMR15E.md index caf09182..76a15308 100644 --- a/_problems/hard/AMR15E.md +++ b/_problems/hard/AMR15E.md @@ -117,8 +117,8 @@ For each tattoo, output the value of the color that Baahubali creates using the 8 14 14 - ### Explanation + For the first tattoo, **L = 1** and **R = 1**, and there is only 1 unique color (= **1**) in that range. Hence, the answer is **1**. For the second tattoo, there are 2 unique colors **\[1, 2\]**, and the new color formed is 1\*1 + 2\*2 = **5**. diff --git a/_problems/hard/ANUAAA.md b/_problems/hard/ANUAAA.md index bae42596..2b2d77b8 100644 --- a/_problems/hard/ANUAAA.md +++ b/_problems/hard/ANUAAA.md @@ -86,8 +86,8 @@ function f(A[0..N-1], L, R, P): if PF == P: ANSWER = MAX(ANSWER, SIZE(S)) return ANSWER - -Clarifications: + +Clarifications: Line 5 loops over all 2^(R-L+1) subsets. GCD(S) returns the Greatest common divisor of all the elements in S. SIZE(S) returns the number of elements in S. @@ -113,7 +113,7 @@ Output single integer which is the required answer modulo 1000000007 - **1** ≤ **N** ≤ **100000** - **1** ≤ **M** ≤ **500** - **1** ≤ **A\[i\]** ≤ **100000** -- ≤ **B\[i\]** < **N** +- 0 ≤ **B\[i\]** < **N** ### Example @@ -124,8 +124,8 @@ Output single integer which is the required answer modulo 1000000007 Output: 34 - ### Explanation + Here are the answers of few calls to function f() f(A, 2, 0, 2) = 1 f(A, 2, 0, 5) = 0 diff --git a/_problems/hard/ANUDTQ.md b/_problems/hard/ANUDTQ.md index 9c611dd2..cf64eb66 100644 --- a/_problems/hard/ANUDTQ.md +++ b/_problems/hard/ANUDTQ.md @@ -72,8 +72,8 @@ layout: problem All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/MAY14/mandarin/ANUDTQ.pdf) and [Russian](http://www.codechef.com/download/translated/MAY14/russian/ANUDTQ.pdf). Given a directed tree with **N** nodes. You need to process **M** queries. -Each node has a **key** and a **value**, a node is referenced by its key. **N** nodes have **keys** from to **N-1**. -Root always has the **key** equal to . Queries can be of the following 4 types: +Each node has a **key** and a **value**, a node is referenced by its key. **N** nodes have **keys** from 0 to **N-1**. +Root always has the **key** equal to 0. Queries can be of the following 4 types: 1\. Given a **key** of a node present in the tree, append a child node to it. The new node gets the smallest never-used positive integer as its key. The **value** of the new node will be given in the input. @@ -142,8 +142,8 @@ For each query of type 4, output the required answer. Output: 30 38 - ### Explanation + **Query #1** **type** = 4 **encoded\_key** = 0 diff --git a/_problems/hard/ANUSAR.md b/_problems/hard/ANUSAR.md index a4d9bd3f..2428953f 100644 --- a/_problems/hard/ANUSAR.md +++ b/_problems/hard/ANUSAR.md @@ -112,8 +112,8 @@ aaeddf 4 0 0 - ### Explanation + There are a total of 6\*(6+1)/2 substrings, all of them occur at least once. So for **F1=1** answer is equal to 21. Note that substring **"a"** is repeated 2 times in **S**, both the instances are added to the answer. Look at **F2=2**. Substring **"a"** and substring **"d"** occurs 2 times each in **S**. The answer for **F2** is 4, that is all the occurrences of **"a"** and **"d"**. diff --git a/_problems/hard/ANUSFR.md b/_problems/hard/ANUSFR.md index f011ebcd..b15d6b50 100644 --- a/_problems/hard/ANUSFR.md +++ b/_problems/hard/ANUSFR.md @@ -98,7 +98,7 @@ For each query, output one line with 2 space separated integers, start and end p - **1** ≤ **Q** ≤ **10^5** - **1** ≤ **x** ≤ **26** - **1** ≤ **minLength** ≤ **maxLength** ≤ **|S|** -- ≤ **L** ≤ **R** ≤ **|S|-1** +- 0 ≤ **L** ≤ **R** ≤ **|S|-1** ### Example @@ -113,8 +113,8 @@ abcc 0 1 1 3 -1 -1 - ### Explanation + **Testcase #1** We need a substring with 2 different characters, of length 1 or 2 or 3 and in between S\[0..3\]. S\[0..1\] = "ab", which has 2 different characters, length 2, and is in between S\[0..3\] diff --git a/_problems/hard/APRPS.md b/_problems/hard/APRPS.md index 73738399..6fee3ad5 100644 --- a/_problems/hard/APRPS.md +++ b/_problems/hard/APRPS.md @@ -114,6 +114,6 @@ Each testcase print an integer **k** denotes the degree of polynomial in a singl 4 1 0 999999997 0 1

- ### Explanation + The first polynomial is **x2 − 2**, and the second one is **x4 − 10x2 + 1**. diff --git a/_problems/hard/ARCHPLG.md b/_problems/hard/ARCHPLG.md index d8f26de6..7ba3f9c8 100644 --- a/_problems/hard/ARCHPLG.md +++ b/_problems/hard/ARCHPLG.md @@ -40,8 +40,8 @@ name x y [name of a terminal and its coordinates] F [number of restricted areas F<20] xl, yd, xr, yu [coordinates of each restricted area, 0 <=xl < xr<=250 0<=yd < yu<=250.] - All coordinates are nonnegative integers measured in BM according to upper left corner of an island. + You can assume that any two restricted areas are disjoint. After the description of all islands all ferry connections are given (each connection is bi-directional).
@@ -53,8 +53,8 @@ and communiaction time]
 [description follows]
 ...
 NBS NWS NBC NWC [start and goal terminal for John]
-
 
### Output + For each test describe the shortest route for John from terminal NBS on NWS island to terminal NBC on NWC island in the following format:
@@ -67,8 +67,8 @@ NBS  NWS
 NBC NWC
 [empty line]
 [consecutive tests]
-
 
If two consecutive terminals are located on the same island and John must take some walk you must give all middle point like in an example. + ![](/content/kuszi:trectarch_example.png) ### Example @@ -106,8 +106,8 @@ Korkyra 0 0 Kamejros W1 Knossos W2 100 Malia W2 Korkyra W3 100 Korkyra W3 Lindos W1 - An example of a correct answer: +
 Output:
 case 1 Y
@@ -122,5 +122,4 @@ Kamejros W1
 2 6
 2 1
 Lindos W1
-
 
\ No newline at end of file diff --git a/_problems/hard/ARRANGE2.md b/_problems/hard/ARRANGE2.md index 895a7a37..9d7446ea 100644 --- a/_problems/hard/ARRANGE2.md +++ b/_problems/hard/ARRANGE2.md @@ -29,16 +29,13 @@ Sample Input : 1 100 499875921 499875921 -
 Sample Output :
 0
 1
 
-
 
 Constraints :
 1 <= T <= 10000
 1 <= A <= B <= 10000000000 (10^10)
-
 
\ No newline at end of file diff --git a/_problems/hard/ARRAYSUM.md b/_problems/hard/ARRAYSUM.md index 6679bd68..73189c90 100644 --- a/_problems/hard/ARRAYSUM.md +++ b/_problems/hard/ARRAYSUM.md @@ -130,8 +130,8 @@ Output a single line containing the number of subsequences **C** as asked in the Output #2: 6 - ### Explanation + **Example case 1.** The suitable subsequences are (1, 2, 7), (1, 4, 7), (5, 4, 7), (2, 4, 7). **Example case 2.** The suitable subsequence is **(7, 7)**, and it appears 6 times: diff --git a/_problems/hard/ASTRD.md b/_problems/hard/ASTRD.md index fb58c010..d6e608a2 100644 --- a/_problems/hard/ASTRD.md +++ b/_problems/hard/ASTRD.md @@ -105,6 +105,6 @@ For each test case, output one integer in a new line: the answer for the test ca Output: 0 - ### Sample explanation: + One of the solutions can be: as all the asteroids have positive coordinates, we can choose some point on the surface which lies in the all-negative octant (see octant VII [here](https://en.wikipedia.org/wiki/Octant_%28solid_geometry%29)), and none of the asteroids will be observed. diff --git a/_problems/hard/AUTHEN.md b/_problems/hard/AUTHEN.md index 64b498ad..ee30b61d 100644 --- a/_problems/hard/AUTHEN.md +++ b/_problems/hard/AUTHEN.md @@ -45,5 +45,4 @@ ababab 10 Explanation: - -In the first test case, the password is definitely "aa". In the second test case, it can be "abc", "abd", "acd" or "bcd", so in the worst case Chef will guess the correct option from the fourth attempt, thus making 3 unsuccessful attempts. \ No newline at end of file +In the first test case, the password is definitely "aa". In the second test case, it can be "abc", "abd", "acd" or "bcd", so in the worst case Chef will guess the correct option from the fourth attempt, thus making 3 unsuccessful attempts. diff --git a/_problems/hard/AVDWAST.md b/_problems/hard/AVDWAST.md index 30e5796b..65f7e52e 100644 --- a/_problems/hard/AVDWAST.md +++ b/_problems/hard/AVDWAST.md @@ -117,8 +117,8 @@ For each test case, output a single line containing the minimum number of food u 9 0 9998 - ### Explanation + **Example case 1.** One of the optimal ways is the following: The 1st pouch is opened on the day **x1 = 4**, the 2nd pouch is opened on the day **x2 = 1**, diff --git a/_problems/hard/BB.md b/_problems/hard/BB.md index 6a7b40de..5eb5fe6a 100644 --- a/_problems/hard/BB.md +++ b/_problems/hard/BB.md @@ -36,5 +36,5 @@ For each test case output a single line containing the requested number of ways 3 6 - -**Explanation:** In the second test case there are 3 ways to place the advertisements: using the 1st and the 3rd, the 2nd and the 3rd, or the 2nd and the 4th billboards. +**Explanation:** + In the second test case there are 3 ways to place the advertisements: using the 1st and the 3rd, the 2nd and the 3rd, or the 2nd and the 4th billboards. diff --git a/_problems/hard/BEARS.md b/_problems/hard/BEARS.md index 54993508..51a9e29e 100644 --- a/_problems/hard/BEARS.md +++ b/_problems/hard/BEARS.md @@ -52,5 +52,4 @@ For each test case output just one line containing two integers -- the number of 8 18 Explanation: - -In the first test case the given graph is a "triangle". It's easy to see that a simple transformation on a triangle results in the same triangle (as it contains three pairwise connected vertices and three pairwise "connected" edges). \ No newline at end of file +In the first test case the given graph is a "triangle". It's easy to see that a simple transformation on a triangle results in the same triangle (as it contains three pairwise connected vertices and three pairwise "connected" edges). diff --git a/_problems/hard/BESTTRI.md b/_problems/hard/BESTTRI.md index e5dd7418..0b8b98f5 100644 --- a/_problems/hard/BESTTRI.md +++ b/_problems/hard/BESTTRI.md @@ -104,8 +104,8 @@ Output a single integer, the maximum area of a triangle which does not exceed ** Output: 4 - ### Example 2 +
Input:
 3 7
 1 1
@@ -115,8 +115,8 @@ Output a single integer, the maximum area of a triangle which does not exceed **
 
 Output:
 -1
-
 
### Example 3 +
Input:
 7 1234567890123
 1234567 7654321
@@ -130,8 +130,8 @@ Output a single integer, the maximum area of a triangle which does not exceed **
 
 Output:
 755024295480
-
 
### Explanation + **Example case 1.** There are 4 triangles in total, and their areas are: 1, 1, 2 and 4. The ones which does not exceed 7/2 are 1, 1 and 2 so the biggest area is 2, and since we are required to multiply the area by 2 before outputting it, it becomes 4. **Example case 2.** The only triangle has an area equal to 9/2, which is more than 7/2. So the answer is -1. diff --git a/_problems/hard/BIGTREE.md b/_problems/hard/BIGTREE.md index 4bd58a1d..c9e87715 100644 --- a/_problems/hard/BIGTREE.md +++ b/_problems/hard/BIGTREE.md @@ -124,7 +124,7 @@ For each test case, output a single line containing a single integer, denoting t - **1** ≤ **T** ≤ **5×104** - **1** ≤ **N** ≤ **1016** -- ≤ **a**, **b** < **m** ≤ **108** +- 0 ≤ **a**, **b** < **m** ≤ **108** ### Example @@ -142,6 +142,6 @@ For each test case, output a single line containing a single integer, denoting t 2 1 2 - ### Explanation + The sample input is illustrated by the image above. diff --git a/_problems/hard/BIKE.md b/_problems/hard/BIKE.md index 979dfa28..70ccacca 100644 --- a/_problems/hard/BIKE.md +++ b/_problems/hard/BIKE.md @@ -75,13 +75,13 @@ All submissions for this problem are available.### Read problems statements in In Chefland, there are **n** cities and **m** one-way roads between cities. The chef will travel between cities along these roads using a very unusual bike. The circumference of the front wheel is **n** (the same as the number of cities) yet the circumference of its rear wheel is only **n - 1**. We think of the circumference of each wheel as being broken up into equal-spaced _positions_. So the front wheel has positions **0, 1, ..., n-1** and the rear wheel has positions **0, 1, ..., n-2**. Each unit of distance travelled will advance each wheel 1 position. -For example, when the chef travels a distance of **d** when both wheels start at position , the position of the front wheel is left at **d (mod n)** and the position of the rear wheel is left at **d (mod (n - 1))**. +For example, when the chef travels a distance of **d** when both wheels start at position 0, the position of the front wheel is left at **d (mod n)** and the position of the rear wheel is left at **d (mod (n - 1))**. Furthermore, the chef bikes very fast and the roads are very bumpy. Quite frequently at least one wheel is not touching the ground. When this happens, the wheel does not turn at all (the bike needs some lubrication). So the front and rear wheel may not even rotate the same total number of positions when travelling along a road. For each road **i**, we are given the start city **s\[i\]**, the end city **e\[i\]**, the distance the front wheel travels **f\[i\]**, and the distance of the rear wheel **r\[i\]**. -Both wheels start at position at the beginning of the chef's trip. After traveling a sequence of roads **i1,i2, ..., ik** the front wheel is in position **F := f\[i1\] + f\[i2\] + ... + f\[ik\] (mod n)**. Similarly, the rear wheel is in position **R := r\[i1\] + r\[i2\] + ... + r\[ik\] (mod n-1)**. +Both wheels start at position 0 at the beginning of the chef's trip. After traveling a sequence of roads **i1,i2, ..., ik** the front wheel is in position **F := f\[i1\] + f\[i2\] + ... + f\[ik\] (mod n)**. Similarly, the rear wheel is in position **R := r\[i1\] + r\[i2\] + ... + r\[ik\] (mod n-1)**. The chef wants to start and end in the same city, but is ok starting in any city. The chef is also ok visiting a city more than once; it is the journey that counts, not the destinations. @@ -133,6 +133,6 @@ The **j**'th number on the **i**'th line of the **k**'th block should describe t 1 8 0 10 1 2 - ### Explanation + I have discovered a truly marvellous enumeration of this, which this margin is too narrow to contain. diff --git a/_problems/hard/BINOMSUM.md b/_problems/hard/BINOMSUM.md index d1a4233a..06f48cb4 100644 --- a/_problems/hard/BINOMSUM.md +++ b/_problems/hard/BINOMSUM.md @@ -112,8 +112,8 @@ Each query, output the answer on a new line. Output: 22 - ### Explanations: + There are 3 hours in a day, and 2 activities to choose from. Let the activities be A1 and A2. Let the dishes be D1 and D2. On Day 1, only D1 is available. We will denote a plan for the day by a triplet (X, Y, Z). For example (D1, A1, A2) means that on the first hour, the Chef eats dish D1 (which is his breakfast), then the next hour he does the first activity and on the last hour of the day he does the second activity. All possible plans for the first day are as follows: diff --git a/_problems/hard/BNGAME.md b/_problems/hard/BNGAME.md index 006c358b..20f2e952 100644 --- a/_problems/hard/BNGAME.md +++ b/_problems/hard/BNGAME.md @@ -73,7 +73,7 @@ All submissions for this problem are available.### Read problems statements in Consider the following game that is played on the field of the size of 1 x **N** cells. The cells are numbered from 1 to **N**. In the i-th cell there are two positive integers written - **Ai** and **Bi**. -The game is as follows. Initially, the player stands at the fictive cell with the index that is located right before all the **N** cells of the board. Then, he makes moves. Each move consists in moving by no more than by **K** cells forward. The goal of the game is to reach the fictive **N+1**-th cell that is located right after all the **N** cells. +The game is as follows. Initially, the player stands at the fictive cell with the index 0 that is located right before all the **N** cells of the board. Then, he makes moves. Each move consists in moving by no more than by **K** cells forward. The goal of the game is to reach the fictive **N+1**-th cell that is located right after all the **N** cells. After the **N+1**-th cell is reached, the player's penalty is calculated. The penalty equals to max(**Ax**) \* max(**By**), where **x** and **y** are the indices of the cells that were visited in between (during the movement to the **N+1**-th cell). @@ -108,5 +108,4 @@ Output the minimal possible penalty on the first line. Output: 9 - \ No newline at end of file diff --git a/_problems/hard/BOUNCE.md b/_problems/hard/BOUNCE.md index 73aa0b1f..27bc74e8 100644 --- a/_problems/hard/BOUNCE.md +++ b/_problems/hard/BOUNCE.md @@ -134,8 +134,8 @@ RLTR Output: 5 0 - ### Explanation + In the first test case, there is only one ACM satisfying the requirements, and that is the ACM with dimensions **5 × 2**. **f(5,2)** = RLTRL has length **5**, so the total cost is **5**. -In the second test case, no ACMs satisfy the requirements, so the total cost is . +In the second test case, no ACMs satisfy the requirements, so the total cost is 0. diff --git a/_problems/hard/BTREE.md b/_problems/hard/BTREE.md index 37a49d79..450b48df 100644 --- a/_problems/hard/BTREE.md +++ b/_problems/hard/BTREE.md @@ -123,12 +123,11 @@ For each day, output the answer in one line. 3 3 3 10 4 19 2 2 3 4 10 2 5 5 4 11 2 16 2 18 1 19 2 +
`Output:````
 
-
`Output:
`
 16
 16
 13
 16
 18
-
 
\ No newline at end of file diff --git a/_problems/hard/BUYLAND.md b/_problems/hard/BUYLAND.md index 0bb1ba68..4dc9de8b 100644 --- a/_problems/hard/BUYLAND.md +++ b/_problems/hard/BUYLAND.md @@ -50,8 +50,8 @@ Output exactly K lines containing the K best pieces of land chef can buy, ordere 3 2 8 2 4 11 3 4 75 -
### Explanation + If the chef decides to buy the land from (3,4) to (5,7), he will end up with the following layout: 0 2 0 2 0 2 0 2 diff --git a/_problems/hard/BWGAME.md b/_problems/hard/BWGAME.md index 8f2da05d..34cd8de9 100644 --- a/_problems/hard/BWGAME.md +++ b/_problems/hard/BWGAME.md @@ -129,6 +129,6 @@ For each test case, output a single line containing the answer to the problem. O Output: Fedor -
### Explanation + In the first round, Fedya picks the permutation **(2, 1)** which has odd number of inversions (**1**) and the cells **(1, 2)** and **(2, 1)** are black. Alex is unable to pick the appropriate permutation, thus, he loses and Fedya wins. So we print "Fedor". diff --git a/_problems/hard/BYTESHOP.md b/_problems/hard/BYTESHOP.md index f596c86c..e38d97c0 100644 --- a/_problems/hard/BYTESHOP.md +++ b/_problems/hard/BYTESHOP.md @@ -18,13 +18,11 @@ Input : The first line contains the number of test cases T. T lines follow containing 3 integers: N,M and R. (1 <= T <= 100. 1 <= N,M <= 200. 1 <= R <= N * M) -
 Output :
 Output T lines, one for each test case, containing the output for the corresponding test case.
 Output all values modulo 1000000007
 
-
 
 Sample Input :
 3
@@ -32,11 +30,9 @@ Sample Input :
 2 1 1
 2 3 3
 
-
 
 Sample Output :
 1
 0
 6
-
 
\ No newline at end of file diff --git a/_problems/hard/C1.md b/_problems/hard/C1.md index f744f0bd..c1df7747 100644 --- a/_problems/hard/C1.md +++ b/_problems/hard/C1.md @@ -34,5 +34,4 @@ For each test, you should output exactly n integers. Output: 4 3 2 1 1 4 3 2 - \ No newline at end of file diff --git a/_problems/hard/CAKE2AM.md b/_problems/hard/CAKE2AM.md index a3d3cdc9..d5ec13e8 100644 --- a/_problems/hard/CAKE2AM.md +++ b/_problems/hard/CAKE2AM.md @@ -73,7 +73,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/COOK42/mandarin/CAKE2AM.pdf) and [Russian](http://www.codechef.com/download/translated/COOK42/russian/CAKE2AM.pdf) as well. -Your friend Chef has made a cake for you on your birthday. Before having the cake you two have made some cuts on the cake. If you consider the cake as a rectangular grid with co-ordinates from (,) to (**n**,**n**), then each of the cut can be considered as a rectilinear polygon (a polygon with sides parallel to the axis and possibly self-intersecting). These cuts turn the cake into several pieces. Now you two want to distribute the pieces among yourself. Since it is your birthday, your friend has given you a choice of choosing some pieces for yourself. You are hungry and you want to have the whole cake. But you don't want to make your friend suspicious. So instead of having all the pieces you want to select the set of pieces such that no pair of pieces have a common side. You want to maximize the total amount of cakes you can have. This amount can be measured as the sum of the areas of the top surface for each piece (or the amount of cake in each piece is the area of the polygon that define that piece). +Your friend Chef has made a cake for you on your birthday. Before having the cake you two have made some cuts on the cake. If you consider the cake as a rectangular grid with co-ordinates from (0,0) to (**n**,**n**), then each of the cut can be considered as a rectilinear polygon (a polygon with sides parallel to the axis and possibly self-intersecting). These cuts turn the cake into several pieces. Now you two want to distribute the pieces among yourself. Since it is your birthday, your friend has given you a choice of choosing some pieces for yourself. You are hungry and you want to have the whole cake. But you don't want to make your friend suspicious. So instead of having all the pieces you want to select the set of pieces such that no pair of pieces have a common side. You want to maximize the total amount of cakes you can have. This amount can be measured as the sum of the areas of the top surface for each piece (or the amount of cake in each piece is the area of the polygon that define that piece). ### Input @@ -105,8 +105,8 @@ For each test case, output a single line containing an integer denoting the maxi Output: 16 19 - ### Explanation + **Example 1:** You have only a single cut and the cake now have two pieces(as seen by the figure in the left). The amount of cake in piece 1 is 9 and the amount of cake in piece 2 is 16. So you will take the piece 2 and leave piece 1 for your friend. ![](/download/extimages/77ea6c0d4a8a3a84ed5e2ca3778e0893.jpg)**Example 2:** You have two cuts and the cake now have four pieces(as seen by the figure in the left). The amount of cake in piece 1 is 18, the amount of cake in piece 2 is 3, the amount of cake in piece 3 is 1 and the amount of cake in piece 4 is 3. So you will take piece 1 and piece 3 for yourself and leave the piece 2 and piece 4 for your friend. diff --git a/_problems/hard/CAPTCITI.md b/_problems/hard/CAPTCITI.md index d908a8b3..4b3f4e1f 100644 --- a/_problems/hard/CAPTCITI.md +++ b/_problems/hard/CAPTCITI.md @@ -119,8 +119,8 @@ Formally, you need to find a subset of cities, S, such that the sum of **Pi** ov Output: 7 - ### Explanation + One of the optimal solutions is to parachute into Cities 1, 6 and 8 on Day 0. So the total number of soldiers needed = **P1** + **P6** + **P8** = 2 + 4 + 1 = 7. Now, we will show that this is indeed a valid solution. For that, we need to show that eventually all the cities will be captured. We will show the cities captured on every day in sequence: diff --git a/_problems/hard/CARDSHUF.md b/_problems/hard/CARDSHUF.md index ece3faf8..8fb964f2 100644 --- a/_problems/hard/CARDSHUF.md +++ b/_problems/hard/CARDSHUF.md @@ -44,5 +44,4 @@ In a single line output the cards in the deck after performing all the moves. Ca Output: 1 2 8 7 3 9 6 5 4 10 - \ No newline at end of file diff --git a/_problems/hard/CBAL.md b/_problems/hard/CBAL.md index f950446f..48897ed2 100644 --- a/_problems/hard/CBAL.md +++ b/_problems/hard/CBAL.md @@ -166,8 +166,8 @@ cchheeff 80 10 4 - ### Explanation +
 After decoding queries will take the following form : 
 1
diff --git a/_problems/hard/CHANGE.md b/_problems/hard/CHANGE.md
index 54b094d6..9c6dd231 100644
--- a/_problems/hard/CHANGE.md
+++ b/_problems/hard/CHANGE.md
@@ -105,8 +105,8 @@ For each test case, output on a separate line the number of ways to make the des
 4
 1
 314159265
-
 
### Explanation + **Example case 1.** There are 4 ways to make a total of 16 using coins with values 3, 4 and 5: - 16 = 4 + 4 + 4 + 4 diff --git a/_problems/hard/CHEFBOOK.md b/_problems/hard/CHEFBOOK.md index 231dfd90..8af83416 100644 --- a/_problems/hard/CHEFBOOK.md +++ b/_problems/hard/CHEFBOOK.md @@ -135,5 +135,4 @@ First line of each test case will contain a single line with a single word "**Un 10 9 Unlike - \ No newline at end of file diff --git a/_problems/hard/CHEFC.md b/_problems/hard/CHEFC.md index dd61ec19..5de18609 100644 --- a/_problems/hard/CHEFC.md +++ b/_problems/hard/CHEFC.md @@ -93,8 +93,8 @@ for (i = 2; i <= |B|; i++) if (B[i] != B[i - 1]) X++; X is the output of the function F(B). - ### Input + The first line of the input contains an integer **T** denoting the number of test cases. The description of **T** test cases follows. The first line of each test case contains a single integer **N** denoting the number of the elements in given array. @@ -135,5 +135,4 @@ For each query of the first type output a single line containing a single intege 4 3 4 - \ No newline at end of file diff --git a/_problems/hard/CHEFFIB.md b/_problems/hard/CHEFFIB.md index 6404f0cf..09076b7a 100644 --- a/_problems/hard/CHEFFIB.md +++ b/_problems/hard/CHEFFIB.md @@ -73,7 +73,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin chinese](http://www.codechef.com/download/translated/DEC17/mandarin/CHEFFIB.pdf), [Russian](http://www.codechef.com/download/translated/DEC17/russian/CHEFFIB.pdf) and [Vietnamese](http://www.codechef.com/download/translated/DEC17/vietnamese/CHEFFIB.pdf) as well. -Chef has a tree with **N** nodes numbered **1** through **N**. Initially, each node has value . +Chef has a tree with **N** nodes numbered **1** through **N**. Initially, each node has value 0. Chef's best friend Leonardo loves queries on trees. He asked Chef to perform **Q** queries. Each query is of one of the following two types: @@ -133,5 +133,4 @@ For each query of type 2, print the answer to it on a separate line. 3 10 - \ No newline at end of file diff --git a/_problems/hard/CHEFKC.md b/_problems/hard/CHEFKC.md index cddb5bc2..71f116c3 100644 --- a/_problems/hard/CHEFKC.md +++ b/_problems/hard/CHEFKC.md @@ -122,7 +122,6 @@ Output a single integer in a line - weight of **k**-th minimum cut of graph **G* Output: 9 -
Input:
 5 19 6
 1 5
@@ -150,5 +149,4 @@ Output a single integer in a line - weight of **k**-th minimum cut of graph **G*
 29
 
 
-
 
\ No newline at end of file diff --git a/_problems/hard/CHEFONM.md b/_problems/hard/CHEFONM.md index 0115e05a..b8b3248d 100644 --- a/_problems/hard/CHEFONM.md +++ b/_problems/hard/CHEFONM.md @@ -125,5 +125,4 @@ Output a single real number corresponding to expected number of swap operations 5.0000000 27.5000000 781.0416667 - \ No newline at end of file diff --git a/_problems/hard/CHEFPC.md b/_problems/hard/CHEFPC.md index b29fa693..e2116ee7 100644 --- a/_problems/hard/CHEFPC.md +++ b/_problems/hard/CHEFPC.md @@ -96,7 +96,7 @@ Output a single line denoting the answer of the problem. Your answer will be con - **1** ≤ **M** ≤ **50** - **-10^4** ≤ **x, y** ≤ **10^4** -- < **r** ≤ **10^4** +- 0 < **r** ≤ **10^4** ### Subtasks @@ -118,6 +118,6 @@ Output a single line denoting the answer of the problem. Your answer will be con Output: 49.087385212341 - ### Explanation + **Example case 1.** Two circles that are not intersecting each other. diff --git a/_problems/hard/CHEFPOL.md b/_problems/hard/CHEFPOL.md index 804b14aa..fa6d456b 100644 --- a/_problems/hard/CHEFPOL.md +++ b/_problems/hard/CHEFPOL.md @@ -114,7 +114,6 @@ Output a single integer in a line denoting number of ways to color polyhedron in Output: 10 -
Input:
 4 4
 3 2 3 4
@@ -124,5 +123,4 @@ Output a single integer in a line denoting number of ways to color polyhedron in
 
 Output:
 35
-
 
\ No newline at end of file diff --git a/_problems/hard/CHEFSPAG.md b/_problems/hard/CHEFSPAG.md index df9c10f0..60f7805d 100644 --- a/_problems/hard/CHEFSPAG.md +++ b/_problems/hard/CHEFSPAG.md @@ -68,7 +68,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/SEPT16/mandarin/CHEFSPAG.pdf), [Russian](http://www.codechef.com/download/translated/SEPT16/russian/CHEFSPAG.pdf) and [Vietnamese](http://www.codechef.com/download/translated/SEPT16/vietnamese/CHEFSPAG.pdf) as well. -Chef is tending a really large _spaghetti garden_. This garden consists of many _spaghetti trees_. Specifically, there is a spaghetti tree planted for each lattice point location **(x, y)** with **x**, **y** ≥ . (Yes, there are an infinite number of trees in Chef's garden!) +Chef is tending a really large _spaghetti garden_. This garden consists of many _spaghetti trees_. Specifically, there is a spaghetti tree planted for each lattice point location **(x, y)** with **x**, **y** ≥ 0. (Yes, there are an infinite number of trees in Chef's garden!) It's the 1st of April, so it's harvest time for Chef. Chef plans to harvest all _spaghetti strands_ within a certain region today. In case you didn't know, a spaghetti tree bears _spaghetti strands_ as its fruits. @@ -100,11 +100,11 @@ For each test case, output a single line containing the integer: the answer for ### Subtasks -**Subtask #1 (10 points):**- ≤ **xi**, **yi** ≤ **100** +**Subtask #1 (10 points):**- 0 ≤ **xi**, **yi** ≤ **100** -**Subtask #2 (30 points):**- ≤ **xi**, **yi** ≤ **104** +**Subtask #2 (30 points):**- 0 ≤ **xi**, **yi** ≤ **104** -**Subtask #3 (60 points):**- ≤ **xi**, **yi** ≤ **109** +**Subtask #3 (60 points):**- 0 ≤ **xi**, **yi** ≤ **109** ### Example @@ -125,8 +125,8 @@ For each test case, output a single line containing the integer: the answer for 18 153 - ### Explanation + In both test cases, we have **Fk = k** for **0 ≤ k ≤ 3** and **Fk = Fk-1 + 2·Fk-2 + 3·Fk-3 + 4·Fk-4**. So you can check that **F4 = 10**, **F5 = 26** and **F6 = 63** - In the first test case, Chef will harvest all spaghetti strands in the locations **(1, 1)**, **(1, 2)**, **(2, 1)**, **(2, 2)**. The total number is **F1+1 + F1+2 + F2+1 + F2+2** = **F2 + F3 + F3 + F4** = **18** diff --git a/_problems/hard/CHEFTRAF.md b/_problems/hard/CHEFTRAF.md index bca1da74..3026b0d9 100644 --- a/_problems/hard/CHEFTRAF.md +++ b/_problems/hard/CHEFTRAF.md @@ -149,8 +149,8 @@ All submissions for this problem are available.### Read problems statements in [ 7 39 - ### Explanation + **Example case 1:** There are 3 people: - The first person goes from city 1 to city 2. He chooses Chef's roads and pays 3 chefcoin. diff --git a/_problems/hard/CHEFTRE.md b/_problems/hard/CHEFTRE.md index a691eefb..81340d80 100644 --- a/_problems/hard/CHEFTRE.md +++ b/_problems/hard/CHEFTRE.md @@ -130,5 +130,4 @@ For each query of second type output your answer in a single line. Yes No Yes - \ No newline at end of file diff --git a/_problems/hard/CHEFTREE.md b/_problems/hard/CHEFTREE.md index 48c24cb8..4cd48bec 100644 --- a/_problems/hard/CHEFTREE.md +++ b/_problems/hard/CHEFTREE.md @@ -81,5 +81,4 @@ For each query of the second type, output a single line containing a single inte 0 4 - \ No newline at end of file diff --git a/_problems/hard/CHEFTRI4.md b/_problems/hard/CHEFTRI4.md index a5b8c4ee..d23d9350 100644 --- a/_problems/hard/CHEFTRI4.md +++ b/_problems/hard/CHEFTRI4.md @@ -117,8 +117,8 @@ Yes No Yes - ### Explanation + **Example case 1.** We can obtain (6, 8, 10). **Example case 2.** We can obtain (182, 303, 472). diff --git a/_problems/hard/CHEF_GAM.md b/_problems/hard/CHEF_GAM.md index 628f29c8..087957b0 100644 --- a/_problems/hard/CHEF_GAM.md +++ b/_problems/hard/CHEF_GAM.md @@ -45,13 +45,13 @@ For each test case, print the minimum number of turns in which the game can end. 3 4 -2 -1 - **Sample output** +
1
 6
 
-
 
**Explanation** + In the first case, cook 2 can take the first turn which converts the sequence into (0, 1, 1) and end the game. In the second case, the following sequence of moves are optimal. diff --git a/_problems/hard/CHMAGIC.md b/_problems/hard/CHMAGIC.md index 9f762825..c24c48ab 100644 --- a/_problems/hard/CHMAGIC.md +++ b/_problems/hard/CHMAGIC.md @@ -108,8 +108,8 @@ The first line of the input contains an integer **q**. The next line contains an 10 10636 10654 - ### Scoring + Subtask 1 (30 points): **200 ≤ q ≤ 109**. Subtask 2 (70 points): Look at constraints diff --git a/_problems/hard/CHN04.md b/_problems/hard/CHN04.md index ad5f5bbb..953b5fd5 100644 --- a/_problems/hard/CHN04.md +++ b/_problems/hard/CHN04.md @@ -57,6 +57,6 @@ Jimma doesn't like this game because she does not get any chocolate. So, she wan Output: 2 - ### Explanation + In the first step, Jimma can choose bar 4, which is of length 2. Bar 3 and bar 1 form **Inversion Pairs** with bar 4. So Chingam eats all these 3 bars. In the second step, Jimma chooses bar 2, and she's done. You can check that Jimma cannot get rid of all the four bars in one step. diff --git a/_problems/hard/CHN10.md b/_problems/hard/CHN10.md index 452eb741..06775d44 100644 --- a/_problems/hard/CHN10.md +++ b/_problems/hard/CHN10.md @@ -70,8 +70,8 @@ Note that adjacency matrix of a graph **G** containing **n** vertices is a matri Output: 1 3 - ### Explanation + **In the first example**, the graph **G** has an edge between 1 and 2. Animesh has to add only one edge in the graph **H** between vertices 1 and 2 to please her. This is the only graph he has to come up with. **In the second example**, the graph **G** has edges {1, 3} and {2, 3}. Animesh can come up with the following graphs `({1, 3}, {2, 3}), ({2, 1}, {3, 1}), ({1, 2}, {3, 2})`. Malvika likes all of these graphs. In this representation, `({1, 3}, {2, 3})` means that a graph has 3 vertices and two edges — between 1 and 3, and between 2 and 3. diff --git a/_problems/hard/CHN12.md b/_problems/hard/CHN12.md index dc9e17c1..6ce1ff7a 100644 --- a/_problems/hard/CHN12.md +++ b/_problems/hard/CHN12.md @@ -39,8 +39,8 @@ while T is not empty: - Increase val by 1, i.e. val += 1 Note that first step of identification of branching nodes is re-done in each execution of the while loop. - Please check the example problem statement to understand how this process works. Note that Praveen cannot actually remove the nodes from the tree. He just simulates the procedure in his head's supercomputer. + After Arjun comes back with the ladder, Praveen decides to ask him **Q** queries about the tree. Each query will contain two nodes **u, v**. Let the path in the tree from node **u** to **v**, be **u, u1, u2, .., ur, v**. Consider the array **S\[u\], S\[u1\],..,S\[ur\], S\[v\]**. For each query, Arjun has to find the number of inversion pairs in this array. **i** and **j** form an inversion pair, if **i > j** and **S\[i\] < S\[j\]**. All these hours sitting atop the tree have made Praveen light in the head, and he refuses to come down until Arjun answers all his queries. Unfortunately, Arjun does not have a supercomputer in his head like Praveen does and he has also left his laptop at home. So please help Arjun answer these queries and get Praveen down. @@ -93,8 +93,8 @@ Unfortunately, Arjun does not have a supercomputer in his head like Praveen does 0 2 0 - ### Explanation + ![](http://www.codechef.com/download/ACM15CHN/tree_s_array.jpg)The figure is the tree corresponding to the given sample input. The nodes marked red have S value 1 and the black nodes have S Value 2. In the first step, the branching nodes are 2, 4 and 7. Nodes 1, 3, 5, 6, 8, 9, 11 are leaf nodes and can be removed, i.e they have S value 1. Even 10 can be removed and it also has S value 1. The branching nodes cannot be touched. In the next iteration, with val = 2, there are no branching nodes and we can remove nodes 2, 4 and 7 giving them S Value 2. The first query is (5,10). The path between nodes numbered 5 and 10 passes through nodes {5,4,2,7,10} with S values {1,2,2,2,1}. The number of inversions in this array is 3 formed by 3 pairs of {2,1}. @@ -141,5 +141,4 @@ The last query is (9,2). The path between nodes numbered 9 and 2 passes through 18 1 0 - \ No newline at end of file diff --git a/_problems/hard/CHNBGMT.md b/_problems/hard/CHNBGMT.md index 45461907..8ea835e7 100644 --- a/_problems/hard/CHNBGMT.md +++ b/_problems/hard/CHNBGMT.md @@ -95,7 +95,7 @@ Find out number of ways in which bunnies can get from cell (1, 1) to cell (**N** ### Constraints - **2** ≤ **N, M** ≤ **105** -- ≤ **D** ≤ **C** ≤ **min{200, N \* M - 2}** +- 0 ≤ **D** ≤ **C** ≤ **min{200, N \* M - 2}** - **1** ≤ **xi** ≤ **N** - **1** ≤ **yi** ≤ **M** - **1** ≤ **MOD** ≤ **109** @@ -118,19 +118,19 @@ Find out number of ways in which bunnies can get from cell (1, 1) to cell (**N** **Subtask #3 (13 pts)** - **1** ≤ **T** ≤ **10** -- **C** = +- **C** = 0 - TL = 2s **Subtask #4 (19 pts)** - **1** ≤ **T** ≤ **5** -- ≤ **C** ≤ **100** +- 0 ≤ **C** ≤ **100** - TL = 10s **Subtask #5 (23 pts)** - **1** ≤ **T** ≤ **5** -- ≤ **C** ≤ **100** +- 0 ≤ **C** ≤ **100** - TL = 2s **Subtask #6 (27 pts)** @@ -156,8 +156,8 @@ Find out number of ways in which bunnies can get from cell (1, 1) to cell (**N** 0 1 0 - ### Explanation + **Example case 1.** \*\*\* diff --git a/_problems/hard/CIELBALL.md b/_problems/hard/CIELBALL.md index 2348efab..a5323aaa 100644 --- a/_problems/hard/CIELBALL.md +++ b/_problems/hard/CIELBALL.md @@ -100,9 +100,11 @@ For each test case, print the maximum number of coins that can be obtained by To 3 1 1 58 30 28 2 ### Sample Output +
80
 2
 
### Explanations + In the first sample, one of the strategy to obtain 80 coins is as follow: At first, Tomya bets 0 coins. Let the color 2 be chosen by Ciel. (Now, **S**1 = 2, **S**2 = 1, Coins = 30) Then, Tomya bets 10 coins on the color 1. diff --git a/_problems/hard/CIELHACK.md b/_problems/hard/CIELHACK.md index cb528337..1f0d3618 100644 --- a/_problems/hard/CIELHACK.md +++ b/_problems/hard/CIELHACK.md @@ -76,7 +76,7 @@ Now Ciel has forgotten the combination for her safe and passwords for all **K** Since her computer is too slow, Ciel decides to use computer centers in her town. There are **C** computer centers in all. Since Ciel is afraid of leaking the combination for her safe, Ciel will use exactly **K** distinct computer centers, one center for one piece. -Currently Ciel is in her restaurant. Apparently her restaurant and all computer centers are located along one street. Hence we will consider Ciel's restaurant and computer centers as points on a coordinate line. Let's assume that Ciel's restaurant has coordinate while the coordinate of the **j**-th computer center is **Xj**. So the distance between Ciel's restaurant and the **j**-th computer center is |**Xj**| meters while the sign of **Xj** indicates in which direction of the street (positive or negative) Ciel should walk to this center. +Currently Ciel is in her restaurant. Apparently her restaurant and all computer centers are located along one street. Hence we will consider Ciel's restaurant and computer centers as points on a coordinate line. Let's assume that Ciel's restaurant has coordinate 0 while the coordinate of the **j**-th computer center is **Xj**. So the distance between Ciel's restaurant and the **j**-th computer center is |**Xj**| meters while the sign of **Xj** indicates in which direction of the street (positive or negative) Ciel should walk to this center. After Ciel will choose **K** different centers for cracking passwords of her **K** pieces she will visit them in some order, crack all the pieces (one piece at one computer center) and return back to her restaurant. At each computer center she should wait until the password for the current piece will be cracked and only then she can proceed to the next center. Ciel's walking speed is **V** meters per nanosecond, so she needs exactly |**A** − **B**| / **V** nanoseconds to walk from the point with coordinate **A** to the point with coordinate **B**. @@ -177,8 +177,8 @@ Every real value has at most 6 digits after the decimal point. 130 182.333333333333333333333 12938.4586699 - ### Explanation + **Case 1.** Here Ciel has no choice other than she goes to the first computer center and cracks the password for the only piece by using 1 computer, then Ciel back to her restaurant. The answer is 1 (going to the computer center) + 50.5 (cracking) + 1 (back to her restaurant) = 52.5. In the cracking phase since Ciel uses only one computer the time for connection is not needed. The program will check passwords one by one and 1 nanosecond is needed for checking one password. So the running time will be **k** nanoseconds with probability 1% for 1 ≤ **k** ≤ 100. Therefore the expected time for the cracking phase is 1 \* 0.01 + 2 \* 0.01 + ... + 100 \* 0.01 = 50.5. **Case 2.** Here Ciel has 3 choices. diff --git a/_problems/hard/CIELKARA.md b/_problems/hard/CIELKARA.md index 14fb8638..57ae5533 100644 --- a/_problems/hard/CIELKARA.md +++ b/_problems/hard/CIELKARA.md @@ -97,8 +97,8 @@ For each test case, output a single line containing the minimum value of the int - **1** ≤ **T** ≤ **250** - **2** ≤ **N** ≤ **8** - **1** ≤ **K** ≤ **4** -- ≤ **A1** < **A2** < ... < **AN−1** ≤ **20130120** -- ≤ **B0**, **B1**, ..., **BN−1** ≤ **20130120** +- 0 ≤ **A1** < **A2** < ... < **AN−1** ≤ **20130120** +- 0 ≤ **B0**, **B1**, ..., **BN−1** ≤ **20130120** - It can occur that **Bi−1** = **Bi** for some **i = 1, 2, ..., N−1** - The sum of **N3** in one test file does not exceed **2013** @@ -121,8 +121,8 @@ For each test case, output a single line containing the minimum value of the int 2500.0000000000 1250.0000000000 625.0000000000 - ### Explanation + The following figure corresponds to the example case 1. Here the bold red line denotes the correct pitch **f(t)** and the blue line denotes the optimal Ciel's pitch **g(t)**. The answer is the area of the green region. ![](http://www.codechef.com/download/CIELKARA.png) diff --git a/_problems/hard/CIELQUAK.md b/_problems/hard/CIELQUAK.md index 604adb5c..771e7928 100644 --- a/_problems/hard/CIELQUAK.md +++ b/_problems/hard/CIELQUAK.md @@ -84,7 +84,7 @@ For each test case output the required probability. Your answer must have an abs 1 ≤ **T** ≤ 50 1 ≤ **R** ≤ 8 1 ≤ **C** ≤ 1000000000000000000 (1018) -0\.1 ≤ **p** ≤ 1 +0.1 ≤ **p** ≤ 1 **p** has at most four digits after the decimal point. ### Sample Input @@ -96,6 +96,7 @@ For each test case output the required probability. Your answer must have an abs 1 1 0.2 7 7 0.8 ### Sample Output +
0.4375
 0.0768204
 0.0768204
diff --git a/_problems/hard/CIELWALK.md b/_problems/hard/CIELWALK.md
index b3c8a805..37200aec 100644
--- a/_problems/hard/CIELWALK.md
+++ b/_problems/hard/CIELWALK.md
@@ -49,10 +49,12 @@ For each 1 ≤ **i** < **N**, Ciel can go from the **i**-th intersection to the
 2 4
 3 4
 
### Sample Output 1 +
0
 0.5
 0.5
 
### Sample Input 2 +
4 6 1
 2
 1 2
@@ -62,12 +64,14 @@ For each 1 ≤ **i** < **N**, Ciel can go from the **i**-th intersection to the
 2 4
 3 4
 
### Sample Output 2 + `0.6666666666667`### Sample Input 3
2 1 1
 1
 1 2
 
### Sample Output 3 + `1`### Notes The sum of output values can be less than 1, because Ciel may go back to her house without seeing beautiful flowers. diff --git a/_problems/hard/CKSCHOOL.md b/_problems/hard/CKSCHOOL.md index e9259cb5..dd393560 100644 --- a/_problems/hard/CKSCHOOL.md +++ b/_problems/hard/CKSCHOOL.md @@ -52,8 +52,8 @@ For each query, print the answer in a new line. 1 1 2 - -**Explanation :** Listing the schools in 'Max Special S' for each of the queries in the given sample case. Schools are listed in (distance, fee) pairs. + +**Explanation :** Listing the schools in 'Max Special S' for each of the queries in the given sample case. Schools are listed in (distance, fee) pairs. 5 3 4 --> (4,3) (3,4) ; 5 4 6 --> (3,4) (1,5) ; 5 1 4 --> (1,1) ; This school is preferred over all other schools ; diff --git a/_problems/hard/CLONES.md b/_problems/hard/CLONES.md index 6b601a02..d6c8a552 100644 --- a/_problems/hard/CLONES.md +++ b/_problems/hard/CLONES.md @@ -55,5 +55,4 @@ AvZvP\A 6 2 - \ No newline at end of file diff --git a/_problems/hard/CLOWAY.md b/_problems/hard/CLOWAY.md index 06391c83..c1ae9fe6 100644 --- a/_problems/hard/CLOWAY.md +++ b/_problems/hard/CLOWAY.md @@ -102,7 +102,7 @@ For each query, print a single integer - the number Chef would like to find out ### Constraints and Subtasks - **1** ≤ **T**, **Nk** ≤ **50** -- ≤ **Mk** ≤ **Nk×(Nk−1)/2** +- 0 ≤ **Mk** ≤ **Nk×(Nk−1)/2** - **1** ≤ **Q** ≤ **2×105** - **1** ≤ **Li** ≤ **Ri** ≤ **T** - **1** ≤ **Ki** ≤ **104** @@ -163,8 +163,8 @@ For each query, print a single integer - the number Chef would like to find out 28 22 915822 - ### Explanation + **Example case 1.** Starts from: (ways of play with length in range \[1, 4\]) **1:** (1,2,1), (1,3,1), (1,2,3,1), (1,3,2,1), (1,2,3,2,1), diff --git a/_problems/hard/CLUE.md b/_problems/hard/CLUE.md index 6325ea4c..5b408678 100644 --- a/_problems/hard/CLUE.md +++ b/_problems/hard/CLUE.md @@ -41,9 +41,11 @@ For each test case output a single integer, on a line by itself, indicating the 12 14 15 16 17 18 ### Sample Output: +
1
 2
 
### Explanation: + In the first example, the cards in the envelope are 1, 7, and 13. All of the logicians immediately know this, however the first logician wins because it must be one's turn in order to win. In the second example, the cards in the envelope are 2, 8, and 13. Note that initially the second player does not have enough information to determine which cards are in the envelope. However, the fact that the first player passes is enough for the second player deduce the first player's cards (if the first player had been holding 2 3 5, for example, he would have won instead of pass), which in turn allows him to determine the secret cards and win. diff --git a/_problems/hard/CNTDIGIT.md b/_problems/hard/CNTDIGIT.md index 9d06929a..6fffa8ca 100644 --- a/_problems/hard/CNTDIGIT.md +++ b/_problems/hard/CNTDIGIT.md @@ -93,5 +93,4 @@ Output the answer to the problem on the first line. Output: 84 - \ No newline at end of file diff --git a/_problems/hard/CNTDSETS.md b/_problems/hard/CNTDSETS.md index b9fb8f76..7659e5b3 100644 --- a/_problems/hard/CNTDSETS.md +++ b/_problems/hard/CNTDSETS.md @@ -105,7 +105,6 @@ For each test case (in the order given in the input), output the number of class 2 10 3 1 3 3 -
 Output:
 512
@@ -113,8 +112,8 @@ For each test case (in the order given in the input), output the number of class
 498134775
 217
 548890725
-
 
### Explanation + **Example case 1:** When **N=1** all the points are arranged in a line. In order to have a diameter equal to **10** each D-set must contain two points at distance **10**. Between two such points there may be up to **9** points which may belong to the D-set or not. Thus, there are **29=512** classes of D-sets. diff --git a/_problems/hard/CONNECT.md b/_problems/hard/CONNECT.md index 781d5157..0afef3b8 100644 --- a/_problems/hard/CONNECT.md +++ b/_problems/hard/CONNECT.md @@ -100,5 +100,4 @@ Only one line contains the minimum cost to finish the task. If the task is impos 9 3 4 Output: 8 - \ No newline at end of file diff --git a/_problems/hard/CONPOIN.md b/_problems/hard/CONPOIN.md index 917f95b4..2277cbe3 100644 --- a/_problems/hard/CONPOIN.md +++ b/_problems/hard/CONPOIN.md @@ -82,7 +82,7 @@ The first line contains one integer **T** - the number of test cases. Each test ### Output -For each test case output a single line containing**1** if it's possible to find points which will satisfy the problem statement and otherwise +For each test case output a single line containing**1** if it's possible to find points which will satisfy the problem statement and 0 otherwise ### Constraints @@ -121,10 +121,10 @@ For each test case output a single line containing**1** if it's possible to find 1 0 1 - ### Explanation + In the first test case we can draw triangle on the plane. Obviously no pair of segments will intersect and we can't add any more straight-line segment(and even not straight-line) so the answer is **1** -In the second test case we can draw 3 points and connect 1 and 3 and 2 and 3. But we can add one more(1 and 3) so the answer is +In the second test case we can draw 3 points and connect 1 and 3 and 2 and 3. But we can add one more(1 and 3) so the answer is 0 In the last test case we can draw a triangle and a point inside it connected to 3 vertexes of the triangle. As in the first test case we can't connect some new pair so the answer is **1** too. diff --git a/_problems/hard/COOK82E.md b/_problems/hard/COOK82E.md index e04fc33f..6095fb6d 100644 --- a/_problems/hard/COOK82E.md +++ b/_problems/hard/COOK82E.md @@ -134,8 +134,8 @@ For each testcase, output **Q** lines, the i-th of which contains the number of 15 12 11 - ### Explanation + We will explain the first testcase. At the beginning, there is just the root, and the tree is as follows: ![](https://puu.sh/vWPJG/7de2e400bf.png)Then, Hussain time travels forward by 1 second, and so after the first operation, the tree looks like this: diff --git a/_problems/hard/COOLNUM.md b/_problems/hard/COOLNUM.md index 2ae8911b..a99a1ad0 100644 --- a/_problems/hard/COOLNUM.md +++ b/_problems/hard/COOLNUM.md @@ -77,7 +77,7 @@ Your task is to find for the given positive integer **N** the values of **LC(N)* Consider some examples. - **1458** is a Cool Number since ((**1** + **4** + **5** + **8**) – (**1** + **5**))**1** + **5** = **126** = **2985984** is divisible by **1458**. Note that here we select two digits: **1** and **5**. -- All numbers of the form **10n** (**n** = , **1**, **2**, ...) are Cool. Indeed, if we select just one digit **1** (the first digit of **10n**) in the definition of Cool Number we obtain the number (**1** + + ... + – **1**)**1** = **01** = and it is divisible by **10n** (recall that is divisible by every positive integer). Now consider some positive integer **N** of **n** digits. Then, clearly, **10n-1** ≤ **N** < **10n** where both **10n-1** and **10n** are Cool Numbers. Hence **LC(N)** and **UC(N)** always exist and, moreover, **LC(N)** ≥ **10n-1** and **UC(N)** ≤ **10n**. +- All numbers of the form **10n** (**n** = 0, **1**, **2**, ...) are Cool. Indeed, if we select just one digit **1** (the first digit of **10n**) in the definition of Cool Number we obtain the number (**1** + 0 + ... + 0 – **1**)**1** = **01** = 0 and it is divisible by **10n** (recall that 0 is divisible by every positive integer). Now consider some positive integer **N** of **n** digits. Then, clearly, **10n-1** ≤ **N** < **10n** where both **10n-1** and **10n** are Cool Numbers. Hence **LC(N)** and **UC(N)** always exist and, moreover, **LC(N)** ≥ **10n-1** and **UC(N)** ≤ **10n**. ### Input @@ -110,11 +110,11 @@ The total number of digits in all numbers **N** in the input file does not excee 999 1000 1458 1460 18895680 18900000 - ### Explanation + **Case 1.** The number **2** is the largest integer which is not greater than **N = 2**, the number **3** is the smallest integer which is greater than **N = 2**, and they both are Cool Numbers, which can be shown similar to the case of **10n** in the example above. -**Case 2.** It is very similar to the first test case and we already know that **1000** is a Cool Number. So we just have to show that **999** is a Cool number. But it is clear, since we can select all the three digits so ((**9** + **9** + **9**) – (**9** + **9** + **9**))**9** + **9** + **9** = **027** = which is divisible by **999**. +**Case 2.** It is very similar to the first test case and we already know that **1000** is a Cool Number. So we just have to show that **999** is a Cool number. But it is clear, since we can select all the three digits so ((**9** + **9** + **9**) – (**9** + **9** + **9**))**9** + **9** + **9** = **027** = 0 which is divisible by **999**. **Unfortunately, we can't provide you with the explanation of the third and the fourth test cases. You should figure it out by yourself. Please, don't ask about this in comments.** diff --git a/_problems/hard/COT5.md b/_problems/hard/COT5.md index 290e6f7e..a0a1e251 100644 --- a/_problems/hard/COT5.md +++ b/_problems/hard/COT5.md @@ -120,5 +120,4 @@ For each distance query, print the distance between **u** and **v**. 2 1 1 - \ No newline at end of file diff --git a/_problems/hard/COUNTARI.md b/_problems/hard/COUNTARI.md index 524006c4..f7c51ce2 100644 --- a/_problems/hard/COUNTARI.md +++ b/_problems/hard/COUNTARI.md @@ -79,8 +79,8 @@ Output the number of ways to choose a triplet such that they are three consecuti Output: 9 - ### Explanation + The followings are all 9 ways to choose a triplet
@@ -93,5 +93,4 @@ The followings are all 9 ways to choose a triplet
 7 : (i, j, k) = (4, 8, 10), (Ai, Aj, Ak) = (6, 4, 2)
 8 : (i, j, k) = (5, 6, 9), (Ai, Aj, Ak) = (3, 4, 5)
 9 : (i, j, k) = (5, 8, 9), (Ai, Aj, Ak) = (3, 4, 5)
-
 
\ No newline at end of file diff --git a/_problems/hard/COVERING.md b/_problems/hard/COVERING.md index e8c2fc27..2bea7085 100644 --- a/_problems/hard/COVERING.md +++ b/_problems/hard/COVERING.md @@ -72,7 +72,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/COOK52/mandarin/COVERING.pdf) and [Russian](http://www.codechef.com/download/translated/COOK52/russian/COVERING.pdf) as well. - Let's consider a set **S** of **N** different elements numbered from to **N - 1**. It's a well-known fact that there are exactly 2**N** subsets of **S** (including the empty subset). Each subset **S'** of **S** can be encoded as a bitmask **B(S')** containing **N** bits, where the **i**'th bit of **B(S')** is equal to 1 if the **i**'th element of **S** belongs to **S'**, and 0 otherwise. Each bitmask can also be considered as a non-negative integer represented in binary. + Let's consider a set **S** of **N** different elements numbered from 0 to **N - 1**. It's a well-known fact that there are exactly 2**N** subsets of **S** (including the empty subset). Each subset **S'** of **S** can be encoded as a bitmask **B(S')** containing **N** bits, where the **i**'th bit of **B(S')** is equal to 1 if the **i**'th element of **S** belongs to **S'**, and 0 otherwise. Each bitmask can also be considered as a non-negative integer represented in binary. For example, suppose **N** is equal to 5. Then **S** = {0, 1, 2, 3, 4}. Let's assume **S'** = {0, 3, 4}. Then **B(S')** = 1 × 20 + 0 × 21 + 0 × 22 + 1 × 23 + 1 × 24 = 110012 = 2510. @@ -111,8 +111,8 @@ All submissions for this problem are available.### Read problems statements in Output: 7680 - ### Explanations + Here's the table of what sets are covered by all the possible triples for **N** = 1: ABCD000{0}001{0, 1}010{0, 1}011{0, 1}100{0, 1}101{0, 1}110{0, 1}111{0, 1} diff --git a/_problems/hard/CPP.md b/_problems/hard/CPP.md index 135919ef..b5c7fc48 100644 --- a/_problems/hard/CPP.md +++ b/_problems/hard/CPP.md @@ -175,7 +175,7 @@ Invalid-ID Format does not conform - ### Notes + - "or" has the least precedence among all keywords. For example 1 or 2 3 times is interpreted as 1 or (2 3 times) instead of (1 or 2) 3 times. - "optional" and "times" have equal precedence, which is lower than all other keywords but higher than "or". Like 1 to 3 4 times is interpreted as (1 to 3) 4 times. diff --git a/_problems/hard/CROCDILE.md b/_problems/hard/CROCDILE.md index 255b0cb5..c34cb284 100644 --- a/_problems/hard/CROCDILE.md +++ b/_problems/hard/CROCDILE.md @@ -65,7 +65,7 @@ time: current: 1493556676 layout: problem --- -All submissions for this problem are available.Archaeologist Benjamas is running for her life after investigating the mysterious Crocodile's Underground City. The city has **N** chambers. There are **M** bidirectional corridors, each connecting a different pair of distinct chambers. Running through different corridors may require different amounts of time. Only **K** of the **N** chambers are exit chambers that allow her to escape. Benjamas starts in chamber . She wants to reach an exit chamber as quickly as possible. +All submissions for this problem are available.Archaeologist Benjamas is running for her life after investigating the mysterious Crocodile's Underground City. The city has **N** chambers. There are **M** bidirectional corridors, each connecting a different pair of distinct chambers. Running through different corridors may require different amounts of time. Only **K** of the **N** chambers are exit chambers that allow her to escape. Benjamas starts in chamber 0. She wants to reach an exit chamber as quickly as possible. The Crocodile gatekeeper wants to prevent Benjamas from escaping. From his den, he controls secret doors that can block any _single_ corridor. That is, whenever he blocks a new corridor, the previously blocked one has to be reopened. @@ -81,8 +81,8 @@ Note that in some cases (for example, if your plan directs Benjamas to run in a Let us assume that: -- **N** – the number of chambers. The chambers are numbered through **N-1**. -- **M** – the number of corridors. The corridors are numbered through **M-1**. +- **N** – the number of chambers. The chambers are numbered 0 through **N-1**. +- **M** – the number of corridors. The corridors are numbered 0 through **M-1**. - **R** – a two-dimensional array of integers representing the corridors. For **0 ≤ i < M**, corridor i connects two distinct chambers **R\[i\]\[0\] and R\[i\]\[1\]**. No two corridors join the same pair of chambers. - **L** – a one-dimensional array of integers containing the times needed to traverse the corridors. For **0 ≤ i < M**, the value **1 ≤ L\[i\] ≤ 1,000,000,000** is the time Benjamas needs to runthrough the **ith** corridor. - **K** – the number of exit chambers. You may assume that **1 ≤ K < N**. @@ -111,8 +111,8 @@ Output an integer, denoting the smallest time **T** for which there exists a goo 3 2 1 2 4 4 1 3 4 - -**Output**/> +**Output** +/> `7`**Explaination**: Consider the case shown in Figure 1, where **N=5, M=4, K=3**, and @@ -143,12 +143,12 @@ Chambers are shown as circles, and corridors connecting them are shown as lines. 0 4 7 3 4 9 1 3 - **Output** +
 14
-
 
**Explaination**: Consider the case shown in Figure 2, where **N=5, M=7, K=2**, and + ![croc_1](http://www.codechef.com/download/croc_1.png) />/> diff --git a/_problems/hard/CUCUMBER.md b/_problems/hard/CUCUMBER.md index cc81cfa7..0199ba8e 100644 --- a/_problems/hard/CUCUMBER.md +++ b/_problems/hard/CUCUMBER.md @@ -169,8 +169,8 @@ raw 1 5 1 - ### Explanation + In the first sample case, Cucumber Boy's objective will be accomplished if and only if he selects buildings **(i1, i2) = (1, 2)**. Let's call the pizza of the shop **x** of the building **1** collaborated with the shop **y** of the building **2** as pizza **(x, y)**. Then the price of the pizza **(1, 1)** is **82\*19+51\*84+44\*64 = 8658**, the price of the pizza **(1, 2)** is **82\*17+51\*43+44\*44 = 5523**, diff --git a/_problems/hard/CUSTPRIM.md b/_problems/hard/CUSTPRIM.md index 20b9cfbb..951466f4 100644 --- a/_problems/hard/CUSTPRIM.md +++ b/_problems/hard/CUSTPRIM.md @@ -134,8 +134,8 @@ NOT PRIME NOT PRIME PRIME -
-
### Explanation +
### Explanation
+
 **Example case 1.** The number **(11,11,11)** is a zero, so it's not prime.
 
 **Example case 2.** The number **(4,4,24)** is a unit, so it's not prime.
diff --git a/_problems/hard/CYDB.md b/_problems/hard/CYDB.md
index 261799bf..ddf96a4d 100644
--- a/_problems/hard/CYDB.md
+++ b/_problems/hard/CYDB.md
@@ -44,8 +44,8 @@ int main() {
 	cout << r << endl;
 	return 0;
 }
-
 **Java**
+
 
import java.util.Scanner;
 
 public class Main {
@@ -77,8 +77,8 @@ public class Main {
 		System.out.println(r);
 	}
 }
-
 
**Python** +
a = raw_input()
 na = len(a)
 b = raw_input()
@@ -95,8 +95,8 @@ for i in range(nb):
 				else: f = False
 		if (f and d <= 2): r = (r + j*j) % 1000000007
 print r
-
 
### Input + The strings A, B and C are provided in a compressed form to keep the input small enough. Sequence 00000 is encoded with letter 'a', 00001 with 'b' and so on until 'z'. 11010 is represented by 'A' and 11111 by 'F'. The input consists of three lines of letters a-z, A-F. First line contains at most 200 characters and the second one at most 2 000 000. Third line has the same length as the first line and will contain at most 40 digits 1 when decompressed. @@ -110,6 +110,6 @@ bbdb Output: 2990 - ### Explanation + After decompression we get strings 00000110111111101101, 1100000110111111101100110 and 00001000010001100001. If we run chef's program with this decompressed input, we will get 2990 as a result. diff --git a/_problems/hard/D4.md b/_problems/hard/D4.md index d3d50e87..bf56d350 100644 --- a/_problems/hard/D4.md +++ b/_problems/hard/D4.md @@ -32,5 +32,4 @@ For each test case write one number - the number of prime numbers Johnny wrote i Output: 30 2791 - \ No newline at end of file diff --git a/_problems/hard/D7.md b/_problems/hard/D7.md index 87f7cadd..19669e3e 100644 --- a/_problems/hard/D7.md +++ b/_problems/hard/D7.md @@ -47,5 +47,5 @@ The output should contain one line for each test case specifying the time when T 1:20.56 -1 3:26.43 - -**Note:** Be careful with precision. + +**Note:** Be careful with precision. diff --git a/_problems/hard/DAGCH.md b/_problems/hard/DAGCH.md index 60cf731d..e3eb5f34 100644 --- a/_problems/hard/DAGCH.md +++ b/_problems/hard/DAGCH.md @@ -95,8 +95,8 @@ Once again, Chef Hawlader is giving lecture to Chef Heickal about graph theory. DFS(v); } - -- "Okey, I can give you a hard problem", says Chef Heickal with evil smile.- "What? Come on", replies Chef Hawlader with grinning face. +- "Okey, I can give you a hard problem", says Chef Heickal with evil smile. +- "What? Come on", replies Chef Hawlader with grinning face. - "I'll give you a directed graph with **N** vertices and **M** edges. Here each vertex of the graph is numbered by DFS in pre-order. Of course, every vertex other than vertex **1** are reachable from vertex **1**." - "Okey, so what's problem?" - "Wait, I give some definitions. A vertex **x** is a _supreme_ vertex of **y**, if there is a directed path **x = v0, v1, ..., vk = y**, where **x < y < vi** for all **0 < i < k**, that is a path from **x** to **y** with zero or more intermediate vertex **vi** and every intermediate vertex should be greater than **x** and **y** and **x** should be less than **y**. A vertex **v** is a _superior_ vertex of **w**, if **v** is the minimum numbered vertex among all the _supreme_ vertices of **w**. You will be given **Q** queries on the graph. On each query you will be given a vertex **v**, you have to find out how many vertices are there in the graph, which have vertex **v** as superior vertex." @@ -112,7 +112,7 @@ The first line of each test contains three space-separated integers **N**, **M** ### Output -For each test case, print a single line containing **Q** space-separated integers, denoting the answer of the **Q** queries according to the order of the input. If there is no superior vertex for a query, print . See the sample input and output for detailed format. +For each test case, print a single line containing **Q** space-separated integers, denoting the answer of the **Q** queries according to the order of the input. If there is no superior vertex for a query, print 0. See the sample input and output for detailed format. ### Constraints @@ -150,8 +150,8 @@ For each test case, print a single line containing **Q** space-separated integer Output: 2 0 0 3 2 0 0 1 0 1 0 - ### Explanation + **Example case 1.** Vertex **3** has only vertex **1** as _supreme_ vertex as well as _superior_ vertex because there is a direct edge from **1** to **3** and vertex **2** has a _supreme_ vertex **1** (**1** → **3** → **2**). As vertex **2** has only one _supreme_ vertex, it is the _superior_ vertex also. **Example case 2.** Vertex **4** has three _supreme_ vertices **1** (**1** → **7** → **8** → **4**), **2** (**2** → **5** → **6** → **4**) and **3** (**3** → **4**). So vertex **1** is the _superior_ vertex of **4**. diff --git a/_problems/hard/DEG3MAXT.md b/_problems/hard/DEG3MAXT.md index 711e54c4..8b33aee1 100644 --- a/_problems/hard/DEG3MAXT.md +++ b/_problems/hard/DEG3MAXT.md @@ -155,8 +155,8 @@ For each test case print a line containing two numbers: **CMAX** and **CNT32**. 4 1 3 3 18 1 - ### Explanation + **Example case 1.** The maximum cost of a part P which satisfies the restrictions is 11. There are two such maximum cost parts, both of them containing all the cities and the following roads: - **(1,5), (2,5), (2,4), (3,5), (4,6)** diff --git a/_problems/hard/DEVLOCK.md b/_problems/hard/DEVLOCK.md index f0554d05..c9a4c716 100644 --- a/_problems/hard/DEVLOCK.md +++ b/_problems/hard/DEVLOCK.md @@ -108,14 +108,13 @@ answer for the problem with given **N, P** and **M = i**. Output: 1 1 1 5 -
Input:
 2 4 4
 
 Output:
 1 1 2 3 5
-
 
### Explanation + **Example #1.** For M = 0, we can have only one lock, ie. all zeros 00, it is divisible by 3. For M = 1, we can have only one lock, ie. all zeros 00, it is divisible by 3. diff --git a/_problems/hard/DFSGRID.md b/_problems/hard/DFSGRID.md index 0c7e861f..17cc0b2b 100644 --- a/_problems/hard/DFSGRID.md +++ b/_problems/hard/DFSGRID.md @@ -146,5 +146,4 @@ The first line of the input contains an integer **T** denoting the number of tes 11 3 1 - \ No newline at end of file diff --git a/_problems/hard/DGCD.md b/_problems/hard/DGCD.md index 8c5c2e29..3d2383e5 100644 --- a/_problems/hard/DGCD.md +++ b/_problems/hard/DGCD.md @@ -101,8 +101,8 @@ F 2 5 2 7 1 - -### Constraints + +### Constraints 1 N 1 Q 0 u, **v** N-1 1 vi 0 d diff --git a/_problems/hard/DIFTRIP.md b/_problems/hard/DIFTRIP.md index dc22f2e2..0c5213c8 100644 --- a/_problems/hard/DIFTRIP.md +++ b/_problems/hard/DIFTRIP.md @@ -104,8 +104,8 @@ Every pair of different cities can be traveled by going through exactly one path Output: 3 - ### Explanation + In the sample, the country consists of three cities. There are two roads. The first road connects city 1 and city 2. The second road connects city 1 and city 3. diff --git a/_problems/hard/DIGFORST.md b/_problems/hard/DIGFORST.md index 6ca31c9b..53c13167 100644 --- a/_problems/hard/DIGFORST.md +++ b/_problems/hard/DIGFORST.md @@ -95,5 +95,4 @@ For each test case, output on a line the minimum sum of digits found, or **-1** Output: 7 - \ No newline at end of file diff --git a/_problems/hard/DIGITS.md b/_problems/hard/DIGITS.md index 8acaf496..7fe661a6 100644 --- a/_problems/hard/DIGITS.md +++ b/_problems/hard/DIGITS.md @@ -29,6 +29,7 @@ For each test case, print on a single line the smallest positive integer whose p 220703118 0 ### Sample output: +
28
 699
 5555555555555
diff --git a/_problems/hard/DIGITS2.md b/_problems/hard/DIGITS2.md
index 34ef0245..e2b52c57 100644
--- a/_problems/hard/DIGITS2.md
+++ b/_problems/hard/DIGITS2.md
@@ -36,11 +36,10 @@ For each test case, output a single integer on a line, giving the minimum value
 11
 7Q2
 PIES
-
 
### Sample Output +
9
 8
 15227
 7845414
-
 
\ No newline at end of file diff --git a/_problems/hard/DISTNUM.md b/_problems/hard/DISTNUM.md index 3f42cf78..af018b50 100644 --- a/_problems/hard/DISTNUM.md +++ b/_problems/hard/DISTNUM.md @@ -104,7 +104,7 @@ For each query of **type 1** or **type 5**, output the answer to the query in a - **1** ≤ **A**i, **y** ≤ **109 + 6** - **1** ≤ **x** ≤ **|A|** - **1** ≤ **l** ≤ **r** ≤ **|A|** -- ≤ **z** ≤ **|A|** +- 0 ≤ **z** ≤ **|A|** ### Example @@ -155,8 +155,8 @@ For each query of **type 1** or **type 5**, output the answer to the query in a 0 6 - ### Subtasks + - **Subtask 1:** **Q**\***N** ≤ 2\*107. **Points - 10** - **Subtask 2:** Queries are of type 5 only. **Points - 5** - **Subtask 3:** Queries are of type 1 only. **Points - 10** diff --git a/_problems/hard/DISTNUM2.md b/_problems/hard/DISTNUM2.md index dc5f0e4e..9ef8568f 100644 --- a/_problems/hard/DISTNUM2.md +++ b/_problems/hard/DISTNUM2.md @@ -98,13 +98,14 @@ Define li = (ai x max(ansi - 1 If li > ri, then swap li and ri. ### Output + For each query, output the answer to the query in a single line. If such a number doesn't exist, output **-1**. ### Constraints - **1** ≤ **N, Q** ≤ **105** - **1** ≤ **Ai** ≤ **109** -- ≤ **ai**, **bi**, **ci**, **di** ≤ **N** +- 0 ≤ **ai**, **bi**, **ci**, **di** ≤ **N** - **1** ≤ **li** ≤ **ri** ≤ **N** - **1** ≤ **ki** ≤ **N** @@ -149,8 +150,8 @@ For each query, output the answer to the query in a single line. If such a numbe 4 6 4 - ### Subtasks + - **Subtask #1 (10 points) :** **Q** x **N** ≤ 107 - **Subtask #2 (20 points) :** **ki** = 1 - **Subtask #3 (30 points) :** **ai** = 0, **ci** = 0 diff --git a/_problems/hard/DIVIDEN.md b/_problems/hard/DIVIDEN.md index 5c97d4a5..31001f7a 100644 --- a/_problems/hard/DIVIDEN.md +++ b/_problems/hard/DIVIDEN.md @@ -153,6 +153,7 @@ Line -848.6692787746 -294.5333120998 -838.7467472625 -295.7718800931 Answer -843.7080130185 -295.1525960964 _There are other acceptable solutions._ + _The line breaks inside the second to last coordinates for each circle are for website display reasons only, and should not exist in your output._ ### Explanation diff --git a/_problems/hard/DIVISORS.md b/_problems/hard/DIVISORS.md index 4e90cf0f..b2843769 100644 --- a/_problems/hard/DIVISORS.md +++ b/_problems/hard/DIVISORS.md @@ -35,6 +35,6 @@ For a given positive integers **B** and **X** find the number of positive intege 5 63 - ### Explanation + In the second test case required numbers are 1, 2, 3, 4, 6. diff --git a/_problems/hard/DIVNODIV.md b/_problems/hard/DIVNODIV.md index 2bf29f3a..08312525 100644 --- a/_problems/hard/DIVNODIV.md +++ b/_problems/hard/DIVNODIV.md @@ -34,8 +34,8 @@ For a given positive integer **N** find the number of all positive integers **X* 2 1 -1 - ### Explanation + In the first test case only numbers 12 and 18 have 6 divisors and are divisible by 6. In the second test case the only number is 113^112. diff --git a/_problems/hard/DMCS.md b/_problems/hard/DMCS.md index 5523d427..c1dede91 100644 --- a/_problems/hard/DMCS.md +++ b/_problems/hard/DMCS.md @@ -103,6 +103,6 @@ For each test case output a single line containing the answer for the problem mo Output: 272 - ### Explanation + I have discovered a truly marvellous enumeration of this, which this margin is too narrow to contain. diff --git a/_problems/hard/DOMNOCUT.md b/_problems/hard/DOMNOCUT.md index 45223eb4..f088215f 100644 --- a/_problems/hard/DOMNOCUT.md +++ b/_problems/hard/DOMNOCUT.md @@ -38,8 +38,8 @@ For each test case output in the first line the word **"IMPOSSIBLE"** without qu 4 3 5 5 - ### Sample output +
IMPOSSIBLE
 1 2
 ab
@@ -53,5 +53,4 @@ ccb
 baa
 bcc
 IMPOSSIBLE
-
 
\ No newline at end of file diff --git a/_problems/hard/DORADM01.md b/_problems/hard/DORADM01.md index 25a62363..108a5c30 100644 --- a/_problems/hard/DORADM01.md +++ b/_problems/hard/DORADM01.md @@ -52,5 +52,4 @@ For each test case, print YES if there is a solution, otherwise print NO. Output: NO YES - \ No newline at end of file diff --git a/_problems/hard/DPOWPERM.md b/_problems/hard/DPOWPERM.md index 5df0e64d..413f3b86 100644 --- a/_problems/hard/DPOWPERM.md +++ b/_problems/hard/DPOWPERM.md @@ -36,6 +36,6 @@ You are given some bijection **f : S --> S** and a positive integer **D**. You n Output: 6 3 - ### Explanation + In the second case the appropriate values of **d** is 1, 5 and 7. diff --git a/_problems/hard/DRAGONST.md b/_problems/hard/DRAGONST.md index c5c92c7a..a2841bbb 100644 --- a/_problems/hard/DRAGONST.md +++ b/_problems/hard/DRAGONST.md @@ -154,8 +154,8 @@ Do not add any newlines between different testcases. 1 7 3 - ### Explanation + First testcase: First trip: When **C** = 1, Stannis can use 1-2 passage and he will reach the destination; diff --git a/_problems/hard/DUALPAL.md b/_problems/hard/DUALPAL.md index 15b35abb..b757d5d3 100644 --- a/_problems/hard/DUALPAL.md +++ b/_problems/hard/DUALPAL.md @@ -100,6 +100,6 @@ For each test case, output a list of space separated integers which are Dual Pal Output: 1 6643 1422773 5415589 90396755477 381920985378904469 - ### Note + Source limit for the problem is 8000B instead of usual 50000B. diff --git a/_problems/hard/E3.md b/_problems/hard/E3.md index 7d1bb03e..878945f9 100644 --- a/_problems/hard/E3.md +++ b/_problems/hard/E3.md @@ -43,5 +43,4 @@ For each test case output a single integer - the area of the field surrounded by Output 2 - \ No newline at end of file diff --git a/_problems/hard/EASYEX.md b/_problems/hard/EASYEX.md index a8a89d04..b4ed163d 100644 --- a/_problems/hard/EASYEX.md +++ b/_problems/hard/EASYEX.md @@ -87,14 +87,14 @@ The first line of the input contains an integer **T** denoting the number of tes ### Output -Let the answer for a test case be an fraction **P / Q**, where **P** and **Q** are integers. Let integer **X** be **P \* Q-1 modulo 2003**, where **Q-1 modulo 2003** is the modular multiplicative inverse of **Q** modulo **2003** or if **Q-1 modulo 2003** doesn't exist. For each test case, output a single line containing the integer **X** for this test case. +Let the answer for a test case be an fraction **P / Q**, where **P** and **Q** are integers. Let integer **X** be **P \* Q-1 modulo 2003**, where **Q-1 modulo 2003** is the modular multiplicative inverse of **Q** modulo **2003** or 0 if **Q-1 modulo 2003** doesn't exist. For each test case, output a single line containing the integer **X** for this test case. ### Constraints - **1** ≤ **T** ≤ **50** -- < **N, K** ≤ **109** -- < **F ≤ 1000** -- < **L \* F** ≤ **50 000** +- 0 < **N, K** ≤ **109** +- 0 < **F ≤ 1000** +- 0 < **L \* F** ≤ **50 000** - **Subtask #1\[39 points\]: F = 1** - **Subtask #2\[61 points\] : no additional constraints** @@ -107,6 +107,6 @@ Let the answer for a test case be an fraction **P / Q**, where **P** and **Q** a Output: 779 -
### Explanation
+
 We roll the 6-face dice 2 times, and we are interested in the value **a1 \* a2**. The only two possible scenarios when this value is not zero are **(1, 2)** and **(2, 1)**. Both of them have **a1 \* a2 = 1** and happen with probability **1 / 36** each. It means that **P / Q = (1 + 1) / 36 = 1 / 18**, so the answer is, **X = 779**.
diff --git a/_problems/hard/ELPHANT.md b/_problems/hard/ELPHANT.md
index 1d7c671f..b5d50d20 100644
--- a/_problems/hard/ELPHANT.md
+++ b/_problems/hard/ELPHANT.md
@@ -106,7 +106,7 @@ In this task, you have to determine the minimum number of cameras needed to take
 
 Let us assume that:
 
-- **N** – the number of elephants. The elephants are numbered  through **N-1**.
+- **N** – the number of elephants. The elephants are numbered 0 through **N-1**.
 - **L** – the length of the segment captured by a single camera. You may assume that L is an integer such that **1 ≤ L ≤ 1,000,000,000**.
 - **M** – the number of acts performed. You may assume that M is an integer such that **1 ≤ M ≤ 150,000**.
 - **i** – the number of the elephant that moves in the current act.
@@ -139,8 +139,8 @@ Output should consist of **M** integers in separate lines, denoting the **minimu
 3 35
 0 38
 2 0
-
-
**Output**/> +**Output** +/>
 1
@@ -148,8 +148,8 @@ Output should consist of **M** integers in separate lines, denoting the **minimu
 2
 2
 3
-
-
**Example 2:**/> +**Example 2:** +/> **Input** /> @@ -161,15 +161,15 @@ Output should consist of **M** integers in separate lines, denoting the **minimu 1 76543 0 66321 0 78754 - -**Output**/> +**Output** +/>
 2
 1
 1
-
 
### Subtasks + **Subtask 1 (10 points)** - There are exactly **N** = 2 elephants. diff --git a/_problems/hard/ESCAPE.md b/_problems/hard/ESCAPE.md index d12c4680..c35d5232 100644 --- a/_problems/hard/ESCAPE.md +++ b/_problems/hard/ESCAPE.md @@ -54,8 +54,8 @@ The output for each test case consists of a single integer on a single line indi 3 Impossible! 2 - ### Explanation of Sample Data + In the first case, Harry can step from (0,0) to (0,1) using d=1 steps. Then, the tiles (1,0) and (2,1), which are adjacent to the hole at (2,0), will collapse. Harry takes one more step from (0,1) to the exit at (1,1) and can safely exit the grid even though the tile (1,1) will collapse in the next expansion of the holes. In the second case, Harry can reach the exit by travelling along the sequence of tiles (0,0), (1,0), (1,1), (1,2) with a speed of d=3. This reaches the exit before the holes expand. However, if Harry travels at a speed d < 3, then he cannot reach the exit after d steps and the hole at tile (0,2) will expand to consume the exit tile (1,2). diff --git a/_problems/hard/EST.md b/_problems/hard/EST.md index f6ecd22b..b6d9226d 100644 --- a/_problems/hard/EST.md +++ b/_problems/hard/EST.md @@ -108,5 +108,4 @@ helloworld 6221124 Explanation: - -In the first test case every string of length 1 satisfies the condition. In the second test case every string consisting of two equal letters is fine. In the third test case every string comprising three pairwise distinct letters adds 1 to the answer. In the fourth test case string 'bee' is one of the 1300 good strings. \ No newline at end of file +In the first test case every string of length 1 satisfies the condition. In the second test case every string consisting of two equal letters is fine. In the third test case every string comprising three pairwise distinct letters adds 1 to the answer. In the fourth test case string 'bee' is one of the 1300 good strings. diff --git a/_problems/hard/EVENPOLY.md b/_problems/hard/EVENPOLY.md index a3fae3f2..d9334daa 100644 --- a/_problems/hard/EVENPOLY.md +++ b/_problems/hard/EVENPOLY.md @@ -46,6 +46,6 @@ a+a Some Odd All Even All Even - ### Explanation of Sample Data + The determinant in the first test case is simply x2+x which has two odd coefficients. A tedious calculation shows that the determinant in the second test case is actually 0. The last test case has determinant 2a, so all coefficients are even. diff --git a/_problems/hard/EVILBOOK.md b/_problems/hard/EVILBOOK.md index 2f41e3a8..d8229a26 100644 --- a/_problems/hard/EVILBOOK.md +++ b/_problems/hard/EVILBOOK.md @@ -109,11 +109,13 @@ For each test case, print the minimum total effort (rounded to the nearest integ 1000000000 1000000000 0 130 ### Sample Output +
168
 impossible
 1000000000
 1882
 
### Output details + In the first case, the optimal way is the following. Initially, Ciel's magical power = 0, Total effort = 0 diff --git a/_problems/hard/EXPCOMM.md b/_problems/hard/EXPCOMM.md index f4cbcf4a..7fbae839 100644 --- a/_problems/hard/EXPCOMM.md +++ b/_problems/hard/EXPCOMM.md @@ -33,8 +33,8 @@ For a given prime number **p** find the number of all pairs **(m, n)** of positi 2 14 - ### Explanation + In the first test required pairs are (1, 1) and (2, 2). In the second test case required pairs are (1, 1), (1, 4), (2, 2), (2, 4), (3, 3), (3, 6), (4, 1), (4, 2), (4, 4), (4, 5), (5, 4), (5, 5), (6, 3) and (6, 6). diff --git a/_problems/hard/F4.md b/_problems/hard/F4.md index 9b18dd87..6decdd04 100644 --- a/_problems/hard/F4.md +++ b/_problems/hard/F4.md @@ -35,5 +35,4 @@ For each testcase, output one integer, the identifier which Tomek should choose 4 2 1311 - \ No newline at end of file diff --git a/_problems/hard/F6.md b/_problems/hard/F6.md index 7ca9eb4e..49137261 100644 --- a/_problems/hard/F6.md +++ b/_problems/hard/F6.md @@ -31,5 +31,4 @@ First, you should output one number n, the maximal achievable number of loaves f 0 0.4 0 0.3 1 0.2 - \ No newline at end of file diff --git a/_problems/hard/FARASA.md b/_problems/hard/FARASA.md index 038d8994..ad11dbe8 100644 --- a/_problems/hard/FARASA.md +++ b/_problems/hard/FARASA.md @@ -110,6 +110,6 @@ Output a single line containing the answer to the problem. Output 28 - ### Explanation + **Test Case 1:** Furik can decide one of the following numbers: 1, 2, 3, 5, 6. For example, let us assume Furik has decided 3. In the worst case, Rubik may call out 4 numbers, since there are only 5 such numbers. diff --git a/_problems/hard/FBCHEF.md b/_problems/hard/FBCHEF.md index a921dad3..c0adc481 100644 --- a/_problems/hard/FBCHEF.md +++ b/_problems/hard/FBCHEF.md @@ -75,7 +75,7 @@ Chef declared war on Byteland. Chefs best scientist Pramod has designed a new Fi Byteland has a structure of a tree with **N** cities connected by **N-1** bidirectional roads. Each city has index between (**1**, **N**) (inclusive) and no two cities have same index. The capital city of Byteland has index **1**. The distance between two cities is the number of roads in the path from one to other. -If the plane drops a bomb on a city **A**, with damage value **X** then the damage done to a city **B** will be floor(**X/2d**) where **d** is the distance between **A** and **B**, note that as the distance of **A** from itself is , the damage done to **A** will be floor(**X/20**) = **X**. +If the plane drops a bomb on a city **A**, with damage value **X** then the damage done to a city **B** will be floor(**X/2d**) where **d** is the distance between **A** and **B**, note that as the distance of **A** from itself is 0, the damage done to **A** will be floor(**X/20**) = **X**. Each city has a certain wealth **Wi** in it, if it is damaged by a value of **X** then its wealth is reduced by **X**. On a day if the wealth of a city becomes less than or equal to zero then it is considered Economically Dead. @@ -128,8 +128,8 @@ For each query of type **2** print the required value asked in the question. Sample Output 1 3 - ### Explanation + Path from Capital to City 1 : 1 Path from Capital to City 2 : 1 <--> 2 diff --git a/_problems/hard/FIBTREE.md b/_problems/hard/FIBTREE.md index 21bf37ee..dee87aaa 100644 --- a/_problems/hard/FIBTREE.md +++ b/_problems/hard/FIBTREE.md @@ -75,7 +75,7 @@ All submissions for this problem are available.### Read problems statements in In mathematical terms, the sequence **F\[N\]** of Fibonacci numbers is defined by the recurrence relation **F\[N\]** = **F\[N-1\]** + **F\[N-2\]**, with seed values **F\[1\] = 1**,**F\[2\] = 1**. -Today, Chef gives you a rooted tree, consisting of **N** nodes. At first, the node **1** is the root. The nodes are numbered from **1** to **N**, and each node has an integer that initially equals to . Then, Chef asks you to perform **M** queries. +Today, Chef gives you a rooted tree, consisting of **N** nodes. At first, the node **1** is the root. The nodes are numbered from **1** to **N**, and each node has an integer that initially equals to 0. Then, Chef asks you to perform **M** queries. The queries are as follows: @@ -92,7 +92,7 @@ Output the sum of all the integers, associated with the nodes on the way from ** - **R x** -All the integers associated with the nodes return to the state after the **x**-th query. If **x** is , then all of them become equal to , as in the very beginning. +All the integers associated with the nodes return to the state after the **x**-th query. If **x** is 0, then all of them become equal to 0, as in the very beginning. @@ -112,7 +112,7 @@ Then, **M** lines follow. Every single line denotes a single query, which has on - **R x1** -As you can see, the number **x** isn't given to you directly. For all queries, actual number **x** will be equal to **x1** xor **lastans**, where lastans denotes the last number that you have output, or if you haven't output any numbers yet. +As you can see, the number **x** isn't given to you directly. For all queries, actual number **x** will be equal to **x1** xor **lastans**, where lastans denotes the last number that you have output, or 0 if you haven't output any numbers yet. ### Output @@ -144,8 +144,8 @@ QC 6 4 13 7 4 - ### Explanation + Let’s denote the first state of integers as **0 0 0 0 0**, where the **i**-th interger means the integer associated with the node **i**. In the first query “**A 4 2**”, the actual number is **x = 4 xor 0 = 4**. Hence the state will be **2 3 1 1 0** after this query. diff --git a/_problems/hard/FINDSEQ.md b/_problems/hard/FINDSEQ.md index 7f742f54..25de37e7 100644 --- a/_problems/hard/FINDSEQ.md +++ b/_problems/hard/FINDSEQ.md @@ -40,7 +40,7 @@ For each test case output five space separated integers in ascending order which Output: 0 2 3 5 6 -1 - + **Explanation of 1st sample:** {0, 2, 3, 5, 6} is a valid solution because the values of those indexes {6, 5, 3, 8, 10} will have ranks {3, 2, 1, 4, 5} after sorting. But {0, 2, 3, 4, 5} is not a solution as the values {6, 5, 3, 13, 8} will have ranks {3, 2, 1, 5, 4} after sorting. **Explanation of 2nd sample:** There is no five length subsequence in the array that will have ranks {1, 2, 3, 4, 5} after sorting. diff --git a/_problems/hard/FLOWERPO.md b/_problems/hard/FLOWERPO.md index 2c3fba38..35726f1a 100644 --- a/_problems/hard/FLOWERPO.md +++ b/_problems/hard/FLOWERPO.md @@ -114,8 +114,8 @@ Find out the minimum amount Chef has to spend in buying the crackers so as to ac Output: 89 - ### Explanation + One optimal way is to choose the strengths of the crackers as (0, 0, 8, 5, 0). That is, the leftmost cracker has strength 0, the next has 0, the next has 8, etc. Now, Chef lights up the 4-th cracker. After 1 second, it explodes and it lights up all the unlit crackers in its interval. Because its strength is 5, its interval would be \[15 - 5, 15 + 5\] = \[10, 20\]. So after 1 second, the third and fifth cracker are also lit. diff --git a/_problems/hard/FLYDIST.md b/_problems/hard/FLYDIST.md index 722e001c..a949c8b2 100644 --- a/_problems/hard/FLYDIST.md +++ b/_problems/hard/FLYDIST.md @@ -42,6 +42,6 @@ Output the minimum sum of modifications as a reduced fraction "X/Y" - greatest c Output: 5/1 - ### Explanation + One possible scenario is to decrease the length of flight (0,3) by 1, increase (0,1) by 3 and (1,2) by 1. diff --git a/_problems/hard/FN.md b/_problems/hard/FN.md index 7a86d618..405c6ff0 100644 --- a/_problems/hard/FN.md +++ b/_problems/hard/FN.md @@ -102,7 +102,7 @@ For each test case, output a single line containing one integer indicates the sm **11** ≤ **P** ≤ **2000000000** and is one **prime number** - ≤ **C** ≤ **P-1** +0 ≤ **C** ≤ **P-1** **(P Mod 10)** is **square number** @@ -131,5 +131,4 @@ F_n(mod 19) 0 1 1 2 3 5 8 13 2 15 17 13 11 5 16 2 18 1 0 1

- \ No newline at end of file diff --git a/_problems/hard/FSFSFS.md b/_problems/hard/FSFSFS.md index 64bdbef5..b504281d 100644 --- a/_problems/hard/FSFSFS.md +++ b/_problems/hard/FSFSFS.md @@ -102,6 +102,6 @@ For each test case, output the answer per line. 2 2 - ### Explanation + In the first case, you can either remove 2 or remove both 1 and 2. In the second case, you can either remove 2, 3, 5 or remove 1, 2, 3, 5. diff --git a/_problems/hard/FUNCTION.md b/_problems/hard/FUNCTION.md index 6574b8be..159428aa 100644 --- a/_problems/hard/FUNCTION.md +++ b/_problems/hard/FUNCTION.md @@ -68,5 +68,5 @@ We may only assign f(a) = b or f(b) = a if a,b is an input pair. Furthermore, a 6 impossible 19 - - Note, one possible solution for the first test case is f(1) = 2, f(2) = 3, and f(3) = 1. The second is impossible since the only possiblity for f(5) is 6 and the only possiblity for f(6) is 5 and both cannot be used in a backup function. Finally, a possible solution for the last test case is f(1) = 2, f(2) = 3, f(3) = 1, and f(4) = 2. + + Note, one possible solution for the first test case is f(1) = 2, f(2) = 3, and f(3) = 1. The second is impossible since the only possiblity for f(5) is 6 and the only possiblity for f(6) is 5 and both cannot be used in a backup function. Finally, a possible solution for the last test case is f(1) = 2, f(2) = 3, f(3) = 1, and f(4) = 2. diff --git a/_problems/hard/FURGRAPH.md b/_problems/hard/FURGRAPH.md index 4299f6c6..2167d85b 100644 --- a/_problems/hard/FURGRAPH.md +++ b/_problems/hard/FURGRAPH.md @@ -125,5 +125,4 @@ You should add edges one by one (with same order as they follows in input), and 1 1 2 - \ No newline at end of file diff --git a/_problems/hard/G4.md b/_problems/hard/G4.md index 2194f97e..98303282 100644 --- a/_problems/hard/G4.md +++ b/_problems/hard/G4.md @@ -30,11 +30,10 @@ For each testcase, output the total effort required to obtain all words in the o Output: 7 64 - ### Explanation +
The optimal encoding for the first testcase is:
 '0','10','11'.
 The optimal encoding for the second testcase is:
 '0000','0001',...,'1110','1111'.
-
 
\ No newline at end of file diff --git a/_problems/hard/G5.md b/_problems/hard/G5.md index 294c04a9..f52139c3 100644 --- a/_problems/hard/G5.md +++ b/_problems/hard/G5.md @@ -39,5 +39,4 @@ Exactly n numbers, representing the measured results of the experiment for each Output: 8.6556936725 8.6556936725 - \ No newline at end of file diff --git a/_problems/hard/GENETICS.md b/_problems/hard/GENETICS.md index b918b77a..44805f7d 100644 --- a/_problems/hard/GENETICS.md +++ b/_problems/hard/GENETICS.md @@ -54,5 +54,4 @@ COUNT 4 3 6 0 2 0 1 0 2 0 2 - \ No newline at end of file diff --git a/_problems/hard/GENIND.md b/_problems/hard/GENIND.md index 99fb5844..a2c3bdb2 100644 --- a/_problems/hard/GENIND.md +++ b/_problems/hard/GENIND.md @@ -65,5 +65,4 @@ If there are multiple such cycles, then any will do. Also, the order in which th Ok Bad Cycle: 4 5 2 0 1 -1 Bad Cycle: 3 2 -1 - \ No newline at end of file diff --git a/_problems/hard/GEOCHEAT.md b/_problems/hard/GEOCHEAT.md index 7aaa2197..ab5e0da8 100644 --- a/_problems/hard/GEOCHEAT.md +++ b/_problems/hard/GEOCHEAT.md @@ -120,9 +120,9 @@ Output **N** lines. The **i**-th line should contain the square of the diameter 500 2000 999999980000029000 - ### Explanation -1. After the first query, the set contains only one point **(20, 20)**. You should print because there are no two points with positive distance between them. + +1. After the first query, the set contains only one point **(20, 20)**. You should print 0 because there are no two points with positive distance between them. 2. After the second query, the set contains points **(20, 20)** and **(40, 30)**. The distance between them is **sqrt((40-20)^2+(30-20)^2) = sqrt(500)** so the squared distance is **500**. 3. After the third query, the set is **{(20,20), (40,30), (35,35)}**. The maximum distance is **sqrt(500)**. 4. After the fourth query, the maximum distance is between **(0,10)** and **(40,30)**. Note that the given points may be collinear. diff --git a/_problems/hard/GERALD07.md b/_problems/hard/GERALD07.md index ecda26a9..6b16dce8 100644 --- a/_problems/hard/GERALD07.md +++ b/_problems/hard/GERALD07.md @@ -118,5 +118,4 @@ For each query of each test case print the required number of connected componen 3 1 1 - \ No newline at end of file diff --git a/_problems/hard/GERALD08.md b/_problems/hard/GERALD08.md index 05814162..871f93b9 100644 --- a/_problems/hard/GERALD08.md +++ b/_problems/hard/GERALD08.md @@ -96,7 +96,7 @@ For each test case, output a single line containing two strings: the name of the - **1** ≤ **T** ≤ **1000** - **1** ≤ **N** ≤ **100000** - **1** ≤ **Ui**, **Vi** ≤ **N** -- ≤ **Ci** ≤ **1** +- 0 ≤ **Ci** ≤ **1** - It's guaranteed that the sum of **N** values for all tests doesn't exceed 100000. ### Example @@ -121,5 +121,4 @@ Chef Chef Ksen Ksen Ksen Chef Chef Chef - \ No newline at end of file diff --git a/_problems/hard/GERALD2.md b/_problems/hard/GERALD2.md index 28a82356..4829f672 100644 --- a/_problems/hard/GERALD2.md +++ b/_problems/hard/GERALD2.md @@ -141,5 +141,4 @@ Sum of all **M** values for test cases is not greater than **200000**. 5 1 1 - \ No newline at end of file diff --git a/_problems/hard/GNUM.md b/_problems/hard/GNUM.md index a4285dbe..ab702a25 100644 --- a/_problems/hard/GNUM.md +++ b/_problems/hard/GNUM.md @@ -106,8 +106,8 @@ For each testcase, print the maximum number of moves Mr. Yagami can make, in one 3 0 - ### Explanation + First testcase: Following are the possible moves denoting by (i,j) and (p,q) 1st move: (1,2) and (2,3) diff --git a/_problems/hard/GOODGAL.md b/_problems/hard/GOODGAL.md index c336a79a..84818fa6 100644 --- a/_problems/hard/GOODGAL.md +++ b/_problems/hard/GOODGAL.md @@ -112,7 +112,7 @@ For each test case output one word per line: "YES" if the galaxy is a good galax - **1** ≤ **T** ≤ **5** - **2** ≤ **N** ≤ **1024** -- ≤ **M** ≤ **40 000** +- 0 ≤ **M** ≤ **40 000** ### Subtasks @@ -154,8 +154,8 @@ NO NO YES NO -
### Explanation
+
 **Test case 1.** This galaxy is equivalent to the red (or blue) galaxy in step 2 in the above image.
 
 **Test case 2.** This galaxy is similar to test case 1, but the connection has been destroyed, so the galaxy is no longer good.
diff --git a/_problems/hard/GQUERY.md b/_problems/hard/GQUERY.md
index 6a0e5a6b..00435df5 100644
--- a/_problems/hard/GQUERY.md
+++ b/_problems/hard/GQUERY.md
@@ -131,8 +131,8 @@ For each testcase, output **Q** lines, the **i-th** line of them must contain a
 5
 5
 4
-
 
### Explanation + The original list of edges is { (1, 2), (1, 3), (2, 3), (3, 5), (1, 5), (4, 5), (1, 4) }. First query: After applying the (5, 6) swap, the list of edges is { (1, 2), (1, 3), (2, 3), (3, 5), (4, 5), (1, 5), (1, 4) }. Just the first 5 edges in this, that is { (1, 2), (1, 3), (2, 3), (3, 5), (4, 5) } connects the entire graph. Hence the answer is 5. diff --git a/_problems/hard/GRAPHCNT.md b/_problems/hard/GRAPHCNT.md index 730df93c..b679f489 100644 --- a/_problems/hard/GRAPHCNT.md +++ b/_problems/hard/GRAPHCNT.md @@ -114,8 +114,8 @@ Print a single integer corresponding to the number of unordered pairs as asked i Output: 14 - ### Explanation + There are 14 pairs of vertices as follows: (1,2) (1,3) diff --git a/_problems/hard/GRAPHCT.md b/_problems/hard/GRAPHCT.md index abdcafbf..bd5c0743 100644 --- a/_problems/hard/GRAPHCT.md +++ b/_problems/hard/GRAPHCT.md @@ -39,7 +39,6 @@ Output T lines, one corresponding to each test case. For a test case, output the 4 4 5 10 -
Sample Output :
 1
 0
@@ -47,10 +46,8 @@ Output T lines, one corresponding to each test case. For a test case, output the
 3
 0
 
-
 
Constraints :
 1 <= T <= 2000
 1 <= n <= 100
 0 <= m <= 10000
-
 
\ No newline at end of file diff --git a/_problems/hard/GRIDGAME.md b/_problems/hard/GRIDGAME.md index f47947a9..eca08e5d 100644 --- a/_problems/hard/GRIDGAME.md +++ b/_problems/hard/GRIDGAME.md @@ -102,14 +102,14 @@ For each test case, print the winner of each of the **Q** games, one per line. 1 2 3 4 6 5 - ### Sample Output +
Alice
 Bob
 Alice
 Bob
-
 
### Explanation + In the first game, the pawn is at cell (2, 2). In order to win Alice can begin by moving the pawn to (1, 2). Bob's only available move is to (0, 2) since (1, 1) is impassable. Alice then moves the pawn to (0, 0), leaving Bob with no available moves. Here is the small portion of the table of winning and losing positions. Here X-direction goes from the left to the right and Y-direction goes from the top to the bottom. Letter **'A'** at the cell **(X, Y)** means that Alice will win when **(X, Y)** is the starting position of the pawn and **'B'** means that Bob will win. We use different background color for Alice and Bob cells for convenience. Impassable cells have black background color. diff --git a/_problems/hard/GST.md b/_problems/hard/GST.md index 235b9cfb..662fc47e 100644 --- a/_problems/hard/GST.md +++ b/_problems/hard/GST.md @@ -73,8 +73,8 @@ If there are multiple non-empty sets whose constraints are violated, then any wi 2 3 4/5 2 4 4/5 3 4 4/5 - ### Output: +
 GST
 
@@ -83,5 +83,4 @@ GST
 2
 3
 2 3 4
-
 
\ No newline at end of file diff --git a/_problems/hard/GTHRONES.md b/_problems/hard/GTHRONES.md index d975f25e..39b59a61 100644 --- a/_problems/hard/GTHRONES.md +++ b/_problems/hard/GTHRONES.md @@ -111,6 +111,6 @@ Your program should print Bran if he has a a winning strategy else it should pri Output: Bran 21 - ### Constraints: + 1 N 1 ui1 ciAll **ui**are distinct. diff --git a/_problems/hard/H3.md b/_problems/hard/H3.md index 2c66f7f6..780d5205 100644 --- a/_problems/hard/H3.md +++ b/_problems/hard/H3.md @@ -57,8 +57,8 @@ Case #1: Case #2: 16 24 - ### Output details + The 8 triangles congruent to the second triangle (in the first test case) are presented in the following figure: ![](/themes/abessive/images/contests/h3.png) diff --git a/_problems/hard/HAMILG.md b/_problems/hard/HAMILG.md index 026f0943..1b4533e7 100644 --- a/_problems/hard/HAMILG.md +++ b/_problems/hard/HAMILG.md @@ -146,8 +146,8 @@ The time limit is 2 seconds for subtasks 1-3 and 5 seconds for subtask 4. 0 4 2 -
### Explanation
+
 **Example case 1.** The graph is a complete graph with 4 vertices, so the game will always last 3 turns; in the 4th turn, Askar will have no way to move and lose.
 
 **Example case 2.** If Askar places the token on vertex 7, Bob will have to move it to vertex 1 and Askar can then move it to vertex 5 and win. A similar strategy exists for vertices 5, 6 and 8.
diff --git a/_problems/hard/HARMONY.md b/_problems/hard/HARMONY.md
index 9f9ae4ca..84470ffc 100644
--- a/_problems/hard/HARMONY.md
+++ b/_problems/hard/HARMONY.md
@@ -79,8 +79,8 @@ For each test case, you are to output a single line. If it is not possible to ad
 1 0 0
 0 1 0 0 0 1
 0 0 1 0 1 1 0 0 0
-
 
### Illustration Of Sample Data + The following three images illustrate the sample data. The thick edges indicate edges that receive a blossom. A red cycle has been highlighted in the last example. Note, in particular, that there are three faces contained in this cycle and there is one edge lying on this cycle that receives a blossom. Test Case 1: diff --git a/_problems/hard/HAUNTED.md b/_problems/hard/HAUNTED.md index 0b8fbe3a..c7ac4ade 100644 --- a/_problems/hard/HAUNTED.md +++ b/_problems/hard/HAUNTED.md @@ -81,5 +81,4 @@ $..## 18 -1 -1 - \ No newline at end of file diff --git a/_problems/hard/HBEAR.md b/_problems/hard/HBEAR.md index d923944f..5e8a84ba 100644 --- a/_problems/hard/HBEAR.md +++ b/_problems/hard/HBEAR.md @@ -41,8 +41,8 @@ HH..H 0 4 - -**Explanation for 2nd query**
+
**Explanation for 2nd query** +
 #: means the chosen cell
 The possibilities are:
 1. Size 2 x 3
diff --git a/_problems/hard/HIGH.md b/_problems/hard/HIGH.md
index 15cfafb5..7035bcd9 100644
--- a/_problems/hard/HIGH.md
+++ b/_problems/hard/HIGH.md
@@ -52,5 +52,4 @@ The number of ways to build the network, for every test case in a separate line.
 1
 3
 
-
 
\ No newline at end of file diff --git a/_problems/hard/HLD.md b/_problems/hard/HLD.md index e1d26443..98fcb5a1 100644 --- a/_problems/hard/HLD.md +++ b/_problems/hard/HLD.md @@ -131,6 +131,6 @@ The output should have only one integer in a new line, the minimum 'cost' achiev Output: 3 1 - ### Explanation + For first input: one solution is to mark these edges as heavy and the other edges as light: {1-2, 2-4, 4-5, 5-6, 3-8, 8-9, 10-11} diff --git a/_problems/hard/HPARITY.md b/_problems/hard/HPARITY.md index d7221bf8..6e93a062 100644 --- a/_problems/hard/HPARITY.md +++ b/_problems/hard/HPARITY.md @@ -38,12 +38,12 @@ For each test case, output the number of black colored cells in the given hyperc 0 3 0 2 6 8 1 5 - -
**Output:**
9
+
**Output:**```
+9
 32
 22
 
-
-
**Constraints**
T < 51 +
**Constraints**``` +T < 51 0 < N < 9 -
All the co-ordinates will be non negative integers with at most 15 digits.
\ No newline at end of file
+
All the co-ordinates will be non negative integers with at most 15 digits.
diff --git a/_problems/hard/HULL.md b/_problems/hard/HULL.md
index e4d30122..ad2bb193 100644
--- a/_problems/hard/HULL.md
+++ b/_problems/hard/HULL.md
@@ -103,6 +103,6 @@ There exists at least one sequence of at most **6** vectors from this set that f
 
 Output:
 2.0
-
 
### Explanation + The only non-strictly convex polygon you can construct from these vectors by the rules described in the problem statement is the [isosceles trapezoid](http://en.wikipedia.org/wiki/Isosceles_trapezoid) that has height of length **1** and bases of length **1** and **3**. It has area **2.0**. diff --git a/_problems/hard/HYPER.md b/_problems/hard/HYPER.md index 1af412a4..8196af8c 100644 --- a/_problems/hard/HYPER.md +++ b/_problems/hard/HYPER.md @@ -44,5 +44,4 @@ For each test case output one line containing the requested number. It's guarant 93268 Explanation: - -
There is just one 3-uniform hypertree on 3 vertices: {(1,2,3)}. There are six of them on 4 vertices: {(1,2,3), (1,2,4)}, {(1,2,3), (1,3,4)}, {(1,2,3), (2,3,4)}, {(1,2,4), (1,3,4)}, {(1,2,4), (2,3,4)}, {(1,3,4), (2,3,4)}. Two of the 25 possible hypertrees on 5 vertices are {(1,2,3), (3,4,5)} and {(1,2,3), (1,2,4), (1,2,5)}. \ No newline at end of file +There is just one 3-uniform hypertree on 3 vertices: {(1,2,3)}. There are six of them on 4 vertices: {(1,2,3), (1,2,4)}, {(1,2,3), (1,3,4)}, {(1,2,3), (2,3,4)}, {(1,2,4), (1,3,4)}, {(1,2,4), (2,3,4)}, {(1,3,4), (2,3,4)}. Two of the 25 possible hypertrees on 5 vertices are {(1,2,3), (3,4,5)} and {(1,2,3), (1,2,4), (1,2,5)}. diff --git a/_problems/hard/ICPC16F.md b/_problems/hard/ICPC16F.md index c32e42d3..4c0276b3 100644 --- a/_problems/hard/ICPC16F.md +++ b/_problems/hard/ICPC16F.md @@ -56,5 +56,4 @@ For each test case, output **-1** if there is no bipartite graph satisfying this 2 2 1 2 -1 - \ No newline at end of file diff --git a/_problems/hard/IMPROVE.md b/_problems/hard/IMPROVE.md index 3bfb2d22..d0e5cff2 100644 --- a/_problems/hard/IMPROVE.md +++ b/_problems/hard/IMPROVE.md @@ -119,8 +119,8 @@ The restrictions for the output sequence are: Output: 6 1 3 2 3 1 2 - ### Explanation + **Example case 1.** Let's perform these operations one-by-one. The positions having **Ai = i** will be highlighted in bold: - Initially we have A = (4, 3, 2, 1) diff --git a/_problems/hard/INSOMB4.md b/_problems/hard/INSOMB4.md index d7cf4cf6..9cba39ff 100644 --- a/_problems/hard/INSOMB4.md +++ b/_problems/hard/INSOMB4.md @@ -74,12 +74,11 @@ Line 1: The minimum number of transfers to be effected for the first production 3 30 17 5 14 - -/> + +/> **Sample Output:**
 9
-
 
\ No newline at end of file diff --git a/_problems/hard/INSOMB8.md b/_problems/hard/INSOMB8.md index b367589e..b8111ae3 100644 --- a/_problems/hard/INSOMB8.md +++ b/_problems/hard/INSOMB8.md @@ -53,13 +53,13 @@ Line 1: Yes/No 4 30 12 30 100 200 200 500 12 4 70 0 70 20 200 20 200 0 4 0 0 0 100 200 100 200 0 - + **Sample Output:**/>/>
 Yes
-
 
**The figure for the sample input is:** + ![](/fallingsnow.jpg)/> diff --git a/_problems/hard/INVBINCF.md b/_problems/hard/INVBINCF.md index 349512c9..c889c1ca 100644 --- a/_problems/hard/INVBINCF.md +++ b/_problems/hard/INVBINCF.md @@ -90,7 +90,7 @@ For each test case output the answer on the separate line. - **1** ≤ **T** ≤ **100** - **1** ≤ **n** ≤ **120** -- ≤ **R** < **2n** +- 0 ≤ **R** < **2n** ### Example @@ -107,11 +107,11 @@ For each test case output the answer on the separate line. 0 1 7 - ### Explanation + **Example case 1.** We have **C(1, 0) = C(1, 1) = 1**. Hence **C(1, K) mod 2 ≠ 0** for all **K**. Therefore, the answer is **-1**. -**Example case 2.** Since **C(1, 0) mod 2 = 1**, the answer is . +**Example case 2.** Since **C(1, 0) mod 2 = 1**, the answer is 0. **Example case 3.** Since **C(7, 0) mod 8 = 1 ≠ 7** and **C(7, 1) mod 8 = 7 mod 8 = 7**, the answer is **1**. diff --git a/_problems/hard/INVERT.md b/_problems/hard/INVERT.md index e69a95e2..4d25e8f4 100644 --- a/_problems/hard/INVERT.md +++ b/_problems/hard/INVERT.md @@ -119,15 +119,15 @@ After each of the Devu's move, report the required answer for Churu. 3 3 2 2 2 3 1 1 2 - **Input** +
 1
 2
 3
 5
-
 
### Explanation + - After Q1, **A** = {2, 5, 1}, **B** = {4, 3}. Therefore, inversion count in **B** is 1. - After Q2, **A** = {2, 5}, **B** = {4, 1, 3}. Therefore, inversion count in **B** is 2. - After Q3, **A** = {2}, **B** = {4, 1, 5, 3}. Therefore, inversion count in **B** is 3. diff --git a/_problems/hard/IRONISL.md b/_problems/hard/IRONISL.md index 6ea60a96..35e07c5f 100644 --- a/_problems/hard/IRONISL.md +++ b/_problems/hard/IRONISL.md @@ -163,5 +163,4 @@ Do not add any newlines between different testcases. 5 8 - \ No newline at end of file diff --git a/_problems/hard/ISOARRAY.md b/_problems/hard/ISOARRAY.md index 665f659e..76f640ca 100644 --- a/_problems/hard/ISOARRAY.md +++ b/_problems/hard/ISOARRAY.md @@ -140,8 +140,8 @@ NO YES YES YES - ### Explanation + **Example case 1:** - query 1: **last** = 0, **x** = 2, **y** = 5, **z** = 1, **t** = 4 diff --git a/_problems/hard/J5.md b/_problems/hard/J5.md index 3f35f160..fa248cb1 100644 --- a/_problems/hard/J5.md +++ b/_problems/hard/J5.md @@ -42,5 +42,4 @@ caaat difference imilaq aat - \ No newline at end of file diff --git a/_problems/hard/J6.md b/_problems/hard/J6.md index 94bb52a4..9036756b 100644 --- a/_problems/hard/J6.md +++ b/_problems/hard/J6.md @@ -47,5 +47,4 @@ MULTIPLE UNIQUE MULTIPLE CONFLICT - \ No newline at end of file diff --git a/_problems/hard/JAKKU.md b/_problems/hard/JAKKU.md index 64562963..1e937e1f 100644 --- a/_problems/hard/JAKKU.md +++ b/_problems/hard/JAKKU.md @@ -122,8 +122,8 @@ For each test case, output a single line containing the minimum number of satell Output: 0 0 - ### Sub tasks + - Sub task #1: N = 3 (10 points) - Sub task #2: N ≤ 20 (30 points) - Sub task #3: N ≤ 50 (60 points) diff --git a/_problems/hard/JUMP.md b/_problems/hard/JUMP.md index 0046ab3e..4e2d11a8 100644 --- a/_problems/hard/JUMP.md +++ b/_problems/hard/JUMP.md @@ -123,6 +123,6 @@ Output a single line containing the answer to the problem i.e. the minimal possi Output: 10 - ### Explanation + **Example case 1.** jumping from first hill to 4th one then to 5th; the answer will be 0 + 0 + 0 + (4-1)^2 + (5-4)^2 = 10 diff --git a/_problems/hard/KILLER.md b/_problems/hard/KILLER.md index 31d27f15..142f8751 100644 --- a/_problems/hard/KILLER.md +++ b/_problems/hard/KILLER.md @@ -157,8 +157,8 @@ For each test case, output one integer per line denoting the minimum total cost. Output 15 11 - ### Explanation + **Example Test case 2.** ![](https://codechef_shared.s3.amazonaws.com/upfiles/killer.png) diff --git a/_problems/hard/KNGHTMOV.md b/_problems/hard/KNGHTMOV.md index bc75fac5..53d07833 100644 --- a/_problems/hard/KNGHTMOV.md +++ b/_problems/hard/KNGHTMOV.md @@ -114,8 +114,8 @@ The absolute values of all other input values are at most 500. 0 - **Explanations:** + In the first and second examples, our knight's move is the similar to ordinary knight's, but only 2 directions are allowed. In the first example, there are 2 ways (0, 0) -> (1, 2) -> (3, 3) and (0, 0) -> (2, 1) -> (3, 3). In the third example, our knight's cannot move toward, so our knight's cannot complete his mission. diff --git a/_problems/hard/KOL1511.md b/_problems/hard/KOL1511.md index 10a23c55..079d1d37 100644 --- a/_problems/hard/KOL1511.md +++ b/_problems/hard/KOL1511.md @@ -59,8 +59,8 @@ Since the value can be large, find it **modulo (109+7).** Output: 8 6 - ### Explanation + **Example case 1.**The summation expands to gcd(1,1) + gcd(5,1) + gcd(1,5) + gcd(5,5) = 8. **Example case 2.**The summation expands to gcd(1,1) + gcd(3,1) + gcd(1,3) + gcd(3,3) = 6. diff --git a/_problems/hard/KOL16C.md b/_problems/hard/KOL16C.md index e9dce36e..5ded764b 100644 --- a/_problems/hard/KOL16C.md +++ b/_problems/hard/KOL16C.md @@ -27,8 +27,8 @@ All submissions for this problem are available.Factorial n or n! is defined as b
 n! = 1*2*3*...*n
-
 
For example **7! = 1\*2\*3\*4\*5\*6\*7 = 5040**. Now, if we prime factorize a factorial we will be able to find the frequency of each prime in it For example **7!= 5040 = 24\*32\*5\*7**. So there are exactly four **2**'s, two **3**'s, one **5** and one **7** in **7!**. For factorials of large numbers prime-factorization is not a good idea and there are many better ways to find out frequency of prime numbers it factorials of large number. Now consider **15** numbers **1!, 2!, 3!, 4!, 5!, 6!, 7!, 8!, 9!, 10!, 11!, 12!, 13!, 14!, 15!** and a set of consecutive prime numbers **{3, 5, 7, 11, 13}** (2nd, 3rd, 4th, 5th and 6th) and an integer **2** (The frequency) and you are asked to find how many of these numbers have one prime from the set of primes exactly two times. The answer will be **9** and these 9 numbers are shown below: + **Value****Primes that are present exactly 2 times** 6!37!38!310!511!512!513!514!5, 715!7 In this problem you are asked to solve a generalized version of this problem. Given a set of factorials of consecutive numbers **F**, a set of consecutive prime numbers **P** and an integer **t**, you job is two find out how many of the numbers in **F** contains any one of the prime numbers from set **P** exactly **t** times. But if more than one prime from **P** is present exactly **t** times in some number, it is ok. ### Input @@ -48,5 +48,4 @@ For each test case produce one line of output. This line contains at integer **M Output 5 3 - \ No newline at end of file diff --git a/_problems/hard/KOL16D.md b/_problems/hard/KOL16D.md index 5f4a64fd..95198b27 100644 --- a/_problems/hard/KOL16D.md +++ b/_problems/hard/KOL16D.md @@ -54,5 +54,4 @@ For each line of input except the last one produce one line of output. This line Output 49/5 - \ No newline at end of file diff --git a/_problems/hard/KOL16G.md b/_problems/hard/KOL16G.md index f13db2bd..e65295fe 100644 --- a/_problems/hard/KOL16G.md +++ b/_problems/hard/KOL16G.md @@ -46,5 +46,4 @@ For each test case produce one line of output. This line contains a floating-poi Output 72.6679 4.7114 -
\ No newline at end of file
diff --git a/_problems/hard/KOL16I.md b/_problems/hard/KOL16I.md
index 8ad805ab..39e90894 100644
--- a/_problems/hard/KOL16I.md
+++ b/_problems/hard/KOL16I.md
@@ -68,6 +68,6 @@ If it's not possible to make such a network of roads at all, just output **-1**
 2 3
 2 4
 -1
-
 
### Explanation + The first case corresponds to the network described in the problem statement. In the second case, it is impossible to find a network for **5** towns such that the attractiveness is equal to **234**, so we output **-1**. diff --git a/_problems/hard/L2.md b/_problems/hard/L2.md index d3b07e79..4c2ae986 100644 --- a/_problems/hard/L2.md +++ b/_problems/hard/L2.md @@ -83,5 +83,4 @@ a?? 1 sp?* 1 *c* 3 uvc 0 - \ No newline at end of file diff --git a/_problems/hard/L5.md b/_problems/hard/L5.md index 79b6afbf..65f3527e 100644 --- a/_problems/hard/L5.md +++ b/_problems/hard/L5.md @@ -40,5 +40,4 @@ Output exactly one value: the radius of largest possible disc satisfying the giv Output: 1.25 -1 - \ No newline at end of file diff --git a/_problems/hard/LAMQUGAM.md b/_problems/hard/LAMQUGAM.md index c51de5c9..69fa5388 100644 --- a/_problems/hard/LAMQUGAM.md +++ b/_problems/hard/LAMQUGAM.md @@ -44,8 +44,8 @@ For each rectangle from the input file, output a single line containing the prob 1/10 1/32 1/1 - ### Explanation + For the first rectangle Chef wins in three cases out of 16. Namely when the starting point is **(1,1), (2,3)** or **(3,2)**. diff --git a/_problems/hard/LCH15JGH.md b/_problems/hard/LCH15JGH.md index 42e7ee55..c29aa169 100644 --- a/_problems/hard/LCH15JGH.md +++ b/_problems/hard/LCH15JGH.md @@ -99,7 +99,7 @@ For each third type query output one integer per line - answer for this query. ### Constraints -- ≤ **N** ≤ **105** +- 0 ≤ **N** ≤ **105** - **1** ≤ **M** ≤ **105** - **1** ≤ **Ai**, **Bi**, **Xi**, **Yi**≤ **105** @@ -127,5 +127,4 @@ For each third type query output one integer per line - answer for this query. 4 3 4 - \ No newline at end of file diff --git a/_problems/hard/LCM.md b/_problems/hard/LCM.md index 1203c5fb..d7685054 100644 --- a/_problems/hard/LCM.md +++ b/_problems/hard/LCM.md @@ -43,5 +43,4 @@ Print the answer to each test case on a separate line. 28 233 178 - \ No newline at end of file diff --git a/_problems/hard/LEBOXES.md b/_problems/hard/LEBOXES.md index b70020f7..d5ca4893 100644 --- a/_problems/hard/LEBOXES.md +++ b/_problems/hard/LEBOXES.md @@ -69,7 +69,7 @@ layout: problem --- All submissions for this problem are available.Little Elephant from Zoo of Lviv has **n** boxes. He don't know what is in the boxes, but he thinks that **i-th** box (0-based numeration) contains **Vi** dollars. The probability that **i-th** box will contain money is **Pi** percents. Instead of money **i-th** box may contain a single diamond (with the probability **100-Pi** percents). -There are **m** things to buy, numbered from to **m-1**, **j-th** thing costs exactly **Cj** dollars plus **Dj** diamonds. Little Elephant is very smart and if he has some number of dollars and diamonds he will always buy the maximal possible number of things he can afford. Note that there is just one copy of all **m** things. +There are **m** things to buy, numbered from 0 to **m-1**, **j-th** thing costs exactly **Cj** dollars plus **Dj** diamonds. Little Elephant is very smart and if he has some number of dollars and diamonds he will always buy the maximal possible number of things he can afford. Note that there is just one copy of all **m** things. Help Little Elephant to find the expected number of things he will buy. @@ -115,5 +115,4 @@ In **T** lines print **T** real numbers - the answers for the corresponding test 1.5000 0.5000 - \ No newline at end of file diff --git a/_problems/hard/LECOINS.md b/_problems/hard/LECOINS.md index 693c67d2..3a734910 100644 --- a/_problems/hard/LECOINS.md +++ b/_problems/hard/LECOINS.md @@ -111,8 +111,8 @@ For each value of **S** in the input, output the maximum number of different col 1 2 2 - ### Explanation + - It is not possible to represent **S = 1** since every coin has value more than 1. - **S = 3** can only be represented using one coin of the second type, hence only one color is used in the representation. - **S = 5** can only be represented as **2 + 3**, which leads to two colors used. diff --git a/_problems/hard/LELUCKYN.md b/_problems/hard/LELUCKYN.md index cc6364f5..9a3878c9 100644 --- a/_problems/hard/LELUCKYN.md +++ b/_problems/hard/LELUCKYN.md @@ -117,8 +117,8 @@ For each test case output a single line containing the answer for the correspond 6 5 1 - ### Explanation + **Case 1.** Here **C4 = C7 = 0** for all pairs **(L; R)**. So **00 = 1 ≤ R − L + 1** for each pair. There are **6** pairs **(L; R)** in all: **(1; 1), (1; 2), (1; 3), (2; 2), (2; 3), (3; 3)**. So the answer is **6**. **Case 2.** Here we have 10 pairs of **(L; R)** in all. Consider them all. diff --git a/_problems/hard/LEPAPER.md b/_problems/hard/LEPAPER.md index b26da2ee..92ceb2d5 100644 --- a/_problems/hard/LEPAPER.md +++ b/_problems/hard/LEPAPER.md @@ -115,8 +115,8 @@ For each test case output a single line containing the number of different sheet 47 3 57 - ### Explanation + **Case 1.** Here the sheet consists of one cell of color **1**. We have **47** available colors. Using one move we can color this cell in any of available colors. So we can get **47** different sheets. **Case 2.** Here the sheet of paper is **{1, 2}** (numbers represent colors of the cells). We have **2** available colors. So there exist **4** different sheets of **2** cells. Using at most one move we can achieve every such sheet except **{2, 1}**. Indeed, diff --git a/_problems/hard/LIGHTING.md b/_problems/hard/LIGHTING.md index 4ad4c7b4..972f8b4c 100644 --- a/_problems/hard/LIGHTING.md +++ b/_problems/hard/LIGHTING.md @@ -54,5 +54,4 @@ Print a blank line after each test case's output. 2 1 0 3 3 0 1 4 4 0 0 1 - \ No newline at end of file diff --git a/_problems/hard/LKYEDGE.md b/_problems/hard/LKYEDGE.md index 375fece6..d5b14706 100644 --- a/_problems/hard/LKYEDGE.md +++ b/_problems/hard/LKYEDGE.md @@ -127,5 +127,4 @@ For each test case, output a single line containing **M** integers, i-th of whic Output: 1 0 1 2 3 3 2 2 - \ No newline at end of file diff --git a/_problems/hard/LMATRIX3.md b/_problems/hard/LMATRIX3.md index c25c4f9c..4c8aaedd 100644 --- a/_problems/hard/LMATRIX3.md +++ b/_problems/hard/LMATRIX3.md @@ -92,7 +92,7 @@ city. She has one number **P** and one array with **N** elements each. Let **Ai** be the **i**th element of the array. -She likes , that's why she is going to get rid of all non zero numbers in the array. +She likes 0, that's why she is going to get rid of all non zero numbers in the array. In each turn she may choose 3 integers: - **1 ≤ s ≤ t ≤ N** @@ -141,7 +141,7 @@ denoting the minimal number of the moves for erasing all non zero numbers from t - **1** ≤ **T** ≤ **100** - **1** ≤ **M** ≤ **100** - **1** ≤ **P** ≤ **10** -- ≤ **Fi**, **Ci**, **Di** < **P** +- 0 ≤ **Fi**, **Ci**, **Di** < **P** - **1** ≤ **Li** ≤ **1015** ### Example @@ -167,8 +167,8 @@ denoting the minimal number of the moves for erasing all non zero numbers from t 2 5 - ### Explanation + **Example case 1:** All numbers are zero. **Example case 2:** Initially, A = {3, 5, 5, 3}. In the first turn, we choose s=2, t=3, and k=8, after which A = {3, 3, 3, 3}. Then all numbers will become zero after the second turn. diff --git a/_problems/hard/LOGO.md b/_problems/hard/LOGO.md index ab209ce9..b94d0ed2 100644 --- a/_problems/hard/LOGO.md +++ b/_problems/hard/LOGO.md @@ -121,14 +121,15 @@ Output 240 lines, each containing 320 characters to describe the canvas. The bac Output: Download the output - ### Notes + If <**X, Y, Z**> value of 2 polygons are exactly same, then the greater color value of two will be visible. Example, for the following input: />
2
 2 1 10 10 0 10 110 0 110 110 0 110 10 0
 2 2 50 50 0 50 150 0 150 150 0 150 50 0
-
The (pictorial) output will be: + +The (pictorial) output will be: ![](//www.codechef.com/download/hR8s1dO.png) assuming color '0' is black, color '1' is red, color '2' is blue./>/>/> diff --git a/_problems/hard/LONGART.md b/_problems/hard/LONGART.md index 45ac464e..128cc6be 100644 --- a/_problems/hard/LONGART.md +++ b/_problems/hard/LONGART.md @@ -87,7 +87,7 @@ For each test case, output on a separate line an integer **K** denoting the numb - **1** ≤ **T** ≤ **2** - **1** ≤ **N, M** ≤ **94** -- ≤ **C(W)** ≤ **10000000** (**107**) +- 0 ≤ **C(W)** ≤ **10000000** (**107**) - All characters in **A** are different and **A** contains exactly **N** characters - All characters in **B** are different and **B** contains exactly **M** characters - Each character in **A** and **B** has ASCII code from 33 to 126, inclusive. @@ -119,8 +119,8 @@ He 2 2 Hn ie 0 0 - ### Explanation + **Example case 1.** The complete article is He is in He diff --git a/_problems/hard/LPARTY.md b/_problems/hard/LPARTY.md index 89391690..a54b8b39 100644 --- a/_problems/hard/LPARTY.md +++ b/_problems/hard/LPARTY.md @@ -99,7 +99,7 @@ For each test case, output a single line containing one integer - the minimal po ### Constraints - **1** ≤ **T** ≤ **120** -- ≤ **M** ≤ **1000** +- 0 ≤ **M** ≤ **1000** Subtask 1 (23 points): @@ -123,8 +123,8 @@ AbC Output: 5 6 - ### Explanation + The first test case is explained in the problem statement. In the second test case we can only take two given subsets and can't find anything less. diff --git a/_problems/hard/LUCKYDAY.md b/_problems/hard/LUCKYDAY.md index 65d02460..b1015cc4 100644 --- a/_problems/hard/LUCKYDAY.md +++ b/_problems/hard/LUCKYDAY.md @@ -52,6 +52,7 @@ For each interval, print the number of lucky days in the interval. 5 58 58 5858 ### Sample Output +
0
 0
 1
@@ -62,6 +63,7 @@ For each interval, print the number of lucky days in the interval.
 4
 362
 
### Output details + In the first case: **S**\[1\] = **A** = 1 **S**\[2\] = **B** = 1 diff --git a/_problems/hard/LYRC.md b/_problems/hard/LYRC.md index 5c30b143..5311cf94 100644 --- a/_problems/hard/LYRC.md +++ b/_problems/hard/LYRC.md @@ -130,5 +130,4 @@ Whoa-W-W-Whoa-Shawtyyyyy 2 3 - \ No newline at end of file diff --git a/_problems/hard/M1.md b/_problems/hard/M1.md index 9cf69fd1..0333e836 100644 --- a/_problems/hard/M1.md +++ b/_problems/hard/M1.md @@ -51,5 +51,4 @@ For each test case, print two numbers on a line. The first number is the maximum Output: 3 1 4 2 - \ No newline at end of file diff --git a/_problems/hard/M2.md b/_problems/hard/M2.md index e6b53ac5..31d28e78 100644 --- a/_problems/hard/M2.md +++ b/_problems/hard/M2.md @@ -60,5 +60,4 @@ Remember to print a new line after each test case. 4 1 4 - \ No newline at end of file diff --git a/_problems/hard/M4.md b/_problems/hard/M4.md index 48f2e65b..81b39091 100644 --- a/_problems/hard/M4.md +++ b/_problems/hard/M4.md @@ -50,5 +50,4 @@ For each of the values of _k_ given at input, print a line containing the toll p 10 11 12 - \ No newline at end of file diff --git a/_problems/hard/M5.md b/_problems/hard/M5.md index 35f7b1e5..9ffaaa70 100644 --- a/_problems/hard/M5.md +++ b/_problems/hard/M5.md @@ -35,5 +35,4 @@ For each testcase, output the total area covered by the intersection of all disc Output: 1.228370 - \ No newline at end of file diff --git a/_problems/hard/MAGIC.md b/_problems/hard/MAGIC.md index ec5d7eb7..e3d2800b 100644 --- a/_problems/hard/MAGIC.md +++ b/_problems/hard/MAGIC.md @@ -112,5 +112,4 @@ Second First Explanation: - -In the first two test cases, the game ends after the second turn (which is the first turn of the second magician) as the passage created by the first magician hands a win to the second magician. In the third test case, the game ends after the fourth turn (the second magician may need to use **1** telepoint here). In the fourth test case, the game ends after the third turn (the first magician has to use **1** telepoint here). \ No newline at end of file +In the first two test cases, the game ends after the second turn (which is the first turn of the second magician) as the passage created by the first magician hands a win to the second magician. In the third test case, the game ends after the fourth turn (the second magician may need to use **1** telepoint here). In the fourth test case, the game ends after the third turn (the first magician has to use **1** telepoint here). diff --git a/_problems/hard/MARCHA3.md b/_problems/hard/MARCHA3.md index 0006ffbe..31545a18 100644 --- a/_problems/hard/MARCHA3.md +++ b/_problems/hard/MARCHA3.md @@ -64,5 +64,4 @@ For each test case output a line containing a single integer, equal to the minim 0 1 2 - -**Explanation:** for the respective test cases, the number picked by Johnny could have been e.g. _n_=100, _n_=5, and _n_=1. \ No newline at end of file +**Explanation:** for the respective test cases, the number picked by Johnny could have been e.g. _n_=100, _n_=5, and _n_=1. diff --git a/_problems/hard/MARCHA6.md b/_problems/hard/MARCHA6.md index 513ca4d9..b8f187ab 100644 --- a/_problems/hard/MARCHA6.md +++ b/_problems/hard/MARCHA6.md @@ -43,8 +43,8 @@ For each test case, print a line containing exactly _p_ space-separated numbers, Output: 1 2 4 4 8 8 8 -1 -1 - **Explanation:** + The first 16 elements of b are: _0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0_ diff --git a/_problems/hard/MARTARTS.md b/_problems/hard/MARTARTS.md index 36bf4009..12be501a 100644 --- a/_problems/hard/MARTARTS.md +++ b/_problems/hard/MARTARTS.md @@ -103,6 +103,6 @@ Output the number of points H scored by home team and the number of points G sco Output: 18 17 - ### Explanation + Chef will pair contestants in the following way: (1,1), (2,3), (3,2). Coach of the guest team will cancel the last fight (3,2) which would earn home team 50 points. This way the final score is 18 points for home team and 17 points for guest team. diff --git a/_problems/hard/MATCH.md b/_problems/hard/MATCH.md index 7966a092..4f166b11 100644 --- a/_problems/hard/MATCH.md +++ b/_problems/hard/MATCH.md @@ -94,7 +94,7 @@ In the only line of the output file print the expected size of the maximum match **1** ≤ **M** ≤ **100** - ≤ **P\[i\]\[j\]** ≤ **1** +0 ≤ **P\[i\]\[j\]** ≤ **1** **P\[i\]\[j\]** will have exactly **5** digits after the decimal point @@ -118,8 +118,8 @@ In the only line of the output file print the expected size of the maximum match Output 2: 1.46 - ### Explanation + In the second example we have four different graphs with non-zero value of **P(G)**. Their adjacent matrices with marked maximum matching as well as the values of **MM(G)** and **P(G)** are listed in the table below. **Adjacent matrix****MM(G)****P(G)**0101**1**(1 – 0.4) ∙ (1 – 0.1) = 0.6 ∙ 0.9 = **0.54**1101**2**0.4 ∙ (1 – 0.1) = 0.4 ∙ 0.9 = **0.36**0111**2**(1 – 0.4) ∙ 0.1 = 0.6 ∙ 0.1 = **0.06**1111**2**0.4 ∙ 0.1 = **0.04**So the answer is **0.54 ∙ 1 + 0.36 ∙ 2 + 0.06 ∙ 2 + 0.04 ∙ 2 = 1.46**. diff --git a/_problems/hard/MATRIXUM.md b/_problems/hard/MATRIXUM.md index 7524aa7f..1bb3119c 100644 --- a/_problems/hard/MATRIXUM.md +++ b/_problems/hard/MATRIXUM.md @@ -125,5 +125,4 @@ Each term should have **N** + 1 lines. The first line of each term should contai 0000 1000 0000 - \ No newline at end of file diff --git a/_problems/hard/MAXCIR.md b/_problems/hard/MAXCIR.md index df873889..edb1f503 100644 --- a/_problems/hard/MAXCIR.md +++ b/_problems/hard/MAXCIR.md @@ -95,7 +95,7 @@ Output should contain a single real number rounded to exactly **13** digits afte **1** ≤ **N** ≤ **500** - ≤ **K** ≤ **N** +0 ≤ **K** ≤ **N** |**Ax**|, |**Ay**|, |**Bx**|, |**By**|, |**Cx**|, |**Cy**| ≤ **109** @@ -128,6 +128,7 @@ Output should contain a single real number rounded to exactly **13** digits afte Output 2: 7.8416192529638 ### Explanation: + **Case 1.** Here the optimal way is to use the 1st and the 3rd spell cards. The new coordinates of the point **A** will be **(1, 2)**. So the circumference of the new triangle **ABC** is: **|(1, 2) − (1, 0)| + |(1, 0) − (-1, 0)| + |(-1, 0) − (1, 2)| = 4 + 2 \* sqrt(2)**. **Case 2.** Here the optimal way is to use all of the spell cards. The new coordinates of the point **A** will be **(2, 2)**. So the circumference of the new triangle **ABC** is: **|(2, 2) − (1, 0)| + |(1, 0) − (-1, 0)| + |(-1, 0) − (2, 2)| = 2 + sqrt(5) + sqrt(13)**. diff --git a/_problems/hard/MEETUP.md b/_problems/hard/MEETUP.md index 540b99f6..3c2c171c 100644 --- a/_problems/hard/MEETUP.md +++ b/_problems/hard/MEETUP.md @@ -111,6 +111,6 @@ Once you are finished asking questions, and are ready to answer the main questio ### Example
-
 
your program the system4 3 1 1 ab bc cd de ab bc bc cd cd de w y x z x w y x y zA cdxA bcyB xcdA abzB wdeC No### Explanation + Here, we have 4 cities and 3 roads. Alice's map has cities with labels "ab", "bc", "cd", "de". Bob's map has cities with labels "w", "y", "x", "z". Alice visits cities {"ab"}. Bob visits cities {"w"}. Here, we show an example of the interaction. The translation function in this case is "ab" = "z", "bc" = "y", "cd" = "x", "de" = "w". In this case, we can see that Alice and Bob don't visit any cities in common, so the final answer is No. diff --git a/_problems/hard/MGCH3D.md b/_problems/hard/MGCH3D.md index f514f053..d7f04741 100644 --- a/_problems/hard/MGCH3D.md +++ b/_problems/hard/MGCH3D.md @@ -131,7 +131,7 @@ For each query, output a single line containing the sum accurate up to **10-6**. 6.783038317971530 5.816449269601737 - ### Subtasks + - **Subtask 1:** **Q**\***N2** ≤ 77777777. **Points - 15** - **Subtask 2:** Original constraints. **Points - 85** diff --git a/_problems/hard/MGCHGEOM.md b/_problems/hard/MGCHGEOM.md index cef16a0c..6f84e7b2 100644 --- a/_problems/hard/MGCHGEOM.md +++ b/_problems/hard/MGCHGEOM.md @@ -122,5 +122,4 @@ After each query, print the area of the convex hull of points which are in multi 8.0 16.0 8.0 - \ No newline at end of file diff --git a/_problems/hard/MGCHGYM.md b/_problems/hard/MGCHGYM.md index 12b68695..3d6233ba 100644 --- a/_problems/hard/MGCHGYM.md +++ b/_problems/hard/MGCHGYM.md @@ -133,8 +133,8 @@ Yes Yes No Yes - #### Second +
 Input:
 3 4
@@ -148,8 +148,8 @@ Yes
 Yes
 No
 Yes
-
 
### Explanation: + ##### First test explanation (step by step)
@@ -164,5 +164,4 @@ Yes
 2 1 4  (Reverse: [3, 5, 1, 1, 2])
 3 2 4 3 ([5, 1, 1] can't make 3 => No)
 3 1 5 7 ([3, 5, 1, 1, 2] 2+1+1+3=7 => Yes)
-
 
\ No newline at end of file diff --git a/_problems/hard/MGCHPERM.md b/_problems/hard/MGCHPERM.md index 327da8c3..31885f64 100644 --- a/_problems/hard/MGCHPERM.md +++ b/_problems/hard/MGCHPERM.md @@ -118,8 +118,8 @@ For each test case, output a single line containing a single integer — the sol 367816 989165211 930411765 - ### Explanation: + **Example case 1.** There is only one subset: {1, 2, 3}. Since, **F**(1, 2, 3) = 0, the answer is 0. **Example case 2.** There are C(6, 4) = 15 possible subsets. **F**(1, 2, 3, 6) = 0, and the value of **F** on all other subsets equals 1. Therefore, the answer is 15 - 1 = 14. diff --git a/_problems/hard/MINDEG.md b/_problems/hard/MINDEG.md index 0bfb02aa..8ff2731c 100644 --- a/_problems/hard/MINDEG.md +++ b/_problems/hard/MINDEG.md @@ -98,8 +98,8 @@ For the constraints given below, it can be proved that the answer (the expected Output2: 199648875 - ### Explanation + **Example #1.** The graph contains 3 vertices and Chef will add 3 edges. No matter what the order of adding edges is, the cost of adding the first edge is 0 because degrees of vertices are 0 initially. Similarly, the cost of adding the second edge is 0 because at least one of two vertices connected with a new edge has degree 0. Finally, the third edge connects vertices that both have degree 1 after adding first two edges, so the cost is min(1, 1) = 1. The total cost is always 1, so its expected value is 1 as well. **Example #2.** There are 4 vertices and Chef will add 6 edges. The answer is 22/5, so you should print 22 \* 5-1 = 22 \* 598946612 = 13176825464 = 199648875 (modulo 998244353). Let's analyze one possible scenario: diff --git a/_problems/hard/MINESREV.md b/_problems/hard/MINESREV.md index 8a2c46cc..0d7ac370 100644 --- a/_problems/hard/MINESREV.md +++ b/_problems/hard/MINESREV.md @@ -43,5 +43,4 @@ Output a single line containing the minumum number of clicks necessary to close Output: 9 2 - \ No newline at end of file diff --git a/_problems/hard/MINPOLY.md b/_problems/hard/MINPOLY.md index 9588c9d9..5a2cd35e 100644 --- a/_problems/hard/MINPOLY.md +++ b/_problems/hard/MINPOLY.md @@ -105,7 +105,6 @@ Print **n - 2** space separated integers corresponding to the answer for **k** = 0 1 3 Output: 6 -
Input:
 4
 0 0 1
@@ -114,8 +113,8 @@ Print **n - 2** space separated integers corresponding to the answer for **k** =
 1 1 2
 Output:
 5 8
-
 
### Explanation + **Example case 1.** The triangle given in the input has beauty equal to 6. **Example case 2.** One of the triangles has a beauty of 5 whereas there is only one rectangle which has beauty equal to 8. diff --git a/_problems/hard/MINWDSUM.md b/_problems/hard/MINWDSUM.md index bc9a2699..6a72da09 100644 --- a/_problems/hard/MINWDSUM.md +++ b/_problems/hard/MINWDSUM.md @@ -26,11 +26,11 @@ time: current: 1493556779 layout: problem --- -All submissions for this problem are available.Let **M** be a fixed positive integer. Your task is for each **R** from to **M − 1**, inclusive, find the minimal non-negative integer having residue **R** modulo **M** and having the minimal weighted digit sum. +All submissions for this problem are available.Let **M** be a fixed positive integer. Your task is for each **R** from 0 to **M − 1**, inclusive, find the minimal non-negative integer having residue **R** modulo **M** and having the minimal weighted digit sum. Namely, let **W\[0\], W\[1\], ..., W\[9\]** be the sequence of weights assigned to the decimal digits. For positive integer **N** having decimal representation **D1D2...DK** the weighted digit sum of **N** is the number **WS(N) = W\[D1\] + W\[D2\] + ... + W\[DK\]**. We set **WS(0) = 0** by definition. -For each **R** from to **M − 1**, inclusive, denote **Smin(R) = min{WS(R + K \* M) : K = 0, 1, 2, 3, ...}**. Therefore, **Smin(R)** is the minimal weighted digit sum over all non-negative integers having residue **R** modulo **M**. Next, denote by **Nmin(R)** the minimum non-negative integer having residue **R** modulo **M** and having weighted digit sum equal to **Smin(R)**. So, formally, **Nmin(R) = min{N ≥ 0 : N mod M = R, WS(N) = Smin(R)}**. Note, that **Smin(0) = Nmin(0) = 0** for any **M** and any sequence of weights. +For each **R** from 0 to **M − 1**, inclusive, denote **Smin(R) = min{WS(R + K \* M) : K = 0, 1, 2, 3, ...}**. Therefore, **Smin(R)** is the minimal weighted digit sum over all non-negative integers having residue **R** modulo **M**. Next, denote by **Nmin(R)** the minimum non-negative integer having residue **R** modulo **M** and having weighted digit sum equal to **Smin(R)**. So, formally, **Nmin(R) = min{N ≥ 0 : N mod M = R, WS(N) = Smin(R)}**. Note, that **Smin(0) = Nmin(0) = 0** for any **M** and any sequence of weights. As mentioned above, your task is for the given **M** and **W\[0\], W\[1\], ..., W\[9\]** find the sequence **Nmin(0), Nmin(1), ..., Nmin(M − 1)**. Since the output could be quite large output the following sum instead: **F(Nmin(0)) + F(Nmin(1)) + ... + F(Nmin(M − 1))**, @@ -49,7 +49,7 @@ For each test case, output a single line containing the required sum. - **1** ≤ **T** ≤ **3141** - **1** ≤ **M** ≤ **3141592** -- ≤ **W\[0\], W\[1\], ..., W\[9\]** ≤ **314** +- 0 ≤ **W\[0\], W\[1\], ..., W\[9\]** ≤ **314** - The sum of **M** in one test file does not exceed **3141592** ### Example @@ -77,9 +77,9 @@ For each test case, output a single line containing the required sum. 9435 10 6500672892792 - ### Explanation -**Example case 1.** Here **M = 1**. So we need to find **F(Nmin(0))**. Since **Smin(0) = Nmin(0) = 0** and **F(0) = 0**, the answer is . + +**Example case 1.** Here **M = 1**. So we need to find **F(Nmin(0))**. Since **Smin(0) = Nmin(0) = 0** and **F(0) = 0**, the answer is 0. **Example case 2.** Here **M = 2** and **W\[0\] = 0**, **W\[1\] = 2**, **W\[9\] = 1**, while all remaining **W\[D\] = 9**. As mentioned above **Smin(0) = Nmin(0) = 0**. For **R = 1** we have **Smin(1) = 1** and **Nmin(1) = 9** since **W\[9\] = 1**. Therefore, the answer is **F(0) + F(9) = 0 + 9 = 9**. @@ -87,6 +87,6 @@ For each test case, output a single line containing the required sum. **Example case 4.** Here values of **Smin(R)** are **{0, 2, 2, 1}** and values of **Nmin(R)** are **{0, 33, 6, 3}**. Since **F(33) = (3 \* 3141 + 3) mod 232 = 9426**, the answer is **F(0) + F(33) + F(6) + F(3) = 0 + 9426 + 6 + 3 = 9435.** -**Example case 5.** Here **Smin(R) = Nmin(R) = R** for all **R** from to **M − 1**, inclusive. +**Example case 5.** Here **Smin(R) = Nmin(R) = R** for all **R** from 0 to **M − 1**, inclusive. **Example case 6.** Make sure that you calculates **F(N)** properly here. Also note that **Nmin(666) = 10106 − 1** and **Nmin(3140) = 10116 − 2** for **M = 3141** and given sequence of weights. It means that brute force solution is not applicable even for such relatively small value of **M**. diff --git a/_problems/hard/MISINT2.md b/_problems/hard/MISINT2.md index e352d8de..95b43379 100644 --- a/_problems/hard/MISINT2.md +++ b/_problems/hard/MISINT2.md @@ -38,11 +38,10 @@ R - L <= 50000** 6 7 45 50 - ### Sample output +
1430
 18252
 871229844
 
-
 
\ No newline at end of file diff --git a/_problems/hard/MIXFLVOR.md b/_problems/hard/MIXFLVOR.md index cd5d880c..03f8d2fc 100644 --- a/_problems/hard/MIXFLVOR.md +++ b/_problems/hard/MIXFLVOR.md @@ -120,8 +120,8 @@ Output the answer of each test-case in new line, the maximum flavor that the Che Output: 13 8 - ### Explanation + **Test case 1:** The binary representations of the 5 flavors, in order, are: (_0100, 0001, 1001, 0110, 1100_), and the corresponding prices are (2,7,5,15,3). If Chef buys only the 5th ice-cream with cost 3 and flavor 12. But if Chef buys the first 3 ice-creams, his total cost is 2+7+5 = 14, which is within his budget of 15, and hence valid. Now, from these three bought ice-creams, he can choose to mix just the first and third, and get a flavor of _0100^1001_ = _1101_, which is 13. You can verify that this is the best that he can do. diff --git a/_problems/hard/MONOPLOY.md b/_problems/hard/MONOPLOY.md index 7af06735..36a68608 100644 --- a/_problems/hard/MONOPLOY.md +++ b/_problems/hard/MONOPLOY.md @@ -55,7 +55,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/NOV13/mandarin/MONOPLOY.pdf) and [Russian](http://www.codechef.com/download/translated/NOV13/russian/MONOPLOY.PDF). -Treeland is a kingdom consisting of **N** cities labelled , **1**, **2**, ... **N-1**. There are **N-1** roads connecting these cities such that each pair of cities is connected by a unique path(forming a tree structure). Needless to say, city is the **capital** of Treeland. Initially, each city is controlled by a different gangster. The citizens are allowed to move from any city to any of its adjacent city. However, if the two cities are controlled by different gangsters, they need to pay unit cost in order to move. The distance between any pair u, v of cities denoted by **dist(u,v)** is defined as the minimum cost a person has to pay to go from **u** to **v**(or v to u). +Treeland is a kingdom consisting of **N** cities labelled 0, **1**, **2**, ... **N-1**. There are **N-1** roads connecting these cities such that each pair of cities is connected by a unique path(forming a tree structure). Needless to say, city 0 is the **capital** of Treeland. Initially, each city is controlled by a different gangster. The citizens are allowed to move from any city to any of its adjacent city. However, if the two cities are controlled by different gangsters, they need to pay unit cost in order to move. The distance between any pair u, v of cities denoted by **dist(u,v)** is defined as the minimum cost a person has to pay to go from **u** to **v**(or v to u). Every year, a new gangster emerges in the capital. As always, the gangster will wish to expand his territory. To do so, he will choose a city **u**, and march with his gangster army from the **capital** to **u**(along the tree path). All the cities they encounter(including **capital** and **u**) will be forciby occupied by this gangster. Because of this, distance between many cities can potentially change, which makes the people mad. Therefore, they will come to you for help. @@ -119,8 +119,8 @@ q 2 0.5000000000 1.8571428571 - ### Explanation + Initially, distance of each city from capital is equal to the number of edges on the shortest path, because each city is controlled by a different gangster. Therefore, value of f(0) is (0+1+1+2+2+2+3+2+2+3+2+3+3)/13 = 2. After performing 'O 4', cost of the edges (0,2) and (2,4) become 0. The cost of all other edges remains same. Therefore, f(6) becomes 1. diff --git a/_problems/hard/MSTONES.md b/_problems/hard/MSTONES.md index aaf1d449..ea01dcea 100644 --- a/_problems/hard/MSTONES.md +++ b/_problems/hard/MSTONES.md @@ -47,5 +47,4 @@ For each test case, output the maximum number of collinear milestones. Output: 3 2 - \ No newline at end of file diff --git a/_problems/hard/MUFFINS.md b/_problems/hard/MUFFINS.md index af21d177..5e9da0ac 100644 --- a/_problems/hard/MUFFINS.md +++ b/_problems/hard/MUFFINS.md @@ -42,5 +42,4 @@ The output for each test case consists of a single line containing "Possible" if Output: Possible Impossible - \ No newline at end of file diff --git a/_problems/hard/MUFFINS2.md b/_problems/hard/MUFFINS2.md index 6fbc3999..7088dc99 100644 --- a/_problems/hard/MUFFINS2.md +++ b/_problems/hard/MUFFINS2.md @@ -34,14 +34,14 @@ For each test case, output on a single line the minimum total energy consumption 0 0 0 0 2 5 2 2 0 0 0 0 - ### Sample output +
3.66667
 0.62500
 0.40000
 2.00000
-
 
### Constraints + T<50 1≤N≤30000 0≤S≤30000 diff --git a/_problems/hard/MULDIG.md b/_problems/hard/MULDIG.md index 08d9fe39..a10c761f 100644 --- a/_problems/hard/MULDIG.md +++ b/_problems/hard/MULDIG.md @@ -121,8 +121,8 @@ There are 5 subtasks, each worth 20 points. 1. **B** = 3 and the checker checks 2 1 6 7 0 0 0 - ### Explanation + The provided output has valid formatting but isn't correct. Let's analyze the printed moves to multiply X = 7 and Y = 5. These X and Y in base 3 are 21 and 12 respectively, so the initial numbers in cells are: 0, 1, 2, 2, 1, 1, 2, 0, 0, ... The first operation is t\[7\] = F(t\[1\], t\[6\]) = F(1, 2) = 2, so now we have cells: 0, 1, 2, 2, 1, 1, 2, **2**, 0, ... diff --git a/_problems/hard/N2.md b/_problems/hard/N2.md index 11593181..023a0990 100644 --- a/_problems/hard/N2.md +++ b/_problems/hard/N2.md @@ -28,8 +28,8 @@ In addition, if your hero's current square is a gate, your hero could choose to
 .@.
 @#@
-
 
For example, in the above map, suppose your hero's starting position is at (1,1) and P = 0.8. If the hero moves down in the first turn, he may succeed and end up in the gate at (2,1) with probability 0.8. With probability 0.2 / 3, he may go right and end up in the gate at (1,2). With probability 2\*0.2 / 3, he just remains at (1,1) since the top and left direction would lead him out of the maze. + If the hero choose to enter the gate at (2,2), he may end up at (1,2) or (2,3) with equal probability 1/2. Find the optimum strategy to control your hero such that _the expected number of turns to collect the first treasure_ is minimized. @@ -83,5 +83,4 @@ S...*.#@*......*@. 3.00 3.50 6.41 - \ No newline at end of file diff --git a/_problems/hard/NPIN.md b/_problems/hard/NPIN.md index 2c46c591..b76ec7b5 100644 --- a/_problems/hard/NPIN.md +++ b/_problems/hard/NPIN.md @@ -111,8 +111,8 @@ For each test case - output on a single line the number of needles required and Output 14 1 - ### Note + 1\) The symmetry constraint - "If we divide entire wooden board into 16 square shaped (virtual) regions .... " is enforced only if number of lines (**M**) is ≥ 1000. 2\) The polygon is convex. diff --git a/_problems/hard/NPLANAR.md b/_problems/hard/NPLANAR.md index 45f66ece..1ef41105 100644 --- a/_problems/hard/NPLANAR.md +++ b/_problems/hard/NPLANAR.md @@ -147,8 +147,8 @@ For each test case, output one line with a single number - the minimum number of 0 3 2 - ### Explanation + **Example case 1.** The graph looks like two cycles of lengths 4 and 5 with a common edge. Since there are no triangles, there's no need to remove any vertex. **Example case 2.** It's sufficient to remove vertices 7, 1 and 2. diff --git a/_problems/hard/OAK.md b/_problems/hard/OAK.md index 6635db23..62c1f504 100644 --- a/_problems/hard/OAK.md +++ b/_problems/hard/OAK.md @@ -88,7 +88,7 @@ The i-th of the following **m** lines describes the i-th event Chef has observed - The first integer is **state** ― the state of the oak we are applying the new event to. **state = 0** means the state at the very beginning with no branches fallen and no acorns grown. **state > 0** means the state right after the event number **state** - The second integer is **q** ― the type of the event -- If **q = 1**, two integers **u** and **x** follow, meaning that **x** acorns have grown on the branch **u**. After this event some branch could have fallen, and if this is the case, output the number of this branch. Otherwise output +- If **q = 1**, two integers **u** and **x** follow, meaning that **x** acorns have grown on the branch **u**. After this event some branch could have fallen, and if this is the case, output the number of this branch. Otherwise output 0 - If **q = 2**, an integer **u** follows meaning that a bird has sat down on the branch **u** and all the acorns from this branch and from all the branches below it have fallen. For this type of event Chef asks you to print the total number of acorns that have fallen ### Output @@ -99,10 +99,10 @@ For each event print the value Chef asked you about on a separate line. - **1** ≤ **T** ≤ **5** - **1** ≤ **n, m** ≤ **105** -- ≤ **pv** v -- ≤ **wv, x** ≤ **107** +- 0 ≤ **pv** v +- 0 ≤ **wv, x** ≤ **107** - **1** ≤ **u** ≤ **n** -- ≤ **state** m +- 0 ≤ **state** m ### Subtasks @@ -135,15 +135,15 @@ For each event print the value Chef asked you about on a separate line. 1 0 1 - ### Explanation + **Example event 1.** Branch **5** can hold at most **4** acorns, so after **5** have grown there, it immediately falls down. Notice that the branch **3** doesn't fall down (even though it also can't hold **5** acorns), because the branch **5** no longer grows out of it. We output **5** as this branch has fallen down and create a state of the oak with index **1** having branch **5** fallen and having no acorns in the other four branches. -**Example event 2.** We take the state as the base, so we once again have branch **5** on the tree. One acorn has grown at the branch **4**. No branch has fallen as every one can hold at least one acorn, thus we print . Resulting state after this event (with index **2**) has all five branches and one acorn on branch **4**. +**Example event 2.** We take the state 0 as the base, so we once again have branch **5** on the tree. One acorn has grown at the branch **4**. No branch has fallen as every one can hold at least one acorn, thus we print 0. Resulting state after this event (with index **2**) has all five branches and one acorn on branch **4**. **Example event 3.** We take the state **2** as the base, which is the resulting state after previous event. After two acorns have grown on the branch **5**, we have one acorn on branch **4** and two acorns on branch **5**. Both these branches are below branch **3** which can hold at most two acorns, so as a result branch **3** falls down. The resulting state (with index **3**) has only two branches left ― **1** and **2** with no acorns on them. -**Example event 4.** We once again take the state **2** as the base, but this time remove all the acorns from branch **3** and from all the branches below it (**4** and **5**). Branch **5** had no acorns and branch **4** had one acorn on it (that has grown during event **2**), so we print **1** as the total number of acorns fallen. The resulting state (with index **4**) has the full tree (no branches have fallen) with no acorns. So, the state **4** is basically equivalent to the state . +**Example event 4.** We once again take the state **2** as the base, but this time remove all the acorns from branch **3** and from all the branches below it (**4** and **5**). Branch **5** had no acorns and branch **4** had one acorn on it (that has grown during event **2**), so we print **1** as the total number of acorns fallen. The resulting state (with index **4**) has the full tree (no branches have fallen) with no acorns. So, the state **4** is basically equivalent to the state 0. **Example event 5.** This event is similar to event **3**. The only difference is that the base state (**4** for this event) doesn't contain any acorns. So branch **3** has only two acorns below it after this event and doesn't fall down. diff --git a/_problems/hard/ORDERS.md b/_problems/hard/ORDERS.md index ae79409c..69814459 100644 --- a/_problems/hard/ORDERS.md +++ b/_problems/hard/ORDERS.md @@ -40,5 +40,4 @@ For each test case, output a single line consisting of n space separated integer Output: 2 1 3 3 2 1 5 4 - -**Warning: large Input/Output data, be careful with certain languages** \ No newline at end of file +**Warning: large Input/Output data, be careful with certain languages** diff --git a/_problems/hard/OVENTIME.md b/_problems/hard/OVENTIME.md index 44b8368c..4f6193b4 100644 --- a/_problems/hard/OVENTIME.md +++ b/_problems/hard/OVENTIME.md @@ -48,8 +48,8 @@ The output for each test case consists of a single integer indicating the maximu Output: 7 - ### Explanation of Sample Output + In the given test case, a profit of 7 can be obtained by satisfying the first and last request in the input. Time 0 has 2 free racks and both are used by these requests. Times 1 and 2 have only 1 free rack but these times are not required by the first request so there are enough racks to accommodate the requests at these times. Now, the last time 3 has a free rack that is not being used. The second last request requires a rack at this time, but it cannot be added because it also requires a rack at time 2, which is already being used by the last request. diff --git a/_problems/hard/OVERPNT.md b/_problems/hard/OVERPNT.md index c4748a06..901c7e1b 100644 --- a/_problems/hard/OVERPNT.md +++ b/_problems/hard/OVERPNT.md @@ -105,7 +105,8 @@ If you are more familiar with Python, you can assume that he wrote:

To show Limak how important it is to watch for overflows, you must find any set of N distinct points that:

-- Any three distinct points in any order would be treated as collinear by Limak's function.- None three points are collinear (what implies that points are distinct). +- Any three distinct points in any order would be treated as collinear by Limak's function. +- None three points are collinear (what implies that points are distinct). - Coordinates are non-negative integers not exceeding 106. @@ -149,6 +150,7 @@ Remember that one of requirements is 0 ≤ xi, yi ≤ 106. 518360 23016 441824 483616 ### Explanation + **Test case 1.** The provided function areCollinear() should return True for the found three points given in any order (there are 3! = 6 possible orders of 3 points). Let's analyze the evaluation of areCollinear(42, 483426, 106732, 139820, 210379, 490375): Without any overflow errors, the calculations would be: diff --git a/_problems/hard/PALPROB.md b/_problems/hard/PALPROB.md index 96c45e10..afdb4d4f 100644 --- a/_problems/hard/PALPROB.md +++ b/_problems/hard/PALPROB.md @@ -81,7 +81,7 @@ Let us define the palindromeness of a string in the following way: Let us consider some examples for better understanding: -- The palindromeness of the string **zxqfd** is , since the string is not a palindrome. +- The palindromeness of the string **zxqfd** is 0, since the string is not a palindrome. - The palindromeness of the string **a** is **1**, by definition. - The palindromeness of the string **aa** is **2**, beucase for "aa" we get **1** + palindromeness of "a", that is one, so we get **2**. - The palindromeness of the string **abacaba** is **3**. @@ -125,8 +125,8 @@ aba Output: 5 5 - ### Explanation + **Example case 1:** There is no palindrome that occurs as the substring of **zxqfd** and has the length more than **1**. The individual characters are palindromes of the palindromeness of **1**. **Example case 2:** The palindromeness of **aba** is **2** and the sum of the palindromenesses of single characters is **3**. diff --git a/_problems/hard/PALSTR.md b/_problems/hard/PALSTR.md index 2563139f..53825b8d 100644 --- a/_problems/hard/PALSTR.md +++ b/_problems/hard/PALSTR.md @@ -114,15 +114,15 @@ ab aa aa aa - **Output** +
 0
 6
 8
 27
-
 
### Explanation + - **Test 1:** No such palindromic string is possible. - **Test 2:** "aaa", "bbb", "aba", "bab", "abba", "baab" are all possible palindromic strings. - **Test 3:** "aaa", "bbb", "aba", "bab", "abba", "baab", "babab", "ababa" are all possible palindromic strings. diff --git a/_problems/hard/PARADE.md b/_problems/hard/PARADE.md index 53641ef5..6289615a 100644 --- a/_problems/hard/PARADE.md +++ b/_problems/hard/PARADE.md @@ -113,8 +113,8 @@ Output **K** lines: each line contain an integer, corresponding to the minimal c 6 21 32 - -**Explanation** + +**Explanation** In the first year, since **C** is very small, an optimal solution is: no hero travel, we pay 1 dollar for each city as compensate. In the second year, an optimal solution is: One hero traveling in the path: 1->3->4->5. We pay 2+2+2=6 dollars for the roads, 5 dollars for taking him back to city 1, and pay 5 dollars for city 2 and 6 as compensate. In the third year, one optimal solution is: One hero traveling in the path: 1->3->4->5, and another hero traveling in the path: 2->3->4->6. diff --git a/_problems/hard/PARSIN.md b/_problems/hard/PARSIN.md index 70f28277..77f7fbbe 100644 --- a/_problems/hard/PARSIN.md +++ b/_problems/hard/PARSIN.md @@ -49,6 +49,7 @@ For each test case, print the value of **f**(**M**, **N**, **X**). This value mu 1 1 5 1 30 0.3 ### Sample Output +
-0.99999714638
 0
 0
diff --git a/_problems/hard/PERMUTE.md b/_problems/hard/PERMUTE.md
index 7baa735b..585ed9cf 100644
--- a/_problems/hard/PERMUTE.md
+++ b/_problems/hard/PERMUTE.md
@@ -93,6 +93,6 @@ For each test case output a single one line containing number of such permutatio
 Output:
 4
 72
-
 
### Explanation + For the 1st case all permutations are: {2,3,1,4}, {3,2,1,4}, {4,1,2,3} and {4,1,3,2}. diff --git a/_problems/hard/POLY.md b/_problems/hard/POLY.md index 56b9d862..9e18e238 100644 --- a/_problems/hard/POLY.md +++ b/_problems/hard/POLY.md @@ -120,5 +120,4 @@ Each query, output the answer on a single line. 47 127 22 - \ No newline at end of file diff --git a/_problems/hard/POST.md b/_problems/hard/POST.md index c6fb1658..1cfe3c4d 100644 --- a/_problems/hard/POST.md +++ b/_problems/hard/POST.md @@ -39,13 +39,13 @@ For each test case, output a line containing the number of shortest paths to the 7 1 2 1 0 4 1 - ### Sample output: +
2
 0
 6
-
 
### Constraints + 1<=T<=30 1<=W,H<=107 0<=xi<=W diff --git a/_problems/hard/POSTERS.md b/_problems/hard/POSTERS.md index d9c05217..20d86977 100644 --- a/_problems/hard/POSTERS.md +++ b/_problems/hard/POSTERS.md @@ -48,5 +48,4 @@ The output for each test case is a single line containing a single integer that Output: 2 1 - \ No newline at end of file diff --git a/_problems/hard/PPTREE.md b/_problems/hard/PPTREE.md index d95cbc70..aed6bea3 100644 --- a/_problems/hard/PPTREE.md +++ b/_problems/hard/PPTREE.md @@ -93,7 +93,7 @@ For each test case, output a single line containing the answer to the correspond - **1** ≤ **T** ≤ **7** - **1** ≤ **N** ≤ **100,000** -- ≤ **W\[i\]** ≤ **1,000,000,000** +- 0 ≤ **W\[i\]** ≤ **1,000,000,000** ### Example @@ -110,8 +110,8 @@ For each test case, output a single line containing the answer to the correspond Output: 3 3 - ### Explanation + **Example case 1.** In this case there are tree ways to choose pair of vertices: - **(1, 2)**: The only edge you path is edge **(1, 2)** with weight **3**. The XOR-sum is simply **3**. @@ -127,6 +127,6 @@ So the maximal value Polo can get is **3**. ### NOTE -[XOR operation](http://en.wikipedia.org/wiki/Exclusive_or) is a bitwise "Exclusive OR" operation performed on two integers in binary representation. First, the shorter number is prepended with leading zeroes until the numbers have equal size in binary. Then the resulting number (also in binary) contains in all positions where the corresponding bits coincide, and **1** on the rest of the positions. +[XOR operation](http://en.wikipedia.org/wiki/Exclusive_or) is a bitwise "Exclusive OR" operation performed on two integers in binary representation. First, the shorter number is prepended with leading zeroes until the numbers have equal size in binary. Then the resulting number (also in binary) contains 0 in all positions where the corresponding bits coincide, and **1** on the rest of the positions. For example, **3** XOR **5** = **0112** XOR **1012** = **1102** = **6**. diff --git a/_problems/hard/PRDIVSUM.md b/_problems/hard/PRDIVSUM.md index 2fd912d4..52941552 100644 --- a/_problems/hard/PRDIVSUM.md +++ b/_problems/hard/PRDIVSUM.md @@ -32,6 +32,6 @@ For each test case, output a single line containing the answer for the correspon 0 4 - ### Explanation + In the second test case required pairs are (3, 6), (4, 12), (6, 12) and (10, 15). diff --git a/_problems/hard/PRIMEDST.md b/_problems/hard/PRIMEDST.md index f4eefdeb..a8ac5dd6 100644 --- a/_problems/hard/PRIMEDST.md +++ b/_problems/hard/PRIMEDST.md @@ -101,8 +101,8 @@ The input must be a tree. Output: 0.5 - ### Explanation + We have C(5, 2) = 10 choices, and these 5 of them have a prime distance: 1-3, 2-4, 3-5: 2 diff --git a/_problems/hard/PRUNING.md b/_problems/hard/PRUNING.md index 0062da01..907edea9 100644 --- a/_problems/hard/PRUNING.md +++ b/_problems/hard/PRUNING.md @@ -57,5 +57,4 @@ The output for each test case consists of a single line containing a single inte 29 7 7 - \ No newline at end of file diff --git a/_problems/hard/PTOSS.md b/_problems/hard/PTOSS.md index df3e88ca..e79f41e6 100644 --- a/_problems/hard/PTOSS.md +++ b/_problems/hard/PTOSS.md @@ -106,8 +106,8 @@ For each test case, output a single line containing the expected number of addit 2 8 254 - ### Explanation + In the third case, for the lucky sequence, 'A' stands for 26 and its 5-bit binary number is 11010. 'n' stands for 13 and its 5-bit binary number is 01101. Concatenate them to get 1101001101. The decoded string will be BBFBFFBBFB. Chef's lucky sequence is the first eight characters, i.e., BBFBFFBB. ### Constraints diff --git a/_problems/hard/PUPPYGCD.md b/_problems/hard/PUPPYGCD.md index 6d3a46cf..c1f2c5dd 100644 --- a/_problems/hard/PUPPYGCD.md +++ b/_problems/hard/PUPPYGCD.md @@ -104,6 +104,6 @@ For each test case, output a single line containing the answer for this test cas Output: 6 - ### Explanation + 6 such pairs: (3, 3), (3, 6), (3, 9), (3, 12), (6, 9), and (9, 12). diff --git a/_problems/hard/PUSHFLOW.md b/_problems/hard/PUSHFLOW.md index 7da40d9b..de303d94 100644 --- a/_problems/hard/PUSHFLOW.md +++ b/_problems/hard/PUSHFLOW.md @@ -139,5 +139,4 @@ For each query of the zeroth type you should to output one integer: the maximum 3 2 7 - \ No newline at end of file diff --git a/_problems/hard/QGRID.md b/_problems/hard/QGRID.md index 5294facd..d0d89d38 100644 --- a/_problems/hard/QGRID.md +++ b/_problems/hard/QGRID.md @@ -167,8 +167,8 @@ For each query of type 2, output the weight of required vertex. 1 1 - ### Explanation + **Example case 1.** See picture below. ![](https://codechef_shared.s3.amazonaws.com/upfiles/QGRID_sample_explanation_mfpOHUo4Bq.png) diff --git a/_problems/hard/QMARKS.md b/_problems/hard/QMARKS.md index bb4e5ada..7b2e0d54 100644 --- a/_problems/hard/QMARKS.md +++ b/_problems/hard/QMARKS.md @@ -114,8 +114,8 @@ abababa bacde 1 aaabecxd - ### Scoring + Subtask 1 (16 points): **T** = 50, 1 <= **N** <= 8, 1 <= **M** <= 10. Only the characters a, b and c and question marks occur in the string. Only the characters a, b, and c occur in the dictionary words. All the words in the dictionary consist of no more than 10 letters. Subtask 2 (32 points): **T** = 50, 1 <= **N** <= 100, 1 <= **M** <= 100. Only the characters a, b and question marks occur in the string. Only the characters a and b occur in the dictionary words. All the words in the dictionary consist of no more than 10 letters. diff --git a/_problems/hard/QPOINT.md b/_problems/hard/QPOINT.md index 87b9e3fe..28fdff37 100644 --- a/_problems/hard/QPOINT.md +++ b/_problems/hard/QPOINT.md @@ -113,8 +113,8 @@ For each query you print out one number which is the index of the country that c -1 1 2 - ### Explanation + **Example case 1.** The test case is represented in figure below. The first country is the rectangle ABCD and the second country is a triangle EFG. Notice that the point J at coordinate (6, 2) is considered to be inside the second country when it is on the boundary of this country diff --git a/_problems/hard/QPOLYSUM.md b/_problems/hard/QPOLYSUM.md index 815391b4..a0f2e172 100644 --- a/_problems/hard/QPOLYSUM.md +++ b/_problems/hard/QPOLYSUM.md @@ -90,10 +90,10 @@ For each test case, output a single line containing the value of the correspondi - **1** ≤ **T** ≤ **5000** - **1** < **M** < **1018** -- ≤ **Q** < **M** +- 0 ≤ **Q** < **M** - **1** ≤ **N** < **10100000** -- ≤ **D** < **20000** -- ≤ **Ai** < **M** for **i = 0, 1, ..., D** +- 0 ≤ **D** < **20000** +- 0 ≤ **Ai** < **M** for **i = 0, 1, ..., D** - The sum of **D + 1** over each input file does not exceed **20000**. - The overall number of digits in all numbers **N** in each input file does not exceed **105**. - ****M** is not divisible by any number from **2** to **D + 14**, inclusive.** @@ -112,8 +112,8 @@ For each test case, output a single line containing the value of the correspondi Output: 31 91 - ### Explanation + **Example case 1.** We have **M = 101, Q = 2, N = 5, D = 0** and **P(0) mod M = 1**. Therefore, **P(X) = C0** and **P(0) mod 101 = 1**. Hence, **C0 mod 101 = 1**. So we can take, for example, **C0 = 1**. Then the corresponding sum takes the form of **(P(0) \* Q0 + P(1) \* Q1 + ... + P(N − 1) \* QN − 1) mod M = (1 \* 20 + 1 \* 21 + 1 \* 22 + 1 \* 23 + 1 \* 24) mod 101 = (1 + 2 + 4 + 8 + 16) mod 101 = 31 mod 101 = 31.** Note, that the polynomial **P(X)** is not unique. We can take, for example, **C0 = 102** or **C0 = 2021**. However, the same will be always the same. **Example case 2.** We have **M = 289, Q = 1, N = 6, D = 2** and **P(0) mod M = 1, P(1) mod M = 4, P(2) mod M = 9**. It is easy to see that we can take **P(X) = (X + 1)2**. Then the corresponding sum takes the form of **(12 + 22 + 32 + 42 + 52 + 62) mod 289 = (1 + 4 + 9 + 16 + 25 + 36) mod 289 = 91.** Note that the polynomial **P(X)** again is not unique. In fact, the set of all polynomials of degree at most 2 that satisfy the conditions **P(0) mod 289 = 1, P(1) mod 289 = 4, P(2) mod 289 = 9** has the form of **{(X + 1)2 + 289 \* (C2 \* X2 + C1 \* X + C0) | C0, C1, C2** are integers}. diff --git a/_problems/hard/QRECT.md b/_problems/hard/QRECT.md index abfcb2c0..c54e2729 100644 --- a/_problems/hard/QRECT.md +++ b/_problems/hard/QRECT.md @@ -113,6 +113,7 @@ Q 3 3 4 4 1 0
+
 ### Explanation
 
 
diff --git a/_problems/hard/QSTRING.md b/_problems/hard/QSTRING.md
index f3073f1f..8a4f93d6 100644
--- a/_problems/hard/QSTRING.md
+++ b/_problems/hard/QSTRING.md
@@ -110,7 +110,6 @@ Select 2 1
 Rank 1 1
 Rank 2 2
 Rank 1 2
-
 
Output:
 1 1
 2 2
@@ -118,5 +117,4 @@ Rank 1 2
 1 1
 1 2
 2 1
-
 
\ No newline at end of file diff --git a/_problems/hard/QTREE.md b/_problems/hard/QTREE.md index 922f32fe..3cbee192 100644 --- a/_problems/hard/QTREE.md +++ b/_problems/hard/QTREE.md @@ -115,6 +115,6 @@ f 2 3 Output: 4 2 - ### Explanation + The shortest path from 5 to 6 is 5, 4, 2, 3, 6. All the edges on this path have weight 1 so the answer to the first query is 4. After the second query, the weight of the edge (2, 3) is - 1. The edges on the path 5, 4, 2, 3, 6 have weights 1, 1, -1, 1 respectively. so the answer for the third query is 2. diff --git a/_problems/hard/QUERY.md b/_problems/hard/QUERY.md index ef28546e..c0e318f7 100644 --- a/_problems/hard/QUERY.md +++ b/_problems/hard/QUERY.md @@ -55,13 +55,13 @@ time: current: 1493556808 layout: problem --- -All submissions for this problem are available.Chef gives you a tree, consisting of **N** nodes. The nodes are numbered from **1** to **N**, and each node has an integer, which is equal to initially. Then, Chef asks you to perform **M** queries. +All submissions for this problem are available.Chef gives you a tree, consisting of **N** nodes. The nodes are numbered from **1** to **N**, and each node has an integer, which is equal to 0 initially. Then, Chef asks you to perform **M** queries. The first type of queries is _changing_: here, you are given integers **X**, **Y**, **A** and **B**. Add **A** to the integer, associated with the node **X**, then add **A+B** to the integer, associated with the second node on the way from **X** to **Y**, then add **A+2\*B** to the integer, associated with the third node on the way from **X** to **Y**, and so on. As you know, there is only one simple path from **X** to **Y**. The second type of queries is a _question_: here, you are given integers **X** and **Y**. Output the sum of all integers, associated with nodes on the way from **X** to **Y**. -The third type of queries is a _rollback_: here, you are given an integer **X**. All the integers associated with the nodes return to the state after the **X**-th changing query. If **X** is , then all of them become equal to zero, as in the very beginning. +The third type of queries is a _rollback_: here, you are given an integer **X**. All the integers associated with the nodes return to the state after the **X**-th changing query. If **X** is 0, then all of them become equal to zero, as in the very beginning. ### Input @@ -108,8 +108,8 @@ q 1 3 35 0 15 - ### Explanation + As you can see, the tree in the sample is like a line. Let's denote the first state of integers **0 0 0 0 0**, where the **i**-th integer means the integer associated with the node **i**. In the first _changing_ query **"c 1 4 2 3"**, the actual numbers are **X = (1 + 0) modulo 5 + 1 = 2, Y = (4 + 0) modulo 5 + 1 = 5**. Hence the state will be **0 2 5 8 11** after this query. diff --git a/_problems/hard/RANKA.md b/_problems/hard/RANKA.md index 4818415f..5454720a 100644 --- a/_problems/hard/RANKA.md +++ b/_problems/hard/RANKA.md @@ -142,8 +142,8 @@ If the player uses "pass" at that step, then output "0 0", otherwise output the 1 2 9 9 2 2 - ### Examples + Here are some examples: You can see the image at this [link](/download/extimages/dff1e253b0a327c9f60f79ec80e10fb1.png) if itis not properly visible in your browser. diff --git a/_problems/hard/REACHRIG.md b/_problems/hard/REACHRIG.md index 2fd4c4d3..7860d8a0 100644 --- a/_problems/hard/REACHRIG.md +++ b/_problems/hard/REACHRIG.md @@ -54,5 +54,4 @@ For each test case, your program should print the minimum amount of food require 111 807 -1 - \ No newline at end of file diff --git a/_problems/hard/REALSET.md b/_problems/hard/REALSET.md index 686332b0..2ba43888 100644 --- a/_problems/hard/REALSET.md +++ b/_problems/hard/REALSET.md @@ -115,8 +115,8 @@ NO YES YES NO - ### Explanation + **Example case 2.** One of the possible sequences B is (1, -1, 0). **Example case 3.** One of the possible sequences B is (1, 1, 1, 1). diff --git a/_problems/hard/REARRAN.md b/_problems/hard/REARRAN.md index e060c579..4e0e737e 100644 --- a/_problems/hard/REARRAN.md +++ b/_problems/hard/REARRAN.md @@ -52,8 +52,8 @@ For each test case output exactly one line containing either a single integer -1 2 9 1 6 5 1 2 5 9 0 9 9 4 1 -1 - ### Explanation + There are 6 sequences of 3 consecutive numbers in (2 5 9 0 9 9 4 1). Formally: - (2 5 9), sum = 16, which is divisible by 2 diff --git a/_problems/hard/REBTET.md b/_problems/hard/REBTET.md index bec96b0d..e72f4b13 100644 --- a/_problems/hard/REBTET.md +++ b/_problems/hard/REBTET.md @@ -116,5 +116,4 @@ For each test case, output a single line. It must contain the number of ways to 9 2439 - \ No newline at end of file diff --git a/_problems/hard/RESN02.md b/_problems/hard/RESN02.md index 4a6ea85a..f904eab3 100644 --- a/_problems/hard/RESN02.md +++ b/_problems/hard/RESN02.md @@ -35,5 +35,4 @@ Output T lines, one per test case. For each test case, output a space seperated 0 0 0 11117 101 1075 12127 12081 - \ No newline at end of file diff --git a/_problems/hard/RESN03.md b/_problems/hard/RESN03.md index 73e00989..1484d4a3 100644 --- a/_problems/hard/RESN03.md +++ b/_problems/hard/RESN03.md @@ -36,5 +36,4 @@ Output T lines, one corresponding to each test case. For each test case output a Output: 3 145 - \ No newline at end of file diff --git a/_problems/hard/REVERSED.md b/_problems/hard/REVERSED.md index c2ba4826..5e76f7db 100644 --- a/_problems/hard/REVERSED.md +++ b/_problems/hard/REVERSED.md @@ -58,5 +58,4 @@ For each test case, print the solution in a single line. If there is no solution Output: -1 353 - \ No newline at end of file diff --git a/_problems/hard/RIN.md b/_problems/hard/RIN.md index 74644d78..5d92099e 100644 --- a/_problems/hard/RIN.md +++ b/_problems/hard/RIN.md @@ -141,8 +141,8 @@ Output one real number: the maximal average score, rounded to 2 digits after the Output 2: 32.50 -
### Explanation
+
 **Example case 1**
 
 The only way she can finish these 3 courses is: take course 1 in the first semester, then take courses 2 and 3 in the second semester. The average score is (70 + 80 + 90) / 3 = 80.00.
diff --git a/_problems/hard/RNG.md b/_problems/hard/RNG.md
index c0bb48d8..4dd2e815 100644
--- a/_problems/hard/RNG.md
+++ b/_problems/hard/RNG.md
@@ -116,8 +116,8 @@ Print a single integer denoting value of **AN**.
 
 Output:
 139
-
 
### Explanation + **A1 = 1.** **A2 = 2.** **A3 = 3.** diff --git a/_problems/hard/ROUTES.md b/_problems/hard/ROUTES.md index 10e40e31..ca75bc5c 100644 --- a/_problems/hard/ROUTES.md +++ b/_problems/hard/ROUTES.md @@ -113,8 +113,8 @@ Output **M** lines. The **i**-th line should contain the number of unsafe pairs 45 35 - ### Scoring + Subtask 1 (22 points): 1 <= **N** <= 5, 1 <= **M** <= 5. Subtask 2 (13 points): 1 <= **N** <= 100, 1 <= **M** <= 100. diff --git a/_problems/hard/RRTREE2.md b/_problems/hard/RRTREE2.md index 6ac8eec8..fe749433 100644 --- a/_problems/hard/RRTREE2.md +++ b/_problems/hard/RRTREE2.md @@ -96,7 +96,7 @@ The first line contains integer **N** — the number of vertices in given tree. ### Output -Let **S** be the sum over all **Wi**. You should output S characters **ith** of which should be equal to **1** if it is possible to get **marked\[i\] = true** and otherwise. Have a look at the example for better understanding. +Let **S** be the sum over all **Wi**. You should output S characters **ith** of which should be equal to **1** if it is possible to get **marked\[i\] = true** and 0 otherwise. Have a look at the example for better understanding. ### Constraints @@ -118,5 +118,4 @@ Let **S** be the sum over all **Wi**. You should output S characters **ith** of Output: 100000010100011010001 - \ No newline at end of file diff --git a/_problems/hard/RUSHHOUR.md b/_problems/hard/RUSHHOUR.md index 9ad3ce56..fff2096b 100644 --- a/_problems/hard/RUSHHOUR.md +++ b/_problems/hard/RUSHHOUR.md @@ -76,5 +76,4 @@ f.g..j Output 5 6 - -The first sample test case is explained in the figure. \ No newline at end of file +The first sample test case is explained in the figure. diff --git a/_problems/hard/SADPAIRS.md b/_problems/hard/SADPAIRS.md index 2e2e1c79..7af6dba2 100644 --- a/_problems/hard/SADPAIRS.md +++ b/_problems/hard/SADPAIRS.md @@ -98,7 +98,7 @@ Output **N** lines. The **i**th line must contain a single integer, the number o - **5** ≤ **N** ≤ **2×105** - **1** ≤ **Gi** ≤ **106** -- ≤ **E** ≤ **min(2×105, **N(N-1)/2**)** +- 0 ≤ **E** ≤ **min(2×105, **N(N-1)/2**)** - **1** ≤ **ai** < **bi** ≤ **N** - No pair (**ai**, **bi**) will appear more than once in the input. @@ -130,6 +130,7 @@ Output **N** lines. The **i**th line must contain a single integer, the number o 7 ### Explanation + In the given network, residents 1, 4, 5 and 7 all have team 1 as their favorite, and 2, 3 and 6 all have team 3 as their favorite. - If resident 1 is disconnected, then there are 5 sad pairs: (1,4), (1,5), (1,7), (2,6), (3,6). diff --git a/_problems/hard/SEAARC.md b/_problems/hard/SEAARC.md index 2be418e9..0ba6cd5c 100644 --- a/_problems/hard/SEAARC.md +++ b/_problems/hard/SEAARC.md @@ -97,5 +97,4 @@ Now Sereja wants to know how many pairs of arc with different color intersect? Output: 1 - \ No newline at end of file diff --git a/_problems/hard/SEABOX.md b/_problems/hard/SEABOX.md index 1c1b2043..1ab5f27b 100644 --- a/_problems/hard/SEABOX.md +++ b/_problems/hard/SEABOX.md @@ -117,8 +117,8 @@ Output two numbers in a single line - minimal and maximal value of **F(D)**. Output: 1 1 - ### Example 2 +
Input:
 2 1
 0 0
@@ -128,5 +128,4 @@ Output two numbers in a single line - minimal and maximal value of **F(D)**.
 
 Output:
 1 8
-
 
\ No newline at end of file diff --git a/_problems/hard/SEAEQ.md b/_problems/hard/SEAEQ.md index 0e3a7c81..4ced4034 100644 --- a/_problems/hard/SEAEQ.md +++ b/_problems/hard/SEAEQ.md @@ -106,5 +106,4 @@ For each testcase output answer modulo **1000000007 (10^9+7)**. 9 1 - \ No newline at end of file diff --git a/_problems/hard/SEAINCR.md b/_problems/hard/SEAINCR.md index 3cba170c..7d6c3ec3 100644 --- a/_problems/hard/SEAINCR.md +++ b/_problems/hard/SEAINCR.md @@ -115,5 +115,4 @@ For each test case, output **M** lines - the answer for each query. 3 2 2 - \ No newline at end of file diff --git a/_problems/hard/SEAINVS.md b/_problems/hard/SEAINVS.md index a78f3b9d..aec15fb2 100644 --- a/_problems/hard/SEAINVS.md +++ b/_problems/hard/SEAINVS.md @@ -96,7 +96,7 @@ For each query, output the corresponding answer in single line. - **Subtask #1: (10 points)** **1** ≤ **N** ≤ **10** - **Subtask #2: (20 points)** **1** ≤ **N** ≤ **1000** -- **Subtask #3: (70 points)** original constraints plus additionally ≤ number of pairs **i, j (1 ≤ i i > Pj)** over all test cases ≤ **3\*106** +- **Subtask #3: (70 points)** original constraints plus additionally 0 ≤ number of pairs **i, j (1 ≤ i i > Pj)** over all test cases ≤ **3\*106** ### Example @@ -118,5 +118,4 @@ For each query, output the corresponding answer in single line. 1 1 24 - \ No newline at end of file diff --git a/_problems/hard/SEALCM.md b/_problems/hard/SEALCM.md index cb59422b..56adb83a 100644 --- a/_problems/hard/SEALCM.md +++ b/_problems/hard/SEALCM.md @@ -111,5 +111,4 @@ For each test case, output required sum modulo **(109 + 7)**. 12310 4202 - \ No newline at end of file diff --git a/_problems/hard/SEAORD.md b/_problems/hard/SEAORD.md index 6afda4c4..5424e8ef 100644 --- a/_problems/hard/SEAORD.md +++ b/_problems/hard/SEAORD.md @@ -111,5 +111,4 @@ For each test case output optimal time in separated line. On the next **N** line 1 3 . - \ No newline at end of file diff --git a/_problems/hard/SEAPERM3.md b/_problems/hard/SEAPERM3.md index 90dc1101..57e07b5f 100644 --- a/_problems/hard/SEAPERM3.md +++ b/_problems/hard/SEAPERM3.md @@ -81,7 +81,7 @@ Output one line per test case that gives the number of good permutations obeying - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **10^9** -- ≤ **M** ≤ **10^4** +- 0 ≤ **M** ≤ **10^4** - **1** ≤ **Xi, Vi** ≤ **N** ### Example @@ -96,8 +96,8 @@ Output one line per test case that gives the number of good permutations obeying Output: 1 0 - ### Explanation + **Example case 1.** The only good permutation is **3,2,1** (i = 1, j = 2). ### Sub tasks diff --git a/_problems/hard/SEAPERMS.md b/_problems/hard/SEAPERMS.md index 58cabb39..df0b3e1e 100644 --- a/_problems/hard/SEAPERMS.md +++ b/_problems/hard/SEAPERMS.md @@ -112,6 +112,6 @@ Output **M** lines. The **i**th line should contain the number of good permutati 6 2 - ### Explanation + **Example case 1.** After the first replacement operation, all permutations will be good. However, after the second operation, **P\[1\]** must be **3**. diff --git a/_problems/hard/SEGMENTQ.md b/_problems/hard/SEGMENTQ.md index 343808a4..b26a0ca8 100644 --- a/_problems/hard/SEGMENTQ.md +++ b/_problems/hard/SEGMENTQ.md @@ -122,8 +122,8 @@ After each query of the type **1**, output the number of just activated segments 0 2 1 - ### Explanation + **Example case 1.** In the first two queries, we add the segments **\[1, 2\]** and **\[2, 3\]**, respectively. The we first mark the point **2**, the only segment that can be activated is **\[2; 2\]**. But since such segment is not yet present in the data structure, nothing will be activated that time. Then we try to add the segment **\[2, 2\]**. Please note that it won't be added, because all its' points are marked already. So nothing will happen on this addition. diff --git a/_problems/hard/SEINC.md b/_problems/hard/SEINC.md index 1be2732f..13ae9b7d 100644 --- a/_problems/hard/SEINC.md +++ b/_problems/hard/SEINC.md @@ -95,7 +95,7 @@ For each testcase output an answer - the mininal number of steps necessary. - **1** ≤ **T** ≤ **10** - **1** ≤ **n** ≤ **105** -- ≤ **Ai, Bi** ≤ **3** +- 0 ≤ **Ai, Bi** ≤ **3** ### Example @@ -108,5 +108,4 @@ For each testcase output an answer - the mininal number of steps necessary. Output: 1 - \ No newline at end of file diff --git a/_problems/hard/SEQCOUNT.md b/_problems/hard/SEQCOUNT.md index cc0da7aa..ddd30cf4 100644 --- a/_problems/hard/SEQCOUNT.md +++ b/_problems/hard/SEQCOUNT.md @@ -96,8 +96,8 @@ Output the number of nice sequences on the first line of the output modulo **109 Output: 1 - ### Explanation + The only suitable sequence is (1, 2, 3, 4). ### Scoring diff --git a/_problems/hard/SEQTOWER.md b/_problems/hard/SEQTOWER.md index aaeca6d4..c8247e42 100644 --- a/_problems/hard/SEQTOWER.md +++ b/_problems/hard/SEQTOWER.md @@ -86,8 +86,8 @@ Fun( Sequence S ) } - where **power(A, B)** returns **AB**, and **A** is **1**-indexed. + Fun(S) :![](https://s3.amazonaws.com/codechef_shared/download/seq.png) Now you need to find the **sum** of the values returned by **Fun(S)** for every _distinct sequence_ **S**. @@ -143,6 +143,6 @@ There are two types of test files: 80 64 - ### Explanation: + Test Case 1 : Answer will be (power(7,7)+power(7,11)+power(11,7)+power(11,11) )%23 diff --git a/_problems/hard/SERVERS.md b/_problems/hard/SERVERS.md index 08c8cdb3..166715d1 100644 --- a/_problems/hard/SERVERS.md +++ b/_problems/hard/SERVERS.md @@ -64,8 +64,8 @@ For each test case you are to output a single line consisting of a single intege 2 3 3 - ### Notes On The Sample Data + One solution to the first test cases uses communicating pairs (1,2) and (2,3). We can't have 3 pairs since one of the frequencies would then be used by two devices. A solution for the second test case uses pairs (1,2), (2,3), and (3,4). All four pairs may not be used since there would be multiple ways for 1 and 3 to communicate (using either 2 or 4 as an intermediate device). Finally, one solution to the last test case uses (1,2), (2,3), and (4,1). One cannot have 4 pairs for the following reason. We can't use all of (1,2),(2,3), and (3,1) since this creates more than one way for 1 and 2 to communicate. On the other hand, we can't use two of (4,1),(4,2),(5,1), or (5,2) since this would violate the bound on the frequencies. diff --git a/_problems/hard/SEZ.md b/_problems/hard/SEZ.md index f5abbc0a..47cdac7e 100644 --- a/_problems/hard/SEZ.md +++ b/_problems/hard/SEZ.md @@ -111,6 +111,6 @@ Print a single integer corresponding to the maximal value of **(x - y)**. Output: 1 - ### Explanation + Ciel will select city **1** and **3** as SEZ. So **x = 2** (city **1** and **3**), **y = 1** (city **2**), **x - y = 1**. diff --git a/_problems/hard/SFUNC.md b/_problems/hard/SFUNC.md index 536dc930..17b20564 100644 --- a/_problems/hard/SFUNC.md +++ b/_problems/hard/SFUNC.md @@ -97,8 +97,8 @@ The first line of contains the only integer, denoting _SuperFuntion_ of **N** an 5 2 100 Output: 30 - ### Explanation + In the test case **N** equals to 5, **K** equals to 2, **M** equals to 100. The answer is (12 + 22 + 32 + 42) mod 100 = 30. ### Scoring diff --git a/_problems/hard/SHORT.md b/_problems/hard/SHORT.md index d4f3f757..29725e12 100644 --- a/_problems/hard/SHORT.md +++ b/_problems/hard/SHORT.md @@ -33,5 +33,4 @@ For each test case output one line containing the required number. 3 Explanation: - -In the first test case, the only sought pairs are (2,2) and (3,3). In the second one, they are (3,3), (3,4) and (4,3). \ No newline at end of file +In the first test case, the only sought pairs are (2,2) and (3,3). In the second one, they are (3,3), (3,4) and (4,3). diff --git a/_problems/hard/SHORT2.md b/_problems/hard/SHORT2.md index d8656d0e..fe444231 100644 --- a/_problems/hard/SHORT2.md +++ b/_problems/hard/SHORT2.md @@ -36,5 +36,4 @@ For each test case output one line containing the required number. It's guarante 116 Explanation: - -In the first test case the sought pairs are (3,3), (3,4), (3,5), (3,8), (4,3), (4,4), (4,6), (5,3), (5,12), (6,4), (6,8), (8,3), (8,6) and (12,5). \ No newline at end of file +In the first test case the sought pairs are (3,3), (3,4), (3,5), (3,8), (4,3), (4,4), (4,6), (5,3), (5,12), (6,4), (6,8), (8,3), (8,6) and (12,5). diff --git a/_problems/hard/SHORTCIR.md b/_problems/hard/SHORTCIR.md index 57a6ff5a..fa142a6d 100644 --- a/_problems/hard/SHORTCIR.md +++ b/_problems/hard/SHORTCIR.md @@ -53,6 +53,6 @@ cd 0.2 2.280000 2.260000 - ### Explanation + In the first test case the best order is c, a, b. diff --git a/_problems/hard/SIGFIB.md b/_problems/hard/SIGFIB.md index 69cbecc6..3c0b439f 100644 --- a/_problems/hard/SIGFIB.md +++ b/_problems/hard/SIGFIB.md @@ -107,6 +107,7 @@ First line of input contains an integer **T** denoting the number of test cases. 6

36

66

60

### Explanation for first test case: + In the first case, we have the following 10 terms for **N** = 3: 6 \* 0\*0\*3\*Fibo\[0\] \* Fibo\[0\] \* Fibo\[3\] 6 \* 0\*1\*2\*Fibo\[0\] \* Fibo\[1\] \* Fibo\[2\] diff --git a/_problems/hard/SINSUMQ.md b/_problems/hard/SINSUMQ.md index 7c43351d..83a78a1f 100644 --- a/_problems/hard/SINSUMQ.md +++ b/_problems/hard/SINSUMQ.md @@ -38,5 +38,4 @@ layout: problem 0.65354865 0.782376860 - \ No newline at end of file diff --git a/_problems/hard/SKIRES.md b/_problems/hard/SKIRES.md index 251b2cf7..21f40303 100644 --- a/_problems/hard/SKIRES.md +++ b/_problems/hard/SKIRES.md @@ -49,5 +49,4 @@ For each test case, output minimum total elevation so that chef can achieve his Output: 4 -1 - \ No newline at end of file diff --git a/_problems/hard/SLIS.md b/_problems/hard/SLIS.md index 66fedf9a..739e6d6d 100644 --- a/_problems/hard/SLIS.md +++ b/_problems/hard/SLIS.md @@ -109,6 +109,6 @@ For each test case, output the answer per line. 3 4 5 - ### Explanation + **Example case 1.** **L** = 2. There are 3 different length-1 IS's. diff --git a/_problems/hard/SNCK02.md b/_problems/hard/SNCK02.md index df8533ef..55757f95 100644 --- a/_problems/hard/SNCK02.md +++ b/_problems/hard/SNCK02.md @@ -62,8 +62,8 @@ For each test case, output a single line of integers. The first integer is |S|, 3 4 0 0 - ### Sample Output: +
2 0 1
 4 0 1 2 3
 3 0 1 2
diff --git a/_problems/hard/SNCK03.md b/_problems/hard/SNCK03.md
index d98236e5..11b814c0 100644
--- a/_problems/hard/SNCK03.md
+++ b/_problems/hard/SNCK03.md
@@ -56,13 +56,13 @@ Time Limit : 20 seconds.
 1 3 4
 10 6
 1 2 5 7 8 10
-
 
### Sample Output : +
2
 3
 6166
-
 
### Note : + For the first test case, (1 3 2) and (2 3 1) are the valid permutations. diff --git a/_problems/hard/SPMATRIX.md b/_problems/hard/SPMATRIX.md index 711e3f36..f0067869 100644 --- a/_problems/hard/SPMATRIX.md +++ b/_problems/hard/SPMATRIX.md @@ -136,6 +136,6 @@ For each test case output the overall number of special matrices of order **N** 1 13 719666144 - ### Explanation + Example cases 1 and 2 are explained above. diff --git a/_problems/hard/SPSHORT.md b/_problems/hard/SPSHORT.md index 4adabdd3..e4306043 100644 --- a/_problems/hard/SPSHORT.md +++ b/_problems/hard/SPSHORT.md @@ -137,5 +137,4 @@ No Solution

Explanation

For First Test Case: Shortest Valid Walk: 4->1->2->3 For Second Test Case: There is no valid Walk satisfying the constraints. - -**Warning: Large Input files, some files are upto 10 MB** \ No newline at end of file +**Warning: Large Input files, some files are upto 10 MB** diff --git a/_problems/hard/STARROAD.md b/_problems/hard/STARROAD.md index f4702bc5..1aae1922 100644 --- a/_problems/hard/STARROAD.md +++ b/_problems/hard/STARROAD.md @@ -134,7 +134,6 @@ Output a single line containing a single integer — the solution of Chef's prob Output: 75 -
 Input:
 3 3 2 3
@@ -144,7 +143,6 @@ Output a single line containing a single integer — the solution of Chef's prob
 
 Output:
 3
-
 
 Input:
 5 8 10000 1000000000
@@ -159,8 +157,8 @@ Output a single line containing a single integer — the solution of Chef's prob
 
 Output:
 2220611572265625
-
 
### Explanation: + **Example case 1.** There are five possible routes between stars 1 and 2 traversable in not more than 3 days: {1-2, 1-3-2, 1-2-1-2, 1-2-3-2, 1-3-1-2}. There are also five routes between stars 2 and 3, and also between stars 1 and 3. There are three possible plans for the remaining routes: - A route remains between 1 and 2, and between 2 and 3. There are 5 x 5 = 25 ways to do this. diff --git a/_problems/hard/STEPNUMS.md b/_problems/hard/STEPNUMS.md index 9a55ea6a..0abd64ce 100644 --- a/_problems/hard/STEPNUMS.md +++ b/_problems/hard/STEPNUMS.md @@ -37,5 +37,4 @@ Output the answer to each test case on a separate line. 54 171 1958 - \ No newline at end of file diff --git a/_problems/hard/STREDUC.md b/_problems/hard/STREDUC.md index 19e40fe0..e5fa9d15 100644 --- a/_problems/hard/STREDUC.md +++ b/_problems/hard/STREDUC.md @@ -39,11 +39,11 @@ Output on a single line an integer which is the minimum length found. abc ac aaa - **Output:** -
2
 
+
2
 
### Limitations + - 0### Explanation + - At the beginning all stores are empty so the answer for the first query which asks about the store 5 is "NA". - The first plan of the Chef is "3 8 3 1" which means the items with price 1, 4, 7, 10, 13, 16 are added to the stores 3, 4, 5, ..., 8 correspondingly. So in the next query (asking about store 5) the answer is 7 (we have only one item to buy with no conservation fee). - The second plan of the Chef is "5 10 -8 2" so the items with price 2, -6, -14, -22, -30, -38 are added to the stores 5, 6, 7, ..., 10 correspondingly. Now the store 5 now contains two items with the corresponding prices are 7 and 2, the answer for the query about store 5 is still 7 (we still don't have any conservation fee). The store 10 contain only one item with price is -38 so the answer for the query about this store is -38. diff --git a/_problems/hard/STRQUER.md b/_problems/hard/STRQUER.md index d8218323..949fba70 100644 --- a/_problems/hard/STRQUER.md +++ b/_problems/hard/STRQUER.md @@ -75,7 +75,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin chinese](http://www.codechef.com/download/translated/LTIME54/mandarin/STRQUER.pdf), [Russian](http://www.codechef.com/download/translated/LTIME54/russian/STRQUER.pdf) and [Vietnamese](http://www.codechef.com/download/translated/LTIME54/vietnamese/STRQUER.pdf) as well. -Chef has a set of integers **A1**, **A2**, ..., **AN**. Define the Chef's number for the set as a minimal sum of penalties of the connections between numbers from this set(each number must be connected with at least one other number), if size of the set more or equal than **2**, and otherwise. The connection between numbers **x** and **y** has a penalty equal the absolute value |**x**-**y**|. Chef can add elements in the set and remove elements from it, after every such operation he wants to know the Chef's number for his set. Please help him to solve this complicated task. ### Input +Chef has a set of integers **A1**, **A2**, ..., **AN**. Define the Chef's number for the set as a minimal sum of penalties of the connections between numbers from this set(each number must be connected with at least one other number), if size of the set more or equal than **2**, and 0 otherwise. The connection between numbers **x** and **y** has a penalty equal the absolute value |**x**-**y**|. Chef can add elements in the set and remove elements from it, after every such operation he wants to know the Chef's number for his set. Please help him to solve this complicated task. ### Input The first line of the input contains an integer **T** denoting the number of test cases. The description of **T** test cases follows. The first line of each test case contains two positive integers **N** denoting the number of elements in the set and **Q** denoting the number of operations performed by Chef. The second line contains **N** space-separated integers **A1**, **A2**, ..., **AN** denoting the set **A**, all numbers in **A** are pairwise distinct. Next **Q** lines contains two integers - **type** and **x**. **type** = 1 **x** denoting that Chef adding the number **x** in the set, it's guaranteed that **x** not in the set. **type** = 2 **x** denoting that Chef erases element **x** from it, it's guaranteed that **x** exists there. @@ -114,8 +114,8 @@ Should contain all the constraints on the input data that you may have. Format i 3 3 3. -
### Explanation + **Example case 1.** After the first operation **A** will be = {1, 7, 2, 4, 3} , the Chef's number for the **A** can be computed with next connections: **1** with **2**, **2** with **3** and **7** with **4**, sum of this values |**1**-**2**|+|**2**-**3**|+|**7**-**4**|=**5**. After the second operation **A** = {1, 7, 2, 4, 3, 6}, Chef's number = |**1**-**2**|+|**4**-**3**|+|**7**-**6**| = 3. After the third operation **A** = {7, 2, 4, 3, 6}, Chef's number = |**4**-**3**|+|**2**-**3**|+|**7**-**6**| = 3 . Finally **A** = {2, 4, 3, 6} and Chef's number = |**3**-**2**|+|**6**-**4**|=3. diff --git a/_problems/hard/STRQUERY.md b/_problems/hard/STRQUERY.md index 8123230a..5d816b00 100644 --- a/_problems/hard/STRQUERY.md +++ b/_problems/hard/STRQUERY.md @@ -71,7 +71,7 @@ layout: problem --- All submissions for this problem are available.Hey, you've got a new mission! This time your client ask you to write a editor and it should run fast! However the client's request is somehow strange, but they give a lot of money so your boss ask you to finish it as fast as possible. -This editor deal with a string **S**. And the length **|S|** of the string **S** would never be smaller than **10**. This editor must support the following **7** operations quickly. Here the string would be indexed starting at . +This editor deal with a string **S**. And the length **|S|** of the string **S** would never be smaller than **10**. This editor must support the following **7** operations quickly. Here the string would be indexed starting at 0. 1. INSERT\_LEFT **c** : insert character **c** at the beginning of **S** 2. INSERT\_RIGHT **c** : insert character **c** at the end of **S** @@ -121,8 +121,8 @@ DELETE_MIDDLE Output: 1 - ### Explanation + In the sample, the string **|S|** will be changed as follows:
@@ -138,5 +138,4 @@ aabbbababbbbaaaaba (after INSERT_LEFT a)
 aabbbabababbbaaaaba (after INSERT_MIDDLE a)
 aabbbababbbbaaaaba (after DELETE_MIDDLE)
 aabbbababbbaaaaba (after DELETE_MIDDLE)
-
-
For QUERY bbaaa, this string occurs once. It is shown in boldface type. \ No newline at end of file +For QUERY bbaaa, this string occurs once. It is shown in boldface type. diff --git a/_problems/hard/SUBGRAPH.md b/_problems/hard/SUBGRAPH.md index 7fbc7d5b..22005ebc 100644 --- a/_problems/hard/SUBGRAPH.md +++ b/_problems/hard/SUBGRAPH.md @@ -124,5 +124,4 @@ For each test case, output a single line containing one integer: the number of d 20 5 -
\ No newline at end of file
diff --git a/_problems/hard/SUBQUERY.md b/_problems/hard/SUBQUERY.md
index 143ce205..78503668 100644
--- a/_problems/hard/SUBQUERY.md
+++ b/_problems/hard/SUBQUERY.md
@@ -101,6 +101,6 @@ abacaba
 
 Output:
 1
-
 
### Explanation + The only such string is **aba**. diff --git a/_problems/hard/SUMDIS.md b/_problems/hard/SUMDIS.md index 3506df92..2c2ac220 100644 --- a/_problems/hard/SUMDIS.md +++ b/_problems/hard/SUMDIS.md @@ -151,4 +151,5 @@ All submissions for this problem are available.### Read problems statements in 6 31 ### Explanation + **Example case 1**. In this test case the distance between the node **A** and the node **B** will be equal to one for all pairs **(A, B)**. So for all six pairs we get the distance **1** and the final sum **6**. diff --git a/_problems/hard/TABISHOP.md b/_problems/hard/TABISHOP.md index 7ed3dbc7..edbc42be 100644 --- a/_problems/hard/TABISHOP.md +++ b/_problems/hard/TABISHOP.md @@ -86,7 +86,7 @@ Output a single line containing the number of safe cells. - **1** ≤ **N** ≤ **109** - **1** ≤ **K** ≤ **100000** (**105**) -- ≤ **M** ≤ **100000** (**105**) +- 0 ≤ **M** ≤ **100000** (**105**) - **1** ≤ **X**, **Y**, **U**, **V** ≤ **N** - Positions of all **K + M** chess pieces are distinct @@ -102,8 +102,8 @@ Output a single line containing the number of safe cells. Output: 22 - ### Explanation +
 -------*
 *--o--**
diff --git a/_problems/hard/TACTQUER.md b/_problems/hard/TACTQUER.md
index 7bcdbfff..cc58dfd6 100644
--- a/_problems/hard/TACTQUER.md
+++ b/_problems/hard/TACTQUER.md
@@ -136,8 +136,8 @@ For each query print out the corresponding result in one line.
 4
 2
 6
-
 
### Explaination + **Test 2:** the graph is shown in the picture below. ![](http://www.codechef.com/download/upload/tactquer-example-2.png) diff --git a/_problems/hard/TAPAIR.md b/_problems/hard/TAPAIR.md index 974c54df..db3e4628 100644 --- a/_problems/hard/TAPAIR.md +++ b/_problems/hard/TAPAIR.md @@ -108,7 +108,7 @@ The first line of the input contains two integers **N M** which are the number o Output: 6 - ### Explanation + There are 5 cities and 6 roads (numbered from 1 to 6). There are 6 pairs of roads cannot be chosen which are (1, 2), (1, 3), (2, 3), (4, 5), (4, 6) and (5, 6). diff --git a/_problems/hard/TASUFFIX.md b/_problems/hard/TASUFFIX.md index 7f82ed20..097763d1 100644 --- a/_problems/hard/TASUFFIX.md +++ b/_problems/hard/TASUFFIX.md @@ -99,7 +99,7 @@ Output a single line containing the number of strings corresponding to the given ### Constraints - **1** ≤ **N** ≤ **1,000,000,000 (109)** -- ≤ **M** ≤ **100,000 (105)** +- 0 ≤ **M** ≤ **100,000 (105)** - For all operations, **1** ≤ **u** ≤ **v** ≤ **N** ### Example @@ -110,8 +110,8 @@ Output a single line containing the number of strings corresponding to the given 0 3 4 Output: 4 - ### Explanation + The initial array is (1, 2, 3, 4). After the first operation the array becomes (1, 3, 2, 4). After the second operation the array becomes (2, 4, 1, 3). diff --git a/_problems/hard/TDRIVER.md b/_problems/hard/TDRIVER.md index 691fe54a..d39906a3 100644 --- a/_problems/hard/TDRIVER.md +++ b/_problems/hard/TDRIVER.md @@ -121,5 +121,4 @@ For each test case, output a single line containing one integer: the sum of the 6 32274 - \ No newline at end of file diff --git a/_problems/hard/TEAMSEL.md b/_problems/hard/TEAMSEL.md index 3f067ab5..70cb031d 100644 --- a/_problems/hard/TEAMSEL.md +++ b/_problems/hard/TEAMSEL.md @@ -76,5 +76,4 @@ Your output should be exactly '2T-1' lines. The output for each test case should 5 13 229 230 - \ No newline at end of file diff --git a/_problems/hard/TERVEC.md b/_problems/hard/TERVEC.md index 97a12f82..e9bb02d1 100644 --- a/_problems/hard/TERVEC.md +++ b/_problems/hard/TERVEC.md @@ -115,8 +115,8 @@ YES YES 1 1 1 -1 - ### Subtasks + **Subtask 1:(10 points)** - **1** ≤ **N** ≤ **8** diff --git a/_problems/hard/TESTERS.md b/_problems/hard/TESTERS.md index d9afd957..9e4a5e8a 100644 --- a/_problems/hard/TESTERS.md +++ b/_problems/hard/TESTERS.md @@ -114,5 +114,4 @@ Here we have S(2)=S(3)=1 and S(1)=10 (1 + 32), so the f 1+1+2+2+3=9 The (1, 1) trip is not interesting. - \ No newline at end of file diff --git a/_problems/hard/TICKETS.md b/_problems/hard/TICKETS.md index 5ffac98f..5899060a 100644 --- a/_problems/hard/TICKETS.md +++ b/_problems/hard/TICKETS.md @@ -99,15 +99,15 @@ For each test case, output a single integer indicating the maximum number of tic 1 4 2 3 3 4 - ### Sample Output +
 4
 2
 4
 
-
 
In the second example, Chef cannot sell 3 tickets because it's possible that 3 patrons will arrive all preferring dishes 1 or 2. + ### Constraints - T ≤ 15 diff --git a/_problems/hard/TKCONVEX.md b/_problems/hard/TKCONVEX.md index f26cdab3..0df31536 100644 --- a/_problems/hard/TKCONVEX.md +++ b/_problems/hard/TKCONVEX.md @@ -106,8 +106,8 @@ Yes Output 2: No - ### Explanation + **Example case 1:** 1 1 1 and 2 2 2 form two triangles. **Example case 2:** Please be careful that convex polygons must be non-degenerated. diff --git a/_problems/hard/TMP01.md b/_problems/hard/TMP01.md index f84afd89..050ab51e 100644 --- a/_problems/hard/TMP01.md +++ b/_problems/hard/TMP01.md @@ -109,8 +109,8 @@ So, print a single integer - the sum of answers for all operations (the sum of * Output: 27 - ### Explanation + In the first test case the string **S** transforms as follows: - After the first operation **S** = a. The number of distinct substrings is 1: a. diff --git a/_problems/hard/TRCNTCT.md b/_problems/hard/TRCNTCT.md index 77b7ee82..8a87d0ed 100644 --- a/_problems/hard/TRCNTCT.md +++ b/_problems/hard/TRCNTCT.md @@ -117,8 +117,8 @@ For each test case, output a single line containing the number Chef is intereste 3 7 - ### Explanation + **Example case 1.** Intervals \[**1**,**1**\], \[**1**,**2**\] and \[**2**,**2**\] are valid. **Example case 2.** Intervals \[**1**,**1**\], \[**1**,**4**\], \[**2**,**2**\], \[**2**,**4**\], \[**3**,**3**\], \[**3**,**4**\] and \[**4**,**4**\] are valid. diff --git a/_problems/hard/TREECNT2.md b/_problems/hard/TREECNT2.md index 9ef0ba19..1a9d4807 100644 --- a/_problems/hard/TREECNT2.md +++ b/_problems/hard/TREECNT2.md @@ -120,8 +120,8 @@ In the first line, print the answer for the initial tree. Then print the answer 2 3 4 - ### Explanation + The below figure shows the initial graph and the graph after each query. **The initial tree.** The sought pairs are **(2, 4)** and **(2, 5)**. For example, in the path between nodes **2** and **4**, there are three integers **10, 6, 15** associated edges, and **GCD(10, 6, 15) = 1**. diff --git a/_problems/hard/TREEPATH.md b/_problems/hard/TREEPATH.md index 436ca8e9..ec5fb4e2 100644 --- a/_problems/hard/TREEPATH.md +++ b/_problems/hard/TREEPATH.md @@ -127,8 +127,8 @@ Subtask 3 (69 points): Output: 4 - ### Explanation + Let's list all the four possible decompositions: - The whole tree is one path. Then, the sum of nodes' associated numbers is 1 + 10 + 5 + (-1) = 15. diff --git a/_problems/hard/TRICONT.md b/_problems/hard/TRICONT.md index 37e8ad04..d5541f21 100644 --- a/_problems/hard/TRICONT.md +++ b/_problems/hard/TRICONT.md @@ -122,8 +122,8 @@ Output **N** lines. The **ith** line must contain a single integer, the answer t 1 2 2 - ### Explanation + - After the first and second installations, there aren't enough guard towers for Chef to choose from. - After the third and fourth installations, there is one set of guard towers that make Chef's house safe: **{(2, 3), (3, 2), (-1, -1)}**. - After the fifth and sixth installations, there are two sets of guard towers that make Chef's house safe: **{(2, 3), (3, 2), (-1, -1)}** and **{(2, 3), (4, 1), (-1, -1)}**. diff --git a/_problems/hard/TRIPS.md b/_problems/hard/TRIPS.md index 30af7a21..ce8a6134 100644 --- a/_problems/hard/TRIPS.md +++ b/_problems/hard/TRIPS.md @@ -121,5 +121,4 @@ For every query, please output the number of days on a separate line. 1 1 1 - \ No newline at end of file diff --git a/_problems/hard/TROOT.md b/_problems/hard/TROOT.md index 4a9d904d..ad7cf3d7 100644 --- a/_problems/hard/TROOT.md +++ b/_problems/hard/TROOT.md @@ -117,5 +117,4 @@ Output **M** lines. Output the product of all the possible roots' numbers modulo 15 30 120 - \ No newline at end of file diff --git a/_problems/hard/TSPAGAIN.md b/_problems/hard/TSPAGAIN.md index 7db7d077..6a315ba3 100644 --- a/_problems/hard/TSPAGAIN.md +++ b/_problems/hard/TSPAGAIN.md @@ -31,17 +31,16 @@ Output T lines, one for each test case, containing the required answer. ### Samp 0 1 1 2 - ### Sample Output : +
 3
 6
 
-
 
### Constraints : +
 1 <= T <= 50
 2 <= n <= 1000
 1 <= K <= 10000
-
 
\ No newline at end of file diff --git a/_problems/hard/TSUBSTR.md b/_problems/hard/TSUBSTR.md index 338ab348..4c5d9d19 100644 --- a/_problems/hard/TSUBSTR.md +++ b/_problems/hard/TSUBSTR.md @@ -138,5 +138,4 @@ aba ba -1 - \ No newline at end of file diff --git a/_problems/hard/TULIPS.md b/_problems/hard/TULIPS.md index fabbd6a0..f4fe886f 100644 --- a/_problems/hard/TULIPS.md +++ b/_problems/hard/TULIPS.md @@ -125,8 +125,8 @@ Cherry has never been to school and is not very good at counting, so she always 2 1 1 - ### Explanation + **Example case 1.** There are **3** queries. The tulips take **4** days to grow fully. In the first query, Cherry will visit nodes **1** and **2**, because the trail **3-1** has length greater than **8**. Both the nodes will have fully grown tulips. After Cherry picks them, the tulips will grow back on day **5+4**, if Cherry doesn't visit them again. So the output is **2**. In the second query, Cherry will visit all the trails because all of them have length less than **20**. The tulips at **1,2** haven't grown back yet and now all the tulips will take **4** more days. There is a tulip at **3**. So the output is **1**. diff --git a/_problems/hard/TUPLES.md b/_problems/hard/TUPLES.md index 61dcf587..81c22693 100644 --- a/_problems/hard/TUPLES.md +++ b/_problems/hard/TUPLES.md @@ -119,5 +119,4 @@ For each test case, output a single line containing the answer. Since the answer Output: 234 - \ No newline at end of file diff --git a/_problems/hard/TUPLES2.md b/_problems/hard/TUPLES2.md index 7873f90f..b2bf8154 100644 --- a/_problems/hard/TUPLES2.md +++ b/_problems/hard/TUPLES2.md @@ -139,6 +139,7 @@ Each of the next **N-1** lines contains two integers **a**i and **b**i denoting Output 2: 43484 ### Explanation + **Example test 1.** Let (**x**, **y**) denote the simple path between nodes **x** and **y**. There are **16** nice triples of paths: - (1, 2), (1, 3), (1, 4) - (1, 2), (1, 3), (2, 3) - (1, 2), (1, 3), (2, 4) diff --git a/_problems/hard/TUZTRN.md b/_problems/hard/TUZTRN.md index 8ea1719b..7a962753 100644 --- a/_problems/hard/TUZTRN.md +++ b/_problems/hard/TUZTRN.md @@ -120,8 +120,8 @@ For each test case, output a line with the string **Yes** or **No**, denoting th Output: Yes No - ### Explanation + The figures from the first test case of the sample: ![](https://s3.amazonaws.com/codechef_shared/download/COOK67/1.png) diff --git a/_problems/hard/TWOCOMP.md b/_problems/hard/TWOCOMP.md index 8c5fea02..ff5c34a2 100644 --- a/_problems/hard/TWOCOMP.md +++ b/_problems/hard/TWOCOMP.md @@ -115,6 +115,6 @@ Output the maximal possible sum of amounts of joy over all the chosen roads. Output: 25 - ### Explanation + If you take the only route of GTN, you'll not be able to take anything of BTS. So, it's better to take the both routes of BTS (a route of a company can cross with another route of this company as well) and to end up with the total sum of 25. diff --git a/_problems/hard/TWOROADS.md b/_problems/hard/TWOROADS.md index 7e13547c..d40c230f 100644 --- a/_problems/hard/TWOROADS.md +++ b/_problems/hard/TWOROADS.md @@ -103,6 +103,6 @@ Print out the minimum sadness of the country with absolute error less than **10- Output: 0 - ### Explanation + The first road goes through the first two cities and the second road goes through the last two cities. diff --git a/_problems/hard/UNGAME.md b/_problems/hard/UNGAME.md index bc510d72..68dba0be 100644 --- a/_problems/hard/UNGAME.md +++ b/_problems/hard/UNGAME.md @@ -109,8 +109,8 @@ For each test case, output a single line containing **m** space separated intege Output: 2 1 1 1 - ### Explanation + **Example case 1.** There are three cells in the horizontal strip. diff --git a/_problems/hard/UPDTREE.md b/_problems/hard/UPDTREE.md index a28f32cd..6667543f 100644 --- a/_problems/hard/UPDTREE.md +++ b/_problems/hard/UPDTREE.md @@ -118,8 +118,8 @@ For each query, print the required answer in one line. Output: 2 4 - ### Explanation + On first operation, value of edge (2-4) is increased by one. On second operation, value of edges (1-3), (1-2), (2-4) are increased by one. **Warning:**Use fast input/output. Large input files. diff --git a/_problems/hard/WALKBT.md b/_problems/hard/WALKBT.md index 345c9c4e..af2243d9 100644 --- a/_problems/hard/WALKBT.md +++ b/_problems/hard/WALKBT.md @@ -131,8 +131,8 @@ For each query of Type 2, you have to print one integer in a new line 5 6 7 - ### Explanation + Let us label the tree nodes as follows: ![](https://codechef_shared.s3.amazonaws.com/download/upload/AUG17/puush-linux%2B%282017-08-04%2Bat%2B02.32.03%29.png)The node 0 corresponds to the root. diff --git a/_problems/hard/WAYPA.md b/_problems/hard/WAYPA.md index 4a5e80cd..38a41b89 100644 --- a/_problems/hard/WAYPA.md +++ b/_problems/hard/WAYPA.md @@ -115,6 +115,6 @@ For each test case, you should output the maximum number of cities that Serega c Output: 7 - ### Explanation + Sequence of classes on the path between the cities **5** and **8** is **210012**. diff --git a/_problems/hard/WEASELSC.md b/_problems/hard/WEASELSC.md index 6afbc9c8..f394055b 100644 --- a/_problems/hard/WEASELSC.md +++ b/_problems/hard/WEASELSC.md @@ -98,9 +98,9 @@ For each test case you should print an integer, the maximum area of a staircase - **1** ≤ **T** ≤ **5** - **1** ≤ **N** ≤ **105** -- ≤ **K** ≤ **50** +- 0 ≤ **K** ≤ **50** - The sum of **N** over all testcases does not exceed **105**. -- ≤ **histogrami** ≤ **105** +- 0 ≤ **histogrami** ≤ **105** ### Subtasks @@ -126,8 +126,8 @@ For each test case you should print an integer, the maximum area of a staircase 33 29 2 - ### Explanation + The cells which form the staircase are colored with yellow. The discarded cells are colored with grey. #### Case **1**: @@ -147,4 +147,4 @@ The computed area is **7** × **2** + **5** × **3** = **29**. ![](https://codechef_shared.s3.amazonaws.com/download/upload/SEPT17/WEASELSC/example_3_2.png)#### Case **4**: -We take the second and the third cell. We have changes in height. This is a viable solution because we can also have staircases with less than **K** changes. +We take the second and the third cell. We have 0 changes in height. This is a viable solution because we can also have staircases with less than **K** changes. diff --git a/_problems/hard/WESTAND.md b/_problems/hard/WESTAND.md index feeda2b9..464be2ae 100644 --- a/_problems/hard/WESTAND.md +++ b/_problems/hard/WESTAND.md @@ -154,8 +154,8 @@ For each test case in a separate line output the minimum of possible costs for h -1 228 - ### Explanation + **Example case 1.** Chef has to hire first, second and third cooks(6 + 7 + 1 = 14). Cook 1: diff --git a/_problems/hard/WINDOW.md b/_problems/hard/WINDOW.md index f24de518..f3ff748d 100644 --- a/_problems/hard/WINDOW.md +++ b/_problems/hard/WINDOW.md @@ -42,8 +42,8 @@ Chef is interested in knowing how many ways he can choose the window. But since 5 4 579415965 - ### Explanation + In the first case we need calculate the number of rectangles which lie in triangle with vertices **(0; 0), (4; 0), (4; 8/3)**. There exist 5 such rectangles. Among them 3 have size **1 x 1**. One has size **2 x 1** and one have size **1 x 2**. In the second case we have two rectangles **2 x 2** and one rectangle **2 x 3** where we can choose middle horizontal segment in two ways. So we have in total 4 possible choices. diff --git a/_problems/hard/WIQ.md b/_problems/hard/WIQ.md index 4f07c0e9..429740b0 100644 --- a/_problems/hard/WIQ.md +++ b/_problems/hard/WIQ.md @@ -103,8 +103,8 @@ For each testcase, output a single line containing **n** integers, the i-th inte Output: 8 4 - ### Explanation + We will see what happens at every minute: - time = 1: The queue is (1, 2), and so the owner of Request 1 is checked as to whether he is ready or not. This checking process takes up this entire minute. He is not ready, because **b1** > time (2 > 1). So the queue now becomes (2, 1). diff --git a/_problems/hard/WRDSUM.md b/_problems/hard/WRDSUM.md index cb391918..8cb6464c 100644 --- a/_problems/hard/WRDSUM.md +++ b/_problems/hard/WRDSUM.md @@ -117,6 +117,6 @@ For each test case, output a single line containing one integer — the above su 7240 2741 382417086 - ### Explanation + **Example case 2.** **F(121) = 11**, thus the answer for this case is by eleven more than for the previous one. **Example case 3.** **F(122) = 122; F(123) = 123; F(124) = 124**, thus the answer for this case is **6866 + 122 + 123 + 124 = 7235**. **Example case 4.** **F(125) = 5**, thus the answer for this case is by five more than for the previous one. **Example case 5.** Here the actual sum is **998247094** that is equal to **2741** modulo **998244353**. **Example case 6.** This case corresponds to the last two subtasks, where the value of **N** doesn't fit into 64-bit integer. diff --git a/_problems/hard/WTHINGS.md b/_problems/hard/WTHINGS.md index f3a087dc..68db4a71 100644 --- a/_problems/hard/WTHINGS.md +++ b/_problems/hard/WTHINGS.md @@ -141,8 +141,8 @@ For each round of the game, output a single line containing the number of differ Output: 2 0 - ### Explanations + For the first query, **A** could be equal to both 2 and 3; For the second query, there are no possible variants for **A**. diff --git a/_problems/hard/XETF.md b/_problems/hard/XETF.md index 2f32ff7c..77678e15 100644 --- a/_problems/hard/XETF.md +++ b/_problems/hard/XETF.md @@ -79,12 +79,12 @@ For each test case, output a single line containing the answer to the problem i. Subtask 1 (7 points): - **1** ≤ **N** ≤ **104** -- ≤ **K** ≤ **104** +- 0 ≤ **K** ≤ **104** Subtask 2 (10 points): - **1** ≤ **N** ≤ **1012** -- **K** = +- **K** = 0 Subtask 3 (28 points): @@ -94,7 +94,7 @@ Subtask 3 (28 points): Subtask 4 (55 points): - **1** ≤ **N** ≤ **1012** -- ≤ **K** ≤ **256** +- 0 ≤ **K** ≤ **256** ### Example @@ -106,8 +106,8 @@ Subtask 4 (55 points): Output: 20 6 - ### Explanation + **Example case 1.** The numbers that are coprime to **10** are **1, 3, 7, 9**. Their sum is **20**. **Example case 2.** **7** is a prime number, so any integer that is less than **7** is coprime to it. diff --git a/_problems/hard/XORTREEH.md b/_problems/hard/XORTREEH.md index c230cfaa..5375546f 100644 --- a/_problems/hard/XORTREEH.md +++ b/_problems/hard/XORTREEH.md @@ -110,7 +110,7 @@ For each test case, output a line containing single integer representing the val - **1** ≤ **N** ≤ **105** - **2** ≤ **K** ≤ **10** - **2** ≤ **X** ≤ **1018** -- ≤ **Ai** ≤ **105** +- 0 ≤ **Ai** ≤ **105** ### Subtasks @@ -131,8 +131,8 @@ For each test case, output a line containing single integer representing the val Output: 87392358 88861416 - ### Explanation + **Example case 1:** Let's name the sub-sequences as A = \[\], B = \[1\], C = \[0\], D = \[2\], E = \[1, 0\], F = \[1, 2\], G = \[0, 2\], H = \[1, 0, 2\]. Possible outcome of xor values after selecting two sub-sequences (repetitions allowed): diff --git a/_problems/hard/XRMTRX.md b/_problems/hard/XRMTRX.md index e75c9ef9..2ebe7fe4 100644 --- a/_problems/hard/XRMTRX.md +++ b/_problems/hard/XRMTRX.md @@ -78,7 +78,7 @@ Every cell of this matrix has an integer written inside it. The cell at the inte Two cells are called adjacent if and only if they have a common side. That way every inner cell have **4** neighbors and any of four corner cells have **2** neighbors. -A walk is a sequence of cells **C0, C1, C2, ..., CK**, where for every **1** ≤ **i** ≤ **K** the cells **Ci-1** and **Ci** are adjacent and for every ≤ **j** ≤ **K** the number written inside cell **Cj** is equal **j**. The number **K** is the length of that walk. +A walk is a sequence of cells **C0, C1, C2, ..., CK**, where for every **1** ≤ **i** ≤ **K** the cells **Ci-1** and **Ci** are adjacent and for every 0 ≤ **j** ≤ **K** the number written inside cell **Cj** is equal **j**. The number **K** is the length of that walk. Your task is for given **L** and **R** values, find the maximal possible value of **K**, as well as the count **C** of different walks with that maximal length. As the value of **C** could be very large, output it modulo **(109 + 7)**. @@ -100,7 +100,7 @@ The value of **C** should be printed modulo **(109 + 7)**. ### Subtasks -- Subtask #1: **1** ≤ **T** ≤ **500**; ≤ **R - L** ≤ **300** (8 points) +- Subtask #1: **1** ≤ **T** ≤ **500**; 0 ≤ **R - L** ≤ **300** (8 points) - Subtask #2: original constraints, only the value of **K** will be checked. (24 points) - Subtask #3: original constraints (68 points) @@ -118,8 +118,8 @@ The value of **C** should be printed modulo **(109 + 7)**. 0 2 3 4 1 4 - ### Explanation + **Example case 1.** The matrix contains just one cell, so, there is no possibility to make a single move, thus **K = 0**. We have just one possibility - to start the walk at the only cell and to end it immediately. **Example case 2.** The matrix doesn't contains a cell with number one inside, so, there once again is no possibility to make a single move, thus **K = 0**. Our walk is just a single cell with number zero inside and there are two such cells, thus **C = 2**. The matrix in this case looks like this: @@ -127,13 +127,14 @@ The value of **C** should be printed modulo **(109 + 7)**.
 (1 xor 1)   (1 xor 2)          =          0 3
 (2 xor 1)   (2 xor 2)          =          3 0
-
 
**Example case 3.** The four possible walks are: +
0 3 2               0 3 2               0 3 2               0 3 2
 3 0 1               3 0 1               3 0 1               3 0 1
 2 1 0               2 1 0               2 1 0               2 1 0
 
 
**Example case 4.** The four possible walks are: +
0 1                   0 1                   0 1                   0 1
 1 0                   1 0                   1 0                   1 0
 
diff --git a/_problems/hard/XRQRS.md b/_problems/hard/XRQRS.md
index 650ea1f5..2b8e4deb 100644
--- a/_problems/hard/XRQRS.md
+++ b/_problems/hard/XRQRS.md
@@ -130,5 +130,4 @@ For each Query of type 1, 3 and 4 output the result in a single line.
 1
 8
 2
-
 
\ No newline at end of file diff --git a/_problems/hard/YASEQ.md b/_problems/hard/YASEQ.md index 21247aa4..8800ba2d 100644 --- a/_problems/hard/YASEQ.md +++ b/_problems/hard/YASEQ.md @@ -40,13 +40,13 @@ For each test case, output Q integers on a line, one per query, indicating the r 5 4 5 6 5 6 5 6 14 22 29 - ### Sample Output +
3 3 3 3
 3 4 4 5 3 4 4 4 4 4 4
 5 5 5 5
-
 
### Constraints + - T≤100 - 0Output:
2 - ### Explanation + In the example you should count **S**\[2..4\] = "BAC" and **S**\[4..6\] = "CAB". diff --git a/_problems/medium/ABX03.md b/_problems/medium/ABX03.md index ca2d78b9..c6fb9297 100644 --- a/_problems/medium/ABX03.md +++ b/_problems/medium/ABX03.md @@ -135,8 +135,8 @@ For each query, print the answer to it on a separate line. 6 0 - ### Explanation + For the first query, they will eat at the restaurant connecting halls 1 and 2; the cost of the meal there is 6. For the second query, 6 is a multiple of 3, but according to the second condition, the cost of this meal isn't between 3 and 5. Hence they will not eat at any restaurant. diff --git a/_problems/medium/ADDFRAC.md b/_problems/medium/ADDFRAC.md index d54a6f14..cd3411ce 100644 --- a/_problems/medium/ADDFRAC.md +++ b/_problems/medium/ADDFRAC.md @@ -35,8 +35,8 @@ For each test case, output N lines. The ith line contains the maximum fraction y 2/5 5/6 6/5 - ### Sample Output : +
 3/1
 7/2
@@ -48,11 +48,10 @@ For each test case, output N lines. The ith line contains the maximum fraction y
 13/16
 1/1
 6/5
-
 
### Constraints : +
 1 <= T <= 5
 1 <= n <= 100000
 1 <= a_k,b_k <= 100000
-
 
\ No newline at end of file diff --git a/_problems/medium/ADDMULT.md b/_problems/medium/ADDMULT.md index 14b9bc62..2efc024a 100644 --- a/_problems/medium/ADDMULT.md +++ b/_problems/medium/ADDMULT.md @@ -112,8 +112,8 @@ For each test case, output a single line containing who will win the game: "Chef Output: Chef Chefu - ### Explanation + **Test case 1:** The game stops as soon as it begins, because there is only one integer, and because it is even, Chef wins. **Test case 2:** Chef has 4 valid first moves: diff --git a/_problems/medium/AGENTS.md b/_problems/medium/AGENTS.md index 9c79b329..cffa6596 100644 --- a/_problems/medium/AGENTS.md +++ b/_problems/medium/AGENTS.md @@ -122,8 +122,8 @@ It's guaranteed that the correct polynomial **P(x)** is not a zero polynomial. 1 -1.5 2 - ### Explanation + In the sample case, we are given the following data: ![](/download/extimages/fb9f4d56106bc391ad1a5869cae0793d.png) diff --git a/_problems/medium/AHWORK.md b/_problems/medium/AHWORK.md index 7b2cbd6c..8074d52c 100644 --- a/_problems/medium/AHWORK.md +++ b/_problems/medium/AHWORK.md @@ -104,6 +104,6 @@ ab a b ba Output: 1 - ### Explanation + **Example case 1.** You need to delete strings either "a" or "b" (one of them), rest of the strings can be concatenated to form a palindrome, i.e. "abbba" and "ababa" respectively. diff --git a/_problems/medium/ALEXROSE.md b/_problems/medium/ALEXROSE.md index 4022e5b1..605df428 100644 --- a/_problems/medium/ALEXROSE.md +++ b/_problems/medium/ALEXROSE.md @@ -113,8 +113,8 @@ For each test case, output a single line containing the minimum number of roses 5 1 - ### Explanation + **Case 1:** Alexey cut two roses of length 5 to length 2 and get the first bouquet with each rose length being 2. The other roses with length 3,4,6 can be cut to length 1 and he gets the second bouquet in which each rose will be of length 1. **Case 2:** The last rose can be cut to length 1. There will be a bouquet with each rose of length 1. diff --git a/_problems/medium/ALOST.md b/_problems/medium/ALOST.md index de3f34af..e0d67655 100644 --- a/_problems/medium/ALOST.md +++ b/_problems/medium/ALOST.md @@ -89,7 +89,7 @@ Next day, he lost the original array. But he still remembered the **E** and **O* ### Constraints -- ≤ **E, O** ≤ **N\*(N+1)/2** +- 0 ≤ **E, O** ≤ **N\*(N+1)/2** - **E + O** = **N\*(N+1)/2** ### Subtasks @@ -112,8 +112,8 @@ Next day, he lost the original array. But he still remembered the **E** and **O* 2 1 2 1 2 2 -1 - ### Explanation + **Example case 1.** There are total 6 subarrays : {2},{1},{2},{2,1},{1,2},{2,1,2}. Their sums {2, 1, 2, 3, 3, 5} are respectively. As 2 of them are even and 4 of them are odd. So, this is one possible answer which satisfies Akhil's requirements. **Example case 3.** There is no array of length 3 whose all the subarrays have odd sum. Akhil might have remembered something incorrectly. Hence, you should print -1. diff --git a/_problems/medium/AMBALLS.md b/_problems/medium/AMBALLS.md index f096cd34..30cdab4a 100644 --- a/_problems/medium/AMBALLS.md +++ b/_problems/medium/AMBALLS.md @@ -101,8 +101,8 @@ For each test case, output an integer, denoting the number of ways that he arran Output: 1 10 - ### Explanation + **Example case 1**: There is only one way to arrange all balls as follows color-**2** color-**1** color-**2** diff --git a/_problems/medium/AMR15B.md b/_problems/medium/AMR15B.md index 7cc02929..2cfe0ed1 100644 --- a/_problems/medium/AMR15B.md +++ b/_problems/medium/AMR15B.md @@ -64,8 +64,8 @@ For each test case, output an single integer on a separate line denoting the ans 1 2 8 - ### Explanation + **For the first test case**, **N = 1**, and **A = \[1\]**. There are 2 possible subsets => **{}, {1}** and both have a gcd of 1. Hence, the answer is 1 \* 1 = **1**. **For the second test case**, **N = 2**, and **A = \[1, 2\]**. There are 4 possible subsets => **{}, {1}, {2}, {1, 2}**, having a gcd of 1, 1, 2 and 1 respectively. Hence, the answer is 1 \* 1 \* 2 \* 1 = **2**. diff --git a/_problems/medium/AMR15C.md b/_problems/medium/AMR15C.md index b62b5d8a..6cf2c453 100644 --- a/_problems/medium/AMR15C.md +++ b/_problems/medium/AMR15C.md @@ -92,7 +92,7 @@ For each test case, output a single line containing **N** space separated intege - **1** ≤ **T** ≤ **1000** - **1** ≤ **N** ≤ **105** -- ≤ **K** ≤ **N** +- 0 ≤ **K** ≤ **N** - The sum of **N** over all test cases in a single test file will not exceed **105** ### Example @@ -107,8 +107,8 @@ For each test case, output a single line containing **N** space separated intege -1 1 2 3 2 3 1 - ### Explanation + **For the first test case**, **N = 2** and **K = 2**. It is impossible to permute **\[1, 2\]** in any way such that **abs(P\[1\]-1) >= 2** and **abs(P\[2\]-2) >= 2**. Hence, output is **-1**. **For the second test case**, **N = 3** and **K = 0**. We can just set **P\[i\] = i**, and hence the answer is **1 2 3** diff --git a/_problems/medium/AMROOK.md b/_problems/medium/AMROOK.md index 50f41a6c..26113fc6 100644 --- a/_problems/medium/AMROOK.md +++ b/_problems/medium/AMROOK.md @@ -111,8 +111,8 @@ For each test case, output a single line containing the number of **valid** (see 8 11 - ### Explanation + **Test Case 1:** Chef has to place a single rook on a 2\*2 board. Of course the Sous Chef can always make sure that the rooks are not under attack from each other (since there is only 1). Hence the Chef cannot place the rook in any way in which the Sous Chef may not win. **Test Case 2:** There are 9 ways the chef can place the rooks initially. The ways that are marked in bold below are those in which the Sous Chef cannot win. The notation used below is simply the number of rooks placed on each of the 2\*2 cells. @@ -144,10 +144,9 @@ For each test case, output a single line containing the number of **valid** (see 0 0 0 2 - Note that the following way to place the rooks was invalid. +
 0 1
 1 0
-
 
\ No newline at end of file diff --git a/_problems/medium/AMSEQT.md b/_problems/medium/AMSEQT.md index c9c47088..e029bd8f 100644 --- a/_problems/medium/AMSEQT.md +++ b/_problems/medium/AMSEQT.md @@ -75,7 +75,7 @@ Chef has encrypted the super secret recipe for his bitsoup into a sequence of ** Chef is now transmitting this recipe to the Sous Chef. He **partitions the sequence** into several **disjoint**, **contiguous** groups and sends them one by one. Each partition may contain one or more integers which are contiguous in the sequence. Chef can partition a sequence of **N** integers in many ways, but the receiving program of the Sous Chef has a constraint. -For each group of integers it receives, let **S** represent the sum of the integers in the group. The receiver program only accepts the group of integers if the **Mth least significant bit** of **S** is . See the explanation section for clarity. +For each group of integers it receives, let **S** represent the sum of the integers in the group. The receiver program only accepts the group of integers if the **Mth least significant bit** of **S** is 0. See the explanation section for clarity. Chef wants to know how many ways exist to partition the recipe such that the Sous Chef can receive it completely. @@ -114,8 +114,8 @@ For each test case, output a single integer denoting the number ways you can par 0 3 - ### Explanation + **Test Case 1.** You can partition the sequence in 32 ways. Note that the sum of all the numbers in the sequence is 24. The 10th bit in 24 is already 0. Any partition's sum will be less than or equal to 24 anyway, thus each partitioning way is valid. Thus the answer is 32. If you don't see why the answer is 32, consider the following diff --git a/_problems/medium/AMSTRING.md b/_problems/medium/AMSTRING.md index 6e2b16c4..2c65fba9 100644 --- a/_problems/medium/AMSTRING.md +++ b/_problems/medium/AMSTRING.md @@ -110,8 +110,8 @@ a 14 13 1 - ### Explanation + **Example case 1**: There are **14** fours as following: **(1, 1, 1, 1) : dist(A\[1, 1\], B\[1, 1\]) = dist(a, a) = 0 ≤ 2** **(1, 1, 2, 2) : dist(A\[1, 1\], B\[2, 2\]) = dist(a, b) = 1 ≤ 2** diff --git a/_problems/medium/AMXOR.md b/_problems/medium/AMXOR.md index 12d15216..484a1d31 100644 --- a/_problems/medium/AMXOR.md +++ b/_problems/medium/AMXOR.md @@ -112,8 +112,8 @@ For each test case, output a single line containing the number of ways your frie 16 6 - ### Explanation + **Test Case 1:** The only possible sequence is **{ 5 }**. **Test Case 2:** There are 4 possible sequences whose bitwise xor is equal to 3^3 = 0 diff --git a/_problems/medium/ANCESTOR.md b/_problems/medium/ANCESTOR.md index 469c63ee..53f13d73 100644 --- a/_problems/medium/ANCESTOR.md +++ b/_problems/medium/ANCESTOR.md @@ -106,8 +106,8 @@ For each test case, output a single line containing **N** integers, i-th integer Output: 0 1 1 2 1 - ### Explanation + Because node 1 is the root in both the trees, there is no node above them. So first output is 0. Node 1 is the only node which is an ancestor of Node 2 in both the trees. So the second output is 1. diff --git a/_problems/medium/ANCOIMP.md b/_problems/medium/ANCOIMP.md index 124fe550..bf2b528d 100644 --- a/_problems/medium/ANCOIMP.md +++ b/_problems/medium/ANCOIMP.md @@ -75,7 +75,7 @@ He defines **A → B** to be a matrix **C** such that **Cij = Aij → Bij** and Now Chef wants to study such system of equations: **A → X = ¬ O** and **X → A = O** - Where **O** is matrix such that all its entries is . + Where **O** is matrix such that all its entries is 0. However, Chef realized that such system has solution if and only if **A = O**. Since such solution is too trivial, Chef has decided to search for an approximate solution for arbitrary **A**. Thus, Chef is searching for such **X** that **A → X = ¬ O** and **X → A** has as much as possible entries which are equal to 0. But the solution space turned to be very large, so he reduced it to a matrices of a special form. Now he is looking for **X** such that **Xij = yi xor yj** for some boolean vector **y**. Since now **X** is symmetric, Chef restricts **A** to also be symmetric. @@ -97,7 +97,7 @@ It's guaranteed that **A** is symmetric. ### Constraints and Subtasks -- ≤ **Aij** ≤ **1** +- 0 ≤ **Aij** ≤ **1** **Subtask 1: (15 points)** @@ -136,8 +136,8 @@ It's guaranteed that **A** is symmetric. 0 0 1 1 -1 0 1 - ### Explanation + **Example case 1.** Matrix which is determined by vector y is @@ -147,14 +147,14 @@ Matrix which is determined by vector y is 0 0 1 1 1 1 0 0 1 1 0 0 - - Then **A → X = ¬ O** and **X → A** is + +Then **A → X = ¬ O** and **X → A** is
 1 1 0 1
 1 1 0 1
 0 0 1 1
 1 1 1 1
-
 
**Example case 2.** + **A11 = 1** and **X11 = y1 xor y1 = 0**. So **A11 → X11 = 0** and condition **A → X = ¬ O** can not be satisfied. diff --git a/_problems/medium/AND.md b/_problems/medium/AND.md index f84d69c6..40127981 100644 --- a/_problems/medium/AND.md +++ b/_problems/medium/AND.md @@ -90,8 +90,8 @@ Output the answer to the problem on the first line of the output. Output: 9 - ### Scoring + Subtask 1 (13 points): **N** <= 1000, **Ai** <= 1. Subtask 2 (39 points): **N** <= 1000, **Ai** <= 109. diff --git a/_problems/medium/ANDGRAPH.md b/_problems/medium/ANDGRAPH.md index 00ba90ea..2f60768c 100644 --- a/_problems/medium/ANDGRAPH.md +++ b/_problems/medium/ANDGRAPH.md @@ -105,6 +105,6 @@ For each test case, output a single line containing one integer ― the number o 1 0 2 - ### Explanation + **Example case 1:** There is a direct edge from vertex 1 to vertex 2 and this is the only path between these two vertices. **Example case 2:** Vertex 3 contains only one incoming edge in graph **G** and this edge is from vertex 0, but as there are no path from vertex 1 to vertex 0, thus there are no paths to vertex 3 as well. **Example case 3:** The two paths are: 1 → 2 → 4 and 1 → 4. diff --git a/_problems/medium/ANDMIN.md b/_problems/medium/ANDMIN.md index 52abaf2c..9ed8d00f 100644 --- a/_problems/medium/ANDMIN.md +++ b/_problems/medium/ANDMIN.md @@ -88,7 +88,7 @@ In the next **Q** lines, each contain one of the queries described above. ### Output -For each query of the type , output a single line containing the answer of the query. +For each query of the type 0, output a single line containing the answer of the query. ### Constraints @@ -111,5 +111,4 @@ For each query of the type , output a single line containing the answer of the q 2 4 0 - \ No newline at end of file diff --git a/_problems/medium/ANDOOR.md b/_problems/medium/ANDOOR.md index 244ad7fb..cd82496e 100644 --- a/_problems/medium/ANDOOR.md +++ b/_problems/medium/ANDOOR.md @@ -90,8 +90,8 @@ For each test case, output a single line containing the sum of the perimeters of - **1** ≤ **H** ≤ **1000** - **1** ≤ **N** ≤ **1000** - The sum of all values of **N** over the input does not exceed **5000** -- < **R** ≤ **1000** -- ≤ **X**, **Y** ≤ **1000** +- 0 < **R** ≤ **1000** +- 0 ≤ **X**, **Y** ≤ **1000** - **X**, **Y**, **R** have exactly two digits after the decimal point - All circles are different, that is, every two circles have either different radii or different centers (or both) @@ -116,8 +116,8 @@ For each test case, output a single line containing the sum of the perimeters of Output: 33.6404284 17.2058395 - ### Explanation + **Example case 1.** The answer is the length of the bold lines on the following picture: ![](http://www.codechef.com/download/ANDOOR_Ex2.jpg) diff --git a/_problems/medium/ANDTUPLE.md b/_problems/medium/ANDTUPLE.md index c69dc293..404ca723 100644 --- a/_problems/medium/ANDTUPLE.md +++ b/_problems/medium/ANDTUPLE.md @@ -88,7 +88,7 @@ For each testcase, print a single line containing the answer. Since the number c ### Constraints -``11. **For 20 points:** 1 ≤ T ≤ 10000, K = 3, 1 ≤ N ≤ 1018 +
11. **For 20 points:** 1 ≤ T ≤ 10000, K = 3, 1 ≤ N ≤ 1018
 12. **For 80 points:** 1 ≤ T ≤ 10000, 3 ≤ K ≤ 4, 1 ≤ N ≤ 1018
 ### Example
 
diff --git a/_problems/medium/ANKINTER.md b/_problems/medium/ANKINTER.md
index 37f10821..bc951ed6 100644
--- a/_problems/medium/ANKINTER.md
+++ b/_problems/medium/ANKINTER.md
@@ -106,13 +106,13 @@ You should output exactly **T** lines each containing answer for corresponding t
 2 3 1
 6 3
 6 1 5 3 4 2 
-
 **Output:**
+
 
 5
 5  
-
 
### Explanation + **Example case #1:** The following **5** subarrays form an interval: diff --git a/_problems/medium/ANKLEX.md b/_problems/medium/ANKLEX.md index 59e08019..22f4ecfc 100644 --- a/_problems/medium/ANKLEX.md +++ b/_problems/medium/ANKLEX.md @@ -107,15 +107,15 @@ abcb 2 3 2 2 - **Output:** +
 2
 2
 -1
 3
-
 
### Explanation + **Request 1:** The last written substring was **a**, so the next substring should be **b**, which is present at index 2 as well as index 4. However, we should print 2 as it is the smaller index. diff --git a/_problems/medium/ANKMARKS.md b/_problems/medium/ANKMARKS.md index b4510e9d..42a5c31c 100644 --- a/_problems/medium/ANKMARKS.md +++ b/_problems/medium/ANKMARKS.md @@ -118,13 +118,13 @@ Output exactly **T** lines, each containing the answer for the corresponding tes 3 2 4 8 - **Sample Output:** +
 2.333333
 1.000000
-
 
**Explanation:** + **Test 1:** Award 0 to student 1, 2 to student 2 and 5 to student 3. Total score of the class = 7 diff --git a/_problems/medium/ANKNIM2.md b/_problems/medium/ANKNIM2.md index 63e2ec0d..1caf21e9 100644 --- a/_problems/medium/ANKNIM2.md +++ b/_problems/medium/ANKNIM2.md @@ -107,15 +107,14 @@ Output the results of each test case on a new line. For each test case, output t 4 1 1 1 1 - **Sample Output:** +
 0 0 3 0 0 1
 0 3 0 1
 
-
 
**Explanation** +
 For the first test case and m = 3, required sub-arrays are [1,2,3], [3,2,1] and [2,1,3].
-
 
\ No newline at end of file diff --git a/_problems/medium/ANUAHR.md b/_problems/medium/ANUAHR.md index c2daa5ab..6786e1c6 100644 --- a/_problems/medium/ANUAHR.md +++ b/_problems/medium/ANUAHR.md @@ -94,7 +94,7 @@ For each test case, output a single line containing the required answer. - **1** ≤ **T** ≤ **105** - **1** ≤ **N** ≤ **105** -- ≤ **M** ≤ **N** +- 0 ≤ **M** ≤ **N** - **1** ≤ **Rectangle Dimensions** ≤ **109** - **1** ≤ **Sum of N over all test cases** ≤ **106** @@ -115,8 +115,8 @@ For each test case, output a single line containing the required answer. 100 25 4 - ### Explanation + **Example case 1** Abhijeet has only one rectangle. He can remove it, but then the area will be 0. Optimal way is not to remove it. Area = 10 \* 10 = 100 diff --git a/_problems/medium/ANUBGC.md b/_problems/medium/ANUBGC.md index ecda9244..2773623e 100644 --- a/_problems/medium/ANUBGC.md +++ b/_problems/medium/ANUBGC.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in Chef gives you a book with **N** pages. The pages are numbered from **1** to **N**. -Chef randomly selects a **Secret Digit** from to **9**. Now he asks you to open one page of the book without looking at the book. You win the game if that page number contains the **Secret Digit**. For example if the **Secret Digit** is 8, then 8, 80, 1238213, 98 are all winning pages and 9, 90, 1239123 are loosing pages. +Chef randomly selects a **Secret Digit** from 0 to **9**. Now he asks you to open one page of the book without looking at the book. You win the game if that page number contains the **Secret Digit**. For example if the **Secret Digit** is 8, then 8, 80, 1238213, 98 are all winning pages and 9, 90, 1239123 are loosing pages. What is the probability of winning, if both Chef's choice and your choice has uniform distribution? @@ -103,6 +103,6 @@ For each test case, output the required probability **P/Q**. **P/Q** is an irred Output: 1/10 1/10 - ### Explanation -Chef can choose any **Secret Digit** from to **9**. But you can only open page with number **1**. Probability that the **Secret Digit** is **1** after you opened the page with number **1** is **1/10**. + +Chef can choose any **Secret Digit** from 0 to **9**. But you can only open page with number **1**. Probability that the **Secret Digit** is **1** after you opened the page with number **1** is **1/10**. diff --git a/_problems/medium/ANUBTT.md b/_problems/medium/ANUBTT.md index 92f35e1c..01f353e1 100644 --- a/_problems/medium/ANUBTT.md +++ b/_problems/medium/ANUBTT.md @@ -113,8 +113,8 @@ For each query, output a single line containing the minimal total cost to add al Output: 40 6 - ### Explanation + **Query 1.** Optimal solution is to add the first node from the query to node 1 of the tree and the second node from the query to node 2 of the tree. Cost is 10\*2 + 10\*2. diff --git a/_problems/medium/ANUCBC.md b/_problems/medium/ANUCBC.md index 10780ad3..85b0d395 100644 --- a/_problems/medium/ANUCBC.md +++ b/_problems/medium/ANUCBC.md @@ -108,8 +108,8 @@ For each query output the required Answer modulo **1000000009**. Answer is the n 4 8 2 - ### Explanation + **Test Case #1, Query #1** {}, {1,-1}, {1,-1,4,5}, {4,5} are winning subsets. Sums are 0, 0, 9, 9 respectively. diff --git a/_problems/medium/ANUGCD.md b/_problems/medium/ANUGCD.md index 4b9b0746..cf36cc32 100644 --- a/_problems/medium/ANUGCD.md +++ b/_problems/medium/ANUGCD.md @@ -112,8 +112,8 @@ For each query output the required Answer. 3 1 5 1 4 2 - ### Explanation + **Query #1** GCD(2,1)=1, GCD(2,2)=2, GCD(2,3)=1, GCD(2,4)=2, GCD(2,5)=1 diff --git a/_problems/medium/ANUMLA.md b/_problems/medium/ANUMLA.md index 2f1459ba..31badd50 100644 --- a/_problems/medium/ANUMLA.md +++ b/_problems/medium/ANUMLA.md @@ -88,7 +88,7 @@ For each test case, output one line with **N** space separated integers in non-d - **1** ≤ **T** ≤ **50** - **1** ≤ **N** ≤ **15** -- ≤ **Values on paper** ≤ **10^9** +- 0 ≤ **Values on paper** ≤ **10^9** - **All input values are valid. A solution always exists** ### Example @@ -103,7 +103,7 @@ For each test case, output one line with **N** space separated integers in non-d Output 10 1 1 - ### Explanation + **Test case #2** For the array \[1,1\], possible subsets are {}, {1}, {1}, {1,1}, respective sums are 0, 1, 1, 2. diff --git a/_problems/medium/ANURRZ.md b/_problems/medium/ANURRZ.md index b89ec000..5d69ab2b 100644 --- a/_problems/medium/ANURRZ.md +++ b/_problems/medium/ANURRZ.md @@ -108,8 +108,8 @@ For each test case, output a single line containing the required answer modulo 1 Output: 2 1 - ### Explanation + **Test case 1** {1, 1} and {1, 2} are valid. diff --git a/_problems/medium/ANUTDP.md b/_problems/medium/ANUTDP.md index 7e08edf2..32aca020 100644 --- a/_problems/medium/ANUTDP.md +++ b/_problems/medium/ANUTDP.md @@ -101,7 +101,7 @@ For example, "..##.." represents 6 coordinates, (0, 0) (1, 0) .. (5.0) out of wh ### Constraints - **1** ≤ **T** ≤ **10^5** -- ≤ **L** ≤ **R** ≤ **10^8** +- 0 ≤ **L** ≤ **R** ≤ **10^8** - **1** ≤ **N** ≤ **10^5** ### Example @@ -118,8 +118,8 @@ For example, "..##.." represents 6 coordinates, (0, 0) (1, 0) .. (5.0) out of wh 9 ....#.... 3 .... -1 - ### Explanation + **Testcase #1** Good numbers in range \[1,3\] are 1, 2, 3. 1st of those is 1. There is one way to reach (0, 0) from (0, 0). diff --git a/_problems/medium/ARIGEOM.md b/_problems/medium/ARIGEOM.md index e276eca4..d7d254da 100644 --- a/_problems/medium/ARIGEOM.md +++ b/_problems/medium/ARIGEOM.md @@ -108,4 +108,5 @@ It is guaranteed that at least one pair of valid beat notations exists. 2 5 8 11

2 4 8 16

1 2 3 4 5

1 2 4

1 10 19 28

1 3 9 27 81

1 7 13

4 10 25



/>/>/>/>/>/>/>/>/>/>/>/>/>/>/>/>/>/> ### Note + In last example, the common ratio is 2.5 (**non-integer**) even when all the elements of geometric progression sequence are integers. diff --git a/_problems/medium/ARITHPR.md b/_problems/medium/ARITHPR.md index 389bc53a..64477159 100644 --- a/_problems/medium/ARITHPR.md +++ b/_problems/medium/ARITHPR.md @@ -36,5 +36,4 @@ You are given positive integers **L, R, k** such that **k <= R - L**. Consider a 3 2 4 3 0 0 4 5 14 - \ No newline at end of file diff --git a/_problems/medium/ARRAYTRM.md b/_problems/medium/ARRAYTRM.md index 9e09f848..77b69c75 100644 --- a/_problems/medium/ARRAYTRM.md +++ b/_problems/medium/ARRAYTRM.md @@ -31,19 +31,16 @@ Sample Input : 3 2 1 2 3 -
 Sample Output :
 YES
 YES
 NO
 
-
 
 Constraints :
 1 <= T <= 1000
 2 <= n <= 100
 1 <= K <= 10
 0 <= a_i <= 1000
-
 
\ No newline at end of file diff --git a/_problems/medium/ASHIGIFT.md b/_problems/medium/ASHIGIFT.md index 67c6f065..7cb10b8a 100644 --- a/_problems/medium/ASHIGIFT.md +++ b/_problems/medium/ASHIGIFT.md @@ -128,8 +128,8 @@ For each test case, print the minimum size of the group (including Chef) that is 5 9 6 - ### Explanation + **Example case 1.** In the first case, there are no tribal clans, and two dishes, one which needs to be eaten by 3 chefs on their way and one to be eaten by 1 chef. Hence, we have to start with atleast 5 people in total to pass _the path of tasty dishes_. **Example case 2.** Similar as Example Case 1. diff --git a/_problems/medium/AX.md b/_problems/medium/AX.md index 48e1a6ea..9e90e998 100644 --- a/_problems/medium/AX.md +++ b/_problems/medium/AX.md @@ -79,6 +79,7 @@ For example, if n=3, the mine "\*" placed on the square at position (1,1) will d ####.... ### Input + The first line will contain integer 8nn is the size of the area). The second line will contain 0n, the number of already planted mines. The next m lines will contain the 0-based x and y coordinates of the existing mines. ### Output @@ -99,6 +100,6 @@ For each test case, you will receive (2n-m)/t-1 points, provided you destroy all 2 0 1 2 2 - You will receive (4-1)/2 - 1 = 0.5 pts for such a mine placement. + **Note:**There will be some tests with no initially placed mines, and some tests with initial placements covering most of the area pretty well. Good luck! diff --git a/_problems/medium/B1.md b/_problems/medium/B1.md index a5d8c707..a8e67e77 100644 --- a/_problems/medium/B1.md +++ b/_problems/medium/B1.md @@ -50,8 +50,8 @@ D...D Output: 2 - ### Example 2 +
 
 Input:
@@ -67,5 +67,4 @@ DDDDD
 Output:
 0
 
-
 
\ No newline at end of file diff --git a/_problems/medium/B3.md b/_problems/medium/B3.md index 019517bd..085fbf9d 100644 --- a/_problems/medium/B3.md +++ b/_problems/medium/B3.md @@ -45,5 +45,4 @@ For each test case, output the number of the enemy battleship's guns that your c Output 2 - \ No newline at end of file diff --git a/_problems/medium/B5.md b/_problems/medium/B5.md index b1c1a12e..ae58cac1 100644 --- a/_problems/medium/B5.md +++ b/_problems/medium/B5.md @@ -37,5 +37,4 @@ You should output n-k+1 rows with n-k+1 numbers in each row. 0 1 2 4 0 0 2 0 0 - \ No newline at end of file diff --git a/_problems/medium/BAKE.md b/_problems/medium/BAKE.md index 218889db..b88ed092 100644 --- a/_problems/medium/BAKE.md +++ b/_problems/medium/BAKE.md @@ -49,8 +49,8 @@ Q 2 4.1 F 37 95 0 - **Sample I/O Explanation** + For the first query at the 4th line of input, only the first input is relevant as the the second input has location specification as 4.1 whereas in the query it is 2. Location specification 2 includes all the cities in the province 2 such as 2.1 whic is the case with the first input. Hence the solution is 22. For the query specification on the second last line, it only includes the first 2 inputs as the third input mismatches with the query w.r.t the location and sex specification. diff --git a/_problems/medium/BALANCED.md b/_problems/medium/BALANCED.md index 005d8918..40bbf3d5 100644 --- a/_problems/medium/BALANCED.md +++ b/_problems/medium/BALANCED.md @@ -44,8 +44,8 @@ The placement P described by this string should minimize the maximum of dS(P) an Output: ABA AABB - ### Explanation of Sample Data + In the first test case, following the first permutation 1 0 2 results in the sequence of objects being BAA while following the second permutation results in the sequence of objects being ABA. In either case, the maximum difference between the number of As seen and the number of Bs seen over the whole trip is at most 1. In the second test case, following permutation 0 2 1 3 results in the sequence being ABAB wherease following permutation 1 2 3 0 results in the sequence being ABBA. Again, the maximum difference in either case is at most 1. diff --git a/_problems/medium/BALANPOL.md b/_problems/medium/BALANPOL.md index 6931fe01..d0c4a476 100644 --- a/_problems/medium/BALANPOL.md +++ b/_problems/medium/BALANPOL.md @@ -149,6 +149,6 @@ For each test case, output a single integer corresponding to the number of _w00t Output: 1 10 - ### Explanation + **Example case 1.** The entire rectangle is _w00t_. diff --git a/_problems/medium/BBSYSTEM.md b/_problems/medium/BBSYSTEM.md index df099575..7170cfe9 100644 --- a/_problems/medium/BBSYSTEM.md +++ b/_problems/medium/BBSYSTEM.md @@ -42,15 +42,18 @@ For each test case, print the number of combinations modulo 500009 (5\*105+9). 5 100 ### Sample Output +
1
 5
 43264
 
### Output details + In the first case, the valid combination is
Box: 123
 Ball: 132
 
since the number of divisors of 2 is equal to the number of divisors of 3. + In the second case, the valid combinations are
Box: 12345 12345 12345 12345 12345
diff --git a/_problems/medium/BCYCLES.md b/_problems/medium/BCYCLES.md
index b8ab02a8..100453eb 100644
--- a/_problems/medium/BCYCLES.md
+++ b/_problems/medium/BCYCLES.md
@@ -115,8 +115,8 @@ In the next **C** lines describe one cycle per line: the i-th line should contai
 6 3 6 2 5 1 4
 6 3 5 2 4 1 6
 6 3 5 1 6 2 4
-
 
### Explanation + The following image depicts the three cycles in the output of the sample case. Note that for every edge in the original graph, there are two cycles that contain it. ![](https://codechef_shared.s3.amazonaws.com/download/upload/SNCKFL17/1.png) diff --git a/_problems/medium/BEAUTY.md b/_problems/medium/BEAUTY.md index 0f173bf4..cb9b33c2 100644 --- a/_problems/medium/BEAUTY.md +++ b/_problems/medium/BEAUTY.md @@ -117,8 +117,8 @@ ac Output: 8 2 - ### Explanation + **First** judge is allergic to ingredient denoted by 'b'. So Chef has to remove this ingredient from the judge's sandwich. After that, the sandwich will be "acaada". Its beauty will be 1\*1 + 1\*1 + 2\*2 + 1\*1 + 1\*1 = 8 **Second** judge is allergic to ingredients denoted by characters 'a' and 'c'. After removing these ingredients, the sandwich will become "bd" and its beauty will be 2. diff --git a/_problems/medium/BESTSUM.md b/_problems/medium/BESTSUM.md index 38731e3d..bd80057d 100644 --- a/_problems/medium/BESTSUM.md +++ b/_problems/medium/BESTSUM.md @@ -20,8 +20,8 @@ For example, consider the following sequence of integers:
     12     13     15     11     16     26     11
 
-
 
Here _N_ = 7. Suppose _K_ = 2 and _P_ = 17. Then, the answer is 2 because 11+16+26 = 53 and 53 mod 17 is 2. On the other hand, if _K_ = 0 the answer is 0 since 15 + 11 + 16 + 26 = 68 and 68 mod 17 is 0. + Input format The first line contains three integers _N_, _K_ and _P_. This is followed by _N_ lines each containing a single integer. @@ -45,9 +45,8 @@ Sample Input 16 26 11 - Sample Output +
 2
-
 
\ No newline at end of file diff --git a/_problems/medium/BICO.md b/_problems/medium/BICO.md index 1ab6fb29..ec00eb53 100644 --- a/_problems/medium/BICO.md +++ b/_problems/medium/BICO.md @@ -73,13 +73,13 @@ All submissions for this problem are available.### Read problems statements in The much anticipated video game "BiCo Grid" has been released. The rules of "Bico Grid" are very simple. -The game field is a 100x100 matrix, where each cell is either a blocked cell, or a cell with some number of coins. For a regular player the look of the field seems pretty random, but the programmer in you recognizes the following pattern: the **i**-th cell on the **n**-th row contains **C(n, i)** coins if and only if ≤ **i** ≤ **n**, all other cells are blocked. Record **C(n, i)** denotes binomial coefficient "**n** choose **i**". +The game field is a 100x100 matrix, where each cell is either a blocked cell, or a cell with some number of coins. For a regular player the look of the field seems pretty random, but the programmer in you recognizes the following pattern: the **i**-th cell on the **n**-th row contains **C(n, i)** coins if and only if 0 ≤ **i** ≤ **n**, all other cells are blocked. Record **C(n, i)** denotes binomial coefficient "**n** choose **i**". The player starts from the cell situated at row **R** and column **C** in the matrix. The objective is to collect **exactly G** number of coins from matrix in several moves. There are some rules: - On each move the player must collect all the coins from some unblocked cell in the current column. - The rules of the game state, that player mustn't be really greedy, so the number of coins he collected must not increase. In other words, if at some move the player collected **X** coins then further he cannot collect more than **X** coins in a single move. -- After each move, the player is immediately moved to some cell of the column **W-1** (where **W** denotes the current column of the player). If the current column of the player has index , the game ends. +- After each move, the player is immediately moved to some cell of the column **W-1** (where **W** denotes the current column of the player). If the current column of the player has index 0, the game ends. - The game ends when player collects **exactly G** number of coins. You are given the description of the game. Please, output the sequence of moves that win the game (collect exactly **G** coins)! It is guaranteed that if the player will play optimally it is possible to win the game. @@ -116,8 +116,8 @@ It is guaranteed that a solution exists. And if there are multiple solutions, pr 10 3 5 1 1 - ### Explanation + **Example case 1.** We first pick 3 coins from \[3, 2\] then we pick 2 coins from \[2, 1\] **Example case 2.** As 3rd column contains 10 coins in cell \[5, 3\] we pick it. **Example case 3.** We first pick 5 coins from \[5, 4\] then we pick 1 coin from \[3, 3\] and again we pick 1 coin from \[2, 2\]./>/> diff --git a/_problems/medium/BINTREEQ.md b/_problems/medium/BINTREEQ.md index 1a58d0f2..309b313f 100644 --- a/_problems/medium/BINTREEQ.md +++ b/_problems/medium/BINTREEQ.md @@ -122,8 +122,8 @@ For each query, print the answer on a separate line. 2 10 1 - ### Explanation + In the first query from the example test case, you should count pairs (**5, 7**) and (**9, 11**). In the second query from the example test case, you should count the following pairs: (**1, 1**), (**2, 2**), (**3, 3**), (**4, 4**), (**5, 5**), (**6, 6**), (**7, 7**), (**8, 8**), (**9, 9**) and (**10, 10**). diff --git a/_problems/medium/BIPARTRE.md b/_problems/medium/BIPARTRE.md index 73155b62..8e02c633 100644 --- a/_problems/medium/BIPARTRE.md +++ b/_problems/medium/BIPARTRE.md @@ -123,8 +123,8 @@ You need to compute the size of the maximum matching in G. Output: 6 - ### Explanation + The left bipartition of G contains 8 vertices: l1, l2, ..., l8 and the right bipartition contains 12: r1, r2, ..., r12. Some of the edges of this bipartite graph are: (l1, r7), (l1, r6), (l2, r7), (l2, r6), (l3, r6), (l3, r11), (l4, r8), (l4, r7), (l4, r6), (l4, r11). There are more edges. diff --git a/_problems/medium/BLOCKING.md b/_problems/medium/BLOCKING.md index 5eaa9458..58dfa953 100644 --- a/_problems/medium/BLOCKING.md +++ b/_problems/medium/BLOCKING.md @@ -83,5 +83,4 @@ If there exists a sequence **block** that satisfies the constraints, then output Output: 3 2 1 - \ No newline at end of file diff --git a/_problems/medium/BMASTER.md b/_problems/medium/BMASTER.md index 994e38db..eba19ca9 100644 --- a/_problems/medium/BMASTER.md +++ b/_problems/medium/BMASTER.md @@ -101,7 +101,7 @@ At the beginning of the game the only Blade Master's image stands on some starti **3.** Whenever there is more than one image at the cell they start one on one fights. In each fight two images participate and both die. So if the number of images in the cell was even than all images will disappear in the end, otherwise exactly one image will remain at this cell. -Now Maelk wants to choose his hero in order to win the fight. The most important thing he needs to know for this is how the number of images changes during Loda's moves. So he asks you for help. Denote by **C(t)** the number of images on the grid after the **t**-th Loda's move for **t** from **1** to **T**. For convenience we denote **C(0) = 1** with meaning that -th move is the putting of the only Blade Master's image at the starting cell. Maelk wants you to calculate the sum **C(0) + C(1) + ... + C(T)**. Since Maelk doesn't know what to expect from Loda he would like to know the answer for several values of **T**. As you remember the total number of games played by Maelk and Loda at ChefCraft doesn't fit in a standard 32-bit integer type. Of course, the same can hold for the number of moves in their final fight. Since Maelk plays ChefCraft the whole life he is not strong in math and can't calculate such large sums. So let's help him to win the final fight and become the only ChefCraft master ever. +Now Maelk wants to choose his hero in order to win the fight. The most important thing he needs to know for this is how the number of images changes during Loda's moves. So he asks you for help. Denote by **C(t)** the number of images on the grid after the **t**-th Loda's move for **t** from **1** to **T**. For convenience we denote **C(0) = 1** with meaning that 0-th move is the putting of the only Blade Master's image at the starting cell. Maelk wants you to calculate the sum **C(0) + C(1) + ... + C(T)**. Since Maelk doesn't know what to expect from Loda he would like to know the answer for several values of **T**. As you remember the total number of games played by Maelk and Loda at ChefCraft doesn't fit in a standard 32-bit integer type. Of course, the same can hold for the number of moves in their final fight. Since Maelk plays ChefCraft the whole life he is not strong in math and can't calculate such large sums. So let's help him to win the final fight and become the only ChefCraft master ever. ### Input @@ -141,8 +141,8 @@ For every Maelk's query output on a separate line the numbers of images Maelk wi 4 12 17 - ### Explanation + The initial grid looks as follows: 100 000 diff --git a/_problems/medium/BOMBING.md b/_problems/medium/BOMBING.md index 6a48b58f..99642adf 100644 --- a/_problems/medium/BOMBING.md +++ b/_problems/medium/BOMBING.md @@ -40,5 +40,4 @@ B 3 Output: 2 1 - \ No newline at end of file diff --git a/_problems/medium/BRIBETR.md b/_problems/medium/BRIBETR.md index 0919ae88..7b844c39 100644 --- a/_problems/medium/BRIBETR.md +++ b/_problems/medium/BRIBETR.md @@ -127,6 +127,7 @@ For each test case, output a single line containing one integer — the minimum 4 -1 ### Explanation + **Test case 1.** We are given **H** = 2 so there are N = 4 bears in the tournament. Limak has strength 70 and he first fights against a bear with strength 78. Limak must bribe this referee because he would lose otherwise. In the other match of the first stage, bears with strengths 67 and 75 fight with each other. Limak can bribe the referee of that match too, so that the bear with strength 67 advances to the next stage, where Limak beats him without bribing the referee (because Limak's strength is greater). The answer is 2 because Limak changes results of 2 matches, and you can verify that this is the minimum. One other optimal strategy is to allow the bear with strength 75 to win his first match. Then Limak fights with that bear in the second stage and he can bribe the referee to win. diff --git a/_problems/medium/BRKTREE.md b/_problems/medium/BRKTREE.md index 9fb30545..e9ba1dac 100644 --- a/_problems/medium/BRKTREE.md +++ b/_problems/medium/BRKTREE.md @@ -61,7 +61,7 @@ For each query output "Yes" or "No" in a new line(without quotes). ### Constrain No No Yes - - ```### Explanation + ``` + ### Explanation **Example case 1.** For the first query the answer is "Yes" because the edge between 5 and 6 can be removed. For the second query, it is not possible to remove an edge and get a difference of 27. diff --git a/_problems/medium/BUTTONS.md b/_problems/medium/BUTTONS.md index e74d2b39..d73d4fd0 100644 --- a/_problems/medium/BUTTONS.md +++ b/_problems/medium/BUTTONS.md @@ -44,5 +44,4 @@ Output "-1" if it is impossible to achieve the final configuration from the init 0 1 2 - \ No newline at end of file diff --git a/_problems/medium/BUYING.md b/_problems/medium/BUYING.md index ad1b5c94..bb24ddbb 100644 --- a/_problems/medium/BUYING.md +++ b/_problems/medium/BUYING.md @@ -42,6 +42,6 @@ For each test case, output just one line containing the smallest possible total -1 Explanation: - In the first test case, it's impossible to buy one candy per friend as three smallest packs contain 6 candies all together. Two candies per friend is possible though -- for example, if you buy packs with 1, 4 and 5 candies. + In the second test case, buying 3 packs implies buying an odd number of candies, which is impossible to distribute equally among 4 friends. diff --git a/_problems/medium/C2.md b/_problems/medium/C2.md index 018573f8..5352fcb4 100644 --- a/_problems/medium/C2.md +++ b/_problems/medium/C2.md @@ -30,11 +30,10 @@ For input: 10 2 1000000 10 3 1000000 10 4 1000000 - the correct output is: +
55
 385
 3025
 25333
-
 
\ No newline at end of file diff --git a/_problems/medium/C3.md b/_problems/medium/C3.md index 4fdec369..316e2733 100644 --- a/_problems/medium/C3.md +++ b/_problems/medium/C3.md @@ -34,5 +34,4 @@ For each test case, output the required answer modulo 531169. Output: 4 - -Explanation: the 4 words from the example are: '0011','1100','0110','1001'. \ No newline at end of file +Explanation: the 4 words from the example are: '0011','1100','0110','1001'. diff --git a/_problems/medium/C5.md b/_problems/medium/C5.md index 04253621..7b71c20f 100644 --- a/_problems/medium/C5.md +++ b/_problems/medium/C5.md @@ -35,7 +35,7 @@ For the input: 2 3 1 4 0 6 10 3 4 1 0 0 - -the unique correct answer is: 2 +the unique correct answer is: ``` +2 3 4
\ No newline at end of file
diff --git a/_problems/medium/CAKECUT.md b/_problems/medium/CAKECUT.md
index e894873a..b5cd8e0c 100644
--- a/_problems/medium/CAKECUT.md
+++ b/_problems/medium/CAKECUT.md
@@ -99,8 +99,8 @@ Output a single integer, the number of sub rectangles which contains even number
 
 Output:
 3
-
 
### Example 2 +
 Input:
 3 4
@@ -110,5 +110,4 @@ Output a single integer, the number of sub rectangles which contains even number
 
 Output:
 26
-
 
\ No newline at end of file diff --git a/_problems/medium/CALLSCHE.md b/_problems/medium/CALLSCHE.md index f6d8116b..d034b36b 100644 --- a/_problems/medium/CALLSCHE.md +++ b/_problems/medium/CALLSCHE.md @@ -84,7 +84,7 @@ The call center responds to client for **H** hours per day, which, for simplicit For each hour in the week, the number of clients connecting to the call center for that hour is known. So, Chef knows that he needs exactly **Ri,j** people talking with clients during the day **i** and hour **j**. -**Fk, i, j** is equal to **1** if person **k** is available to talk to clients during hour **j** of day **i** and if they have a meeting during that time. +**Fk, i, j** is equal to **1** if person **k** is available to talk to clients during hour **j** of day **i** and 0 if they have a meeting during that time. Please note that Chef lives in an alien world, which may not have 24 hours in a day or 7 days in a week. @@ -124,8 +124,8 @@ For each test case in a single line output **"Yes"** (without quotes) if it's po - **1** ≤ **D** ≤ **MAX** - **1** ≤ **P** ≤ **MAX** - **1** ≤ **Li** ≤ **N\*D** -- ≤ **Ri,j** ≤ **15** -- ≤ **Fk,i,j** ≤ **1** +- 0 ≤ **Ri,j** ≤ **15** +- 0 ≤ **Fk,i,j** ≤ **1** - **1** ≤ **LTbegin, LTend** ≤ **N** ### Subtasks @@ -160,5 +160,4 @@ For each test case in a single line output **"Yes"** (without quotes) if it's po Output: Yes No - \ No newline at end of file diff --git a/_problems/medium/CANDY.md b/_problems/medium/CANDY.md index cc04f8a9..478acfc9 100644 --- a/_problems/medium/CANDY.md +++ b/_problems/medium/CANDY.md @@ -32,9 +32,11 @@ For each test case, output on a single line the minimum number of candies the ch 1 1 **Output 1:** +
3
  
 
In this example, the chef purchases one of each candy and combines them to form a candy with 10 grams chocolate and 10 grams caramel. + **Input 2:**
3
@@ -44,9 +46,11 @@ For each test case, output on a single line the minimum number of candies the ch
 5 8
  
 
**Output 2:** +
-1
  
 
### Constraints: + 1 ≤ N ≤ 15 1 ≤ Chocolatei ≤ 500 1 ≤ Carameli ≤ 500 diff --git a/_problems/medium/CANDYGAM.md b/_problems/medium/CANDYGAM.md index 6c004abb..aa829706 100644 --- a/_problems/medium/CANDYGAM.md +++ b/_problems/medium/CANDYGAM.md @@ -108,8 +108,8 @@ For each test case, output a single line containing the number of candies the wi 1 ≤ N, M ≤ 50 0 ≤ A[i][j] ≤ 1000000000 - ### Example: + **Input:**
3
@@ -123,12 +123,12 @@ For each test case, output a single line containing the number of candies the wi
 1 4
 1 2 3 4
 
-
 
**Output:** +
39
 4
 9
 
-
-
**Explanation:** _1st case:_ Alice picks the first column (with all 0's). We're left with a 3x2 grid now. Bob picks the first column (9+6+9=24). We're left with a 3x1 grid. Alice picks the last row (6). A 2x1 grid is left. Bob picks the entire column (9+6=15). Thus, Bob has 24+15=39 candies and Alice has 6. So clearly, Bob is the winner. +**Explanation:** + _1st case:_ Alice picks the first column (with all 0's). We're left with a 3x2 grid now. Bob picks the first column (9+6+9=24). We're left with a 3x1 grid. Alice picks the last row (6). A 2x1 grid is left. Bob picks the entire column (9+6=15). Thus, Bob has 24+15=39 candies and Alice has 6. So clearly, Bob is the winner. _2nd case:_ Here, both end up with two candies each. Hence both are the winners. Thus the winner(s) have 2+2=4 candies in all. diff --git a/_problems/medium/CAOS3.md b/_problems/medium/CAOS3.md index 03d0f8ca..633083bd 100644 --- a/_problems/medium/CAOS3.md +++ b/_problems/medium/CAOS3.md @@ -127,8 +127,8 @@ For each test case, output a single line containing the the name of the winner. Output: Asuna - ### Explanation + This is the intial configuration, you can see the positions of monsters at CPC's. ![](//www.codechef.com/download/caos3-1.png) diff --git a/_problems/medium/CARDLINE.md b/_problems/medium/CARDLINE.md index 15984b9a..ab0b4b98 100644 --- a/_problems/medium/CARDLINE.md +++ b/_problems/medium/CARDLINE.md @@ -113,8 +113,8 @@ For each test case, output a single line containing the integer **L**: the maxim Output: 2 4 - ### Explanation + **First Example :** One of the possible card arrangements is: diff --git a/_problems/medium/CARDS777.md b/_problems/medium/CARDS777.md index c197cc2f..89f7a10b 100644 --- a/_problems/medium/CARDS777.md +++ b/_problems/medium/CARDS777.md @@ -111,6 +111,6 @@ For each test case, output a single floating point value, the expected score you 2.2000000000 14.4482758621 100000.0000000000 - ### Explanation + For the first case, we have three red cards, one blue card, two red tokens, and two blue tokens. An optimal strategy is to choose the red token first. There are two cases. Either the card we choose first is red or blue. If it is blue, then we know for sure all remaining cards will be red, so it doesn't matter how we play the remaining tokens. This gives us 1 point. If it is red, then we will next play our last red token. We can check that the expected value of our score is equal to 2, and there is no other strategy that is strictly better. diff --git a/_problems/medium/CAREFUL.md b/_problems/medium/CAREFUL.md index 03ff7278..1ddd9410 100644 --- a/_problems/medium/CAREFUL.md +++ b/_problems/medium/CAREFUL.md @@ -39,5 +39,4 @@ For each test case output just one line containing the required smallest positiv 3 Explanation: - -In the example test case **N** = 22\*31 = 12. Then **N1** = 4, **N2** = 2 and **NX** = 1 for **X** ≥ 3, so the answer is 3. \ No newline at end of file +In the example test case **N** = 22\*31 = 12. Then **N1** = 4, **N2** = 2 and **NX** = 1 for **X** ≥ 3, so the answer is 3. diff --git a/_problems/medium/CARLOS.md b/_problems/medium/CARLOS.md index ccc918f1..07759324 100644 --- a/_problems/medium/CARLOS.md +++ b/_problems/medium/CARLOS.md @@ -96,7 +96,7 @@ For each test case, output a single line containing **-1** if it's impossible to - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **200000** -- ≤ **K** ≤ **M(M-1)/2** +- 0 ≤ **K** ≤ **M(M-1)/2** - **1** ≤ **x,y** ≤ **M** - all unordered pairs **(x,y)** will be distinct - **1** ≤ **ai** ≤ **M** @@ -131,8 +131,8 @@ Subtask 3 (22 points): Output: 2 -1 - ### Explanation + **Example case 1.** It's possible to transform the first letter to 1 and the last letter to 2. The resulting word has letters 1 2 2. **Example case 2.** This word can only be transformed to 2 1 or 3 1. diff --git a/_problems/medium/CATCHSM.md b/_problems/medium/CATCHSM.md index 41d5dbcb..60a4ae05 100644 --- a/_problems/medium/CATCHSM.md +++ b/_problems/medium/CATCHSM.md @@ -119,6 +119,6 @@ For each test case, for each query, output a single line containing the minimum 12.7279220614 - ### Explanation + ![](https://s3.amazonaws.com/codechef_shared/download/upload/SNCKFL16/2.png)**Example case 1.** Luckily initial position of Bat-Chef and Spider-Chef is precisely the same, so it won't take any time to Bat-Chef to catch Spider-Chef. diff --git a/_problems/medium/CBARS.md b/_problems/medium/CBARS.md index 6bd89cbc..a19f4ce0 100644 --- a/_problems/medium/CBARS.md +++ b/_problems/medium/CBARS.md @@ -93,17 +93,16 @@ Print in output a single integer which is the answer. Answer can be a very big n Output: 322 - ### Explanation + In the first sample, there are 2^(2\*2) = 16 ways coloring the chocolate in total, and the only following 2 chocolates are not good
 WW
 WW
-
 
The bar contains a totally white rectangle of length = 2 and width = 2. +
 BB
 BB
-
-
The bar contains a totally black rectangle of length = 2 and width = 2. \ No newline at end of file +The bar contains a totally black rectangle of length = 2 and width = 2. diff --git a/_problems/medium/CFTREE.md b/_problems/medium/CFTREE.md index f0bdaf05..f6b5b165 100644 --- a/_problems/medium/CFTREE.md +++ b/_problems/medium/CFTREE.md @@ -138,5 +138,4 @@ Q 5

- \ No newline at end of file diff --git a/_problems/medium/CHEFAFD.md b/_problems/medium/CHEFAFD.md index 163f690b..13fd0a75 100644 --- a/_problems/medium/CHEFAFD.md +++ b/_problems/medium/CHEFAFD.md @@ -123,8 +123,8 @@ R D U L NO - ### Explanation + **Example case 1.** Chef can keep the direction **R** for cell **(1, 1)**, **D** for **(1, 2)**, **U** for **(2, 1)** and **L** for **(2, 2)**. Then he can go **(1,1) -> (1,2) -> (2,2) -> (2,1) -> (1,1)**. It means that from any cell he always can go back to that cell. **Example case 2.** There is no way to keep only 1 direction for each cell to satisfy the condition. diff --git a/_problems/medium/CHEFANUP.md b/_problems/medium/CHEFANUP.md index 76c9a46f..c46e310a 100644 --- a/_problems/medium/CHEFANUP.md +++ b/_problems/medium/CHEFANUP.md @@ -110,8 +110,8 @@ Given an integer **L**, determine the **L**th possible dish in increasing order 1 1 2 1 1 3 1 2 1 - ### Explanation + First 4 dishes in order have ingredients (1,1,1), (1,1,2), (1,1,3), and (1,2,1).
Input:
@@ -126,6 +126,6 @@ First 4 dishes in order have ingredients (1,1,1), (1,1,2), (1,1,3), and (1,2,1).
 1 1 1 2
 1 1 1 3
 1 1 2 1
-
 
### Explanation + First 4 dishes in order have ingredients (1,1,1,1), (1,1,1,2), (1,1,1,3), and (1,1,2,1). diff --git a/_problems/medium/CHEFAOR.md b/_problems/medium/CHEFAOR.md index 4cef4825..dd58f523 100644 --- a/_problems/medium/CHEFAOR.md +++ b/_problems/medium/CHEFAOR.md @@ -101,7 +101,7 @@ For each test case, output a single line, containing the maximal achievable cost - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **5000** - **1** ≤ **K** ≤ **N** -- ≤ **Ai** ≤ **230** +- 0 ≤ **Ai** ≤ **230** - Subtask 1(15 points): **1** ≤ **N** ≤ **100** - Subtask 2(35 points): **1** ≤ **N** ≤ **1000** - Subtask 3(50 points): **1** ≤ **N** ≤ **5000** @@ -125,8 +125,8 @@ For each test case, output a single line, containing the maximal achievable cost 10 3 704 - ### Explanation + **Example case 1**. The optimal group division is the following one: put the first two numbers to the first group, and the next one into the second. This way, you will obtain the cost of the array equal to (1 OR 2) + 2 = 3 + 2 = 5. **Example case 2**. The first two integers should be in the first group, the third one should be in the second group, the fourth one should be in the third group. This way, we will obtain a cost of an array equal to (1 OR 2) + 3 + 4 = 3 + 3 + 4 = 10. diff --git a/_problems/medium/CHEFB.md b/_problems/medium/CHEFB.md index 10db2906..6a8f4e06 100644 --- a/_problems/medium/CHEFB.md +++ b/_problems/medium/CHEFB.md @@ -104,5 +104,4 @@ For each test case, output a single line containing one integer - the minimum nu Output: 2 - \ No newline at end of file diff --git a/_problems/medium/CHEFCLOS.md b/_problems/medium/CHEFCLOS.md index 7dd8f2ef..93e807fc 100644 --- a/_problems/medium/CHEFCLOS.md +++ b/_problems/medium/CHEFCLOS.md @@ -118,8 +118,8 @@ For each test case, output a single line containing an integer corresponding to Output: 2 1 - ### Explanation + **In Test 1 :** The array **A = \[2, 1\]**. The array is already closed under gcd operation since gcd(2, 2) = 2, gcd(1, 1) = 1 and gcd(2, 1) = 2. So, the remaining element which needs to be added can be either **1** or **2**. So, answer is **2**. **In Test 2 :** The array **A = \[1, 4, 6\]**. gcd(1, 1), gcd(1, 4) and gcd(1, 6) = 1 which is present in the array. gcd(4, 6) is 2 which is not present in the array. We have to add only one element in the array and make it closed under gcd operation. So the number to be added can only be **2**. There is only one way of doing that. So, the answer is **1**. diff --git a/_problems/medium/CHEFCODE.md b/_problems/medium/CHEFCODE.md index 83d46ea6..4a226ebb 100644 --- a/_problems/medium/CHEFCODE.md +++ b/_problems/medium/CHEFCODE.md @@ -106,6 +106,6 @@ Print the answer to the given test case in a separate line. Output: 5 - ### Explanation + For the given sample case, there are **7** non-empty subsequences out of which **2** have their product > **4**. Those include {**2**, **3**} and {**1**, **2**, **3**}. Hence, the answer is **7** - **2** = **5**. diff --git a/_problems/medium/CHEFD.md b/_problems/medium/CHEFD.md index eb8fa6ba..a5a3d75e 100644 --- a/_problems/medium/CHEFD.md +++ b/_problems/medium/CHEFD.md @@ -118,5 +118,4 @@ Each of the following **M** lines describes a single query in the format given i Output: 5 1 1 - \ No newline at end of file diff --git a/_problems/medium/CHEFDIV.md b/_problems/medium/CHEFDIV.md index d71d7c82..2ff52232 100644 --- a/_problems/medium/CHEFDIV.md +++ b/_problems/medium/CHEFDIV.md @@ -120,14 +120,13 @@ Output a single integer corresponding to the answer of the problem. Output 1: 14 -
Input 2:
 932451 935212
 
 Output 2:
 101245
-
 
### **Explanation** + **Input 1.** Here we have, **A** = 11 and **B** = 12. diff --git a/_problems/medium/CHEFDOMA.md b/_problems/medium/CHEFDOMA.md index 387b891d..8c857a05 100644 --- a/_problems/medium/CHEFDOMA.md +++ b/_problems/medium/CHEFDOMA.md @@ -108,8 +108,8 @@ Output the answer to the query in a single line. Output: 11 - ### Subtasks + - **Subtask 1:** **N** ≤ 102. **Points - 10** - **Subtask 2:** **N** ≤ 104. **Points - 20** - **Subtask 3:** **N** ≤ 105. **Points - 30** diff --git a/_problems/medium/CHEFDTRE.md b/_problems/medium/CHEFDTRE.md index 41ed151c..82fcb44e 100644 --- a/_problems/medium/CHEFDTRE.md +++ b/_problems/medium/CHEFDTRE.md @@ -122,8 +122,8 @@ GET 9 1 3 2 1 - ### Explanation + - Initially, the sets are: {1}, {2}, {3}, {4}, {5}, {6}, {7}. - After the first query: {}, {}, {3}, {4}, {5}, {6}, {7}, {1, 2}. - After the second query the configuration of sets is: {}, {}, {}, {4}, {5}, {6}, {7}, {}, {1, 2, 3}. diff --git a/_problems/medium/CHEFEXQ.md b/_problems/medium/CHEFEXQ.md index 04e5b593..7fe5869b 100644 --- a/_problems/medium/CHEFEXQ.md +++ b/_problems/medium/CHEFEXQ.md @@ -117,5 +117,4 @@ For each operation of type 2, print the number of magical subarrays on a separat 3 1 - \ No newline at end of file diff --git a/_problems/medium/CHEFGAME.md b/_problems/medium/CHEFGAME.md index 82c47465..7abeb3c7 100644 --- a/_problems/medium/CHEFGAME.md +++ b/_problems/medium/CHEFGAME.md @@ -112,8 +112,8 @@ For each test case, output the maximal score modulo **747474747**. Output: 8 - ### Explanation + The distance between the first point and the second point is **((0−(−1))2+(0−(−1))2)1/2 = 21/2**. The distance between the first point and the third point is **((0−1)2+(0−(−1))2)1/2 = 21/2**. The distance between the second point and the third point is **(((−1)−1)2+((−1)−(−1))2)1/2 = 2**. diff --git a/_problems/medium/CHEFGIRL.md b/_problems/medium/CHEFGIRL.md index 97ed2bdf..3f70a1b6 100644 --- a/_problems/medium/CHEFGIRL.md +++ b/_problems/medium/CHEFGIRL.md @@ -118,7 +118,6 @@ Chef can perform operations of the following kind: take some edge, and extend it Output: 50 -
 

Explanation

Example case 1.

@@ -140,5 +139,4 @@ Here is the solution: Now, all secrets in the range [1-9] will go through 1-2-4 and all secrets in the range [10-32] will go through 1-3-5, finally reaching Chef. And the total cost is 50. -
\ No newline at end of file diff --git a/_problems/medium/CHEFGRPH.md b/_problems/medium/CHEFGRPH.md index 8f7e0160..c8b76e6f 100644 --- a/_problems/medium/CHEFGRPH.md +++ b/_problems/medium/CHEFGRPH.md @@ -72,7 +72,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/FEB15/mandarin/CHEFGRPH.pdf) and [Russian](http://www.codechef.com/download/translated/FEB15/russian/CHEFGRPH.pdf). -Consider directed graph which has **n + 2** layers numbered from left to right by integers from up to **n + 1**. The leftmost () and the rightmost (**n + 1**) layers both contain **only one** vertex while every other layer contains exactly **m** vertices. Vertices are numbered independently in each layer by integers from to **m - 1**. For each pair of vertices which are in the adjacent layers (**i** and **i + 1** for any **i (0 <= i <= n)**), there exists an edge. The vertex which is in the layer with smaller number is the initial vertex for such edge and the other one is the terminal vertex. +Consider directed graph which has **n + 2** layers numbered from left to right by integers from 0 up to **n + 1**. The leftmost (0) and the rightmost (**n + 1**) layers both contain **only one** vertex while every other layer contains exactly **m** vertices. Vertices are numbered independently in each layer by integers from 0 to **m - 1**. For each pair of vertices which are in the adjacent layers (**i** and **i + 1** for any **i (0 <= i <= n)**), there exists an edge. The vertex which is in the layer with smaller number is the initial vertex for such edge and the other one is the terminal vertex. Based on a graph as described above, Chef added **k** more edges. Each edge connects two vertices which are in the different layers, no matter the adjacent layers or not. Also, each edge is directed from left to right (as well as all previously existing edges). @@ -82,7 +82,7 @@ Chef is interested in the number of ways to get from the leftmost layer to the r The first line of the input contains three space-separated integers: **n**, **m** and **k**. -**k** lines follow. Each of them describes one of the **k** additional edges and contains four space-separated integers **edgei** (where <= **i** <= **3**). First two integers are for the initial vertex and the other two - for the terminal one. Two integers each vertex is described by are the number of the layer (**edge0** and **edge2** respectively) and number of the vertex in its layer (**edge1** and **edge3** respectively). +**k** lines follow. Each of them describes one of the **k** additional edges and contains four space-separated integers **edgei** (where 0 <= **i** <= **3**). First two integers are for the initial vertex and the other two - for the terminal one. Two integers each vertex is described by are the number of the layer (**edge0** and **edge2** respectively) and number of the vertex in its layer (**edge1** and **edge3** respectively). ### Output @@ -92,11 +92,11 @@ Output a single integer: the number of ways to reach the last layer from the ini - **1** <= **n** <= **1012** - **1** <= **m** <= **105** -- <= **k** <= **5 \* 104** +- 0 <= **k** <= **5 \* 104** - for each added edge: - - Layers: <= **edge0** < **edge2** <= **n+1** + - Layers: 0 <= **edge0** < **edge2** <= **n+1** - Numbers inside the layer: - - In general: <= **edge1**, **edge3** <= **m-1** + - In general: 0 <= **edge1**, **edge3** <= **m-1** - When **edge0** = 0, **edge1** = 0 - When **edge2** = **n + 1**, **edge3** = 0 @@ -115,6 +115,6 @@ Output a single integer: the number of ways to reach the last layer from the ini Output: 19 - ### Explanation + Consider the graph without **2** edges added by Chef. There are **16** ways to get from the layer **\#0** to the layer **\#5**. Now recall added edges. There are **2** ways to get from the layer **\#0** to the layer **\#5** using the edge **2 1 5 0** (0, 0 -> 1, 0 -> 2, 1 -> 5, 0 and 0, 0 -> 1, 1 -> 2, 1 -> 5, 0) and also **1** way to do it using the edge **0 0 4 0** (0, 0 -> 4, 0 -> 5, 0). Note, that there is no path traversing both added edges. diff --git a/_problems/medium/CHEFHCK2.md b/_problems/medium/CHEFHCK2.md index 18696298..f4ae792b 100644 --- a/_problems/medium/CHEFHCK2.md +++ b/_problems/medium/CHEFHCK2.md @@ -47,12 +47,12 @@ All Non-Power Servers have a friendly screen with the color indicator. Suppose y On the other hand, each Power Server has no such screen and the only way to crack it is to try all Power Passwords until you find out the correct password. So our Chef simply iterate over the list of Power Passwords in increasing order and try them until he finds the correct password. -After the last adventure with Aliens, Chef became smarter so he will use binary search to crack Non-Power Servers. Namely, let **A\[1\], A\[2\], A\[3\], A\[4\], ...** be the sequence of all Non-Power Passwords. At first he will try passwords **A\[2\], A\[4\], A\[8\], A\[16\], ...** until he either reaches the correct one or the indicator becomes red for the first time. If indicator becomes red at the password **A\[2\] = 1** then he enters **A\[1\] = 0** at the next step and cracks the server (since is the only Non-Power Password less than **1**). Let the indicator becomes red at the password **A\[2k\]** where **k ≥ 2** while for the password **A\[2k−1\]** indicator was green. Then Chef sets **L = 2k−1**, **R = 2k** and uses usual binary search to crack the server after that. Namely, at each step he sets **M = (L + R) div 2** and checks the password **A\[M\]**. If it is correct he finishes the process; if indicator becomes green he sets **L = M** and continue the process; finally, if indicator becomes red he sets **R = M** and continue the process. +After the last adventure with Aliens, Chef became smarter so he will use binary search to crack Non-Power Servers. Namely, let **A\[1\], A\[2\], A\[3\], A\[4\], ...** be the sequence of all Non-Power Passwords. At first he will try passwords **A\[2\], A\[4\], A\[8\], A\[16\], ...** until he either reaches the correct one or the indicator becomes red for the first time. If indicator becomes red at the password **A\[2\] = 1** then he enters **A\[1\] = 0** at the next step and cracks the server (since 0 is the only Non-Power Password less than **1**). Let the indicator becomes red at the password **A\[2k\]** where **k ≥ 2** while for the password **A\[2k−1\]** indicator was green. Then Chef sets **L = 2k−1**, **R = 2k** and uses usual binary search to crack the server after that. Namely, at each step he sets **M = (L + R) div 2** and checks the password **A\[M\]**. If it is correct he finishes the process; if indicator becomes green he sets **L = M** and continue the process; finally, if indicator becomes red he sets **R = M** and continue the process. Let's consider some examples: - Suppose the password is **9**. It's a Power Password, so Chef will not see the friendly screen which means for him that the server is a Power Server. Hence he will try the password **4**, then **8** and then **9**, making 3 tries in all. -- Suppose the password is . It's a Non-Power Password, so Chef will see the friendly screen which means for him that the server is a Non-Power Server. Hence he will try the passwords **A\[2\] = 1, A\[1\] = 0** in order, making 2 tries in all. +- Suppose the password is 0. It's a Non-Power Password, so Chef will see the friendly screen which means for him that the server is a Non-Power Server. Hence he will try the passwords **A\[2\] = 1, A\[1\] = 0** in order, making 2 tries in all. - Suppose the password is **7**. It's a Non-Power Password. Hence he will try the passwords **A\[2\] = 1, A\[4\] = 3, A\[8\] = 10, A\[6\] = 6, A\[7\] = 7** in order, making 5 tries in all. - Suppose the password is **1**. It's a Non-Power Password. He will crack this server from the first try since **A\[2\] = 1**. @@ -69,7 +69,7 @@ Output a single line containing **N** space separated integers. The **i**-th num ### Constraints - **1** ≤ **N** ≤ **314159** -- ≤ **each password** ≤ **31415** +- 0 ≤ **each password** ≤ **31415** - Chef Po does not know this bound on the password and assumes that password can be any non-negative integer when he is cracking ### Example @@ -81,6 +81,6 @@ Output a single line containing **N** space separated integers. The **i**-th num Output: 3 2 5 1 15 12 - ### Explanation + The cracking process of first 4 servers explained in the problem statement. diff --git a/_problems/medium/CHEFHOME.md b/_problems/medium/CHEFHOME.md index b4509d5c..d6b896f6 100644 --- a/_problems/medium/CHEFHOME.md +++ b/_problems/medium/CHEFHOME.md @@ -116,5 +116,4 @@ The number of possible locations (grid points) where houses can be built. 1 1 4 - \ No newline at end of file diff --git a/_problems/medium/CHEFINS.md b/_problems/medium/CHEFINS.md index 2d51c5fa..b42f0477 100644 --- a/_problems/medium/CHEFINS.md +++ b/_problems/medium/CHEFINS.md @@ -102,8 +102,8 @@ For each query output "Yes" or "No" (without quotess) in separate line. Yes Yes No - ### Explanation + **Example case 1.** 2 = 2 **Example case 2.** 8 = 2 + 2 + 4 diff --git a/_problems/medium/CHEFINV.md b/_problems/medium/CHEFINV.md index bb11bac4..9c36de89 100644 --- a/_problems/medium/CHEFINV.md +++ b/_problems/medium/CHEFINV.md @@ -110,8 +110,8 @@ Output **M** lines. Output the answer to the **i**-th question of the **i**-th l 6 0 - ### Explanation + Inversions for the first case: **(2, 3), (2, 4), (2, 5), (3, 5), (4, 5)**. Inversions for the second case: **(1, 3), (1, 5), (2, 3), (2, 4), (2,5), (4, 5)**. diff --git a/_problems/medium/CHEFKLCS.md b/_problems/medium/CHEFKLCS.md index 4738e02a..6884d575 100644 --- a/_problems/medium/CHEFKLCS.md +++ b/_problems/medium/CHEFKLCS.md @@ -73,8 +73,8 @@ ab Output: -1 - ### Explanation: + **Example case 1.**L = LCS(**A**, **B**) = 1. There are three common sequences with length L, S = {"a", "b", "c"}. Answer is "c". **Example case 2.**L = LCS(**A**, **B**) = 3. There are four common sequences with length L, S = {"aca", "acb", "bca", "bcb"}. Answer is "-1". diff --git a/_problems/medium/CHEFLAND.md b/_problems/medium/CHEFLAND.md index 2dc1106d..b7028f22 100644 --- a/_problems/medium/CHEFLAND.md +++ b/_problems/medium/CHEFLAND.md @@ -90,7 +90,7 @@ Output "YES" (without quotes) if it possible to make all pairs of node good by a ### Constraints - **1** ≤ **N** ≤ **105** -- ≤ **M** ≤ **2 \* 105** +- 0 ≤ **M** ≤ **2 \* 105** - **1** ≤ **x, y** ≤ **N** - It is guaranteed that the graph is connected. - The given graph may contain multi-edges. It doesn't contain any self loops. @@ -106,6 +106,6 @@ Output "YES" (without quotes) if it possible to make all pairs of node good by a Output: YES - ### Explanation + We can connect nodes 3 and 4 via an edge. After that all the pair of vertices will be good. diff --git a/_problems/medium/CHEFLIQD.md b/_problems/medium/CHEFLIQD.md index 93ce54c5..6b60b321 100644 --- a/_problems/medium/CHEFLIQD.md +++ b/_problems/medium/CHEFLIQD.md @@ -129,6 +129,6 @@ For each test case, output a single line containing the maximum amount of total 8 17 19 - ### Explanation + **Example case 1.** In the first case, Hari buys 5th ingredient. In second case, Hari buys 2nd and 5th ingredient. In third case, Hari buys 1st, 2nd and 4th ingredients. diff --git a/_problems/medium/CHEFLKJ.md b/_problems/medium/CHEFLKJ.md index 3ff78473..b63c1ef3 100644 --- a/_problems/medium/CHEFLKJ.md +++ b/_problems/medium/CHEFLKJ.md @@ -120,8 +120,8 @@ Yes Yes No Yes - ### Explanation + For first query, we have to tell whether the entire array **A** is dominating or not. It turns out that it is not dominating, because occurrences of 1 and 2 are equal to 2 (which is not more than half the size of array, i.e. 2) and that of 3 is 1. For second query, the subarray **\[2, 3, 2\]** is dominating and 2 is the dominator of it. Number of occurrences of 2 is 2 which is strictly greater than half the size of subarray, i.e. **floor(3/2) = 1**. diff --git a/_problems/medium/CHEFNUM.md b/_problems/medium/CHEFNUM.md index ca0b5d91..ca7ac0ce 100644 --- a/_problems/medium/CHEFNUM.md +++ b/_problems/medium/CHEFNUM.md @@ -130,6 +130,6 @@ For each test case, output a single integer in separate line corresponding to th Output: 15 23 - ### Explanation + **Example case 2:** The _amazingness_ values of numbers 11, 12, 13, 14 are 1, 6, 6 and 10 respectively. They sum up to 23. diff --git a/_problems/medium/CHEFNUMK.md b/_problems/medium/CHEFNUMK.md index 1e60d6d2..2e96d58d 100644 --- a/_problems/medium/CHEFNUMK.md +++ b/_problems/medium/CHEFNUMK.md @@ -107,5 +107,4 @@ For each query output answer for it in separate line. 1 3 - \ No newline at end of file diff --git a/_problems/medium/CHEFPASS.md b/_problems/medium/CHEFPASS.md index cac7ed04..37e02c1a 100644 --- a/_problems/medium/CHEFPASS.md +++ b/_problems/medium/CHEFPASS.md @@ -100,19 +100,19 @@ such that the overall set of strings represent the substrings for 1 or more pass 1 ≤ N ≤ 1000 1 ≤ M ≤ 1000 All characters would be upper case or lower case English letters. Passwords are case sensitive. - ### Sample Input +
2
 4 aB aB Ca Bc
 6 aB Ca ca ab ba bc
 4 aB aB Ca Bc
 3 Ba aC bc
-
 
### Sample Output +
YES
 NO
-
 
### Explanation + In the first Sample Input, you can construct "aBaC" from (**aB** **aB** **Ca** Ca) and "aBc" from (**Bc** aB ca). Strings selected from A are shown in bold. Remember that substrings can be reversed. Note that although there are repeated strings, each string is used in at most one of the passwords. diff --git a/_problems/medium/CHEFPCHF.md b/_problems/medium/CHEFPCHF.md index 1abf4c0b..2049a96e 100644 --- a/_problems/medium/CHEFPCHF.md +++ b/_problems/medium/CHEFPCHF.md @@ -100,7 +100,7 @@ All submissions for this problem are available.### Read problems statements in [ - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **109** -- ≤ **K** ≤ **105** +- 0 ≤ **K** ≤ **105** - **1** ≤ **p1** < **p2** < ... < **pK** ≤ **N** - **1** ≤ **qi** ≤ **109** @@ -139,8 +139,8 @@ All submissions for this problem are available.### Read problems statements in [ 12 30 - ### Explanation + **Example case 1:** s={0,0,0,0,1,1,0}. The 9 pairs (i,j) are: (1,1), (2,2), ..., (7,7), (1,3) and (2,4). **Example case 2:** s={0,1,0,2,0,1,0}. diff --git a/_problems/medium/CHEFPOLY.md b/_problems/medium/CHEFPOLY.md index f826d9dc..c054852d 100644 --- a/_problems/medium/CHEFPOLY.md +++ b/_problems/medium/CHEFPOLY.md @@ -152,8 +152,8 @@ For each query, output a new line containing the answer to it. 0 3 - ### Subtasks + - **Subtask 1:** **N** = 3. **Points - 10** - **Subtask 2:** **N, M** ≤ 100. **Points - 20** - **Subtask 3:** Sum of **k** over all queries not be greater than **105**, **M** ≤ 1000 **Points - 30** diff --git a/_problems/medium/CHEFPRAD.md b/_problems/medium/CHEFPRAD.md index d772d656..c4a12830 100644 --- a/_problems/medium/CHEFPRAD.md +++ b/_problems/medium/CHEFPRAD.md @@ -109,5 +109,4 @@ output ans Output: 4 -
\ No newline at end of file
diff --git a/_problems/medium/CHEFPRES.md b/_problems/medium/CHEFPRES.md
index 270af67c..5e666a66 100644
--- a/_problems/medium/CHEFPRES.md
+++ b/_problems/medium/CHEFPRES.md
@@ -157,8 +157,8 @@ For each of the **Q** queries, output on separate lines the number of the city f
 1
 4
 
-
 
### Explanation + In the first query, Chef must purchase product 1 from either city 5 or city 6. In both cases Chef will pass directly through the capital while travelling from city 2, so he chooses the smallest city number, 5. In the third query, the path from city 2 to city 3 is always at least 2 steps away from the capital. The path from city 2 to city 1 is less preferred, as the path comes within 1 step of the capital. diff --git a/_problems/medium/CHEFSHOP.md b/_problems/medium/CHEFSHOP.md index e379d2a9..76622bf3 100644 --- a/_problems/medium/CHEFSHOP.md +++ b/_problems/medium/CHEFSHOP.md @@ -92,7 +92,7 @@ For each test case, output a single line containing the minimal purchase cost. - **T** ≤ **5** - **1** ≤ **N** ≤ **15** - **1** ≤ **Ai** ≤ **106** -- ≤ **M** ≤ **2N-1** +- 0 ≤ **M** ≤ **2N-1** - **2** ≤ **Ci** ≤ **N** - Subtask 1 (15 points): 1 ≤ **N** ≤ 5 - Subtask 2 (25 points): 1 ≤ **N** ≤ 10 @@ -111,5 +111,4 @@ For each test case, output a single line containing the minimal purchase cost. Output: 6 - \ No newline at end of file diff --git a/_problems/medium/CHEFUNI.md b/_problems/medium/CHEFUNI.md index 11d73c9f..85455afd 100644 --- a/_problems/medium/CHEFUNI.md +++ b/_problems/medium/CHEFUNI.md @@ -115,8 +115,8 @@ For each test case, output a single line containing one integer — the minimum 3 5 - ### Explanation + **Example case 1:** One of the possible solutions is \[0, 0, 0\] --> \[1, 0, 1\] --> \[1, 1, 2\] --> \[1, 2, 3\]. The minimum energy loss is **B** + **B** + **B** = 3 · **B** = 3 · 1 = 3. **Example case 2:** One of the possible solutions is \[0, 0, 0\] --> \[1, 1, 1\] --> \[2, 2, 1\]. The minimum energy loss is **C** + **B** = 3 + 2 = 5. diff --git a/_problems/medium/CHEFVEC.md b/_problems/medium/CHEFVEC.md index 728418b2..203530ed 100644 --- a/_problems/medium/CHEFVEC.md +++ b/_problems/medium/CHEFVEC.md @@ -59,6 +59,6 @@ Output a single line containing a single integer — the answer to Chef's proble Output: 6 - ### Explanation: + There are 6 such vectors: (17, 30), (18, 29), (19, 28), (20, 27), (21, 26), (22, 25). diff --git a/_problems/medium/CHEFWD.md b/_problems/medium/CHEFWD.md index bfe99c74..be3eeccd 100644 --- a/_problems/medium/CHEFWD.md +++ b/_problems/medium/CHEFWD.md @@ -75,14 +75,14 @@ But today, Ciel being little casual stepped in wrong direction on her way to her She does not go past her restaurant because it is altogether different world and once she reaches her restaurant she stops. For example, if **N** is **3** then - -> **1** -> **-1** -> -> **1** -> **3**, - -> **2** -> **1** -> **3** +0 -> **1** -> **-1** -> 0 -> **1** -> **3**, +0 -> **2** -> **1** -> **3** are some possible ways where as - -> **-1** -> **1** -> **3**, (She did not set her foot wrong at her home) - -> **1** -> **3**, (She sets her foot wrong direction exactly once) - -> **1** -> -> **3**, (Her steps are always size 1 or 2) - -> **1** -> **2** -> **4** -> **3**, (She does not go past her restaurant) - -> **1** -> **2** -> **3** -> **2** -> **3** (Once she reaches her restaurant, she stops) +0 -> **-1** -> **1** -> **3**, (She did not set her foot wrong at her home) +0 -> **1** -> **3**, (She sets her foot wrong direction exactly once) +0 -> **1** -> 0 -> **3**, (Her steps are always size 1 or 2) +0 -> **1** -> **2** -> **4** -> **3**, (She does not go past her restaurant) +0 -> **1** -> **2** -> **3** -> **2** -> **3** (Once she reaches her restaurant, she stops) are not. ### Input @@ -102,5 +102,4 @@ Number of ways Ciel can reach her restaurant modulo 1000000007 (109+7). Sample Output: 18 44 - \ No newline at end of file diff --git a/_problems/medium/CHEFWORD.md b/_problems/medium/CHEFWORD.md index dd32f0af..33c5d4d5 100644 --- a/_problems/medium/CHEFWORD.md +++ b/_problems/medium/CHEFWORD.md @@ -94,7 +94,7 @@ Also Chef has a list of words. He asks you what is the probability that after ** - **1** ≤ **|S|, |si|** ≤ **3** - **1** ≤ **N** ≤ **10^5** - **1** ≤ **K** ≤ **10^9** -- ≤ **aij** ≤ **1** +- 0 ≤ **aij** ≤ **1** - Sum of **ai, 1** + **ai, 2** + ... + **ai, 26** = 1 - All words contains only letters from **a** to **z**. @@ -142,12 +142,11 @@ ccc zz Output: 0.125000000000000 - ### Explanation +
 daa (a->d) * (b->a) * (c->a) | 0.25*0.5*0.1 = 0,0125
 bbb (a->b) * (b->b) * (c->b) | 0.25*0.5*0.9 = 0,1125
 ccc (a->c) * (b->c) * (c->c) | 0
 zz (a->z) * (b->z) * (c can't transform to empty space as it is not allowed).
-
 
\ No newline at end of file diff --git a/_problems/medium/CHESSGM.md b/_problems/medium/CHESSGM.md index e1348afb..f7c55de0 100644 --- a/_problems/medium/CHESSGM.md +++ b/_problems/medium/CHESSGM.md @@ -37,5 +37,4 @@ Output an only integer which is the result calculated, by modulo of 1,000,000,00 2 6 Output: 5 - \ No newline at end of file diff --git a/_problems/medium/CHFQUEUE.md b/_problems/medium/CHFQUEUE.md index 68e70755..48b3fa1d 100644 --- a/_problems/medium/CHFQUEUE.md +++ b/_problems/medium/CHFQUEUE.md @@ -102,8 +102,8 @@ Output description. Output: 2 - ### Explanation + **Example case 1.** Only the second chef has a junior in front of him and the fearfulness he causes to the head chef is 3 - 2 + 1 = 2. Every other chef causes a fearfulness of 1 for the Head Chef. ### Scoring diff --git a/_problems/medium/CHGIFT1.md b/_problems/medium/CHGIFT1.md index 2f69248e..7167a570 100644 --- a/_problems/medium/CHGIFT1.md +++ b/_problems/medium/CHGIFT1.md @@ -102,8 +102,8 @@ For each test case, output a single line containing the minimal value of given e Output: -4 9 - ### Explanation + Example case 1: **1-2-3 = -4** ### Scoring diff --git a/_problems/medium/CHGLSTGT.md b/_problems/medium/CHGLSTGT.md index 0fa1ea57..e7697dc0 100644 --- a/_problems/medium/CHGLSTGT.md +++ b/_problems/medium/CHGLSTGT.md @@ -106,6 +106,7 @@ ABCCBDA

Output: 4

### Explanation + **Example case 1.** The given string can be broken into **"A" , "BCCB" , "D" , "A"**. It can be verified that you can't break the given string into less than 4 substrings such that each substring in a palindrome. ### Scoring diff --git a/_problems/medium/CHIEFETT.md b/_problems/medium/CHIEFETT.md index 6695375d..76e6de5a 100644 --- a/_problems/medium/CHIEFETT.md +++ b/_problems/medium/CHIEFETT.md @@ -46,13 +46,13 @@ For each test case, print the expected amount of money Chef should expect to sav 100 200 300 400 10 20 30 - **Sample output** +
66.667
 175.000
 
-
 
**Explanation** + In the second case, Chief can make the following selections: - (100, 200, 300), with probability 1/4. Chef can apply the coupons to at best save 140. diff --git a/_problems/medium/CHINSM.md b/_problems/medium/CHINSM.md index f761dcbd..f3455732 100644 --- a/_problems/medium/CHINSM.md +++ b/_problems/medium/CHINSM.md @@ -106,6 +106,6 @@ A single line containing an integer - the answer to the problem. Output: 4 - ### Explanation: + We can check **5 mod 3 = 2**, **5 mod 1 = 0** and **3 mod 1 = 0**. Thus **(5, 3)** is the only bad pair in the array. The **4** subsegments **A\[1;1\] = {5}, A\[2;2\] = {3}, A\[3;3\] = {1}, A\[2;3\] = {3, 1}** are OK. The other subsegments **A\[1;2\] = {5, 3}, A\[1;3\] = {5, 3, 1}** have a bad pair. diff --git a/_problems/medium/CHITHH.md b/_problems/medium/CHITHH.md index 2b4784de..fad7399e 100644 --- a/_problems/medium/CHITHH.md +++ b/_problems/medium/CHITHH.md @@ -76,7 +76,7 @@ If you take away all the foreword, then the task set is this: you have **N** non Concatanation example: If you have **2** numbers **11, 22** - after concatenation you will have **1122**. If you have **3** number **13, 44, 12** - after concatenation you will have **134412**. -One more example: **0, 3, 11, 0** - after concatenation you will have **03110**. First digit of this string is , not **3**. +One more example: **0, 3, 11, 0** - after concatenation you will have **03110**. First digit of this string is 0, not **3**. ### Input @@ -90,7 +90,7 @@ For each request output a single line containing **k-th** digit of **MagicIntege - **1** ≤ **N** ≤ **105** - **1** ≤ **M** ≤ **105** -- ≤ **Ai** ≤ **109** +- 0 ≤ **Ai** ≤ **109** - **1** ≤ **l, v** ≤ **105** - **1** ≤ **k** ≤ **106** @@ -112,8 +112,8 @@ For each request output a single line containing **k-th** digit of **MagicIntege 0 So sad 3 - ### Scoring + Subtask 1 (30 points): **N ≤ 1000** Subtask 2 (25 points): **V ≤ 100** diff --git a/_problems/medium/CHN02.md b/_problems/medium/CHN02.md index 70f0668b..5e36ee4e 100644 --- a/_problems/medium/CHN02.md +++ b/_problems/medium/CHN02.md @@ -67,6 +67,6 @@ His friend Malvika, a long time shepherd herself (this is _the other_ Malvika), Output: 20.000 - ### Explanation + Each region in the current case is rectangular in shape. You can check that the area of intersection of all the three input rectangles is another rectangle with corners at **(5,3), (15,3), (15,5)** and **(5,5)**. This is the place Animesh is going to settle in. The area of this rectangle is 10 \* 2 = 20. diff --git a/_problems/medium/CHN06.md b/_problems/medium/CHN06.md index bf19b9e0..700cf109 100644 --- a/_problems/medium/CHN06.md +++ b/_problems/medium/CHN06.md @@ -63,6 +63,6 @@ Unfortunately, when it is Praveen's turn to present the graph to the King, he re Output: 74 - ### Explanation + Out of the 4 edges, the costs of 3 edges are already given to us. The edge (2, 4) must cost 6 to satisfy the "All Perfect Matchings should have equal costs" constraint. Therefore, now, the sum of the squares of the costs of all the 4 edges is (22 + 32 + 52 + 62) = (4 + 9 + 25 + 36) = 74 diff --git a/_problems/medium/CHN07.md b/_problems/medium/CHN07.md index 705c8af0..cd621f36 100644 --- a/_problems/medium/CHN07.md +++ b/_problems/medium/CHN07.md @@ -56,8 +56,8 @@ BB Output: Malvika Animesh - ### Explanation + **In the first example**, Malvika will flip the red faced card in the first move, so it will now be blue faced. Now Animesh can't make any move, so he will lose. Hence Malvika is the winner. **In the second example**, Malvika can not make any move in the first turn itself, and therefore she loses. Hence Animesh is the winner. diff --git a/_problems/medium/CHN11.md b/_problems/medium/CHN11.md index c67d839d..7f56d33a 100644 --- a/_problems/medium/CHN11.md +++ b/_problems/medium/CHN11.md @@ -65,8 +65,8 @@ Two arrangements of the army — **A** and **B** — are said to be distinct if 2 4 1 - ### Explanation + **In the first example**, the strength of the army is zero irrespective of the way she arranges her army. There are two ways of arranging the army, namely {1, 2} and {2, 1}. **In the second example**, she can arrange a maximum strength army in four ways. Those are {1, 2, 1, 2}, {1, 2, 2, 1}, {2, 1, 1, 2}, {2, 1, 2, 1}. Strength of her army in all the four cases will be 4, the maximum possible strength of the army that she can get. diff --git a/_problems/medium/CHNGSEQ.md b/_problems/medium/CHNGSEQ.md index 5d789323..e0f3e2e5 100644 --- a/_problems/medium/CHNGSEQ.md +++ b/_problems/medium/CHNGSEQ.md @@ -111,8 +111,8 @@ For each test case, output an integer corresponding to the answer to the test ca 1 2 616 - ### Explanation + **Example 1**. Only possible sequence will be 0 0. Its beauty value will be zero. **Example 2**.The subsequences with beauty equal to 3 will be 0 1 and 1 0. So, the answer is 2. @@ -133,4 +133,5 @@ Please note that the above three examples don't have **C** = 220. These examples Output: 100
### Explanation
+
 There are **100** sequences in total that have length **2** and each integer is less than **1048576** such that sum of the beauty values of their subsequences modulo **109 + 7** is **345**.
diff --git a/_problems/medium/CHPLNTS.md b/_problems/medium/CHPLNTS.md
index 3f68b8b6..4e600160 100644
--- a/_problems/medium/CHPLNTS.md
+++ b/_problems/medium/CHPLNTS.md
@@ -104,8 +104,8 @@ For each test case, output a single integer – the minimum no. of moves require
 Output:
 2
 12
-
 
### Explanation + **Example case 1.** In first case, we can first choose (2,2) and then (1,2) diff --git a/_problems/medium/CHRL1.md b/_problems/medium/CHRL1.md index 0c57a0bb..6291bb91 100644 --- a/_problems/medium/CHRL1.md +++ b/_problems/medium/CHRL1.md @@ -102,8 +102,8 @@ For each test case, output a single line containing maximal weight among all the Output: 2 5 - ### Scoring + Subtask 1 (30 points): All the oranges' weights equals to 1. Subtask 2 (30 points): **N = 5** diff --git a/_problems/medium/CHRL3.md b/_problems/medium/CHRL3.md index 8714c215..45454774 100644 --- a/_problems/medium/CHRL3.md +++ b/_problems/medium/CHRL3.md @@ -94,7 +94,6 @@ Output a single line containing the minimal number of moves required to remove a Output: 1 -
Input:
 4
 4 1 2 3
@@ -102,8 +101,8 @@ Output a single line containing the minimal number of moves required to remove a
 Output:
 2
 
-
 
### Scoring + Subtask 1 (10 points): **N = 10** Subtask 2 (40 points): **N = 2000** diff --git a/_problems/medium/CHSEQ22.md b/_problems/medium/CHSEQ22.md index 51d696d9..1c4ce191 100644 --- a/_problems/medium/CHSEQ22.md +++ b/_problems/medium/CHSEQ22.md @@ -69,7 +69,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/FEB14/mandarin/CHSEQ22.pdf) and [Russian](http://www.codechef.com/download/translated/FEB14/russian/CHSEQ22.pdf). -Chef has an integer sequence **a1**, **a2**, ..., **aN** of size **N**, where all the elements of the sequence are initially. Chef also has **M** segments, here the **i**th one is **\[Li, Ri\]**. He wants to create new sequences using the following operation: +Chef has an integer sequence **a1**, **a2**, ..., **aN** of size **N**, where all the elements of the sequence are 0 initially. Chef also has **M** segments, here the **i**th one is **\[Li, Ri\]**. He wants to create new sequences using the following operation: - In a single operation, he picks a segment from the **M** segments. Let the chosen segment be **\[s, t\]**. - Then _flip_ the all elements from **s**th to **t**th elements, namely, **ai** is changed to **1 − ai** for all **s ≤ i ≤ t**. @@ -100,6 +100,6 @@ Print a single line containing one integer, denoting the number of the sequences Output: 8 - ### Explanation + In the example case, all the sequences **(0,0,0)**, **(0,0,1)**, **(0,1,0)**, **(1,0,0)**, **(0,1,1)**, **(1,0,1)**, **(1,1,0)**, **(1,1,1)** can be created by Chef. diff --git a/_problems/medium/CHSPARR.md b/_problems/medium/CHSPARR.md index c424104f..52c36b3a 100644 --- a/_problems/medium/CHSPARR.md +++ b/_problems/medium/CHSPARR.md @@ -115,8 +115,8 @@ Chef wants to know the sum of elements between **xth** and **yth** positions in Output: 38 36 -
### Explanation
+
 **Example case 1.**
  After the first minute **A** = {1, 7, 6, 15, 9} and sum of all elements will be 38.
 
diff --git a/_problems/medium/CHSQARR.md b/_problems/medium/CHSQARR.md
index 4ede099f..5c73ce87 100644
--- a/_problems/medium/CHSQARR.md
+++ b/_problems/medium/CHSQARR.md
@@ -133,8 +133,8 @@ Please note that sub-matrix of a matrix is a **continuous** rectangular block of
 4
 15
 9
-
 
### Explanation + **Question #1:** Chef can choose any 1 × 1 submatrix and it will take his 0 minutes to make it beautiful. @@ -144,17 +144,16 @@ The best variant is submatrix
 3 1
 2 2
-
-
**Question #3:**The next submatrix Chef can make equal in 15 minutes +**Question #3:** +The next submatrix Chef can make equal in 15 minutes
 5 2 3
 3 6 2
-
 
**Question #4:** +
 3 4
 3 1
 2 2
-
 
\ No newline at end of file diff --git a/_problems/medium/CHXORR.md b/_problems/medium/CHXORR.md index 3a4a60f3..df24ffbb 100644 --- a/_problems/medium/CHXORR.md +++ b/_problems/medium/CHXORR.md @@ -99,8 +99,8 @@ All submissions for this problem are available.Chef loves to cook pies. But more Output: 0 3 - ### Scoring + Subtask 1 (15 points): **3 ≤ N ≤ 100** Subtask 2 (10 points): **1 ≤ Ai ≤ 50** diff --git a/_problems/medium/CIELBTL.md b/_problems/medium/CIELBTL.md index 51cd1666..6e782bfa 100644 --- a/_problems/medium/CIELBTL.md +++ b/_problems/medium/CIELBTL.md @@ -26,7 +26,7 @@ When a fighter's HP is down to zero or a negative integer, this fighter loses. I ### Input -An input contains 5 integers **VA**, **VB**,**SA**, **SB** and **MA**. +An input contains 5 integers **VA**, **VB**, **SA**, **SB** and **MA**. ### Output diff --git a/_problems/medium/CIELNUM3.md b/_problems/medium/CIELNUM3.md index 62b1a574..a5c03ed9 100644 --- a/_problems/medium/CIELNUM3.md +++ b/_problems/medium/CIELNUM3.md @@ -112,6 +112,7 @@ The sum of the length of **N** in one judge input file does not exceed 1000000 ( 1 1 2 1 ### Sample Output +
58588
 128
 5354388
diff --git a/_problems/medium/CIELQUIZ.md b/_problems/medium/CIELQUIZ.md
index 10b2550c..9c72f33c 100644
--- a/_problems/medium/CIELQUIZ.md
+++ b/_problems/medium/CIELQUIZ.md
@@ -45,11 +45,13 @@ For each test case, print **K** distinct integers denoting the numbers of chosen
 10 5
 90 90 90 90 90 90 90 90 90 90
 
### Sample Output +
1 2
 1
 1
 5 8 1 4 9
 
### Output details + In the first case, all patterns choosing 2 problems are: If problems 1 and 2 are chosen, the probability is 0.7 \* (1 - 0.8) + (1 - 0.7) \* 0.8 = 0.14 + 0.24 = 0.38 If problems 1 and 3 are chosen, the probability is 0.7 \* (1 - 0.9) + (1 - 0.7) \* 0.9 = 0.07 + 0.27 = 0.34 diff --git a/_problems/medium/CIRCLEQ.md b/_problems/medium/CIRCLEQ.md index 03ff7494..891b3fd7 100644 --- a/_problems/medium/CIRCLEQ.md +++ b/_problems/medium/CIRCLEQ.md @@ -92,10 +92,10 @@ Output **Q** lines, the **i-th** line contains the total area covered by restaur - **1** ≤ **N** ≤ **50 000** - **1** ≤ **Q** ≤ **100 000** -- ≤ **xi, yi** ≤ **50 000** +- 0 ≤ **xi, yi** ≤ **50 000** - **1** ≤ **ri** ≤ **50** -- ≤ **xi1** < **xi2** ≤ **50 000** -- ≤ **yi1** < **yi2** ≤ **50 000** +- 0 ≤ **xi1** < **xi2** ≤ **50 000** +- 0 ≤ **yi1** < **yi2** ≤ **50 000** - No two circles touch or intersect each other. ### Subtasks @@ -107,9 +107,9 @@ Output **Q** lines, the **i-th** line contains the total area covered by restaur **Subtask #2 (10 pts)** - **1** ≤ **N, Q** ≤ **1000** -- ≤ **xi, yi** ≤ **1000** -- ≤ **xi1** < **xi2** ≤ **1000** -- ≤ **yi1** < **yi2** ≤ **1000** +- 0 ≤ **xi, yi** ≤ **1000** +- 0 ≤ **xi1** < **xi2** ≤ **1000** +- 0 ≤ **yi1** < **yi2** ≤ **1000** **Subtask #3 (10 pts)** @@ -139,5 +139,4 @@ Output **Q** lines, the **i-th** line contains the total area covered by restaur 15.707963267948966 2.456739397217513 0.000000000000000 - \ No newline at end of file diff --git a/_problems/medium/CK87DANC.md b/_problems/medium/CK87DANC.md index 9243136f..a32b12b4 100644 --- a/_problems/medium/CK87DANC.md +++ b/_problems/medium/CK87DANC.md @@ -128,8 +128,8 @@ For each test case print **Q** lines, where each line contains a single integer, 1 -1 - ### Explanation + **Example case 1:** The test asks for the smallest dance whose value is **greater** than or **equal** to **7** . The first query asks for the smallest dance which belongs to the interval **\[1, 3\]**. The possible dances are: { **\[1,1\] \[1,2\] \[1,3\] \[2,2\] \[2,3\] \[3,3\]**}, but only the dance **\[1, 3\]** is valid, whose value is **7**. diff --git a/_problems/medium/CK87MEAD.md b/_problems/medium/CK87MEAD.md index 4d86f40e..ee71e005 100644 --- a/_problems/medium/CK87MEAD.md +++ b/_problems/medium/CK87MEAD.md @@ -132,10 +132,10 @@ For each test case, print a single number, the number of pairs (**u**, **v**) th Output: 7 - ### Explanation + **Example case 1:** All possible pairs are: { **(1,1) (1,2) (1,3) (1,4) (1,5) (2,2) (2,3) (2,4) (2,5) (3,3) (3,4) (3,5) (4,4) (4,5) (5,5)** }. The valid pairs are: { **(1,1) (1,2) (1,3) (1,4) (2,3) (3,3) (3,4)** }. -The pair **(1,5)** is invalid because if we get all the nodes values in the path from node **1** to node **5**, the array will be: **{1, 4, -100}**, and the mean is: **-31,666** which is less than . +The pair **(1,5)** is invalid because if we get all the nodes values in the path from node **1** to node **5**, the array will be: **{1, 4, -100}**, and the mean is: **-31,666** which is less than 0. The pair **(2,2)** is invalid because the median of the array **{5}** is **5** which is greater than **4** diff --git a/_problems/medium/CLONEME.md b/_problems/medium/CLONEME.md index 42620fe7..3256dd25 100644 --- a/_problems/medium/CLONEME.md +++ b/_problems/medium/CLONEME.md @@ -129,8 +129,8 @@ For each query output "YES" or "NO" (without the double quotes) depending on whe YES NO YES - ### Explanation + In the first query the first sub-array looks like \[1, 3, 4\] on sorting and the second sub-array looks like \[2, 3, 4\] on sorting. These two sub-arrays only differ at first position so they are _similar_. In the second query the first sub-array on sorting looks like \[1, 3\] on sorting and the second sub-array looks like \[3, 4\] on sorting. These two sub-arrays differ at both the positions so they are not _similar_. diff --git a/_problems/medium/CLOSEFAR.md b/_problems/medium/CLOSEFAR.md index 119a111a..3e1b466a 100644 --- a/_problems/medium/CLOSEFAR.md +++ b/_problems/medium/CLOSEFAR.md @@ -147,8 +147,8 @@ F 2 4 6 5 2 - ### Explanation + Given below is the tree corresponding to the sample input. Each node has two numbers written in it. The first number represents the node index and the second number indicates node value. diff --git a/_problems/medium/CLOSESTQ.md b/_problems/medium/CLOSESTQ.md index 2f9f36a7..ed12b65f 100644 --- a/_problems/medium/CLOSESTQ.md +++ b/_problems/medium/CLOSESTQ.md @@ -123,8 +123,8 @@ For each query, output a single line containing one integer — the square of th 8 8 315218 -
### Explanation
+
 **Query 1.** There is only 1 point, so the answer is 0
 
 **Query 2.** There are only 2 points, (1, 1) and (2, 2), so answer is (1 - 2)2 + (1 - 2)2, which equals to 2
diff --git a/_problems/medium/CNPIIM.md b/_problems/medium/CNPIIM.md
index 5df9e446..4279cb3b 100644
--- a/_problems/medium/CNPIIM.md
+++ b/_problems/medium/CNPIIM.md
@@ -111,8 +111,8 @@ Read here for additional info:
 
 Output:
 2	
-
 
### Explanation + The only two matrices that exist with trace equal to 3 and that satisfy all the given conditions are: ![Matrices](/download/extimages/0a3c6a4adf4feefa0ff7eb3765ac8959.gif) diff --git a/_problems/medium/CNR.md b/_problems/medium/CNR.md index 0e8f2033..ae030b62 100644 --- a/_problems/medium/CNR.md +++ b/_problems/medium/CNR.md @@ -105,8 +105,8 @@ For each test case output the answer on a separate line . Output: 101 - ### Explanation + **Example case 1.** The set of strings in lexicographic order is "011", "101", and "110" ### Scoring diff --git a/_problems/medium/CNTSOLS.md b/_problems/medium/CNTSOLS.md index c8dee4ec..90bb105e 100644 --- a/_problems/medium/CNTSOLS.md +++ b/_problems/medium/CNTSOLS.md @@ -105,8 +105,8 @@ For each test case, output a single line containing number of solutions for the 4 1 - ### Explanation + The first equation has 4 solutions: - (0,2,2) diff --git a/_problems/medium/CNTWAYS.md b/_problems/medium/CNTWAYS.md index f0a1475f..ea27a782 100644 --- a/_problems/medium/CNTWAYS.md +++ b/_problems/medium/CNTWAYS.md @@ -102,7 +102,7 @@ For each rectangle, output a single line containing the number of ways, modulo 1 Output: 5 - -**Explanations:**In the sample case, there are 5 ways the turtle can reach the bottom right corner as follows: +**Explanations:** +In the sample case, there are 5 ways the turtle can reach the bottom right corner as follows: ![]( http://codechef.com/download/CNTWAYS2.png) diff --git a/_problems/medium/COALSCAM.md b/_problems/medium/COALSCAM.md index ba860aa3..e3bf54de 100644 --- a/_problems/medium/COALSCAM.md +++ b/_problems/medium/COALSCAM.md @@ -102,8 +102,8 @@ Output a single line for each test case. If it is impossible to choose a subset Output: 10 14 Impossible - ### Constraints + 1 ≤ T ≤ 5 2 ≤ N ≤ 5,000 1 ≤ M1 ≤ 20,000 diff --git a/_problems/medium/COFFEE.md b/_problems/medium/COFFEE.md index 70cc2ff9..22d10cff 100644 --- a/_problems/medium/COFFEE.md +++ b/_problems/medium/COFFEE.md @@ -112,6 +112,6 @@ For each test case, output a single line containing the maximum number of kiloby Output: 110 - ### Explanation + **Example case 1.** Sergey will have coffee during the periods numbered **1** and **3**. In these periods, the amount of code he produces will be zero, but during the rest, his code production quantities will get multiplied by **10**. Thus, we will write **(2 + 4 + 5) \* 10** KB of code. diff --git a/_problems/medium/COINS.md b/_problems/medium/COINS.md index 6aaae517..b6f0054e 100644 --- a/_problems/medium/COINS.md +++ b/_problems/medium/COINS.md @@ -36,5 +36,4 @@ For each test case output a single line, containing the maximum amount of Americ Output: 13 2 - -You can change 12 into 6, 4 and 3, and then change these into $6+$4+$3 = $13. If you try changing the coin 2 into 3 smaller coins, you will get 1, 0 and 0, and later you can get no more than $1 out of them. It is better just to change the 2 coin directly into $2. \ No newline at end of file +You can change 12 into 6, 4 and 3, and then change these into $6+$4+$3 = $13. If you try changing the coin 2 into 3 smaller coins, you will get 1, 0 and 0, and later you can get no more than $1 out of them. It is better just to change the 2 coin directly into $2. diff --git a/_problems/medium/COLCHAIN.md b/_problems/medium/COLCHAIN.md index b1e0c4c4..1ac85e82 100644 --- a/_problems/medium/COLCHAIN.md +++ b/_problems/medium/COLCHAIN.md @@ -36,5 +36,4 @@ For each test case output the number of ways for David to color the chain modulo 1 10 132 - \ No newline at end of file diff --git a/_problems/medium/COLLECT.md b/_problems/medium/COLLECT.md index 6962411f..fde651c1 100644 --- a/_problems/medium/COLLECT.md +++ b/_problems/medium/COLLECT.md @@ -113,5 +113,4 @@ query 4 4 1 1 - \ No newline at end of file diff --git a/_problems/medium/COLORING.md b/_problems/medium/COLORING.md index 0aeecfdb..1461d0f4 100644 --- a/_problems/medium/COLORING.md +++ b/_problems/medium/COLORING.md @@ -136,5 +136,4 @@ For each query of type **2** and **3**, print the sought answer. 2 5 4 - \ No newline at end of file diff --git a/_problems/medium/COMB4SUM.md b/_problems/medium/COMB4SUM.md index 687a9c7b..41d47b73 100644 --- a/_problems/medium/COMB4SUM.md +++ b/_problems/medium/COMB4SUM.md @@ -75,16 +75,16 @@ All submissions for this problem are available.### Read problems statements in [ ``` |a+b-c-d| + |a+c-b-d| + |a+d-b-c| + |c+d-a-b| + |b+d-a-c| + |b+c-a-d| -
where **|x|** denotes absolute value of **x**.
+
 ### Read problems statements in [Mandarin Chinese](/download/translated/COOK60/mandarin/COMB4SUM.pdf) and [Russian](/download/translated/COOK60/russian/COMB4SUM.pdf) as well.
 
 **Special Sum** of **4** numbers **(a, b, c, d)** is defined as:
 
  ```
 |a+b-c-d| + |a+c-b-d| + |a+d-b-c| + |c+d-a-b| + |b+d-a-c| + |b+c-a-d|
-
 
where **|x|** denotes absolute value of **x**. + Given an array **A** of size **N**, you need to find the sum of **Special Sum** of numbers taken over all quadruples of different indices of the array. ![](https://s3.amazonaws.com/codechef_shared/download/specialsum.png) @@ -123,8 +123,8 @@ For each test case output the sum as explained above. 10 76 1176 -
### Explanation:
+
 Test Case 1: SpecialSum(1,2,3,3) = 10 .
 
 Test Case 2: SpecialSum(1,2,3,4) + SpecialSum(1,2,3,5) + SpecialSum(1,2,4,5)+ SpecialSum(1,3,4,5) + SpecialSum(2,3,4,5) are called.
diff --git a/_problems/medium/COOK82D.md b/_problems/medium/COOK82D.md
index 9fbf126f..1a692dcb 100644
--- a/_problems/medium/COOK82D.md
+++ b/_problems/medium/COOK82D.md
@@ -120,8 +120,8 @@ Output **Q** lines, the i-th of which should contain a single word: "Yes" if the
 Yes
 No
 Yes
-
 
### Explanation + The given original graph is as follows: ![](https://codechef_shared.s3.amazonaws.com/download/upload/COOK82/COOK82D/image1.png)The first query corresponds to the graph with edges **E1, E2 and E3**: diff --git a/_problems/medium/COOKOFF.md b/_problems/medium/COOKOFF.md index 06fa6675..916a60a7 100644 --- a/_problems/medium/COOKOFF.md +++ b/_problems/medium/COOKOFF.md @@ -33,13 +33,13 @@ For each test case, output on a single line the minimum possible value of the la 6 3 0 100 21 64 34 55 64 89 - ### Sample Output: +
55
 30
 34
-
 
### Contsraints + T≤250 0≤M≤N≤1000 All difficulty ratings are between 0 and 1000000, inclusive. diff --git a/_problems/medium/COOKOFF2.md b/_problems/medium/COOKOFF2.md index cc0d634b..185566e5 100644 --- a/_problems/medium/COOKOFF2.md +++ b/_problems/medium/COOKOFF2.md @@ -29,10 +29,9 @@ For each test case, output the expected difference in prize tokens, rounded to 6 3 1 1 1 3 1 1 2 4 10 10 10 30 - ### Sample Output +
1.000000
 1.333333
 26.666667
-
 
\ No newline at end of file diff --git a/_problems/medium/COPRIME3.md b/_problems/medium/COPRIME3.md index 61f12886..80e9c3c0 100644 --- a/_problems/medium/COPRIME3.md +++ b/_problems/medium/COPRIME3.md @@ -100,6 +100,6 @@ Output the required number of triples on the first line of the output. Output: 4 - ### Explanation + Any triple will be a coprime one. diff --git a/_problems/medium/CORRCHK.md b/_problems/medium/CORRCHK.md index bb1fe520..0c717b51 100644 --- a/_problems/medium/CORRCHK.md +++ b/_problems/medium/CORRCHK.md @@ -90,8 +90,8 @@ Output an answer to the problem of the first line of output. Output: 2 - ### Scoring + **T** = 105, Every statement is either true in the base 10, either false in all the bases : 50 points. **T** = 105, No additional constraints : 50 points. diff --git a/_problems/medium/COTA.md b/_problems/medium/COTA.md index 99108450..d597fb7e 100644 --- a/_problems/medium/COTA.md +++ b/_problems/medium/COTA.md @@ -76,7 +76,7 @@ Chef likes to play computer games very much. Recently he played a new game, Dota Chef is thinking to start a new game called Cota (Chef of the ancient). There will be two teams in Cota, Radiant and Dire. -There are **2\*N** players in Cota and the players are numbered by integers from to **2\*N – 1**. +There are **2\*N** players in Cota and the players are numbered by integers from 0 to **2\*N – 1**. Each team will have **N** players. One team will have all the players with even numbers **(0, 2, …, 2\*N - 2)** and other team will have all the odd numbered players **(1, 3, …, 2\*N – 1)**. @@ -114,7 +114,7 @@ There will always be a valid answer. - **2** ≤ **N** ≤ **18** - **N** is divisible by **2** - **2\*N-1** ≤ **M** ≤ **2\*N(2\*N-1)/2** -- ≤ **u, v** ≤ **2\*N-1** and **u** ≠ **v** +- 0 ≤ **u, v** ≤ **2\*N-1** and **u** ≠ **v** - **1** ≤ **Pu,v** ≤ **106** - For each player **u** and **v (u≠v)** , there is a sequence **x0, x1, ... xk**, where **x0 = u** and **xk = v** and player **xi** and **xi+1** (**0≤iOutput: 5 9 - ### Explanation + **Example case 1.** If the odd numbered players are assigned as Radiant and even numbered players as Dire, and Chef assigns players {0, 1, 3} as elite players and keeps only the friendships between (0, 1) and (0, 3) and breaks up any other pair of friendships. So the total power of friendship is 1 + 4 = 5. Elite player 1 and 3 have friendship with only elite player 0. So each Radiant player has odd number of elite friends. Similarly player 0 has friendship with 1 and 3, and players 2 do not have any friend(0 elite friends). So each Dire player has even number of elite friends. **Example case 2.** diff --git a/_problems/medium/COUNTIES.md b/_problems/medium/COUNTIES.md index 169d0337..8fe62ffc 100644 --- a/_problems/medium/COUNTIES.md +++ b/_problems/medium/COUNTIES.md @@ -134,5 +134,4 @@ For each of **Q** queries, output the sought minimal distance on a separate line 2 2 2 - \ No newline at end of file diff --git a/_problems/medium/COUNTWAY.md b/_problems/medium/COUNTWAY.md index 8def943a..389be999 100644 --- a/_problems/medium/COUNTWAY.md +++ b/_problems/medium/COUNTWAY.md @@ -103,8 +103,8 @@ Output the required answer modulo **13313** in one line. Output 2: 1 - ### Explanation + Input 1: Three possible ways are: diff --git a/_problems/medium/COUPON.md b/_problems/medium/COUPON.md index fb9421b0..e9863e87 100644 --- a/_problems/medium/COUPON.md +++ b/_problems/medium/COUPON.md @@ -101,8 +101,8 @@ For each test case, output on a separate line the least amount that has to be sp 0 ≤ Prices, Discounts ≤ 1000000 1 ≤ T * N * M ≤ 1000000 - ### Example: + **Input:**
@@ -119,14 +119,14 @@ For each test case, output on a separate line the least amount that has to be sp
 1 2 1 1
 
 
-
 
**Output:** +
 3
 2
 
-
 
### Scoring: + You will be awarded **40** points for solving the problem correctly for **M = 2**. Another **20** points for solving the problem correctly for **M <= 100**. diff --git a/_problems/medium/CROWNS.md b/_problems/medium/CROWNS.md index 549d5370..04029c2e 100644 --- a/_problems/medium/CROWNS.md +++ b/_problems/medium/CROWNS.md @@ -69,8 +69,8 @@ The output for each test case is a single floating point number with 1 decimal o 36.5 57.0 66.5 - ### Figures + The following figures illustrate the solutions for each test case. The dotted lines indicate the x and y axis. The bold line on a crown indicates that the endpoints of this line are the endpoints p1 and pk of the crown. Case 1. Notice that having endpoints (1,0) and (0,0) would not form a crown since, after translating and rotating the points so (1,0) is on the origin and (0,0) is on the positive x axis, every other point would share an x coordinate with one of the endpoints. diff --git a/_problems/medium/CSS2.md b/_problems/medium/CSS2.md index 621ca9e5..e754b3ff 100644 --- a/_problems/medium/CSS2.md +++ b/_problems/medium/CSS2.md @@ -90,8 +90,8 @@ Print exactly M lines, ith line contains the answer to the ith query as describe
-
-
12. 1 ≤ value, priority ≤ 106, for all subtasks.13. **For 20 points :** 1 ≤ id, N, M, attr ≤ 103 +12. 1 ≤ value, priority ≤ 106, for all subtasks. +13. **For 20 points :** 1 ≤ id, N, M, attr ≤ 103 14. **For 30 points :** 1 ≤ N, M ≤ 103, 1 ≤ id, attr ≤ 106 15. **For 50 points :** 1 ≤ N, M ≤ 105, 1 ≤ id, attr ≤ 106 ### Example diff --git a/_problems/medium/CSUBQ.md b/_problems/medium/CSUBQ.md index 12bf6434..1c065dba 100644 --- a/_problems/medium/CSUBQ.md +++ b/_problems/medium/CSUBQ.md @@ -125,8 +125,8 @@ For each query of type 2, print the required answer in a new line. 5 2 4 - -### Explanation + +### Explanation **Query 1.** A = {0, 0, 0, 0, 0} diff --git a/_problems/medium/CUTSQRS.md b/_problems/medium/CUTSQRS.md index 81c25fcd..e591ee09 100644 --- a/_problems/medium/CUTSQRS.md +++ b/_problems/medium/CUTSQRS.md @@ -42,5 +42,4 @@ For each test case, output the number of characters Michael has to write down (e Sample output: 7 8 - -(In the first case Michael has to write '1 1 first', in the second case '2 1 second'.) \ No newline at end of file +(In the first case Michael has to write '1 1 first', in the second case '2 1 second'.) diff --git a/_problems/medium/CYCLRACE.md b/_problems/medium/CYCLRACE.md index a6ef8fcb..e7e8158b 100644 --- a/_problems/medium/CYCLRACE.md +++ b/_problems/medium/CYCLRACE.md @@ -101,7 +101,7 @@ Output integers **A1**, **A2**, … , **AR** each in a separate line. Here **Ai* - **1** ≤ **N** ≤ **50000** - **1** ≤ **Q** ≤ **105** -- ≤ **Time** ≤ **109** +- 0 ≤ **Time** ≤ **109** - **1** ≤ **NewSpeed** ≤ **109** - **1** ≤ **cyclist** ≤ **N** - **The speed of any cyclist cannot decrease.** @@ -139,5 +139,4 @@ Output integers **A1**, **A2**, … , **AR** each in a separate line. Here **Ai* 42 49 56 - \ No newline at end of file diff --git a/_problems/medium/CYLINDER.md b/_problems/medium/CYLINDER.md index 970820f9..80148d6e 100644 --- a/_problems/medium/CYLINDER.md +++ b/_problems/medium/CYLINDER.md @@ -104,8 +104,8 @@ For each test case, output a single line containing the maximum volume of the co 3.471819240663 0.824190535860 0.785398163397 - ### Explanation + In all examples blue circles are top and bottom of container. Yellow rectangle is used to create lateral surface. Namely, we roll up it along the direction of blue arrow to match green borders. **Example case 1:** diff --git a/_problems/medium/D2.md b/_problems/medium/D2.md index e2ae0731..12121414 100644 --- a/_problems/medium/D2.md +++ b/_problems/medium/D2.md @@ -47,8 +47,8 @@ For each test case, print a line containing a single number which is the maximum 1 2 4 - ### Output details + Case 1: No matter where who reads there number first, just one person is eligible for the lucky draw. Case 2: The person in the last position could read their number first to obtain the sequence 1 3 2. We could then pick 2 sheets with numbers 1 and 2. diff --git a/_problems/medium/D3.md b/_problems/medium/D3.md index c8985b72..7b627e90 100644 --- a/_problems/medium/D3.md +++ b/_problems/medium/D3.md @@ -45,6 +45,6 @@ For each test case, print a single line containing the number of ways of arrangi 4 22 13102 - ### Output details + Case 1: There are four ways of arranging the cannons: put the cannon at positions {(1,1), (2,3), (3,2)}, {(1,2), (2,3), (3,1)}, {(1,2), (2,1), (3,3)}, or {(1,3), (2,1), (3,1)}. The cannon in the middle column is always in the safe position. diff --git a/_problems/medium/DCE01.md b/_problems/medium/DCE01.md index eb5d289c..92c7b714 100644 --- a/_problems/medium/DCE01.md +++ b/_problems/medium/DCE01.md @@ -23,8 +23,8 @@ A ship is represented in sectors as below: + + + + + + + + + + + + - -n is the number of sectors in the topmost level, k is the number of levels. + +n is the number of sectors in the topmost level, k is the number of levels. The first(topmost) level contains n sectors, 2nd contains n-1 sectors, and the k-th(lowermost) sector contains n-k+1 sectors. A sector can only drown when one of the following conditions are met: \* a neighbor of the sector is completely drowned. @@ -32,8 +32,8 @@ A sector can only drown when one of the following conditions are met:
    +  a  +
      b  c  
-
-
"a" will drown when both "b" and "c" are drowned.### Input + "a" will drown when both "b" and "c" are drowned. +### Input The first line contains the number of test cases (about 10). t test cases follow. For each test case, the first line contains three integers n(<=1000), k( The next k lines contain the integers denoting the time taken for the sectors in k-th level to drown completely. @@ -54,11 +54,11 @@ Display t lines each having the single integer, the total time after which, the Output: 33 - + **Explanation:**The sinking time of all the sectors for this example are: ``` 17 15 12 16 21 27 33 15 11 5 9 16 18 - -
Hence the answer 33.
+
+Hence the answer 33.
diff --git a/_problems/medium/DDILEMMA.md b/_problems/medium/DDILEMMA.md
index fcfb1508..9865f661 100644
--- a/_problems/medium/DDILEMMA.md
+++ b/_problems/medium/DDILEMMA.md
@@ -66,5 +66,4 @@ direzti
 50
 25
 
-
 
\ No newline at end of file diff --git a/_problems/medium/DECORATE.md b/_problems/medium/DECORATE.md index 48e446d8..a010a52a 100644 --- a/_problems/medium/DECORATE.md +++ b/_problems/medium/DECORATE.md @@ -108,5 +108,4 @@ aba Output: 21 -
\ No newline at end of file diff --git a/_problems/medium/DEVBDAY.md b/_problems/medium/DEVBDAY.md index ec14663c..6b783ac8 100644 --- a/_problems/medium/DEVBDAY.md +++ b/_problems/medium/DEVBDAY.md @@ -121,8 +121,8 @@ You have to help Devu in choosing an optimal set of friends to invite so that th 2 6 0 - ### Explanation + **Example case 1.** Both his friends are giving him gifts. So he will invite both of them to the party and will collect 8 rupees from the gifts received. **Example case 2.** He invites both of the friends and total rupees collected will be 2 rupees. He can not invite 2nd friend only, because 1st person is a best friend of 2nd person and he must be invited too if 2nd friend is invited. diff --git a/_problems/medium/DEVGOSTR.md b/_problems/medium/DEVGOSTR.md index f8fc9725..a9b1c082 100644 --- a/_problems/medium/DEVGOSTR.md +++ b/_problems/medium/DEVGOSTR.md @@ -92,7 +92,7 @@ Hamming distance between two strings of same size is defined as the number of in ### Constraints - **1** ≤ **T** ≤ **50** -- ≤ **K** ≤ **|s|** +- 0 ≤ **K** ≤ **|s|** ### Subtask @@ -124,8 +124,8 @@ aba Output: 1 5 - ### Explanation + **Example case 1.** Only string of length 1 and alphabet size 1 will be 'a'. Hamming distance of "a" with "a" is zero which is ≤ 1. So answer is 1. **Example case 2.** There can be total 8 strings. 6 of them are good. aaa and bbb are not good, remaining all are good. From the 6 good strings, bab has a hamming distance of 3, remaining other 5 have hamming distance ≤ 2. Hence answer is 5. diff --git a/_problems/medium/DEVHAND.md b/_problems/medium/DEVHAND.md index 892a55ef..9efdb8c2 100644 --- a/_problems/medium/DEVHAND.md +++ b/_problems/medium/DEVHAND.md @@ -108,8 +108,8 @@ For each test case, print a single line corresponding to the answer of the probl 0 6 36 - ### Explanation + **Example #1.** There is no valid arrangement of three strings to the watches, because at least one of the string will be equal to other which will violate the property stated in the problem. diff --git a/_problems/medium/DEVSHOW.md b/_problems/medium/DEVSHOW.md index 41bcf160..a7fe37a8 100644 --- a/_problems/medium/DEVSHOW.md +++ b/_problems/medium/DEVSHOW.md @@ -117,8 +117,8 @@ both 3 5 2 4 - ### Explanation + **Example case 1.** There is exactly one way of voting for Devu and Amit. So after the voting, all the persons will have equal votes. So they all will be kicked out of the show. So as Devu and Amit both are kicked out, print "none" in first line. In second line, print votes of Devu(index 2) and in third line print votes of Amit. **Example case 2.** Devu and Amit can plan to save both of them. Devu will vote to 3rd person and Amit. Amit will vote 2nd person and Devu. In this way, 1st person will have highest 3 votes and 2nd person will have 2 votes, where as the 3rd person will have 0 votes. Devu and Amit both will have 2-2 votes each. So 1st and 3rd both persons will get kicked out of the show. Both Devu and Amit will survive :) diff --git a/_problems/medium/DEVVOTE.md b/_problems/medium/DEVVOTE.md index 30c4184b..30f6bfe8 100644 --- a/_problems/medium/DEVVOTE.md +++ b/_problems/medium/DEVVOTE.md @@ -114,8 +114,8 @@ For each test case, print a single real number corresponding to the answer of th Output: 1.000000 2.000000 - ### Explanation + **Example 1:** **1st** Devu votes himself and get elected for president. So expected number of presidents are **1**. diff --git a/_problems/medium/DGTCNT.md b/_problems/medium/DGTCNT.md index 1d6b1fb4..0c804fb8 100644 --- a/_problems/medium/DGTCNT.md +++ b/_problems/medium/DGTCNT.md @@ -118,6 +118,6 @@ For each test case, output an integer corresponding to the answer, in a new line Output 6 19627 - ### Explanation + **In example 1**. Chef dislikes the integers 24 because the digit 4 appears exactly 1 time in 24, and **a**4 = 1. Similarly, he also dislikes the integer 25 because the digit 5 appears exactly 1 time in 25 and **a**5 = 1. These are the only two integers which Chef dislikes in the range \[21,28\]. Thus Chef loves the integers 21, 22, 23, 26, 27, and 28. Therefore the answer is 6. diff --git a/_problems/medium/DIGITLIS.md b/_problems/medium/DIGITLIS.md index 7460d485..d8b6b6f0 100644 --- a/_problems/medium/DIGITLIS.md +++ b/_problems/medium/DIGITLIS.md @@ -117,8 +117,8 @@ For each test case, output a single integer ― count of different **n**-digit n 36 54 84 - ### Explanation + **Example case 1.** All one-digit numbers have the same **LIS** array, so the answer is **10**: **0, 1, 2, 3, ..., 9**. **Example cases 2 & 3.** Overall we have **90** two-digit numbers (from **10** to **99**). Numbers with second digit strictly greater than first digit have **LIS** array **\[1, 2\]** and there are **36** such numbers. All the other two-digit numbers have **LIS** array **\[1, 1\]**. @@ -127,4 +127,4 @@ An example of how array **LIS** is constructed We will take **7**-digit number **1730418**, its **LIS** array is **\[1, 2, 2, 1, 3, 2, 4\]**: - index LIS length 1 **1**730418 1 2 **17**30418 2 3 **1**7**3**0418 2 4 173418 1 5 **1**7**3**0**4**18 3 6 1734**1**8 2 7 **1**7**3**0**4**1**8** 4 + index LIS length 1 **1**730418 1 2 **17**30418 2 3 **1**7**3**0418 2 4 1730418 1 5 **1**7**3**0**4**18 3 6 17304**1**8 2 7 **1**7**3**0**4**1**8** 4 diff --git a/_problems/medium/DIGVIRUS.md b/_problems/medium/DIGVIRUS.md index 75ba4950..52cf30aa 100644 --- a/_problems/medium/DIGVIRUS.md +++ b/_problems/medium/DIGVIRUS.md @@ -120,8 +120,8 @@ For each test case, output a single line containing one integer — the number o 3 6 4 - ### Explanation + **Test case 1.** In the string 555755555, the virus with index 4 (the one with strength 7) affects two viruses to the left, and two viruses to the right, i.e. viruses with indices 2, 3, 5 and 6. These four viruses will be changed to strength 7 after the first second. The new string will be 577777555. In the next second, viruses with indices 1, 7 and 8 will be changed, and the string will become 777777775. diff --git a/_problems/medium/DINING.md b/_problems/medium/DINING.md index 31bc61fd..21705f2f 100644 --- a/_problems/medium/DINING.md +++ b/_problems/medium/DINING.md @@ -120,6 +120,6 @@ For each test case, output two lines. Output: 0.8 1 2 3 - ### Explanation + **Example case 1.**On the first day, Sergey will eat the first dish. On the second day, he'll eat the second dish. On the third day, he'll try eat the third dish that will appear with the probability of **0.8**. The total probability of dishes being available on these days is 0.8. It is impossible to achieve the better result. diff --git a/_problems/medium/DIREL.md b/_problems/medium/DIREL.md index b68fceef..9f15bd62 100644 --- a/_problems/medium/DIREL.md +++ b/_problems/medium/DIREL.md @@ -136,8 +136,8 @@ john anne 3 1 1 - ### Explanation + Consider the first query: kel is son of john, so the distance = 1 Consider the second query: ron is brother of father of kel, so the distance = 2 diff --git a/_problems/medium/DISTNUM3.md b/_problems/medium/DISTNUM3.md index 8d763d7d..14a46d56 100644 --- a/_problems/medium/DISTNUM3.md +++ b/_problems/medium/DISTNUM3.md @@ -93,7 +93,7 @@ For each query of **type 1**, output the answer to the query in a single line. ### Constraints - **1** ≤ **N, Q** ≤ **105** -- ≤ **C**i, **y** ≤ **109** +- 0 ≤ **C**i, **y** ≤ **109** - **1** ≤ **u, v** ≤ **N** ### Subtasks @@ -125,5 +125,4 @@ For each query of **type 1**, output the answer to the query in a single line. 4 3 3 - \ No newline at end of file diff --git a/_problems/medium/DIVGAME.md b/_problems/medium/DIVGAME.md index 644cd3fc..f89ad053 100644 --- a/_problems/medium/DIVGAME.md +++ b/_problems/medium/DIVGAME.md @@ -111,5 +111,4 @@ Tom Tom Mike Mike - \ No newline at end of file diff --git a/_problems/medium/DIVIDE.md b/_problems/medium/DIVIDE.md index e00f7ca0..7bfa7f5e 100644 --- a/_problems/medium/DIVIDE.md +++ b/_problems/medium/DIVIDE.md @@ -113,6 +113,6 @@ For each test case output a single line with a single integer - the answer to th Output: 1048576 - ### Explanation + The first and the fourth girl will form the first group; the second and the third will form the second group. diff --git a/_problems/medium/DIVPAIR.md b/_problems/medium/DIVPAIR.md index df59cb17..77ea396f 100644 --- a/_problems/medium/DIVPAIR.md +++ b/_problems/medium/DIVPAIR.md @@ -91,5 +91,4 @@ Output one line per testcase, the number of pairs **(a,b)** as described before. 2 0 - \ No newline at end of file diff --git a/_problems/medium/DIVPRO.md b/_problems/medium/DIVPRO.md index 350768b7..7bc4516e 100644 --- a/_problems/medium/DIVPRO.md +++ b/_problems/medium/DIVPRO.md @@ -83,8 +83,8 @@ Let's consider some examples: - **DIVPRO(1)** = **1**. In fact, **DIVPRO(N)** = **N** for any 1-digit number **N**. - **DIVPRO(42)** = **4** / **2** = **2** is an integer. - **DIVPRO(123)** = **1** / **2** \* **3** = **3** / **2** = **1.5** is non-integer. -- **DIVPRO(370)** = **3** / **7** \* = , while intermediate result was **3** / **7** which is non-integer. -- **DIVPRO(3465009)** = **3** / **4** \* **6** / **5** \* / \* **9** is undefined since we have division by zero. +- **DIVPRO(370)** = **3** / **7** \* 0 = 0, while intermediate result was **3** / **7** which is non-integer. +- **DIVPRO(3465009)** = **3** / **4** \* **6** / **5** \* 0 / 0 \* **9** is undefined since we have division by zero. Now Dr. Bobo would like to know how many **L**-digit numbers have their **DIVPRO** value equal to **V** and he wants your help. Since this number can be quite large output it modulo **232**, that is, you need to find the remainder of the division of the answer by **232**. @@ -100,7 +100,7 @@ The first line of the input contains an integer **T** denoting the number of tes - **1** ≤ **T** ≤ **320000** (**320** thousands) - **1** ≤ **L** ≤ **36** -- ≤ **V** < **1018** +- 0 ≤ **V** < **1018** ### Example @@ -117,9 +117,9 @@ The first line of the input contains an integer **T** denoting the number of tes 5 486 2349595 - ### Explanation -**Example case 1.** No 2-digit number has **DIVPRO** value of (as leading zeros are not allowed). Hence the answer is zero. + +**Example case 1.** No 2-digit number has **DIVPRO** value of 0 (as leading zeros are not allowed). Hence the answer is zero. **Example case 2.** The only 3-digit numbers having **DIVPRO** value of **27** are **319**, **629**, **913**, **926** and **939**. So there are 5 such numbers in all. diff --git a/_problems/medium/DIVSET.md b/_problems/medium/DIVSET.md index da282443..a7a71c33 100644 --- a/_problems/medium/DIVSET.md +++ b/_problems/medium/DIVSET.md @@ -116,8 +116,8 @@ For each test case output the answer in a new line. Output: 1 2 - ### Explanation + **Testcase 1:** You can make one step by choosing **{1, 2, 4}**. **Testcase 2:** You can make one step by choosing **{1, 2, 4}** and another by choosing **{1, 2, 4}**. diff --git a/_problems/medium/DIVSUBS.md b/_problems/medium/DIVSUBS.md index 3de4356c..53327dce 100644 --- a/_problems/medium/DIVSUBS.md +++ b/_problems/medium/DIVSUBS.md @@ -108,6 +108,6 @@ If there are several such subsets, you can output any. 1 2 - ### Explanation + We can pick {6} as the subset, then its sum is 6 and this is divisible by 3 - the size of the initial multiset. diff --git a/_problems/medium/DYNAINV.md b/_problems/medium/DYNAINV.md index b7b4dff6..9c7c2f6f 100644 --- a/_problems/medium/DYNAINV.md +++ b/_problems/medium/DYNAINV.md @@ -104,5 +104,4 @@ Output **Q** lines. Output the number of inversions in the permutation (modulo 2 Output: 1 - \ No newline at end of file diff --git a/_problems/medium/E2.md b/_problems/medium/E2.md index 35d16587..42397432 100644 --- a/_problems/medium/E2.md +++ b/_problems/medium/E2.md @@ -56,5 +56,4 @@ The states of the game after pressing each light are: 000 110 010 000 000 000 110 (1,1) 010 (2,1) 100 (2,2) 011 (3,2) 001 (3,3) 000 010 -> 010 -> 110 -> 100 -> 011 -> 000 - \ No newline at end of file diff --git a/_problems/medium/E4.md b/_problems/medium/E4.md index 25c12d68..eae53ab0 100644 --- a/_problems/medium/E4.md +++ b/_problems/medium/E4.md @@ -37,5 +37,4 @@ For each test case, write the result in one line. The first number K is the numb Output: 2 0 1 0 - \ No newline at end of file diff --git a/_problems/medium/ECODE.md b/_problems/medium/ECODE.md index 4d672d24..6df6e9f2 100644 --- a/_problems/medium/ECODE.md +++ b/_problems/medium/ECODE.md @@ -37,10 +37,10 @@ Output in a single line the exit code found. **Input:**
3 11 111 92
-
-
**Output:**084 - +**Output:**``` +084
### Limitations
+
 \* 1<=n<=12
 
 \* 10<=A,B<=1015
diff --git a/_problems/medium/EQUAKE.md b/_problems/medium/EQUAKE.md
index 911d0786..25579aed 100644
--- a/_problems/medium/EQUAKE.md
+++ b/_problems/medium/EQUAKE.md
@@ -92,7 +92,7 @@ You want to get a promotion and promised to complete this task. Now it's time to
 
 Each test file contains only one test case.
 
- The first line of input contains an integer **N** denoting the number of buildings in Bytetown. The second line contains **N** space-separated integers **A0, A1, ..., AN−1** denoting the initial height of the buildings. The third line contains an integer **M** denoting the number of queries. Each of next **M** lines starts with  or **1**, where  denotes a query _Type 0_ and **1** denotes a _Type 1_ query. If it's a _Type 0_ query then **3** integers follows **Li**, **Ri**, **Fi**, denoting number of the leftmost building, number of the rightmost building and force of this shake. If it's a _Type 1_ query then **2** integers follows **Li**, **Ri**, denoting numbers of the leftmost building and the rightmost building of necessary segment.
+ The first line of input contains an integer **N** denoting the number of buildings in Bytetown. The second line contains **N** space-separated integers **A0, A1, ..., AN−1** denoting the initial height of the buildings. The third line contains an integer **M** denoting the number of queries. Each of next **M** lines starts with 0 or **1**, where 0 denotes a query _Type 0_ and **1** denotes a _Type 1_ query. If it's a _Type 0_ query then **3** integers follows **Li**, **Ri**, **Fi**, denoting number of the leftmost building, number of the rightmost building and force of this shake. If it's a _Type 1_ query then **2** integers follows **Li**, **Ri**, denoting numbers of the leftmost building and the rightmost building of necessary segment.
 
 ### Output
 
@@ -127,12 +127,12 @@ For each _Type 1_ query, output an integer denoting the answer for the query wit
 71
 832
 3140
-
 
### Explanation + The initial array: **\[17, 3140, 832\]**. -The first query is a _Type 1_ query with numbers of buildings and **2**, so the answer is the maximum of the array: **3140**. +The first query is a _Type 1_ query with numbers of buildings 0 and **2**, so the answer is the maximum of the array: **3140**. -The second query is a _Type 0_ query with numbers of buildings and **2**, and force **1**, so the array turns to: **\[71, 1403, 328\]**. +The second query is a _Type 0_ query with numbers of buildings 0 and **2**, and force **1**, so the array turns to: **\[71, 1403, 328\]**. The third query is a _Type 1_ query again with numbers of buildings **1** and **2**, so the answer is the maximum of **1403** and **328**: **1403** diff --git a/_problems/medium/EQUATIO.md b/_problems/medium/EQUATIO.md index 7aa23d7c..5a656c9c 100644 --- a/_problems/medium/EQUATIO.md +++ b/_problems/medium/EQUATIO.md @@ -40,5 +40,4 @@ For each test case output one line containing the sought number of solutions to 4 Explanation: - -In the first test case, the only pairs are (2,4) and (4,2). \ No newline at end of file +In the first test case, the only pairs are (2,4) and (4,2). diff --git a/_problems/medium/ES.md b/_problems/medium/ES.md index b660cf9b..c10a09f1 100644 --- a/_problems/medium/ES.md +++ b/_problems/medium/ES.md @@ -99,13 +99,13 @@ A single line which contains a single integer which should be the answer. Output: 15 - ### Explanation +
 floor[1*e] = floor[2.71828..] = 2.
 floor[2*e] = floor[5.43656..] = 5.
 floor[3*e] = floor[8.15484..] = 8.
 So the answer is 2+5+8=15.
-
 
### Note + Source code limit is 1000 bytes. diff --git a/_problems/medium/EXAMCOPY.md b/_problems/medium/EXAMCOPY.md index af31a9c5..59a7d44a 100644 --- a/_problems/medium/EXAMCOPY.md +++ b/_problems/medium/EXAMCOPY.md @@ -135,8 +135,8 @@ No additional constraint 7 8 9 10 2 - + **Output** />/> @@ -151,5 +151,4 @@ No additional constraint 3 1 -1 -1 - \ No newline at end of file diff --git a/_problems/medium/EXGCD.md b/_problems/medium/EXGCD.md index fe6b577c..74ea5a06 100644 --- a/_problems/medium/EXGCD.md +++ b/_problems/medium/EXGCD.md @@ -101,14 +101,14 @@ For each test case, output the value **N** according to the problem statement. I 2 2700 2701 2612 2724 - ### Sample Output +
333333334
 875000005
 722222226
 314159265
-
 
### Explanation + **Sample test 1.** Here **X0** is randomly chosen between 2 and 4, inclusive, and **X1** is randomly chosen between 3 and 5, inclusive. The distribution of the greatest common divisor of **X0** and **X1** can be seen from the following table: 234313142145111The expected value is therefore (1 + 3 + 1 + 2 + 1 + 4 + 1 + 1 + 1) / 9 = 15 / 9 = 5 / 3. diff --git a/_problems/medium/EXNETWRK.md b/_problems/medium/EXNETWRK.md index 85680649..aa45892a 100644 --- a/_problems/medium/EXNETWRK.md +++ b/_problems/medium/EXNETWRK.md @@ -118,8 +118,8 @@ If it is impossible to construct a network with the given parameters for the cor 3 4 4 5 5 1 - ### Explanation + **Example case 1.** There are not enough connections even to satisfy the first requirement. **Example case 2.** The obtained network satisfies all the requirements. diff --git a/_problems/medium/EXPALIN.md b/_problems/medium/EXPALIN.md index 1e22a485..cc1261bf 100644 --- a/_problems/medium/EXPALIN.md +++ b/_problems/medium/EXPALIN.md @@ -117,6 +117,6 @@ Time limit for the first and the second subtasks is 3s. Time limit for the third 9 18 - ### Explanation of the first case in the example test + The following sequences are counted in the answer: {1}, {2}, {3}, {4}, {5}, {1, 2}, {1, 4}, {2, 4}, {1, 2, 4}. diff --git a/_problems/medium/EXPGAME.md b/_problems/medium/EXPGAME.md index 84f3f8ca..012235af 100644 --- a/_problems/medium/EXPGAME.md +++ b/_problems/medium/EXPGAME.md @@ -103,8 +103,8 @@ Output description. Output: Little Chef - ### Explanation + **Example case 1.** Little Chef can remove all the four stones and Head Chef will lose. ### Scoring diff --git a/_problems/medium/F2.md b/_problems/medium/F2.md index b31a7782..0840c206 100644 --- a/_problems/medium/F2.md +++ b/_problems/medium/F2.md @@ -53,8 +53,8 @@ For each test case, print a single number that is the number of different contro 4 1 0 - **Output details** + Case 1: the different control sequences are +-, +-+-, ++--, +-+-+- and the empty sequence. Case 2: same as case 1 together with 4 additional sequences: -+, -+-+, -++-, +--+. These additional sequences no longer make the robot go outside the runway as in case 1. diff --git a/_problems/medium/F3.md b/_problems/medium/F3.md index 7d681f0b..fa17e1e3 100644 --- a/_problems/medium/F3.md +++ b/_problems/medium/F3.md @@ -68,8 +68,8 @@ For each test case, print a single number that is the number of disconnected bro 6 22 1 - ### Output details + ![](../../../content/paulmcvn:paper.png) Case 1 and 2: There are 6 brown regions in the 8x8 napkin. If we unfold it once, it has 22 brown regions: 11 regions in the top half and 11 regions in the bottom half (as shown in the figure above). diff --git a/_problems/medium/FACTSUM.md b/_problems/medium/FACTSUM.md index 84c1c2df..e67c0cb6 100644 --- a/_problems/medium/FACTSUM.md +++ b/_problems/medium/FACTSUM.md @@ -20,8 +20,8 @@ K = p1^a1 * p2^a2 ... * pn^an Compute the following: S = a1*p1 + a2*p2 ... + an*pn. - ### Input + A list of <100 integers, one on each line, all less than 2\*10^19. ### Output @@ -37,5 +37,4 @@ For each integer compute the super factor sum and output it on a single line. Output: 5 7 - \ No newline at end of file diff --git a/_problems/medium/FAIRPAIR.md b/_problems/medium/FAIRPAIR.md index 06c170c4..62f2662a 100644 --- a/_problems/medium/FAIRPAIR.md +++ b/_problems/medium/FAIRPAIR.md @@ -122,8 +122,8 @@ The second line should describes assignment. It should contain **N** space separ 2 3 4 1 1 2 3 1 - ### Explanation + **Example case 1.** Here, there exists an assignment where no student is assigned to the topic he/she studied for: - Student **1** gets task **2**, diff --git a/_problems/medium/FALLDOWN.md b/_problems/medium/FALLDOWN.md index a0aab8a4..5531ddf2 100644 --- a/_problems/medium/FALLDOWN.md +++ b/_problems/medium/FALLDOWN.md @@ -37,8 +37,8 @@ for i : 0 to R-1 The writer's solution does not depend on the factors X, P, Q, M used for input generation. They are used just to decrease the size of input files ( Max 8MB ). - ### Output + For each test case, output the maximum possible sum of ratings along a path that starts in the top row and ends in the bottom row. ### Constraints @@ -64,8 +64,8 @@ For each test case, output the maximum possible sum of ratings along a path that Output: 10 3 - -**Explanation:** + +**Explanation:** The path with maximum sum of ratings in Case 1 is shown in bold 1 1 -5 **3** **1** -1 **1** **1** **-1** **3** 2 -3 **2** -1 1 diff --git a/_problems/medium/FAVGAME.md b/_problems/medium/FAVGAME.md index 6eeb338c..b09c3c60 100644 --- a/_problems/medium/FAVGAME.md +++ b/_problems/medium/FAVGAME.md @@ -111,7 +111,7 @@ For each test case, output a single integer ― the minimum number of working da - **1** ≤ **T** ≤ **10** - **1** ≤ **n** ≤ **1000** - **1** ≤ **ti** ≤ **h** ≤ **24** -- ≤ **mx** ≤ **10** +- 0 ≤ **mx** ≤ **10** - It is guaranteed that the structure of the Game levels is a tree, i.e. it is possible to unlock all **n** levels and every level (except for **1**) has exactly one other level that unlocks it. ### Subtasks @@ -149,8 +149,8 @@ For each test case, output a single integer ― the minimum number of working da 5 4 - ### Explanation + **Example case 1:** Chef has to complete every level during separate working days, and so to complete all **5** levels he needs **5** working days. **Example case 2:** Chef will complete the Game if he will always push unlocked levels into stack starting with the largest indexed one and ending with the smallest indexed one. That is, after Chef completes level **1** he first pushes level **10** (**S = \[10\]**), then level **5** (**S = \[10, 5\]**) and then level **2** (**S = \[10, 5, 2\]**). So the second level Chef will play is **2**. diff --git a/_problems/medium/FAVNUM.md b/_problems/medium/FAVNUM.md index 82299c62..150df293 100644 --- a/_problems/medium/FAVNUM.md +++ b/_problems/medium/FAVNUM.md @@ -99,16 +99,16 @@ Output one integer - the solution to the problem described above or a string "** Output: 163 - -
+
+
 Input:
 1 1 1 1
 2
 
 Output:
 no such number
-
-
+
+
 Input:
 1 1000 15 2
 6
@@ -116,5 +116,4 @@ no such number
 
 Output:
 67
-
 
\ No newline at end of file diff --git a/_problems/medium/FCUBE.md b/_problems/medium/FCUBE.md index bf25a14f..9f3d98b9 100644 --- a/_problems/medium/FCUBE.md +++ b/_problems/medium/FCUBE.md @@ -108,8 +108,8 @@ For each test case, output a single line containing the first term of the sequen Output: 8 216 - ### Explanation + **Example case 1.** First few numbers in the infinite sequence 4, 8, 12, 16, 20, , etc. In this sequence, 8 is the first number which is also a cube (as **23 = 8**). **Example case 2.** First few numbers in the infinite sequence 6, 12, 18, 24, , etc. In this sequence, 216 is the first number which is also a cube (as **63 = 216**). diff --git a/_problems/medium/FDIVGAME.md b/_problems/medium/FDIVGAME.md index 22e48db6..e4c3f19c 100644 --- a/_problems/medium/FDIVGAME.md +++ b/_problems/medium/FDIVGAME.md @@ -110,8 +110,8 @@ For each test case, output a single line containing either “Henry” or “Der Henry Derek - ### Explanation + **Example case 1.** In this test case, the numbers on the board are \[3,4\]. Henry can win by selecting 4 and then dividing it by 2. The integers on the board are now \[3,2\]. Derek now has a couple of choices: - Derek can divide 2 by 3, 4, 5 or 6, making it 0 and removing it. Now only one integer remains on the board, 3, and Henry can just divide it by 6 to finish, and win, the game. diff --git a/_problems/medium/FFUNCT.md b/_problems/medium/FFUNCT.md index b6647953..5c25faa2 100644 --- a/_problems/medium/FFUNCT.md +++ b/_problems/medium/FFUNCT.md @@ -72,7 +72,7 @@ All submissions for this problem are available.### Read problems statements in You are given **N** boolean functions. Formally, each boolean function is a mapping from **{0, 1}K** to **{0, 1}**, where **K** is a number of variables of the function. Different functions in this problem can have different parameters of **K**. -We describe a boolean function **F(x1, x2, ..., xK)** by a string of **2K** characters. Let's enumerate these characters from to **2K-1**. Let's take the **i**-th character of this string. This character will correspond to the value of the boolean function **F** on the set of parameters, corresponding to the last **K** bits of **i** in binary representation. For better understanding, let us have boolean function of **K = 3** variables, described by a string **S = 10101010**. The value of **F(0, 0, 0)** is one, because in binary representation "000" is zero, and **S\[0\] = 1**. The value of F(0, 1, 1) is zero, because "011" in binary representation is three, and **S\[3\] = 0**. +We describe a boolean function **F(x1, x2, ..., xK)** by a string of **2K** characters. Let's enumerate these characters from 0 to **2K-1**. Let's take the **i**-th character of this string. This character will correspond to the value of the boolean function **F** on the set of parameters, corresponding to the last **K** bits of **i** in binary representation. For better understanding, let us have boolean function of **K = 3** variables, described by a string **S = 10101010**. The value of **F(0, 0, 0)** is one, because in binary representation "000" is zero, and **S\[0\] = 1**. The value of F(0, 1, 1) is zero, because "011" in binary representation is three, and **S\[3\] = 0**. Consider a set of boolean functions **{F1, F2, ..., FM}**. We can combine the functions of this set, thus, obtaining the new functions. One function can be used as much times as possible in a single combination. For example, if we have set of two functions: **{F1(x1, x2), F2(y1, y2, y3)}**, we can obtain the following functions: @@ -127,8 +127,8 @@ q 2 3 Output: 3 1 - ### Explanation + The first function of an initial array corresponds to conjunction (AND operation), the second one corresponds to disjunction (OR operation) and the third one corresponds to negation (NOT operation). In the second query we replace the third function in the array (negation) to the function that does not have a common name. diff --git a/_problems/medium/FLOORDIS.md b/_problems/medium/FLOORDIS.md index 197bb30b..d0d6445a 100644 --- a/_problems/medium/FLOORDIS.md +++ b/_problems/medium/FLOORDIS.md @@ -129,8 +129,8 @@ Output a single integer - sum of the rent and support costs per month. 2 3 11 22 Output: 48 - ### Explanation + Here's the scheme of the floor ![](https://lh3.googleusercontent.com/Kf814fLVhIDx-8ZczUSmJAqNDTWpVLHBD6lwZr3HMxxk5OUb1xOU01vCTSIAcgD9Vpo4fYhVwIfRLc9VNDE_g0kVnbFrZRfKkDyfdUJjXaP2VhsYwy1nGXTOwGpsgXNcoOpkpLc4Qs_rDsX23T56BGkTX4M4Z0Q8gcP0T7UqYGI4x2luDAw5MSSgdJlg186Rgo0YATY8HW4HIDUbvWa_zPITOJojByg62rWs8HcKfTxg4T5hD1QVTNfUUxTkyv9b9jivONq2RWxFPAcOt_o2WNmMYAFiEHkkZ-h6hLxWwrb2LA4VLa92xIvLV8mG3W_ZOD8ZGFCG-F6GXskHW8jhq8IppGi9Hp2dGJ2I4PvWIT9yY8R-9h3BbNk6YoC9iYkuge2ghzuJ2N-Q5CogdnnZ-wUh6WK0yC37E7MLKAEKWyy4LGRTlq0689T_OVOKkIHBHKSUvUgYmbwGbtbkO71HXPIYUXgX0xtrnEWxKYuHtmM1KMmV8gY4f55vCnd3Hc1Mw5LqMphYfI1eWOFVBITsbHwmt41TomOyJIXboRpSfcxFst_o-Cd1TiCHpFpNiBEi52oT=w426-h210-no) diff --git a/_problems/medium/FLOORSMV.md b/_problems/medium/FLOORSMV.md index 2844d664..10a47e2f 100644 --- a/_problems/medium/FLOORSMV.md +++ b/_problems/medium/FLOORSMV.md @@ -44,6 +44,6 @@ For each test case, output the sum of the shortest time it takes from (bq,fq) to 10 10 8 - + _**Note :** There are multiple test sets, and the judge shows the sum of the time taken over all test sets of your submission, if Accepted._ diff --git a/_problems/medium/FLY.md b/_problems/medium/FLY.md index 2b4cd358..6b456ab1 100644 --- a/_problems/medium/FLY.md +++ b/_problems/medium/FLY.md @@ -91,11 +91,11 @@ For each test case output a single value, the minimum possible cost of a model. **1** ≤ **N** ≤ **109** - ≤ **C** ≤ **109** +0 ≤ **C** ≤ **109** **C** either will be an integer or will have at most **9** digits after the decimal point. - ≤ **M** ≤ **2** +0 ≤ **M** ≤ **2** **1** ≤ **U**, **V** ≤ **N** @@ -121,8 +121,8 @@ All **M** unordered pairs **{U, V}** will be different. 20.920000000 11.141592653 0.000000000 - ### Explanation + **Case 1.** We will compare two models: **M1** and **M2**. We will denote a fly-over that connects the restaurants with indexes **U** and **V** by **\[U, V\]**. In the model **M1** we have two fly-overs: **\[1, 2\]** and **\[1, 3\]**. Clearly, **T(1, 2) = T(2, 1) = 1** and **T(1, 3) = T(3, 1) = 1** while **T(2, 3) = T(3, 2) = 2** since traveling from **2** to **3** (and vice versa) requires traversing of two fly-overs. Thus, the time penalty is **1+1+1+1+2+2 = 8** seconds, while the cost of the fly-overs constructing is **2 ∙ 1.5 = 3** rupees. Hence, the total cost is **8 + 3 = 11**. diff --git a/_problems/medium/FOMBRO.md b/_problems/medium/FOMBRO.md index d02a62c1..10336c9f 100644 --- a/_problems/medium/FOMBRO.md +++ b/_problems/medium/FOMBRO.md @@ -123,8 +123,8 @@ For each test case, output **Q** lines, each line containing the required answer 624 1144 - ### Explanation for first test case + f\[1\] = 1 f\[2\] = 2 diff --git a/_problems/medium/FOURPTS.md b/_problems/medium/FOURPTS.md index 0011b4d0..638bd5bf 100644 --- a/_problems/medium/FOURPTS.md +++ b/_problems/medium/FOURPTS.md @@ -97,8 +97,8 @@ The triangle will be accepted if, for every input point A = (**xi, yi**), there Output: YES 1.000 1.000 1.000 4.000 3.000 1.000 YES 0.000 0.000 3.000 3.000 3.000 0.000 - ### Explanation + The first testcase corresponds to this image: ![](https://codechef_shared.s3.amazonaws.com/download/upload/SNCKEL17/fourpts1.png)The Ai's (marked in red) correspond to the input points, and the triangle is the outputted triangle. diff --git a/_problems/medium/FOURSQ.md b/_problems/medium/FOURSQ.md index ac3fee8d..575c15ed 100644 --- a/_problems/medium/FOURSQ.md +++ b/_problems/medium/FOURSQ.md @@ -97,7 +97,7 @@ Type 2 operations are given as "**2 L R**" (without the double quotes) where **L ### Output -For each query of the type 2, **output the respective 4 numbers** in arbitrary order that when squared and summed under modulo **P** make that respective product modulo **P**. In case there is no such quadruple then **output -1.** All the 4 numbers should be between to **P - 1**(inclusive) +For each query of the type 2, **output the respective 4 numbers** in arbitrary order that when squared and summed under modulo **P** make that respective product modulo **P**. In case there is no such quadruple then **output -1.** All the 4 numbers should be between 0 to **P - 1**(inclusive) ### Constraints @@ -144,8 +144,8 @@ Note that **X**, **L** and **R** for the queries will always be in the range fro 8 6 4 2 0 1 1 2 0 2 4 2 - ### Explanation + 1 x 2 x 3 x 4 x 5 mod 100 = 120 mod 100 = ( 82 + 62 + 42 + 22 ) mod 100 1 x 2 x 3 mod 100 = 6 mod 100 = ( 02 + 12 + 12 + 22 ) mod 100 diff --git a/_problems/medium/FRBSUM.md b/_problems/medium/FRBSUM.md index 264e7f3e..518e3cb7 100644 --- a/_problems/medium/FRBSUM.md +++ b/_problems/medium/FRBSUM.md @@ -122,8 +122,8 @@ Output should consists of **M** lines. The **i**'th line should contains the ans 8 8 8 - ### Explanation + In the example test there are **M**=5 questions. We won't describe all of them, only two ones. **The first question** diff --git a/_problems/medium/FRJUMP.md b/_problems/medium/FRJUMP.md index 57ed8652..6b7a68c5 100644 --- a/_problems/medium/FRJUMP.md +++ b/_problems/medium/FRJUMP.md @@ -141,8 +141,8 @@ For each query of type **2**, output two space separated integers, first digit o Output: 1 120 5 50 - ### Explanation + **In the first query**, Chef is going to visit cities 1, 2, 3, 4, 5 in order. At the end of the trip, his total enjoyment will be 1 \* 2 \* 3 \* 4 \* 5 = 120. First digit of enjoyment is 1 and 120 modulo **109 + 7** is 120. **In the third query**, Chef is going to visit cities 1, 3, 5 in order. At the end of the trip, his total enjoyment will be 1 \* 10 \* 5 = 50. diff --git a/_problems/medium/FRMQ.md b/_problems/medium/FRMQ.md index 9592837d..afded259 100644 --- a/_problems/medium/FRMQ.md +++ b/_problems/medium/FRMQ.md @@ -87,8 +87,8 @@ For the next questions, values of **xi** and **yi** are generated in the followi for i = 2 to M: xi = (xi-1 + 7) mod (N - 1) yi = (yi-1 + 11) mod N - Here **a mod b** denotes the remainder of division of **a** by **b**. + ### Input The first line contains a single integer **N**, denoting the number of elements in the array. @@ -106,7 +106,7 @@ Output a single integer denoting the **sum** of the answers to the questions. - **2** ≤ **N** ≤ **105** - **1** ≤ **M** ≤ **108** - **1** ≤ **Ai** ≤ **109** -- ≤ **x1, y1** ≤ **N-1** +- 0 ≤ **x1, y1** ≤ **N-1** **Subtask 1: (20 points)** @@ -129,8 +129,8 @@ Output a single integer denoting the **sum** of the answers to the questions. Output: 7 - ### Explanation + 28. The first question: **x1** = 0, **y1** = 1 => **ans1** = 2 29. The second question: **x2** = (0 + 7) mod 2 = 1, **y2** = (1 + 11) mod 3 = 0 => **ans2** = 2 30. The third question: **x3** = (1 + 7) mod 2 = 0, **y3** = (0 + 11) mod 3 = 2 => **ans3** = 3 diff --git a/_problems/medium/FUNAGP.md b/_problems/medium/FUNAGP.md index d133dcf1..ffa25f2d 100644 --- a/_problems/medium/FUNAGP.md +++ b/_problems/medium/FUNAGP.md @@ -79,7 +79,7 @@ The first line of input contains an integer **T** denoting the number of test ca The first line of each test case contains **5** single space separated integers: **N**, **Q**, **R**, **p1**, **p2**). -The next line contains **N** single space separated integers (each is between and **100000** inclusive). +The next line contains **N** single space separated integers (each is between 0 and **100000** inclusive). Then, there are **Q** lines denoting the queries in the format, described above. diff --git a/_problems/medium/FUNC.md b/_problems/medium/FUNC.md index 5bb5b609..f8599b70 100644 --- a/_problems/medium/FUNC.md +++ b/_problems/medium/FUNC.md @@ -119,6 +119,7 @@ where **A** is an array of integers of size **N** (indexed from 1 onwards) a

/>/> ### Explanation + **Query 1.** **(root(1,8)\*4 + root(2,8)\*5 + root(3,8)\*6) % 1000000007 = (8\*4 + 2\*5 + 2\*6) % 1000000007 = 54 % 1000000007 = 54 diff --git a/_problems/medium/G1.md b/_problems/medium/G1.md index 1a2f63a9..a6a5f7ad 100644 --- a/_problems/medium/G1.md +++ b/_problems/medium/G1.md @@ -54,8 +54,8 @@ Johnny wins Mary wins 11000011 - ### Output details + Case 1: Mary knocks down the middle pin. Regardless of which pin Johnny takes out in the next move, Mary always takes out the remaining pin and wins the game. Case 2: Mary will lose the game regardless of which move she plays. For example if she takes out the rightmost pin, it is easy to verify that Johnny will always win if he then takes out the leftmost pin. diff --git a/_problems/medium/G2.md b/_problems/medium/G2.md index f878300d..92db592a 100644 --- a/_problems/medium/G2.md +++ b/_problems/medium/G2.md @@ -61,5 +61,4 @@ A possible set of cells that Bibi could jump into is marked in bold: 4 5 3 8 9 7 8 9 9 9 9 5 - \ No newline at end of file diff --git a/_problems/medium/G3.md b/_problems/medium/G3.md index 14356831..87aac160 100644 --- a/_problems/medium/G3.md +++ b/_problems/medium/G3.md @@ -56,8 +56,8 @@ Move 5 to 4 Mary wins Move 2 to 1 - ### Output details + Case 1: Mary's only possible move is to move the coin at position 2 to position 1. Johnny then moves 3 to 2 and wins the game. Case 2: After Mary moves 5 to 4, the only possible move for Johnny is to move 3 to 2. Mary then finishes the game by moving 4 to 3. diff --git a/_problems/medium/GAMCOUNT.md b/_problems/medium/GAMCOUNT.md index fbb926a3..2d39ce1f 100644 --- a/_problems/medium/GAMCOUNT.md +++ b/_problems/medium/GAMCOUNT.md @@ -95,7 +95,7 @@ For each test case, output a single line containing a single integer, the number - **1** ≤ **T** ≤ **3** - **1** ≤ **K** ≤ **106** - **1** ≤ **N** ≤ **105** -- ≤ **v(i)** ≤ **104** +- 0 ≤ **v(i)** ≤ **104** ### Example @@ -112,6 +112,6 @@ For each test case, output a single line containing a single integer, the number 4 94 100 - ### Explanation + In the first case, the following initial states result in a win for Henry: \[1,1,1\], \[0,0,1\], \[0,1,0\], \[1,0,0\]. diff --git a/_problems/medium/GAMSTICK.md b/_problems/medium/GAMSTICK.md index 0eb20e98..c65d09ac 100644 --- a/_problems/medium/GAMSTICK.md +++ b/_problems/medium/GAMSTICK.md @@ -121,5 +121,4 @@ Slava Draw Draw Miron - \ No newline at end of file diff --git a/_problems/medium/GANGAAM.md b/_problems/medium/GANGAAM.md index d54b888c..a436fa13 100644 --- a/_problems/medium/GANGAAM.md +++ b/_problems/medium/GANGAAM.md @@ -115,8 +115,8 @@ For each test case, output a single line containing the minimum number of gangst 1 2 0 - ### Explanation + **Example case 1.** Gangsters 1 and 2 are friends each other. Also Gangsters 2 and 3 are friends with each other. So it is enough to interrogate gangster 2 only. **Example case 2.**All of the four gangsters are friends with each other. The police suspects that the size of the group is 3. So it is enough to interrogate any two of the gangsters. diff --git a/_problems/medium/GAPFILL.md b/_problems/medium/GAPFILL.md index d0e03ef0..32c5701b 100644 --- a/_problems/medium/GAPFILL.md +++ b/_problems/medium/GAPFILL.md @@ -40,7 +40,7 @@ For each test case, print the number of initial configurations of N \* M board t 2 2 32 - -**Description :** + +**Description :** In first case 1 \* 1 board can have 2 configurations - off or on. Both can be solved. In second case we've a row of 3 lights. There are total of 8 configurations. Out of these only 2 configurations can be solved (one with all lights on and one with all lights off) diff --git a/_problems/medium/GERALD06.md b/_problems/medium/GERALD06.md index 6648939c..4ea13352 100644 --- a/_problems/medium/GERALD06.md +++ b/_problems/medium/GERALD06.md @@ -134,5 +134,4 @@ You should number vertices in graph **G** from **1** to **K**. If there are mult 1 4 1 5 2 3 - \ No newline at end of file diff --git a/_problems/medium/GERALD3.md b/_problems/medium/GERALD3.md index ae6ef3ab..999e27dc 100644 --- a/_problems/medium/GERALD3.md +++ b/_problems/medium/GERALD3.md @@ -109,5 +109,4 @@ a 1 5 1 - \ No newline at end of file diff --git a/_problems/medium/GIVCANDY.md b/_problems/medium/GIVCANDY.md index 935d11a4..01b4ea0f 100644 --- a/_problems/medium/GIVCANDY.md +++ b/_problems/medium/GIVCANDY.md @@ -116,6 +116,7 @@ For each test case, output a single line containing a single integer, the minimu 1
### Explanation
+
 **Example case 1.** In this test case, Alvin has 1 candy and Berto has 5. The apple candies come in packs of 10, and the banana ones come in packs of 3. In this situation, Chef can make them equal by giving 1 pack of 10 to Alvin and 2 packs of 3 to Berto, so they now have 1 + 10 = 5 + 3 + 3 = 11 candies each.
 
 **Example case 2.** In this test case, Alvin has 1 candy and Berto has 2. The apple and banana candies come in packs of 2. In this situation, the number of candies of Alvin is always odd, and the number of candies of Berto is always even, so Chef cannot make them equal. The minimum difference is 1, which Chef can achieve by not giving any packs at all.
diff --git a/_problems/medium/GLASS.md b/_problems/medium/GLASS.md
index d083f687..7430f49e 100644
--- a/_problems/medium/GLASS.md
+++ b/_problems/medium/GLASS.md
@@ -33,13 +33,13 @@ It is always possible to construct volume 0.
 2
 8 1 10
 
-
 
###  Sample Output 
+
 
7 1 1 -
###  Constraints 
+
 1 < n ≤ 10 
 1 ≤ xi ≤ 107 
 MIN(xi) ≤ 100000 
diff --git a/_problems/medium/GPD.md b/_problems/medium/GPD.md
index 3c9559c0..8b6a9af0 100644
--- a/_problems/medium/GPD.md
+++ b/_problems/medium/GPD.md
@@ -133,8 +133,8 @@ For each operation of type 1, output a single line containing the two requested
 0 6
 2 7
 0 1
-
 
### Explanation + Initially, there are 6 police stations in Gotham and our heroes have 4 operations to perform Gordon's station is the one that has id 1 and key 2. **First query:** The values on the path from **4** to **1** are **1 xor 2 = 3**, **4 xor 2 = 6** and **2 xor 2 = 0**. The answer is **0 6**. @@ -149,8 +149,8 @@ The decoded version of all operations is: ``` 0 6 10 6 (t v u k) 1 10 1 (t v k) 1 5 2 (t v k) -
### Note
+
 
c++ cin >> N >> Q; cin >> R >> key; diff --git a/_problems/medium/GRAPLANE.md b/_problems/medium/GRAPLANE.md index d6c09176..058be52e 100644 --- a/_problems/medium/GRAPLANE.md +++ b/_problems/medium/GRAPLANE.md @@ -64,5 +64,4 @@ For each test case output exactly **N**+1 lines. The first of them should contai 7 -5 -2 -3 -7 5 -
\ No newline at end of file diff --git a/_problems/medium/GRIDCHEF.md b/_problems/medium/GRIDCHEF.md index 7c5d5f6d..59bedb91 100644 --- a/_problems/medium/GRIDCHEF.md +++ b/_problems/medium/GRIDCHEF.md @@ -39,9 +39,9 @@ If there are multiple such optimal paths, any path would suffice. 2 2 2 3 3 2 - ### Sample Output +
 6
 5
@@ -50,7 +50,7 @@ If there are multiple such optimal paths, any path would suffice.
 1 1 
 1 0
 0 0
-
 
### Constraints + 1 < m\*n ≤ 100000 0 ≤ Gij ≤ 10000 diff --git a/_problems/medium/GRIDCOL.md b/_problems/medium/GRIDCOL.md index 3eeb6d44..ae832dd9 100644 --- a/_problems/medium/GRIDCOL.md +++ b/_problems/medium/GRIDCOL.md @@ -111,7 +111,7 @@ For each test case, output the number of ways to color the **3rd** row such that Output: 2 4 - ### Explanation + For the 1st case the valid ways to color the **3rd** row are: {1,3,2,4} and {3,4,1,2}. For the 2nd case the valid ways are: {3,1,4,2} , {3,2,4,1} , {4,1,3,2} and {4,2,3,1}. diff --git a/_problems/medium/GRIDCONN.md b/_problems/medium/GRIDCONN.md index 651db125..6d9b1664 100644 --- a/_problems/medium/GRIDCONN.md +++ b/_problems/medium/GRIDCONN.md @@ -108,6 +108,6 @@ For each test case, output a single line containing the minimal position number Output: 7 2679 - ### Explanation + Please pay attention that in the second test case the answer is not 788, as it may seem at first glance. This is because the part 2982**9930**0301 doesn't contain any integer completely in it - neither 299, nor 300. But the part 92892**9930**931932 contains the integer 930 completely. diff --git a/_problems/medium/GROUPING.md b/_problems/medium/GROUPING.md index 31f0034e..c49443e0 100644 --- a/_problems/medium/GROUPING.md +++ b/_problems/medium/GROUPING.md @@ -15,7 +15,7 @@ layout: problem ### Input - The first line contains a single integer **T** denoting the number of test cases (at most **20**). Each test case begins with three integers **N**, **M** and **K**. Here, **N** is the number of employees (between **1** and **10000**), **M** is the number of compatible pairs of employees (between and **20000**) and **K** is the number of friendly groups that you need to find (between **1** and **50**). The employees are numbered from to **N-1**. The next line contains **N** integers **c0, c1, ..., cN-1** described in the problem statement. These numbers are different non-negative integers not greater than **109**. The next **M** lines describe pairs of compatible employees, one per line. The **i**'th such line contains two distinct integers **ui, vi** between and **N-1**. + The first line contains a single integer **T** denoting the number of test cases (at most **20**). Each test case begins with three integers **N**, **M** and **K**. Here, **N** is the number of employees (between **1** and **10000**), **M** is the number of compatible pairs of employees (between 0 and **20000**) and **K** is the number of friendly groups that you need to find (between **1** and **50**). The employees are numbered from 0 to **N-1**. The next line contains **N** integers **c0, c1, ..., cN-1** described in the problem statement. These numbers are different non-negative integers not greater than **109**. The next **M** lines describe pairs of compatible employees, one per line. The **i**'th such line contains two distinct integers **ui, vi** between 0 and **N-1**. No pair of employees will be given more than once in the input. That is, for distinct indices **i** and **j**, we do not have both **ui = uj** and **vi = vj**, nor do we have both **ui = vj** and **vi = uj**. @@ -53,5 +53,4 @@ layout: problem 0 - \ No newline at end of file diff --git a/_problems/medium/GRTRIP.md b/_problems/medium/GRTRIP.md index d8fa7ca4..ea289628 100644 --- a/_problems/medium/GRTRIP.md +++ b/_problems/medium/GRTRIP.md @@ -115,33 +115,33 @@ Output should contain a single integer on the first line - answer for the proble 1 ≤ u,vN 1 ≤ w ≤ 10000 - ### Example: + **Input #1:**
 2 0
 
-
 
**Output #1:** +
 4
 
-
 
**Input#2:** +
 3 3
 1 2 1
 1 3 2
 2 3 2
 
-
 
**Output#2:** +
 8
 
-
 
**Explanation:** + For input#1 every possible pair is valid. for input#2 pair(1,3) is not valid, since Chef's algorithm will always go this way 1->2->3, while 1->3 is right way to get from 1 to 3. />/>/> diff --git a/_problems/medium/H2.md b/_problems/medium/H2.md index 00616a90..a22b0ffb 100644 --- a/_problems/medium/H2.md +++ b/_problems/medium/H2.md @@ -32,5 +32,4 @@ Output one number: the maximum speed of the group which can be achieved by optim Output: 0.842105 - \ No newline at end of file diff --git a/_problems/medium/H4.md b/_problems/medium/H4.md index 807395e0..fe7968b5 100644 --- a/_problems/medium/H4.md +++ b/_problems/medium/H4.md @@ -39,5 +39,4 @@ For each test case simply write a single line containing the answer to the probl 288 3413 50069 - \ No newline at end of file diff --git a/_problems/medium/HAIRCUT.md b/_problems/medium/HAIRCUT.md index e536a36c..72a11b5e 100644 --- a/_problems/medium/HAIRCUT.md +++ b/_problems/medium/HAIRCUT.md @@ -131,8 +131,8 @@ For each test case, output a single line containing one integer — the maximum 5 20 3 - ### Explanation + **Test case 1.**There are 5 important days. Since Limak had his hair cut on the day 0, he can just wait and he will look good on days 4 through 8 (during that time, the number of days from the most recent haircut will be between **A** and **B**). There are 2 important days (6 and 8) in that interval. There exists a strategy that allows Limak to look good on 3 important days. For example, he could get a new haircut on the day 1 — then he will look good on days 5 through 9, including 3 important days. It turns out that it's impossible that Limak would look good on 4 or more important days. So the answer is 3. **Test case 2.**Limak should get a haircut on the day 6, to look good on days 12 through 18. Then he should get a haircut on the day 19, to look good on days 25 through 31. In total, he will look good on 6 important days: 12, 13, 15, 17, 18, 25. diff --git a/_problems/medium/HAPPY.md b/_problems/medium/HAPPY.md index c9fc96fb..a7025ff3 100644 --- a/_problems/medium/HAPPY.md +++ b/_problems/medium/HAPPY.md @@ -42,5 +42,4 @@ For each test case print the number of days Johnny will be happy in this situati Output: 4 - \ No newline at end of file diff --git a/_problems/medium/HBIRD.md b/_problems/medium/HBIRD.md index 72d95129..9ab30c86 100644 --- a/_problems/medium/HBIRD.md +++ b/_problems/medium/HBIRD.md @@ -119,13 +119,13 @@ For each of the chef's question, Print the maximum number of birds he can feed. 10 15 +
**Output**```
 
-
**Output**
 2
 4
 5
-
 
### Explanation + ![](https://s3.amazonaws.com/hr-challenge-images/16094/1456949882-92fd6e6d3e-final.jpg "final.jpg")There are these 10 birds possible with their hungriness as follows:
@@ -139,5 +139,5 @@ For each of the chef's question, Print the maximum number of birds he can feed.
 (H) 2
 (I) 0
 (J) 3
-
-
Note that bird **(I)** is not hungry and therefore we don't need to feed it. 31. With **5** grams of grains, we can only feed maximum of **2** birds say birds **(C)** and **(F)**.32. With **10** grams of grains, we can only feed at maximum of **4** birds say birds **(C), (F), (G)** and **(H)**. +
Note that bird **(I)** is not hungry and therefore we don't need to feed it. 31. With **5** grams of grains, we can only feed maximum of **2** birds say birds **(C)** and **(F)**. +32. With **10** grams of grains, we can only feed at maximum of **4** birds say birds **(C), (F), (G)** and **(H)**. diff --git a/_problems/medium/HCLEAN.md b/_problems/medium/HCLEAN.md index b2cc15a1..976c7f96 100644 --- a/_problems/medium/HCLEAN.md +++ b/_problems/medium/HCLEAN.md @@ -135,8 +135,8 @@ Subtask 4 (71 point): -1 1 -2 -
### Explanation + **Example case 1.** It is easy to see that the square of the euclidean distance between any two adjacent rooms in the route will not exceed **D = 5**. **Example case 2.** It is clearly impossible to accomplish the task. diff --git a/_problems/medium/HILLJUMP.md b/_problems/medium/HILLJUMP.md index 532cae35..d83d4c23 100644 --- a/_problems/medium/HILLJUMP.md +++ b/_problems/medium/HILLJUMP.md @@ -118,8 +118,8 @@ For each operation of Type 1, output the index of the hill in which the particip Output: 3 4 - ### Explanation + The initial heights are (1, 2, 3, 4, 5). The first operation is of Type 1 and starts from Hill 1 and wants to jump twice. The first jump will be to Hill 2, and the second jump will be to Hill 3. Hence the output for this is 3. The second operation changes the heights to (1, 2, 2, 3, 5). diff --git a/_problems/medium/HISTJUNK.md b/_problems/medium/HISTJUNK.md index 64797ed1..15a512c8 100644 --- a/_problems/medium/HISTJUNK.md +++ b/_problems/medium/HISTJUNK.md @@ -140,8 +140,8 @@ If it is impossible to accomplish the requirement, print "-1 -1" (without quotes 3 7 4 8 0 0 - ### Explanation + **In the first example**, the obtained road system satisfies the required constraints. Please note that you don't need to minimize the number of added roads and junctions. **In the second example**, you can leave everything as it is because the given graph already satisfies the constraints. diff --git a/_problems/medium/HLDOTS.md b/_problems/medium/HLDOTS.md index f08e14dc..ae44415f 100644 --- a/_problems/medium/HLDOTS.md +++ b/_problems/medium/HLDOTS.md @@ -109,6 +109,6 @@ Output the number of correct heavy-light decompositions of the given tree. Since Output: 8 - ### Explanation + **Example case 1.** Input is a complete binary tree. It consists of 7 nodes, therefore you can't have more than **⌊log2 7⌋ = ⌊(2.80735492206)⌋ = 2** light edges on the path from the root node to any other one. But the tree's height is 2, so you can choose the decomposition in any way you like. All the decompositions will be correct ones. There are three nodes that has outgoing edges from them (in the direction opposite to the root's one), their numbers are **1**, **2** and **3**. Each of them has 2 outgoing edges from which you can colour exactly one of them heavy, so overall you'll have 2 \* 2 \* 2 = 8 options of creating the correct heavy-light decompositions. diff --git a/_problems/medium/HOB.md b/_problems/medium/HOB.md index 517b25fc..097e279a 100644 --- a/_problems/medium/HOB.md +++ b/_problems/medium/HOB.md @@ -68,13 +68,13 @@ time: current: 1493557694 layout: problem --- -All submissions for this problem are available.Byteland has always been popular among tourists. Seeing a business opportunity, Chef has built a brand new Hotel Balifornia there. The hotel has **R** unique comfortable rooms for guests' purpose. The rooms are numbered by integers from to **R-1**, inclusive. All rooms in the hotel are on the same floor and arranged in a circle. Namely, +All submissions for this problem are available.Byteland has always been popular among tourists. Seeing a business opportunity, Chef has built a brand new Hotel Balifornia there. The hotel has **R** unique comfortable rooms for guests' purpose. The rooms are numbered by integers from 0 to **R-1**, inclusive. All rooms in the hotel are on the same floor and arranged in a circle. Namely, -- the room next to the room is the room **1**; +- the room next to the room 0 is the room **1**; - the room next to the room **1** is the room **2**; - ... - the room next to the room **R-2** is the room **R-1**; -- finally, the room next to the room **R-1** is the room . +- finally, the room next to the room **R-1** is the room 0. When **R = 1** we have only one room and it is next to itself. @@ -136,9 +136,9 @@ For each visit of each test, output a single line containing the inconvenience c - **1** ≤ **T** ≤ **1000** - **1** ≤ **N** ≤ **200000** (**2 \* 105**) - **1** ≤ **R** ≤ **500** (**R** is not divisible by **33**) -- ≤ **H** ≤ **23** -- ≤ **M** ≤ **59** -- ≤ **G** ≤ **9999999** (**107 − 1**) +- 0 ≤ **H** ≤ **23** +- 0 ≤ **M** ≤ **59** +- 0 ≤ **G** ≤ **9999999** (**107 − 1**) - The total number of visits over the input does not exceed **200000** (**2 \* 105**) - The name of each guest contains only uppercase and lowercase letters of English alphabet and has length from 1 to 10, inclusive @@ -166,8 +166,8 @@ For each visit of each test, output a single line containing the inconvenience c -134 1 1 - ### Explanation + Guest's nameCur TimePrev. inconv.RNG outputRoomStatusOrder of roomsOutputBrad00:10091513 + 01`----`10Kanye00:12013097144 + 00`-B--`00Angelina01:10060979313407 + 03`KB--`30John05:380375983 + 03`KB-A`3 → 0 → 22Bill12:55282083 + 21`-BJA`1 → 2 → 02Tom12:56422288 + 40`BBJA`0 → 1 → 3 → 2-134Nicole20:01138558693338 + 1380`B-JA`0 → 11Daniel03:00139158240589 + 1390`B-J-`0 → 11- The **Prev. inconv.** column contains the total inconvenience caused to all previous guests. - By **RNG output** here we mean the value before taking it modulo **R**. - The **Room** column contains the room that was initially assigned to the guest and it is the actual value returned by RNG. It is equal to the value in the previous column take modulo **R = 4**. diff --git a/_problems/medium/HOB2.md b/_problems/medium/HOB2.md index bbba1be4..148fdd72 100644 --- a/_problems/medium/HOB2.md +++ b/_problems/medium/HOB2.md @@ -28,7 +28,7 @@ layout: problem --- All submissions for this problem are available.I hope all of you remember that Chef built a Hotel Balifornia in Byteland and some complicated scheme for allocating guests, invented by lift boy, was used. But after realizing all badness of this scheme Chef fired lift boy and simplifies the process of allocating guests drastically. Now at the time of check-in each guest only provides the preferable room for him and the number of minutes he will stay in the hotel. After that the hotel manager finds the first available room starting from the provided one assuming that rooms in the hotel are arranged in cyclic manner. -Namely, let there be **R** rooms in the hotel and they are numbered by numbers from to **R − 1**, inclusive. Suppose guest chooses the room **K**. Then the hotel manager checks rooms in order +Namely, let there be **R** rooms in the hotel and they are numbered by numbers from 0 to **R − 1**, inclusive. Suppose guest chooses the room **K**. Then the hotel manager checks rooms in order **K, K + 1, K + 2, ..., R − 2, R − 1, 0, 1, 2, ..., K − 2, K − 1** and allocates the guest in the first free room in this list or report the guest that all rooms are occupied if this is the case./>/> @@ -42,15 +42,15 @@ The first line of the input contains an integer **T**, denoting the number of te ### Output -For each test case output **N** lines. The **i**-th line among them should contain two space separated integers **room** and **stay\_time**, the room chosen by the **i**-th guest and the time he will stay in the hotel, **room** should be from to **R − 1** inclusive and **stay\_time** should be from **1** to **31415926**, inclusive. If there are several possible answers you can output any of them. But your output should be consistent as stated above. Existence of such answer is always guaranteed for our test data (see **Constraints** section below). +For each test case output **N** lines. The **i**-th line among them should contain two space separated integers **room** and **stay\_time**, the room chosen by the **i**-th guest and the time he will stay in the hotel, **room** should be from 0 to **R − 1** inclusive and **stay\_time** should be from **1** to **31415926**, inclusive. If there are several possible answers you can output any of them. But your output should be consistent as stated above. Existence of such answer is always guaranteed for our test data (see **Constraints** section below). ### Constraints - **1** ≤ **T** ≤ **314159** - **1** ≤ **R** ≤ **314159** - **1** ≤ **N** ≤ **314159** -- ≤ **time** < **31415926** -- ≤ **inconv** ≤ **R** +- 0 ≤ **time** < **31415926** +- 0 ≤ **inconv** ≤ **R** - The sum of **R** over the input does not exceed **314159** - The sum of **N** over the input does not exceed **314159** - Visit times will be given in strictly increasing order @@ -84,8 +84,8 @@ For each test case output **N** lines. The **i**-th line among them should conta 0 3 1 3 0 31415 - ### Explanation + **Example case 1.** Here **R = 1** and **N = 2**. Let's check that provided output is consistent. The first guest comes at time 0 and asks for room 0 for 31 minutes. Since the hotel is initially empty we settle him at this room causing zero inconvenience. The second guest comes at time 314 and asks for room 0 for 31415 minutes. The first guest made this room free at time 31 so at time 314 it is free and we settle the second guest at room 0 causing zero inconvenience. **Example case 2.** Here **R = 5** and **N = 3**. Again let's check that provided output is consistent. The first guest comes at time 3 and asks for room 4 for 31 minutes. Since the hotel is initially empty we settle him at this room causing zero inconvenience. The second guest comes at time 31 and asks for room 4 for 314 minutes. But the first guest is still living in this room (he will free it at time 34). Therefore, we settle the second guest at the room 0 (the next after 4 in cyclic manner) causing inconvenience 1. Finally the third guest comes at time 314 and asks for room 2 for 3141 minutes. This room is free and we settle him at this room causing zero inconvenience. diff --git a/_problems/medium/IDOLS.md b/_problems/medium/IDOLS.md index ab350770..6a3b8ee9 100644 --- a/_problems/medium/IDOLS.md +++ b/_problems/medium/IDOLS.md @@ -125,8 +125,8 @@ For each query of the second type, output a single line containing two integers, Output: 5 5 - ### Explanations + In the input, before the second query, **F**'s and **G's** equals to the following: **ID****F****G**111222333444555After the second query, **F**'s and **G's** equals to the following: diff --git a/_problems/medium/INCXOR.md b/_problems/medium/INCXOR.md index 4b32a2fe..d68d708f 100644 --- a/_problems/medium/INCXOR.md +++ b/_problems/medium/INCXOR.md @@ -116,8 +116,8 @@ Output a single number, the number of sequences, modulo 109+7. 986095186 0 468598063 - ### Explanation + In the first case, there are 231 possible sequences, so the answer is 231 modulo 109+7 = 147483634 For the second case, one possible example of a valid sequence is b = 9, 9, 18, 19, 32. We can check that this sequence is nondecreasing, and also, we have (**a**1 XOR b1) = 12, (**a**2 XOR b2) = 13, (**a**3 XOR b3) = 17, (**a**4 XOR b4) = 17, (**a**5 XOR b5) = 33, which is also nondecreasing. diff --git a/_problems/medium/INSOMA3.md b/_problems/medium/INSOMA3.md index 8f2f37f2..3e2c2d88 100644 --- a/_problems/medium/INSOMA3.md +++ b/_problems/medium/INSOMA3.md @@ -47,5 +47,4 @@ Line 1: The disorderliness index of the street. Output: 2 - \ No newline at end of file diff --git a/_problems/medium/INSOMA4.md b/_problems/medium/INSOMA4.md index 17c73003..bf9e3ac1 100644 --- a/_problems/medium/INSOMA4.md +++ b/_problems/medium/INSOMA4.md @@ -58,5 +58,4 @@ PJQ Output: 3 - \ No newline at end of file diff --git a/_problems/medium/INSOMA5.md b/_problems/medium/INSOMA5.md index a0986add..341ce383 100644 --- a/_problems/medium/INSOMA5.md +++ b/_problems/medium/INSOMA5.md @@ -32,5 +32,5 @@ T.F+T*F Output: 5 - -**Description**The 5 values correspond to the parenthesizations (((T.F)+T)\*F), ((T.F)+(T\*F)), ((T.(F+T))\*F, (T.((F+T)\*F)), (T.(F+(T\*F))) - all of which evaluate to true. +**Description** +The 5 values correspond to the parenthesizations (((T.F)+T)\*F), ((T.F)+(T\*F)), ((T.(F+T))\*F, (T.((F+T)\*F)), (T.(F+(T\*F))) - all of which evaluate to true. diff --git a/_problems/medium/INSOMB3.md b/_problems/medium/INSOMB3.md index d21aa671..4c150136 100644 --- a/_problems/medium/INSOMB3.md +++ b/_problems/medium/INSOMB3.md @@ -72,14 +72,14 @@ Line 1: The number of I's in the given figure. />/>/> * * * # # # # * * * # # # # # # # # # # # # # # # # # # # # - + **Sample Output:**/>
 0
-
 
+ Explanation: The given I is invalid because of 2 reasons: diff --git a/_problems/medium/INVITES.md b/_problems/medium/INVITES.md index 18165efa..6e3b269d 100644 --- a/_problems/medium/INVITES.md +++ b/_problems/medium/INVITES.md @@ -106,8 +106,8 @@ For each test-case, output the number of ways modulo **1000000007** (**109 + 7** 7 5 3 - ### Explanation + The first test case: {}, {1}, {2}, {3}, {4}, {1,3}, {2,4} The second test case: {}, {1}, {2}, {3}, {1,3} diff --git a/_problems/medium/ISONUM.md b/_problems/medium/ISONUM.md index e56f3351..76c9e70c 100644 --- a/_problems/medium/ISONUM.md +++ b/_problems/medium/ISONUM.md @@ -105,8 +105,8 @@ For each test case, output a single line containing the answer to the problem. # Output: 70 102768568246676 - ### Explanation + **Example case 1.** Numbers 1, 2, 3, ..., 9 are isomorphic to 1. Numbers 10, 12, 13, 14, 15 are isomorphic to 10. Among the numbers from 1 to 15, 11 is isomorphic only to itself. So, we get 1 + 1 + ... + 1 + 10 + 11 + 10 + 10 + 10 + 10 = 70. **Example case 2.** This is just a large case so that you can check your solution better. diff --git a/_problems/medium/J1.md b/_problems/medium/J1.md index d826df9a..b0cfa541 100644 --- a/_problems/medium/J1.md +++ b/_problems/medium/J1.md @@ -76,5 +76,4 @@ For each puzzle, output the solution in the same format as the input. Print a bl 531824976 476953812 982176543 - \ No newline at end of file diff --git a/_problems/medium/J2.md b/_problems/medium/J2.md index 5f09737c..07fb3276 100644 --- a/_problems/medium/J2.md +++ b/_problems/medium/J2.md @@ -50,5 +50,4 @@ vn Output details

The only LCS in the first case is "acbd" and in the second case is "vn".

- \ No newline at end of file diff --git a/_problems/medium/JABO.md b/_problems/medium/JABO.md index 2a269bc7..74ea2f4a 100644 --- a/_problems/medium/JABO.md +++ b/_problems/medium/JABO.md @@ -138,8 +138,8 @@ ON OFF OFF OFF - ### Explanation + The input is to interpreted as
@@ -153,5 +153,4 @@ L 10 8 6 1
 L 1 1 2 1
 R 10 10
 L 9 10 10 9
-
 
\ No newline at end of file diff --git a/_problems/medium/JRNTREE.md b/_problems/medium/JRNTREE.md index 965d270b..14ce6772 100644 --- a/_problems/medium/JRNTREE.md +++ b/_problems/medium/JRNTREE.md @@ -88,7 +88,7 @@ Please help him to calculate this number. Since it can be large, output it modul The first line of the input contains an integer **N** denoting the number of cities in TreeLand. -The second line contains **N** space-separated integer numbers. Let's denote the **i**th of them by **Ai**. If **Ai** is , then Sergey is not certain about the number of the city that was the **i**th in his records. Otherwise, **Ai** denotes the number of the **i**th city in Sergey's records. +The second line contains **N** space-separated integer numbers. Let's denote the **i**th of them by **Ai**. If **Ai** is 0, then Sergey is not certain about the number of the city that was the **i**th in his records. Otherwise, **Ai** denotes the number of the **i**th city in Sergey's records. Each of the following **N-1** lines contains two space-separated integers, **Xj Yj**, denoting a road in TreeLand. @@ -99,7 +99,7 @@ Output the total number of possible trips Sergey could have done, which do not c ### Constraints - **1** ≤ **N** ≤ **500** -- ≤ **Ai** ≤ **N** +- 0 ≤ **Ai** ≤ **N** - **1** ≤ **Xj**, **Yj** ≤ **N** - Every city is directly connected with no more than **8** other cities. - The road system forms a tree. @@ -117,8 +117,8 @@ Output the total number of possible trips Sergey could have done, which do not c Output: 4 - ### Explanation + Sergey could have obtained the following sequences: - 1 2 3 4 5: 1 -> 2 -> 1 -> 3 -> 4 -> 3 -> 5 -> 3 -> 1. diff --git a/_problems/medium/JTREE.md b/_problems/medium/JTREE.md index 978b7626..c3ada1f5 100644 --- a/_problems/medium/JTREE.md +++ b/_problems/medium/JTREE.md @@ -132,8 +132,8 @@ Output **Q** lines: the answer for each friend. 10 22 5 - ### Subtasks + - **Subtask #1 (10 points) : N, M, Q ≤ 102, wi ≤ 105** - **Subtask #2 (15 points) : N, M, Q ≤ 103, wi ≤ 108** - **Subtask #3 (25 points) : N, M, Q ≤ 5\*104, wi ≤ 109** diff --git a/_problems/medium/JUNONGF.md b/_problems/medium/JUNONGF.md index fe83d898..eafc1172 100644 --- a/_problems/medium/JUNONGF.md +++ b/_problems/medium/JUNONGF.md @@ -151,8 +151,8 @@ All N dimensions after calculation will be between 1 and 2^63 – 1. 1 729 387420489 - ### Explanation + **Test case 1**: Since V is equal to 1, there is only way to open restaurants in the 2 dimensional city of dimensions 3\*3: | 0 0 0 | diff --git a/_problems/medium/K3.md b/_problems/medium/K3.md index 9ee5fa40..07faace3 100644 --- a/_problems/medium/K3.md +++ b/_problems/medium/K3.md @@ -76,5 +76,4 @@ For each test case, print the minimum number of steps that WallB needs to travel 8 -1 6 - \ No newline at end of file diff --git a/_problems/medium/KCHIPS.md b/_problems/medium/KCHIPS.md index 64794101..462f5bfe 100644 --- a/_problems/medium/KCHIPS.md +++ b/_problems/medium/KCHIPS.md @@ -43,7 +43,7 @@ For each of the R rounds, print the answer in a new line. V[0..5] = { 3, 1, 2, 2, 1, 1 } : Only Village 1 occurs more than K ( = 2) times. V[2..4] = { 2, 2, 1} : None of the villages occur more than 2 times. V[1..7] = { 1, 2, 2, 1, 1, 2, 1 } : Villages 1 and 2 occur more than 2 times. - -_Warning : Large input / output. You may have to use efficient input / output methods if you are using languages with heavy input / output overload. Eg: Prefer using scanf/printf to cin/cout for C/C++ + +_Warning : Large input / output. You may have to use efficient input / output methods if you are using languages with heavy input / output overload. Eg: Prefer using scanf/printf to cin/cout for C/C++ Note : There are multiple test sets, and the judge shows the sum of the time taken over all test sets of your submission, if Accepted. Time limit on each test set is 2 sec_ diff --git a/_problems/medium/KCONNECT.md b/_problems/medium/KCONNECT.md index 1dba0d00..45049650 100644 --- a/_problems/medium/KCONNECT.md +++ b/_problems/medium/KCONNECT.md @@ -107,6 +107,6 @@ For each test case, output the required answer. 8 7 - ### Explanation: + ![](https://s3.amazonaws.com/hr-challenge-images/3194/1448608384-4e93622266-final_image.png "final_image.png") diff --git a/_problems/medium/KINT.md b/_problems/medium/KINT.md index 454ff797..51f44cae 100644 --- a/_problems/medium/KINT.md +++ b/_problems/medium/KINT.md @@ -89,7 +89,7 @@ For each test case, output a single line containing the answer to the correspond - **1** ≤ **T** ≤ **5** - **1** ≤ **N** ≤ **109** - **1** ≤ **K** ≤ **7** -- ≤ **B** ≤ **30** +- 0 ≤ **B** ≤ **30** ### Example @@ -103,13 +103,13 @@ For each test case, output a single line containing the answer to the correspond 0 2 1 - ### Notes + XOR-sum of **n** integers **A\[1\], , , A\[n\]** will be **A\[1\] xor A\[2\] xor .. A\[n\]**. By xor, we mean [bit-wise xor](http://en.wikipedia.org/wiki/Bitwise_operation#XOR). ### Explanation -**Example case 1.** There is no way to choose a subset of **2** integers from **{0, 1, 2}** such that the XOR-sum contains set bits. +**Example case 1.** There is no way to choose a subset of **2** integers from **{0, 1, 2}** such that the XOR-sum contains 0 set bits. **Example case 2.** The two possible subsets in this case are **{0, 1}** and **{0, 2}**. In both cases the XOR-sum (**1** and **2** respectively) contains exactly one set bit. diff --git a/_problems/medium/KIRMEME.md b/_problems/medium/KIRMEME.md index 0ff466d0..241ea119 100644 --- a/_problems/medium/KIRMEME.md +++ b/_problems/medium/KIRMEME.md @@ -142,5 +142,4 @@ For each test case, output a single line containing one integer denoting amount 1 1 24 - \ No newline at end of file diff --git a/_problems/medium/KMHAMHA.md b/_problems/medium/KMHAMHA.md index 8262ea0c..03dcef9c 100644 --- a/_problems/medium/KMHAMHA.md +++ b/_problems/medium/KMHAMHA.md @@ -103,5 +103,4 @@ For each case print the minimum number of attacks that are needed to kill all th Output 2 - \ No newline at end of file diff --git a/_problems/medium/KNIGHTS.md b/_problems/medium/KNIGHTS.md index 1a5ef400..9a015333 100644 --- a/_problems/medium/KNIGHTS.md +++ b/_problems/medium/KNIGHTS.md @@ -42,8 +42,8 @@ For each test case, output on a single line the maximum number of knights that m
4
 11
 
-
-
The following image represents the chessboard and a possible solution to the second test case:![nn#_n +The following image represents the chessboard and a possible solution to the second test case: +![nn#_n #n_#n ##__n _n_## diff --git a/_problems/medium/KNODES.md b/_problems/medium/KNODES.md index 0b56db46..75ab1fa0 100644 --- a/_problems/medium/KNODES.md +++ b/_problems/medium/KNODES.md @@ -137,8 +137,8 @@ No Yes No - ### Explanation: + Query 1: The path corresponding to it is 8->5->3->4->10. Query 2: There does not exists any path joining all 4. diff --git a/_problems/medium/KNPSK.md b/_problems/medium/KNPSK.md index 27aeb9b4..42619003 100644 --- a/_problems/medium/KNPSK.md +++ b/_problems/medium/KNPSK.md @@ -109,8 +109,8 @@ For each capacity **C** (**1 ≤ C ≤ M**) of the knapsack, output a single int Output: 1 5 6 9 10 12 13 14 15 - ### Explanations + In the test case, **M** equals to 9. For **C** = 1, it's optimal to choose {1} items; diff --git a/_problems/medium/KOL1501.md b/_problems/medium/KOL1501.md index 42e98efb..d8a85a09 100644 --- a/_problems/medium/KOL1501.md +++ b/_problems/medium/KOL1501.md @@ -53,6 +53,7 @@ For example, if the result of 2 multiplied with 4 is 9, 5 multiplied with 3 is 1 --------------- The final answer will be 1329 (following the addition algorithm of the earth for managing carry). + Finally Jalebi Bai meets the head chef of the planet, but the problem is he is ready to give her the recipe only if she can solve a puzzle. He asks her to find the sum of the results of multiplication (according to the planet) between all possible ordered pairs of numbers from the set of positive integer less than or equal to a given number **A**. **Note:** If **i** and **j** are distinct, then the pair (**i**,**j**) is considered different from (**j**,**i**). Jalebi Bai then asks him for a formal multiplication algorithm of the planet, to which the head chef agrees and gives following description. @@ -81,6 +82,7 @@ Multiply(X[1..p], Y[1..q]) } Aliens cannot hear any large number, so they want to hear the output modulo **Mod**, where **Mod** is some integer. + If Jalebi Bai gives a wrong output, she would be eaten up! (Surprise surprise!) Jalebi Bai can contact someone on earth for help. She reaches you for a code which can evaluate the output for any given input. Can you help her solve this puzzle? @@ -129,8 +131,8 @@ For each test case, output the solution modulo **Mod** in a single line. 2025 1 96 - ### Example2 +
Input:
 1 1 1 1 1 1 1 1 1
 1 4 6 8 10 12 14 16 18
@@ -147,8 +149,8 @@ For each test case, output the solution modulo **Mod** in a single line.
 
 Output:
 1953
-
 
### Explanation + **Example case 1.** Normal multiplication rule follows. **Example case 2.** The only pairs with multiplication different from normal multiplication are (1, 2), (1, 3), ..., (1, 9) and (2, 1), (3, 1), ..., (9, 1). diff --git a/_problems/medium/KOL1503.md b/_problems/medium/KOL1503.md index 93bbf9a3..e2e4c900 100644 --- a/_problems/medium/KOL1503.md +++ b/_problems/medium/KOL1503.md @@ -82,8 +82,8 @@ No No No - ### Explanation + **Example case 1.** - **Query 1:** The path contains (()). diff --git a/_problems/medium/KOL1505.md b/_problems/medium/KOL1505.md index 67ecb43b..250ea5d9 100644 --- a/_problems/medium/KOL1505.md +++ b/_problems/medium/KOL1505.md @@ -61,8 +61,8 @@ jr Output: Yes No - ### Explanation + **In the first example**, Jalebi Bai can change the first deck from "rrrjj" to "rrrj" in a single operation, then both the decks will be equal. Example taken from the statements. diff --git a/_problems/medium/KOL1507.md b/_problems/medium/KOL1507.md index 9d51fa55..4d2983f1 100644 --- a/_problems/medium/KOL1507.md +++ b/_problems/medium/KOL1507.md @@ -75,8 +75,8 @@ For each road (in the **same order as input**), output the value of the minimum 20 20 20 - ### Explanation + **Example case 1** - Road from House 1 to House 2 (i.e Road 1) is blocked: diff --git a/_problems/medium/KOL1508.md b/_problems/medium/KOL1508.md index 8c2db2bc..b2b1d9b8 100644 --- a/_problems/medium/KOL1508.md +++ b/_problems/medium/KOL1508.md @@ -75,8 +75,8 @@ Since **N** can be large, the input is the prime factorization of **N**. The inp Output: 2 1 2 2 - ### Explanation + **Example case 1.** The largest antichain size is 2, and there is only one of it {2,3} **Example case 2.** The largest antichain size is 2, and there are two of those: {2,3} and {4,3} diff --git a/_problems/medium/KOL1510.md b/_problems/medium/KOL1510.md index 5ae882ef..5627e049 100644 --- a/_problems/medium/KOL1510.md +++ b/_problems/medium/KOL1510.md @@ -73,8 +73,8 @@ BGB BGB BGGB BGBB - ### Explanation + **In the first example**, Devu can give necklace the BGB to Jalebi Bai, as it contains both the Barfi's necklace BG and GB as subsequence. Note that Devu can also give GBG to Jalebi Bai. diff --git a/_problems/medium/KOL16A.md b/_problems/medium/KOL16A.md index 9eb6d27f..8a879187 100644 --- a/_problems/medium/KOL16A.md +++ b/_problems/medium/KOL16A.md @@ -45,8 +45,8 @@ foreach Battle, bi else total -= probability of Allies winning in bi PEB = max(total / no. of battles, 0) - As the Allies already deciphered Enigma, they can choose to win or lose any battle they want. Consider the following scenario as example: + ![](https://www.codechef.com/download/upload/ACM16KOL/A.png) Some battles are more important than others; the ith battle has an Impact Factor **Fi**. As a war analyst, your job is to maximize the sum of Impact Factors of all the battles won. But the enemies must not know that Allies have deciphered Enigma, so you must keep PEB less than a certain **threshold, S**; throughout the whole war. @@ -81,5 +81,4 @@ For each test case, print case number and the maximum sum of impact factors. Output Case 1: 300 Case 2: 9 - \ No newline at end of file diff --git a/_problems/medium/KOL16E.md b/_problems/medium/KOL16E.md index 923437d7..fb2bdef2 100644 --- a/_problems/medium/KOL16E.md +++ b/_problems/medium/KOL16E.md @@ -54,5 +54,4 @@ For each line of input, produce exactly one line of output like either "Case -
\ No newline at end of file
diff --git a/_problems/medium/KOL16K.md b/_problems/medium/KOL16K.md
index 66da3f23..14d9aa18 100644
--- a/_problems/medium/KOL16K.md
+++ b/_problems/medium/KOL16K.md
@@ -68,8 +68,8 @@ For a each test case, output a single integer in separate line corresponding to
  3
  3
  4
-
 
### Explanation + **Explanation case 1.** We can get sequence (1, 1) - (4, 2) - (9, 3), point (9, 3) lies below line between point (1, 1) and (4, 2). **Explanation case 2.** diff --git a/_problems/medium/KOL16L.md b/_problems/medium/KOL16L.md index e2781a2b..2261d748 100644 --- a/_problems/medium/KOL16L.md +++ b/_problems/medium/KOL16L.md @@ -56,8 +56,8 @@ Output a single line containing the answer, which is the minimum Cost over all v 1 3 2 1 2 Output: 5 - ### Explanation + For **N** = 3, there are 5 valid BSTs possible: ``` T1: @@ -116,5 +116,4 @@ Cost(T4, S) = Depth(1) + Distance(1, 3) + Distance(3, 2) + Distance(2 Cost(T5, S) = Depth(1) + Distance(1, 3) + Distance(3, 2) + Distance(2, 1) + Distance(1, 2) = 1 + 1 + 2 + 1 + 1 = 6 - -
We see that the minimum **Cost** is attained by **T2**, and it is **5**. Hence the answer is **5**.
\ No newline at end of file
+
We see that the minimum **Cost** is attained by **T2**, and it is **5**. Hence the answer is **5**.
diff --git a/_problems/medium/KTHCON.md b/_problems/medium/KTHCON.md
index 77ba9192..b2d66519 100644
--- a/_problems/medium/KTHCON.md
+++ b/_problems/medium/KTHCON.md
@@ -115,5 +115,4 @@ If there's no 1-concave polygon, print -1. Otherwise, print one integer: twice t
 Output:
 28
 -1
-
 
\ No newline at end of file diff --git a/_problems/medium/KUNIQUE.md b/_problems/medium/KUNIQUE.md index 7c614f12..89f646da 100644 --- a/_problems/medium/KUNIQUE.md +++ b/_problems/medium/KUNIQUE.md @@ -50,11 +50,10 @@ For each test case, output a single line containing a permutation of the sequenc 4 7 7 7 6 2 2 10 2 8 3 6 - -
**Output:**```
+
+**Output:**```
 
 42
 -1
 2 3 2 6 8 10
-
 
\ No newline at end of file diff --git a/_problems/medium/L1.md b/_problems/medium/L1.md index 10cb9ec6..7823ede3 100644 --- a/_problems/medium/L1.md +++ b/_problems/medium/L1.md @@ -54,8 +54,8 @@ For each test case, print a single number, describing the number of pairs of tow Output 6 -
### Output details + ![](/download/celltwr.png) In the above figure, the blue points represent the cell towers and the red points represent the skyscrapers as in the example input. The 6 segments AE, BE, BC, AC, AD and BD correspond to the 6 pairs of towers that can communicate with each other. diff --git a/_problems/medium/L4.md b/_problems/medium/L4.md index 18fa282f..1e4827cc 100644 --- a/_problems/medium/L4.md +++ b/_problems/medium/L4.md @@ -34,5 +34,4 @@ Output exactly one number, the maximal possible travel time. Output: 20 - -
**Please note: the time limit for this problem is _extremely_ strict!** \ No newline at end of file +**Please note: the time limit for this problem is _extremely_ strict!** diff --git a/_problems/medium/LABEL.md b/_problems/medium/LABEL.md index 38b1ace1..63515f0e 100644 --- a/_problems/medium/LABEL.md +++ b/_problems/medium/LABEL.md @@ -122,6 +122,6 @@ For each test case, print the answer in a separate line. 4 2 12 - ### Explanation + ![](https://s3.amazonaws.com/hr-challenge-images/15909/1461164061-a8af760fd8-C.png "C.png") diff --git a/_problems/medium/LCH15CD.md b/_problems/medium/LCH15CD.md index aa04b199..5742eefe 100644 --- a/_problems/medium/LCH15CD.md +++ b/_problems/medium/LCH15CD.md @@ -109,5 +109,4 @@ Output **T** lines. Every line should contain one integer - the minimal number o 5 1 10 - \ No newline at end of file diff --git a/_problems/medium/LCH15JEF.md b/_problems/medium/LCH15JEF.md index 34b0e1ec..93121e5e 100644 --- a/_problems/medium/LCH15JEF.md +++ b/_problems/medium/LCH15JEF.md @@ -92,7 +92,7 @@ For each test case, output a single line containing one integer corresponding to - **1** ≤ **T** ≤ **20** - **1** ≤ **M** ≤ **1018** - **1** ≤ **length of S** ≤ **104** -- ≤ **Xi, Yi** ≤ **109997** +- 0 ≤ **Xi, Yi** ≤ **109997** - It's guaranteed that there will not be **0\*\*0** expression ### Subtasks @@ -110,5 +110,4 @@ For each test case, output a single line containing one integer corresponding to Output: 24 1936 - \ No newline at end of file diff --git a/_problems/medium/LEBINARY.md b/_problems/medium/LEBINARY.md index 356af953..af170e90 100644 --- a/_problems/medium/LEBINARY.md +++ b/_problems/medium/LEBINARY.md @@ -90,15 +90,15 @@ Print YES if N is an Asmany number, NO otherwise.
1 ≤ T ≤ 100
 1 ≤ Number of digits in N ≤ 1000
-
 
### Sample Input +
2
 3
 4
-
 
### Sample Output +
NO
 YES
-
 
### Explanation + 4 is an Asmany number. To be precise, it is the 4th Asmany number: There are 4 Asmany strings of length 4. 0011, 1100, 0101, 1010. diff --git a/_problems/medium/LEBLOCKS.md b/_problems/medium/LEBLOCKS.md index 0c253c8c..e8b9a3dd 100644 --- a/_problems/medium/LEBLOCKS.md +++ b/_problems/medium/LEBLOCKS.md @@ -73,7 +73,7 @@ All submissions for this problem are available.### Read problems statements in Little Elephant from Zoo of Lviv has **n** (0-based numeration) blocks consisted of **1x1x1** cubes in such way that the size of **i-th** block is **1x1xAi**. Each of the blocks also has a color, which is a positive integer. The color of **i-th** block is **Ci**. There will be no more than two blocks of the same color. -Little Elephant wants to stack the blocks in the stack. In order to do so, he choose some random permutation **P** of integers from to **n-1**, inclusive, and stacks all the blocks in order of **P**, i. e. at first he stacks **P0-th** block, then **P1-th** and so on. +Little Elephant wants to stack the blocks in the stack. In order to do so, he choose some random permutation **P** of integers from 0 to **n-1**, inclusive, and stacks all the blocks in order of **P**, i. e. at first he stacks **P0-th** block, then **P1-th** and so on. After stacking Little Elephant has a sequence of size **S** consisted of cubes (0-based numeration) in order from the stack, where **S = A0 + A1 + ... + An-1**. Then he counts the number of such pairs of cubes with indices **i** and **j** that **j - i = k** and **i-th** cube has same color as **j-th**. Call this number as colorfulness of the corresponding permutation. @@ -118,5 +118,4 @@ There will be no three or more blocks of the same color in a single test case. Output: 0.9095238 - \ No newline at end of file diff --git a/_problems/medium/LEBOBBLE.md b/_problems/medium/LEBOBBLE.md index 80ef9a6d..46ee642d 100644 --- a/_problems/medium/LEBOBBLE.md +++ b/_problems/medium/LEBOBBLE.md @@ -120,5 +120,4 @@ In **T** lines print **T** real numbers - the answers for the corresponding test 0.2500 1.6049 - \ No newline at end of file diff --git a/_problems/medium/LEFEED.md b/_problems/medium/LEFEED.md index 6dfb2b39..345b8a21 100644 --- a/_problems/medium/LEFEED.md +++ b/_problems/medium/LEFEED.md @@ -90,7 +90,7 @@ The output values will be considered as correct if and only if they have the abs - **1** ≤ **T** ≤ **10** - **1** ≤ **N, M** ≤ **50** -- ≤ **Ai** ≤ **M** +- 0 ≤ **Ai** ≤ **M** ### Example @@ -104,8 +104,8 @@ The output values will be considered as correct if and only if they have the abs Output: 1.500000000 2.285714286 - ### Explanation + **Example case 1**: There are **4** possibilities (with equal probability) of the serving as follows. **1 1** : maximal number of consecutive seats with the same type = **2** **1 2** : maximal number of consecutive seats with the same type = **1** diff --git a/_problems/medium/LEMOVIE.md b/_problems/medium/LEMOVIE.md index 3cf192f3..4b6c44aa 100644 --- a/_problems/medium/LEMOVIE.md +++ b/_problems/medium/LEMOVIE.md @@ -71,7 +71,7 @@ All submissions for this problem are available.### Read problems statements in Little Elephant from Zoo of Lviv likes to watch movies. -There are **N** different movies (numbered from to **N − 1**) he wants to watch in some order. Of course, he will watch each movie exactly once. The priority of **i**th movie is **Pi**. +There are **N** different movies (numbered from 0 to **N − 1**) he wants to watch in some order. Of course, he will watch each movie exactly once. The priority of **i**th movie is **Pi**. A watching of a movie is called _exciting_ if and only if one of the following two conditions holds: @@ -111,8 +111,8 @@ For each test case, print the number of different watching orders having at most Output: 2 24 - ### Explanation + In the first case, there are two boring watching orders whose _excitingness_ not greater than **K=1**: **\[3, 1, 2\]**, **\[3, 2, 1\]**. Both watching orders have one _exciting_ watching: the first watching. In the second case, every watching order has at most **3** _excitingness_. diff --git a/_problems/medium/LEPAINT.md b/_problems/medium/LEPAINT.md index 208eeafc..dad4293a 100644 --- a/_problems/medium/LEPAINT.md +++ b/_problems/medium/LEPAINT.md @@ -72,7 +72,7 @@ All submissions for this problem are available.### Read problems statements in Little Elephant from Zoo of Lviv likes to paint. -He has **n** objects to paint, ordered in a row and numbered form left to right starting from **1**. There are totally **c** colors, numbered from to **c-1**. At the beggining all objects are colored in color with number **1**. When object with color **a** is painted in color **b**, the resulting color will have number **(a\*b) mod c**. +He has **n** objects to paint, ordered in a row and numbered form left to right starting from **1**. There are totally **c** colors, numbered from 0 to **c-1**. At the beggining all objects are colored in color with number **1**. When object with color **a** is painted in color **b**, the resulting color will have number **(a\*b) mod c**. Little Elephant is going to make **k** turns. At **i-th** (0-based numeration) turn he will randomly choose any subset (even empty) of objects with indices in range **\[Li; Ri\]** (inclusive) and paint all objects in chosen subset with random color (the same for all objects in the subset). @@ -121,5 +121,4 @@ Any results within 10^-6 absolute error will be accepted. 3.444444444 22.943125000 - \ No newline at end of file diff --git a/_problems/medium/LFEB14A.md b/_problems/medium/LFEB14A.md index 639664b5..14cfb107 100644 --- a/_problems/medium/LFEB14A.md +++ b/_problems/medium/LFEB14A.md @@ -109,8 +109,8 @@ For each testcase print expected number of inversions. Output: 13.833333333 87.818181818 - ### Note + **Test #0-1 (25 points): n,m ≤ 10** **Test #2 (25 points): n,m ≤ 1000** diff --git a/_problems/medium/LFIVES.md b/_problems/medium/LFIVES.md index 9f18656c..b8901ad6 100644 --- a/_problems/medium/LFIVES.md +++ b/_problems/medium/LFIVES.md @@ -112,8 +112,8 @@ For each query, output a single line containing one integers: the number of trip 8 0 - ### Explanation + The following triples(**i**, **j**, **k**) are valid for the first and the second queries: - (3, 5, 7) diff --git a/_problems/medium/LIGHT.md b/_problems/medium/LIGHT.md index 768d34e5..3151274f 100644 --- a/_problems/medium/LIGHT.md +++ b/_problems/medium/LIGHT.md @@ -105,5 +105,4 @@ Output the maximum height you can reach. The value must have an absolute error l Output: 3.300759642 - \ No newline at end of file diff --git a/_problems/medium/LIKECS04.md b/_problems/medium/LIKECS04.md index 3fc146fd..5db5b8d6 100644 --- a/_problems/medium/LIKECS04.md +++ b/_problems/medium/LIKECS04.md @@ -98,17 +98,17 @@ Output the number of possible winning arrays modulo **109 + 7**.
 2 ≤ N ≤ 50
 0 ≤ B[i] ≤ 50, where B[i] denotes the ith element of the array.
-
 
### Sample Input +
 3
 2 0 1
-
 
### Sample Output +
 4
-
 
### Explanation + The possible winning arrays are **(1, 0, 0)**, **(0, 0, 1)**, **(2, 0, 0)** and **(1, 0, 1)**. Let us consider why array **(2, 0, 1)** is losing. The only move is 2 pick the pair **(2, 1)**. After applying the operation, we get the pair **(1, 2)**. Thus, only the order of elements in the array change and we are in a situation of deadlock. Thus, Chef Dobby can't convert the array to contain **2** zeros. diff --git a/_problems/medium/LIKECS05.md b/_problems/medium/LIKECS05.md index 8847a4a3..a169439f 100644 --- a/_problems/medium/LIKECS05.md +++ b/_problems/medium/LIKECS05.md @@ -126,8 +126,8 @@ Output 4 integers, denoting the number of cells with no color, cells with red co 1 ≤ idx_row, idx_column ≤ N 2 ≤ idx_diagonal ≤ 2 * N 0 ≤ color ≤ 1 - ### Sample Input +
 5 10
 2 4 1
@@ -140,12 +140,12 @@ Output 4 integers, denoting the number of cells with no color, cells with red co
 1 5 0
 2 4 1
 2 2 0
-
 
### Sample Output +
 4 6 7 8
-
 
### Explanation + You can refer to the below image which shows the colored grid after each step. ![Mixing Colors-1](https://cook86.discuss.codechef.com/upfiles/img-2_Jh81yrs.png) diff --git a/_problems/medium/LISLDS.md b/_problems/medium/LISLDS.md index 1c92d0c8..21933726 100644 --- a/_problems/medium/LISLDS.md +++ b/_problems/medium/LISLDS.md @@ -107,8 +107,8 @@ For each test case, output a single line containing **N** space separated intege Output: 3 5 1 6 2 4 -1 - ### Explanation + **Example case 1.** In the array **\[3, 5, 1, 6, 2, 4\]**, the longest increasing subsequence has length **3** (e.g. **\[3,5,6\]**), and the longest decreasing subsequence has length **2** (e.g. **\[3, 2\]**). **Example case 2.** You can check that no permutation of **\[1, 2, 3, 4\]** has longest increasing subsequence and longest decreasing subsequence of length **3** at the same time. diff --git a/_problems/medium/LMA1.md b/_problems/medium/LMA1.md index 635365bc..2b242379 100644 --- a/_problems/medium/LMA1.md +++ b/_problems/medium/LMA1.md @@ -98,8 +98,8 @@ For each test case, output a single line containing the answer to the correspond 17.903573407202216066481994459833795013850415 796.867901234567901234 0.187143148658300173451688603203754718906234057749209264360779512294 - ### Scoring + In all the test cases, 0.01 <= **a** < 1.00, 0.00 <= **p** <= 10.00, 0.00 <= **q** <= 10.00 Output will not exceed 1 MB diff --git a/_problems/medium/LOGGERS.md b/_problems/medium/LOGGERS.md index 81e755a8..8ca2ba1a 100644 --- a/_problems/medium/LOGGERS.md +++ b/_problems/medium/LOGGERS.md @@ -27,10 +27,9 @@ For each test case, output a single line containing the name of the winner of th 1 2 2 3 4 3 7 8 9 - ### Sample Output +
Alice
 Alice
 Bob
-
 
\ No newline at end of file diff --git a/_problems/medium/LOTERY.md b/_problems/medium/LOTERY.md index 33c7ca44..6717ca42 100644 --- a/_problems/medium/LOTERY.md +++ b/_problems/medium/LOTERY.md @@ -105,7 +105,7 @@ For each test case, output a single integer — the answer for the given query. ### Constraints and Subtasks - **1** ≤ **T** ≤ **106** -- ≤ **A**, **B**, **Ci**, **Di** < **M** ≤ **105** +- 0 ≤ **A**, **B**, **Ci**, **Di** < **M** ≤ **105** - **1** ≤ **K1** ≤ **N1**< **M** **Subtask1:(10 points)** @@ -141,7 +141,6 @@ For each test case, output a single integer — the answer for the given query. 2 3 6 -
Input:
 4
 5 2
diff --git a/_problems/medium/LPAIR.md b/_problems/medium/LPAIR.md
index bb2b3877..7592fab9 100644
--- a/_problems/medium/LPAIR.md
+++ b/_problems/medium/LPAIR.md
@@ -87,7 +87,7 @@ Output the number of marriage line pairs that intersect with each other on a sin
 ### Constraints
 
 - **1** ≤ **N** ≤ **100000 (105)**
-- ≤ **Mi, Fi** ≤ **1000000000 (109)**
+- 0 ≤ **Mi, Fi** ≤ **1000000000 (109)**
 
 ### Example
 
@@ -110,8 +110,8 @@ Output the number of marriage line pairs that intersect with each other on a sin
 Output:
 6
 
-
 
### Explanation + **Example case 1.** Only marriage lines (3, 6) and (5, 4) intersect with each other. **Example case 2.** All the marriage lines intersect with each other. diff --git a/_problems/medium/LSTGRPH.md b/_problems/medium/LSTGRPH.md index 2842714b..6b543a5f 100644 --- a/_problems/medium/LSTGRPH.md +++ b/_problems/medium/LSTGRPH.md @@ -132,8 +132,8 @@ All submissions for this problem are available.### Read problems statements in Output: 1 4 8 4 5 - ### Explanation + The first lexicographically valid sequence is equal to (0, 5, 9, 5, 4); The second lexicographically valid sequence is equal to (1, 4, 8, 4, 5) - that's the one that should be printed out as the answer. diff --git a/_problems/medium/LTM40EF.md b/_problems/medium/LTM40EF.md index a0164151..22ff0f93 100644 --- a/_problems/medium/LTM40EF.md +++ b/_problems/medium/LTM40EF.md @@ -110,5 +110,4 @@ Output in a single line **K**-th **M**-letter in Chef's order. Output: aaaba - \ No newline at end of file diff --git a/_problems/medium/LTM40GH.md b/_problems/medium/LTM40GH.md index 5fe910c6..058ebf1e 100644 --- a/_problems/medium/LTM40GH.md +++ b/_problems/medium/LTM40GH.md @@ -123,5 +123,4 @@ For each test case for each node in range from 1 to **N**, output its ugliness i 3 4 5 - \ No newline at end of file diff --git a/_problems/medium/LUCKFILL.md b/_problems/medium/LUCKFILL.md index 86b5169a..38666018 100644 --- a/_problems/medium/LUCKFILL.md +++ b/_problems/medium/LUCKFILL.md @@ -77,7 +77,7 @@ Consider some example. From the string **47?4?** we can obtain four lucky string Let **S** be some lucky string. Then - **|S|** denotes the length of the string **S**; - **S\[i\]** (**1 ≤ i ≤ |S|**) denotes the **i**th character of **S** (the numeration of characters starts from **1**); -- The string **T** of the length **M** is called a _substring_ of **S** if for some **k** from to **|S| - M** we have +- The string **T** of the length **M** is called a _substring_ of **S** if for some **k** from 0 to **|S| - M** we have **T\[1\] = S\[k + 1\], T\[2\] = S\[k + 2\], ..., T\[M\] = S\[k + M\]**. ### Input @@ -110,5 +110,4 @@ The first line of the input file contains a single positive integer **T**, the n 2 4 - \ No newline at end of file diff --git a/_problems/medium/LUCKG.md b/_problems/medium/LUCKG.md index 56c42ac5..c07d950c 100644 --- a/_problems/medium/LUCKG.md +++ b/_problems/medium/LUCKG.md @@ -106,5 +106,5 @@ No Solution 2 6 7 3 4 8 1 5 9 - -**Explanation**For second test case, probability is 5/9 for each player to get a point. +**Explanation** +For second test case, probability is 5/9 for each player to get a point. diff --git a/_problems/medium/LUCKY3.md b/_problems/medium/LUCKY3.md index 58ed0112..4722eec1 100644 --- a/_problems/medium/LUCKY3.md +++ b/_problems/medium/LUCKY3.md @@ -13,7 +13,7 @@ layout: problem Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits **4** and **7**. For example, numbers **47**, **744**, **4** are lucky and **5**, **17**, **467** are not. - Chef also use term **"lucky sum"**. Lucky sum is an operation between two integers. Let the first integer is **A**, **A\[i\]** equals **i-th** digit of **A** (0-base numeration, from right to left) and the second integer is **B**, **B\[i\]** equals to **i-th** digit of **B**. Then the lucky sum of **A** and **B** is equal to **C**, **C\[i\] = max(A\[i\], B\[i\])**. If **i** is greater than or equal to size of integer, the **i-th** digit is equal to . For example, the lucky sum of **47** and **729** equals **749**, the lucky sum of **74** and **92** and **477** equals **497**. + Chef also use term **"lucky sum"**. Lucky sum is an operation between two integers. Let the first integer is **A**, **A\[i\]** equals **i-th** digit of **A** (0-base numeration, from right to left) and the second integer is **B**, **B\[i\]** equals to **i-th** digit of **B**. Then the lucky sum of **A** and **B** is equal to **C**, **C\[i\] = max(A\[i\], B\[i\])**. If **i** is greater than or equal to size of integer, the **i-th** digit is equal to 0. For example, the lucky sum of **47** and **729** equals **749**, the lucky sum of **74** and **92** and **477** equals **497**. Chef has an array **W** of integers. Find a number of non-empty subsequences of **W** such that the lucky sum of integers in that subsequences is a lucky number. @@ -48,5 +48,4 @@ For each **T** test cases print one integer - result for the corresponding test. Output: 3 2 - \ No newline at end of file diff --git a/_problems/medium/LUCKY4.md b/_problems/medium/LUCKY4.md index 70957c97..86431a71 100644 --- a/_problems/medium/LUCKY4.md +++ b/_problems/medium/LUCKY4.md @@ -71,7 +71,7 @@ All submissions for this problem are available. Chef loves lucky numbers. Everyb Chef likes sequences of **n** positive integers, each of which does not exceed **m**. The total number of such sequences is equal to **m^n**. - Chef has an array **C** of **n-1** integers. Let **F(x)** be equal to the number of lucky digits in decimal representation of integer **x**. Let there be a sequence **A** of **n** integers (1-based numeration). Chef calls it lucky when the following hold: if for each **i (1 <= i < n)** if **C\[i\]** equals to **1**, then **F(A\[i\])** must be equal to **F(A\[i+1\])** and if **C\[i\]** equals to , then **F(A\[i\])** must not be equal to **F(A\[i+1\])**. + Chef has an array **C** of **n-1** integers. Let **F(x)** be equal to the number of lucky digits in decimal representation of integer **x**. Let there be a sequence **A** of **n** integers (1-based numeration). Chef calls it lucky when the following hold: if for each **i (1 <= i < n)** if **C\[i\]** equals to **1**, then **F(A\[i\])** must be equal to **F(A\[i+1\])** and if **C\[i\]** equals to 0, then **F(A\[i\])** must not be equal to **F(A\[i+1\])**. Chef has integers **n, m, k** and an array **C**. He wants to find out the **k-th** lucky sequence for a given array **C**. Help him. If the **k-th** lucky sequence does not exist, print the only integer **-1**. diff --git a/_problems/medium/LUCKY8.md b/_problems/medium/LUCKY8.md index 985f86a4..9bd91b89 100644 --- a/_problems/medium/LUCKY8.md +++ b/_problems/medium/LUCKY8.md @@ -70,7 +70,7 @@ layout: problem --- All submissions for this problem are available. A Little Elephant from the Zoo of Lviv likes lucky numbers very much. Everybody knows that the lucky numbers are positive integers whose decimal representation contains only the lucky digits **4** and **7**. For example, numbers **47**, **744**, **4** are lucky and **5**, **17**, **467** are not. - Let **F4**(**X**) be the number of digits **4** in the decimal representation of **X**, and **F7**(**X**) be the number of digits **7** in the decimal representation of **X**. For example, **F4**(**456**) = **1**, **F4**(**444**) = **3**, **F7**(**1**) = , **F7**(**747**) = **2**. The Little Elephant wants to know the largest product **F4**(**X**) ∙ **F7**(**X**), where **L** ≤ **X** ≤ **R**. In other words he wants to know the value **max**{**F4**(**X**) ∙ **F7**(**X**) : **L** ≤ **X** ≤ **R**}. + Let **F4**(**X**) be the number of digits **4** in the decimal representation of **X**, and **F7**(**X**) be the number of digits **7** in the decimal representation of **X**. For example, **F4**(**456**) = **1**, **F4**(**444**) = **3**, **F7**(**1**) = 0, **F7**(**747**) = **2**. The Little Elephant wants to know the largest product **F4**(**X**) ∙ **F7**(**X**), where **L** ≤ **X** ≤ **R**. In other words he wants to know the value **max**{**F4**(**X**) ∙ **F7**(**X**) : **L** ≤ **X** ≤ **R**}. ### Input @@ -99,6 +99,6 @@ All submissions for this problem are available. A Little Elephant from the Zoo o 0 1 1 - ### Explanation + In both second and third test cases the maximal product is achieved at the numbers **47** and **74**. diff --git a/_problems/medium/LUCKY9.md b/_problems/medium/LUCKY9.md index cce1fbbe..9b0ff57b 100644 --- a/_problems/medium/LUCKY9.md +++ b/_problems/medium/LUCKY9.md @@ -98,5 +98,4 @@ The first line of the input contains one integer **T**, the number of test cases Output: 1 4 - \ No newline at end of file diff --git a/_problems/medium/LUCKYCOM.md b/_problems/medium/LUCKYCOM.md index 6a0051ac..b3d44ec4 100644 --- a/_problems/medium/LUCKYCOM.md +++ b/_problems/medium/LUCKYCOM.md @@ -115,6 +115,6 @@ The first line of the input file contains two space separated integers **N** and Output: 5 - ### Explanation + For the sample input all different CNSes are **4**, **7**, **44**, **47** and **447**. Note, that **444** is not a CNS since it requires at least 3 replacements of the question marks. diff --git a/_problems/medium/LUCKYSWP.md b/_problems/medium/LUCKYSWP.md index 8e8e61e1..631ab4b8 100644 --- a/_problems/medium/LUCKYSWP.md +++ b/_problems/medium/LUCKYSWP.md @@ -126,8 +126,8 @@ For each test case, output a single line containing the answer for this test cas 4 11 - ### Explanation + In the first test case all different swap permutations of **S = 7474** are **4747, 4774, 7447, 7474, 7744**. Corresponding values of **F(T)** are **3, 3, 3, 2, 2**. Hence the answer is **3**. In the second, third and fourth test cases there exists a non-decreasing swap permutation and hence the answer is equal to the length of the string. Namely, **S = 47** is itself non-decreasing, for **S = 47744** we can obtain the non-decreasing **T = 44477** if we delete the substring **S\[2,3\] = 77** and then insert it back into the end of the string, finally, for **S = 7744** we can obtain the non-decreasing **T = 4477** if we delete the substring **S\[1,2\] = 77** and then insert it back into the end of the string. diff --git a/_problems/medium/LVGFT.md b/_problems/medium/LVGFT.md index 4e21fc8f..12d1df80 100644 --- a/_problems/medium/LVGFT.md +++ b/_problems/medium/LVGFT.md @@ -135,8 +135,8 @@ That is, Chef now lives in City **C**, and you know where all the bank branches -1 4 3 - ### Explanation + The map of the country is as follows: ![](http://tinyurl.com/y9vtq58r)The first query says that the bank opened a branch in city 4. The second query also does the same, and it doesn't make anything different for us. So now, the maps looks as follows, where the circled city means that it has a bank branch: diff --git a/_problems/medium/M3.md b/_problems/medium/M3.md index c426c27d..6d20f810 100644 --- a/_problems/medium/M3.md +++ b/_problems/medium/M3.md @@ -62,5 +62,4 @@ For each test case, print a binary string of length N, in which the i-th charact 010 0001 11001 - \ No newline at end of file diff --git a/_problems/medium/MACGUN.md b/_problems/medium/MACGUN.md index e560b641..b6aae313 100644 --- a/_problems/medium/MACGUN.md +++ b/_problems/medium/MACGUN.md @@ -114,5 +114,4 @@ FPF 3 6 - \ No newline at end of file diff --git a/_problems/medium/MADHAT.md b/_problems/medium/MADHAT.md index 37c0e605..56f9bdb7 100644 --- a/_problems/medium/MADHAT.md +++ b/_problems/medium/MADHAT.md @@ -96,7 +96,7 @@ For each test case, output the answer to the problem modulo **109+7**. ### Constraints - **1** ≤ **n** ≤ **105**, the sum of **n** over all test cases is at most **106** -- ≤ **ci** n +- 0 ≤ **ci** n ### Example @@ -110,8 +110,8 @@ For each test case, output the answer to the problem modulo **109+7**. Output: 3 0 - ### Explanation + In the **first example**, the possible students IQs are the following: - \[1, 4, 3, 2\] diff --git a/_problems/medium/MAKELIS.md b/_problems/medium/MAKELIS.md index 6a3596a9..e12c2d0a 100644 --- a/_problems/medium/MAKELIS.md +++ b/_problems/medium/MAKELIS.md @@ -112,6 +112,7 @@ For each test case, output two lines. The first line contains a single integer, 1 3 2 4
### Explanation
+
 **Example case 1.** Here, **K** = 1. The array **\[1, 2, 3, 4, 5\]** indeed contains exactly one longest increasing subsequence: the whole sequence itself.
 
 **Example case 2.** Here, **K** = 2. As explained in the problem statement, the array **\[1, 3, 2, 4\]** contains exactly two longest increasing subsequences: **\[1, 3, 4\]** and **\[1, 2, 4\]**.
diff --git a/_problems/medium/MAKPALIN.md b/_problems/medium/MAKPALIN.md
index 934692de..f4aa80e2 100644
--- a/_problems/medium/MAKPALIN.md
+++ b/_problems/medium/MAKPALIN.md
@@ -100,6 +100,6 @@ aca
 Output:
 4
 2
-
 
### Explanation + First sample has been explained in the problem statement. diff --git a/_problems/medium/MANYLIST.md b/_problems/medium/MANYLIST.md index 0295e9c6..ff5a89e7 100644 --- a/_problems/medium/MANYLIST.md +++ b/_problems/medium/MANYLIST.md @@ -113,8 +113,8 @@ For each query of type **1**, output the size of the specified set. 1 2 - ### Explanation + Have a look at the sets during the operations: - Initially, all the sets are empty: ({}, {}, {}, {}, {}). diff --git a/_problems/medium/MARBLES.md b/_problems/medium/MARBLES.md index 218e4174..c6c57fdb 100644 --- a/_problems/medium/MARBLES.md +++ b/_problems/medium/MARBLES.md @@ -37,5 +37,4 @@ You can assume that this number fits into a signed 64 bit integer. Output: 1 475020 - \ No newline at end of file diff --git a/_problems/medium/MARCHA4.md b/_problems/medium/MARCHA4.md index 7e72a5cb..5eda0443 100644 --- a/_problems/medium/MARCHA4.md +++ b/_problems/medium/MARCHA4.md @@ -36,5 +36,4 @@ For each test case, print out one line containing two numbers, separated by a sp Output 25 56 387 489 - \ No newline at end of file diff --git a/_problems/medium/MARRAYS.md b/_problems/medium/MARRAYS.md index 2561367c..043e06f0 100644 --- a/_problems/medium/MARRAYS.md +++ b/_problems/medium/MARRAYS.md @@ -128,8 +128,8 @@ For each test case, output in a single line an integer corresponding to the maxi 8 4 10 - ### Explanation +

Example case 1. 01) 123|32|45 = 0 * 1 + 2 * 2 = 4 02) 312|32|45 = 1 * 1 + 2 * 2 = 5 diff --git a/_problems/medium/MATCUT.md b/_problems/medium/MATCUT.md index 2f9a44f0..ccbcdd00 100644 --- a/_problems/medium/MATCUT.md +++ b/_problems/medium/MATCUT.md @@ -167,8 +167,8 @@ All submissions for this problem are available.### Read problems statements in [ -1 4 1 -

### Explanation +
 First test
 
@@ -185,5 +185,4 @@ The second one is longer so the answer is 4.
 
 Fourth test
 There is only one path that generates a cubic number and it contains only one node.
-
 
\ No newline at end of file diff --git a/_problems/medium/MATRIX2.md b/_problems/medium/MATRIX2.md index 898ee022..5468f414 100644 --- a/_problems/medium/MATRIX2.md +++ b/_problems/medium/MATRIX2.md @@ -89,8 +89,8 @@ Output should consist of a single integer - the answer to the problem. Output: 6 - ### Scoring + Subtask 1 (9 points): 1 <= **N,M** <= 2000, All the numbers in the matrix are equal to one. Subtask 2 (12 points): 1 <= **N,M** <= 10. diff --git a/_problems/medium/MAXGAME.md b/_problems/medium/MAXGAME.md index 5994e518..c3a0ec57 100644 --- a/_problems/medium/MAXGAME.md +++ b/_problems/medium/MAXGAME.md @@ -97,8 +97,8 @@ For each test case, output the number of ways to conduct the game modulo 1000000 4 0 1 - -**Explanation:**For the 1st case, there are 3 players. Let's call them p1, p2, p3. Different games possible are:Game 1: p1-p2 (numbers of bondings of p1, p2 are 1 ≤ **K** = 2) +**Explanation:**For the 1st case, there are 3 players. Let's call them p1, p2, p3. Different games possible are: +Game 1: p1-p2 (numbers of bondings of p1, p2 are 1 ≤ **K** = 2) Game 2: p1-p3 (numbers of bondings of p1, p3 are 1 ≤ **K** = 2) Game 3: p2-p3 (numbers of bondings of p2, p3 are 1 ≤ **K** = 2) Game 4: p1-p2, p1-p3, p2-p3 (numbers of bondings of p1, p2, p3 are 2 ≤ **K**= 2) For the 2nd test case, we cannot form the game, because K = 0 and hence no player is allowed to make any bonding. As any game must have atleast one bonding, no game is possible here. For the 3rd case, only possible game is: diff --git a/_problems/medium/MAXGRID.md b/_problems/medium/MAXGRID.md index 100efdc0..847cd0b4 100644 --- a/_problems/medium/MAXGRID.md +++ b/_problems/medium/MAXGRID.md @@ -108,6 +108,6 @@ Output a single line containing two space separated integers: the maximum value Output: 6 2 - ### Explanation + In the given example, you can create a 2X2 sub-grid with top-left corner as (2,1) and bottom right corner as (3,2) with value 6. All other sub-grids have value lower than or equal to this sub-grid. diff --git a/_problems/medium/MAXMATCH.md b/_problems/medium/MAXMATCH.md index 5ed5c6b0..be84b97c 100644 --- a/_problems/medium/MAXMATCH.md +++ b/_problems/medium/MAXMATCH.md @@ -124,8 +124,8 @@ For each test case, print a single integer representing the answer of that test Output: 1 17 - ### Explanation + **For N=3, graph can be shown as below:** ![Mountain View](/download/extimages/e0e32ec8077fe8a8e8a759c8d8f5d9eb.jpg) diff --git a/_problems/medium/MAXOR.md b/_problems/medium/MAXOR.md index f36a4a74..5d59f86d 100644 --- a/_problems/medium/MAXOR.md +++ b/_problems/medium/MAXOR.md @@ -110,8 +110,8 @@ For each test case, output a single line containing the answer for that test cas Output: 2 - ### Explanation + There are three possible pairs of indices which satisfy 1 ≤ **i** j ≤ **N**: (1, 2), (1, 3) and (2, 3). Let us see which of those satisfy **Ai** | **Aj** ≤ max(**Ai**, **Aj**): - (1, 2): **A1** | **A2** = 1 | 2 = (01)2 | (10)2 = (11)2 = 3. But max(**A1**, **A2**) = max(1, 2) = 2, and 3 ≤ 2 is not correct. Hence this is not a valid pair. diff --git a/_problems/medium/MAZE.md b/_problems/medium/MAZE.md index 11e2be78..3d94df20 100644 --- a/_problems/medium/MAZE.md +++ b/_problems/medium/MAZE.md @@ -117,8 +117,8 @@ For each test case, output either "Chefland is doomed" (without quotes), or a si Output: 2 0 - ### Explanation + **Example case 1.** ![](https://s3.amazonaws.com/codechef_shared/download/upload/COOK70/example_1_city_before.png) diff --git a/_problems/medium/MBOARD.md b/_problems/medium/MBOARD.md index 1674e61b..9b4bb8b5 100644 --- a/_problems/medium/MBOARD.md +++ b/_problems/medium/MBOARD.md @@ -66,17 +66,17 @@ time: current: 1493557785 layout: problem --- -All submissions for this problem are available.Long long ago, there is a magic board. The magic board has **N\*N** cells: **N** rows and **N** columns. Every cell contains one integer, which is initially. Let the rows and the columns be numbered from **1** to **N**. +All submissions for this problem are available.Long long ago, there is a magic board. The magic board has **N\*N** cells: **N** rows and **N** columns. Every cell contains one integer, which is 0 initially. Let the rows and the columns be numbered from **1** to **N**. There are **2** types of operations can be applied to the magic board: 1. **RowSet i x**: it means that all integers in the cells on **row i** have been changed to **x** after this operation. 2. **ColSet i x**: it means that all integers in the cells on **column i** have been changed to **x** after this operation. -And your girlfriend sometimes has an interest in the total number of the integers s on some row or column. +And your girlfriend sometimes has an interest in the total number of the integers 0s on some row or column. -1. **RowQuery i**: it means that you should answer the total number of s on **row i**. -2. **ColQuery i**: it means that you should answer the total number of s on **column i**. +1. **RowQuery i**: it means that you should answer the total number of 0s on **row i**. +2. **ColQuery i**: it means that you should answer the total number of 0s on **column i**. ### Input @@ -111,8 +111,8 @@ ColQuery 1 2 0 1 - ### Explanation + At first, the magic board is
000 <- row 1
@@ -120,6 +120,7 @@ At first, the magic board is
 000
 
 
So the answer of first query _"RowQuery 1"_ is **3**. + After the _"ColSet 1 1"_, the board becomes
column 1
@@ -129,11 +130,12 @@ V
 100
 100
 
-
So the answer of the second query _"RowQuery 1"_ is clearly **2**, since the cell **(1,1)** became **1**. And the answer of the third query _"ColQuery 1"_ is . +So the answer of the second query _"RowQuery 1"_ is clearly **2**, since the cell **(1,1)** became **1**. And the answer of the third query _"ColQuery 1"_ is 0. + Finally, apply the operation _"RowSet 1 0"_, the board has changed to
000
 100
 100
 
-
From this board, the answer of the last query _"ColQuery 1"_ should be **1**. \ No newline at end of file +From this board, the answer of the last query _"ColQuery 1"_ should be **1**. diff --git a/_problems/medium/MCKTUR.md b/_problems/medium/MCKTUR.md index 42a19249..924a552e 100644 --- a/_problems/medium/MCKTUR.md +++ b/_problems/medium/MCKTUR.md @@ -115,8 +115,8 @@ For each game, output a single line containing the answer to the problem, since Output: 1 3 - ### Explanation + In the **first query** the Mock Turtle can build only the parentheses ()()() In the **second query** the three possible parentheses are diff --git a/_problems/medium/MDIST.md b/_problems/medium/MDIST.md index 4e30c6b7..0c6832ba 100644 --- a/_problems/medium/MDIST.md +++ b/_problems/medium/MDIST.md @@ -76,7 +76,7 @@ Devu has taken the course of computational geometry in the university of Coderpu **Manhattan Distance = abs(x1-x2) + abs(y1-y2)** -Devu has N points in the Co-ordinate plane. Co-ordinate of **ith** point is **(xi,yi)**. Points are indexed from to **(N-1)**(both inclusive). +Devu has N points in the Co-ordinate plane. Co-ordinate of **ith** point is **(xi,yi)**. Points are indexed from 0 to **(N-1)**(both inclusive). He has **Q** updates or queries, for each update **U\[i, x,y\]**, change the co-ordinate of **ith** point to **(x,y)**. @@ -122,8 +122,8 @@ Q 0 3 Output: 20 - ### Explanation + After first updates points will be: 10 10 diff --git a/_problems/medium/MEANMEDI.md b/_problems/medium/MEANMEDI.md index ca4aa6fb..adf58dcb 100644 --- a/_problems/medium/MEANMEDI.md +++ b/_problems/medium/MEANMEDI.md @@ -40,13 +40,13 @@ For each test case, print the minimum absolute difference between the mean and t 5 4 10 7 4 5 9 - ### Sample output +
0.000
 0.500
 
-
 
### Explanation + In the first case, you can select \[4, 4\]. In the second case, you can select \[10, 7, 4, 9\]. The mean would be 7.500, where as median would be 7. diff --git a/_problems/medium/MEDIAN.md b/_problems/medium/MEDIAN.md index 09e3e4a0..e59dc016 100644 --- a/_problems/medium/MEDIAN.md +++ b/_problems/medium/MEDIAN.md @@ -104,5 +104,4 @@ In **T** lines print the results for each test case, one per line. Output: 2 1 - \ No newline at end of file diff --git a/_problems/medium/MENU.md b/_problems/medium/MENU.md index 1532f8f7..64338044 100644 --- a/_problems/medium/MENU.md +++ b/_problems/medium/MENU.md @@ -44,5 +44,4 @@ If every menu exceeds the budget, print only the benefit value of 0. 13.0 1 5 1 - \ No newline at end of file diff --git a/_problems/medium/METEORAK.md b/_problems/medium/METEORAK.md index 1eae5601..936cc0a6 100644 --- a/_problems/medium/METEORAK.md +++ b/_problems/medium/METEORAK.md @@ -85,7 +85,7 @@ The last **Q** lines describe the queries: each line contains two integers **L** ### Output -In the output file, print **Q** lines, where i-th line contains the answer for **i**-th query. If you cannot build the house, then output . +In the output file, print **Q** lines, where i-th line contains the answer for **i**-th query. If you cannot build the house, then output 0. ### Constraints @@ -116,5 +116,4 @@ In the output file, print **Q** lines, where i-th line contains the answer for * 6 3 6 - \ No newline at end of file diff --git a/_problems/medium/MIKE2.md b/_problems/medium/MIKE2.md index 7ea11275..bb9680f8 100644 --- a/_problems/medium/MIKE2.md +++ b/_problems/medium/MIKE2.md @@ -101,8 +101,8 @@ The first line should contain two integers: the number of failed packages and th 3 4 5 Output: 0 2 - ### Explanation + In the test case **N** equals to 3, **X** equals to 10, **A** equals to {3, 4, 5}. It is optimal to solve all the problems in the first and the second packages and to solve 3 problems in the third package. ### Scoring diff --git a/_problems/medium/MINSHIFT.md b/_problems/medium/MINSHIFT.md index 241ae7b0..802ddb77 100644 --- a/_problems/medium/MINSHIFT.md +++ b/_problems/medium/MINSHIFT.md @@ -125,6 +125,7 @@ For each query of the type **1 L R P**, output a single line containing the **P* e o ### Explanation + **Example case 1.** Let's perform all the queries one-by-one: - Initially **S = "codechef"**. diff --git a/_problems/medium/MINXOR.md b/_problems/medium/MINXOR.md index a7fc8e1e..0226f857 100644 --- a/_problems/medium/MINXOR.md +++ b/_problems/medium/MINXOR.md @@ -112,8 +112,8 @@ For each query of the first type you need to output two numbers: the minimal num Output: 0 3 0 2 - ### Explanation + Initially **A\[\]** = {0, 1, 0, 1, 0}. After the second query **A\[\]** = {1, 0, 1, 0, 1}. diff --git a/_problems/medium/MIXTURES.md b/_problems/medium/MIXTURES.md index b9f29d60..0973dced 100644 --- a/_problems/medium/MIXTURES.md +++ b/_problems/medium/MIXTURES.md @@ -44,8 +44,8 @@ For each test case, output the minimum amount of smoke. Output: 342 2400 - In the second test case, there are two possibilities: + - first mix 40 and 60 (smoke: 2400), getting 0, then mix 0 and 20 (smoke: 0); total amount of smoke is 2400 - first mix 60 and 20 (smoke: 1200), getting 80, then mix 40 and 80 (smoke: 3200); total amount of smoke is 4400 diff --git a/_problems/medium/MLCHEF.md b/_problems/medium/MLCHEF.md index 8e65bdd5..ae47f508 100644 --- a/_problems/medium/MLCHEF.md +++ b/_problems/medium/MLCHEF.md @@ -71,7 +71,7 @@ layout: problem --- All submissions for this problem are available.These days Chief Chef is becoming more and more merciless. His mind is becoming full of cruel intentions. Today he has decided to slowly poison and kill some of the staff members of his kitchen. Yeah, he is bored with them. There are **N** Chefs in the kitchen besides the Chief Chef. Every Chef in the kitchen has an index. -The index of the Chief Chef is . Remaining **N** chefs have indices between **1** and **N** and no two chefs have the same index. As any other kitchen in the street, every chef has exactly one Immediate-Superior and can have any number of Superiors above him. A chef (say **A**) is Superior of another chef (say **B**) if either **A** is the Immediate-Superior of **B** or **A** is the Superior of Immediate-Superior of **B**. The Chief Chef is on the top position and Superior to all **N** chefs and has no Superior above him. +The index of the Chief Chef is 0. Remaining **N** chefs have indices between **1** and **N** and no two chefs have the same index. As any other kitchen in the street, every chef has exactly one Immediate-Superior and can have any number of Superiors above him. A chef (say **A**) is Superior of another chef (say **B**) if either **A** is the Immediate-Superior of **B** or **A** is the Superior of Immediate-Superior of **B**. The Chief Chef is on the top position and Superior to all **N** chefs and has no Superior above him. If **A** is Immediate-Superior of **B**, then **B** is called Immediate-Inferior of **A**. If **A** is Superior of **B** then **B** is called Inferior of **A** (See the example for better explanation). @@ -124,13 +124,13 @@ For each query of the second type, print one integer as asked in the question. Sample Output 1 1 - ### Example explanation -In this sample, chef-**1** and chef-**2** have Chief Chef(chef-) as immediate superior and chef-**3** and chef-**4** have chef-**2** as immediate-superior. + +In this sample, chef-**1** and chef-**2** have Chief Chef(chef-0) as immediate superior and chef-**3** and chef-**4** have chef-**2** as immediate-superior. Immediate inferiors of the chefs are : -chef- -> chef-**1** and chef-**2** +chef-0 -> chef-**1** and chef-**2** chef-**1** -> _None_ chef-**2** -> chef-**3** and chef-**4** chef-**3** -> _None_ @@ -138,7 +138,7 @@ chef-**4** -> _None_ Inferior chefs of the respective chefs are : -chef- -> chef-**1**,chef-**2**,chef-**3**,chef-**4** +chef-0 -> chef-**1**,chef-**2**,chef-**3**,chef-**4** chef-**1** -> _None_ chef-**2** -> chef-**3**, chef-**4** chef-**3** -> _None_ @@ -147,7 +147,7 @@ chef-**4** -> _None_ Initially the healths of these **4** chefs are (**1**, **2**, **2**, **1**). On the _first_ day Chief Chef poisons the dish of chef-**2**, which will be tasted by his inferiors - (chef-**3**, chef-**4**), with a poison of sickness value **1**. So after that the healths of these chefs become (**1**, **2**, **1**, ). + (chef-**3**, chef-**4**), with a poison of sickness value **1**. So after that the healths of these chefs become (**1**, **2**, **1**, 0). As the **4**-th chef's health dropped to _zero_, he dies on this day. He will be replaced by a new chef with INF (infinite) health. Healths of Chefs after Day-1 = (1,2,1,INF). @@ -157,11 +157,11 @@ is old chef, and output is **1**. Healths of Chefs after Day-2 = (1,2,1,INF). -On the _third_ day Chief Chef poisons the dish of chef-(i.e, his dish) with poison sickness **1**, and it is tasted by everyone and poisons all the **4** other chefs, so after that the healths of these chefs - become (, **1**, , **INF**). As the **1**-st and the **3**-rd chefs' health dropped to _zero_, they die on this day and are replaced by two new chefs with INF(infinite) health. +On the _third_ day Chief Chef poisons the dish of chef-0(i.e, his dish) with poison sickness **1**, and it is tasted by everyone and poisons all the **4** other chefs, so after that the healths of these chefs + become (0, **1**, 0, **INF**). As the **1**-st and the **3**-rd chefs' health dropped to _zero_, they die on this day and are replaced by two new chefs with INF(infinite) health. The health of Chefs after Day-3 is (INF,1,INF,INF). -On the _fourth_ day Chief Chef asked you the second type query to give the number of old chefs among the inferiors of chef-(Chief Chef himself). As only chef-**2** is an old chef, output is **1**. +On the _fourth_ day Chief Chef asked you the second type query to give the number of old chefs among the inferiors of chef-0(Chief Chef himself). As only chef-**2** is an old chef, output is **1**. Healths of Chefs after Day-4 = (INF,1,INF,INF). diff --git a/_problems/medium/MMADNESS.md b/_problems/medium/MMADNESS.md index b0b43174..3ca796be 100644 --- a/_problems/medium/MMADNESS.md +++ b/_problems/medium/MMADNESS.md @@ -38,8 +38,8 @@ B D Output: 200 - Explanation: In this case, the least cost you have to incur is $200 and it can be achieved by converting machines A and B to administrative machines. + The diagrammatic representation for the example test case above: ![](http://careers.directi.com/download/attachments/25657412/puzzle_march09.png) diff --git a/_problems/medium/MMATCH.md b/_problems/medium/MMATCH.md index 91dcb162..79737c20 100644 --- a/_problems/medium/MMATCH.md +++ b/_problems/medium/MMATCH.md @@ -59,5 +59,4 @@ For each test case print the maximal number of happy children. 3 3 2 - \ No newline at end of file diff --git a/_problems/medium/MMPROD.md b/_problems/medium/MMPROD.md index 3aa7b8f6..d650b004 100644 --- a/_problems/medium/MMPROD.md +++ b/_problems/medium/MMPROD.md @@ -119,8 +119,8 @@ For each test case, output a single line containing the **maximum K-product** of 30 999999937 1000000006 - ### Explanation + **Example case 1.** The maximum 2-product of the array **\[5, -3, -4, 6\]** is **30** and is achieved by the subsequence **\[5, 6\]**. **Example case 2.** The maximum 2-product of the array **\[-5, 3, 4, -6\]** is **30** and is achieved by the subsequence **\[-5, -6\]**. diff --git a/_problems/medium/MONEY.md b/_problems/medium/MONEY.md index ffdac1d2..aac4b95c 100644 --- a/_problems/medium/MONEY.md +++ b/_problems/medium/MONEY.md @@ -48,5 +48,4 @@ For each value of N output the total number of valid sets on a separate line. 4 75 13 - \ No newline at end of file diff --git a/_problems/medium/MOREFB.md b/_problems/medium/MOREFB.md index 9a2d591d..36b5ba51 100644 --- a/_problems/medium/MOREFB.md +++ b/_problems/medium/MOREFB.md @@ -121,6 +121,6 @@ Print a single integer representing the answer. Output: 4 - ### Explanation + **FIBOSUM(S)** = Fib(1) + Fib(2) + Fib(3) = 4. diff --git a/_problems/medium/MOSTDIST.md b/_problems/medium/MOSTDIST.md index a313b20b..3223b8d9 100644 --- a/_problems/medium/MOSTDIST.md +++ b/_problems/medium/MOSTDIST.md @@ -135,8 +135,8 @@ All submissions for this problem are available.### Read problems statements in 4 11 - ### Explanations + Here's a non-encrypted version of the example:
@@ -151,5 +151,4 @@ Here's a non-encrypted version of the example:
 ? 5 10
 ? 0 1
 - 2
-
-
The answers are the same. \ No newline at end of file +The answers are the same. diff --git a/_problems/medium/MOU1H.md b/_problems/medium/MOU1H.md index 4145a169..7d03b941 100644 --- a/_problems/medium/MOU1H.md +++ b/_problems/medium/MOU1H.md @@ -82,8 +82,8 @@ Next to every place, is some mountain. A Mountain is a sequence of points **(0,h /\/\/ \ / \/\ - Visitors may start their climbing from some position **i** and finish in position **j**, where **(i < j)**.They calculate the attractiveness of a mountain, as the number of different climbs that it offers. Of course, so does our Chef! + A climb from position **i** to position **j** is the sequence **(i,heighti), ... (j,heightj)**.Two climbs, say **i1** to **j1** and **i2** to **j2,** are different if and only if **(j1 – i1 != j2 – i2)** or @@ -102,8 +102,8 @@ and / \ \ - The first one is the climb from **(0 to 3)**, and the second one is the climb from **(4 to 6)**. They are different because **(3 - 0 != 6 - 4)**. On the other hand, climbs such as **(0 to 1)** and **(4 to 5)** are the same. + Given the array, **heights**, find the number of different climbs that exist on the mountain which is described by the sequence of these heights. Because answer can be very large, output it modulo **1,000,000,009**. ### Input @@ -139,6 +139,6 @@ For each test case, output a single number, the **number of unique climbs**. 31 20 - ### Explanation + The second test case is taken from the problem statement. diff --git a/_problems/medium/MOU2H.md b/_problems/medium/MOU2H.md index 528bfd96..6f92fb73 100644 --- a/_problems/medium/MOU2H.md +++ b/_problems/medium/MOU2H.md @@ -80,8 +80,8 @@ For example, the mountain described by **N = 9, H = \[0, 2, 1, 2, 1, 3, 0, 1, 0\ /\ /\/\/ \ / \/\ - In the mountain, all of the tourists will go from the point **1** to point **N**. + For comfort of the tourists, Chef has bought teleports too. Using a teleport, a tourist can be transferred from point **i** to point **j**, for all **i** < **j**. Of course, tourists can also walk from point **i** to point **i+1** on foot. Now Chef wants to calculate the attractiveness of the mountain, as the number of the different climbs. @@ -129,8 +129,8 @@ For each test case, output an integer denoting the number of the different climb 5 199 55 - ### Explanation + In the first test case, since height increases by one for each move on foot, there will be one unique climb for each length. So there are **5** climbs with length **1, 2, ..., 5**. Here length means the number of moves by foot. We can get the following **5** distinct climbs. diff --git a/_problems/medium/MSTQS.md b/_problems/medium/MSTQS.md index 9bce5597..ba834ac7 100644 --- a/_problems/medium/MSTQS.md +++ b/_problems/medium/MSTQS.md @@ -138,8 +138,8 @@ For each query of type 3, output an integer in a single line corresponding to th 3 2 3 - ### Explanation + The input graph has 4 vertices and 4 edges, it can be drawn like this:
@@ -150,8 +150,8 @@ The input graph has 4 vertices and 4 edges, it can be drawn like this:
 |_____ |
 1         2
 
-
 
Initially, all edges have weight equal 1. There are 5 queries to handle. + In the first query, we are asked for the weight of Minimal Spanning Tree, which is 3 (taking any 3 edges produces such a tree). After that, weight of edge between vertices 1 and 2 is changed to 0. Then we are asked again for the weight of Minimal Spanning Tree. It is now 2, because we can take edge from 1 to 2 and any 2 of the remaining edges. diff --git a/_problems/medium/MTMXSUM.md b/_problems/medium/MTMXSUM.md index 287f1d3a..36b5c54e 100644 --- a/_problems/medium/MTMXSUM.md +++ b/_problems/medium/MTMXSUM.md @@ -87,8 +87,8 @@ Constructed matrix C will look like: C = [12, 18, 12], [48, 72, 48], - Then, for a given **K**, they will create a list **LK** of all sub-matrices of size **K x K** from the constructed matrix **C** and compute the following expression over the created list **LK**. + ![](https://s3.amazonaws.com/hr-challenge-images/0/1454483411-9199f9c2a5-image1.JPG "image1.JPG")where **max( X )** denotes the maximum element present in the matrix **X**. @@ -99,8 +99,8 @@ For example, consider the above matrix **C** and **K = 2**. Here, **LK** contain [12, 18] [18, 12] [48, 72] [72, 48] M1 = 30 M2 = 30 M3 = 72 M4 = 72 - -Therefore, for **K = 2**, **S = M1 + M2 + M3 + M4 = (30 + 30 + 72 + 72) % (109 + 7) = 204.** + +Therefore, for **K = 2**, **S = M1 + M2 + M3 + M4 = (30 + 30 + 72 + 72) % (109 + 7) = 204.** Devu and Churu like the task very much and decided to compute the above expression for all possible values of **K** such that **1 ≤ K ≤ N** but suddenly their mom called them for some urgent work and they had to leave the task in between. Can you help them completing this task? @@ -129,5 +129,4 @@ Output **N** space-separated integers, where the **ith** integer in the output d Output 280 204 72 - \ No newline at end of file diff --git a/_problems/medium/MTRICK.md b/_problems/medium/MTRICK.md index 1d0ec230..681ae5ee 100644 --- a/_problems/medium/MTRICK.md +++ b/_problems/medium/MTRICK.md @@ -96,8 +96,8 @@ for i from 1 to N do end -
Vidhi's boyfriend got jealous when he saw her getting impressed by Mandwarf, the brown's wisdom. He wants to learn the trick to gain her undivided admiration. How about you help him?
+
 ### Constraints:
 
 1 ≤ **T** ≤ 100 
@@ -131,5 +131,4 @@ AMAM
 Output:
 3 3 9
 1 2 3 4
-
 
\ No newline at end of file
diff --git a/_problems/medium/MULTQ3.md b/_problems/medium/MULTQ3.md
index 1f0f07e7..651656fd 100644
--- a/_problems/medium/MULTQ3.md
+++ b/_problems/medium/MULTQ3.md
@@ -36,7 +36,6 @@ Sample Input :
 1 3 3
 1 0 3
 
-
 
 Sample Output :
 4
@@ -44,11 +43,9 @@ Sample Output :
 0
 2
 
-
 
 Constraints :
 1 <= N <= 100000
 1 <= Q <= 100000
 0 <= A <= B <= N - 1
-
 
\ No newline at end of file diff --git a/_problems/medium/MXSM.md b/_problems/medium/MXSM.md index fd9035fc..4a191939 100644 --- a/_problems/medium/MXSM.md +++ b/_problems/medium/MXSM.md @@ -115,8 +115,8 @@ For each test case, output **2** space separated integers (second integer modulo Output 63 1 12 2 -
### Explanation + ![](https://s3.amazonaws.com/hr-challenge-images/3194/1452934896-d5e873b4f2-image1.jpg "image1.jpg") All the matrices with maximum sum are highlighted with coloured fencing. diff --git a/_problems/medium/N3.md b/_problems/medium/N3.md index ac124fcb..c72ae2b5 100644 --- a/_problems/medium/N3.md +++ b/_problems/medium/N3.md @@ -81,5 +81,4 @@ abcfabc 0 0 2 1 0 4 - \ No newline at end of file diff --git a/_problems/medium/NETWORK.md b/_problems/medium/NETWORK.md index 0f687570..0ee5b5b4 100644 --- a/_problems/medium/NETWORK.md +++ b/_problems/medium/NETWORK.md @@ -50,6 +50,7 @@ For each test case, output C lines, where the i'th line contains the greatest di 6 8 1 3 3 ### Sample Output +
2.000
 3.000
 5.000
@@ -61,6 +62,7 @@ For each test case, output C lines, where the i'th line contains the greatest di
 
 5.831
 
### Constraints + T is between 1 and 15, inclusive. S is between 1 and 30, inclusive. Each access point supports between 1 and 30 connections, inclusive. diff --git a/_problems/medium/NEWREST.md b/_problems/medium/NEWREST.md index 15dd7225..69bf99d7 100644 --- a/_problems/medium/NEWREST.md +++ b/_problems/medium/NEWREST.md @@ -40,6 +40,7 @@ For each test case, output a single line consisting the number of different ways 4 3 2 5 7 3 **Output:** +
1
 4
 45
diff --git a/_problems/medium/NI03.md b/_problems/medium/NI03.md
index 89ca80f4..41c165ba 100644
--- a/_problems/medium/NI03.md
+++ b/_problems/medium/NI03.md
@@ -71,5 +71,4 @@ Where **A** is the case number (starting with 1 for the first case and so on) an
 1 15 0 0
 2 5 59 50
 
-
 
\ No newline at end of file diff --git a/_problems/medium/NI04.md b/_problems/medium/NI04.md index 0911d5e1..1ed88185 100644 --- a/_problems/medium/NI04.md +++ b/_problems/medium/NI04.md @@ -57,5 +57,4 @@ For each test case, print on a single line separated by spaces, the number of ae 6 5 0 3 7 12 0 1 - \ No newline at end of file diff --git a/_problems/medium/NI05.md b/_problems/medium/NI05.md index 7005bd4c..3fa993ce 100644 --- a/_problems/medium/NI05.md +++ b/_problems/medium/NI05.md @@ -58,5 +58,4 @@ Output m lines, one for each test case. The output for a test case should contai 295 264 - \ No newline at end of file diff --git a/_problems/medium/NOKIA.md b/_problems/medium/NOKIA.md index 65b9529b..623e9b3f 100644 --- a/_problems/medium/NOKIA.md +++ b/_problems/medium/NOKIA.md @@ -97,8 +97,8 @@ For each test case, output the minimum length of the unused wire, or -1 if the t 0 -1 5 - + **Explanation:** In the 1st case, for example, the permutation _P_ = {2, 1, 3} will use the exact 8 miles wires in total. diff --git a/_problems/medium/NONPALIN.md b/_problems/medium/NONPALIN.md index e5c300c1..61155a5f 100644 --- a/_problems/medium/NONPALIN.md +++ b/_problems/medium/NONPALIN.md @@ -43,8 +43,8 @@ aaaa 10001500056 18134494634143926857 0 - ### Explanation + Actual values of **K(1), K(2), ..., K(N)** in the tests are: abacaba: {0, 1, 2, 1, 1, 1, 0} abba: {0, 1, 1, 0} diff --git a/_problems/medium/NUMFACT.md b/_problems/medium/NUMFACT.md index a07094f9..87308c33 100644 --- a/_problems/medium/NUMFACT.md +++ b/_problems/medium/NUMFACT.md @@ -90,8 +90,8 @@ For each test case, output on a separate line the total number of factors of the 1 ≤ N ≤ 10 2 ≤ Ai ≤ 1000000 - ### Example: + **Input:**
@@ -103,15 +103,15 @@ For each test case, output on a separate line the total number of factors of the
 2
 5 5
 
-
 
**Output:** +
 8
 10
 3
 
-
 
### Scoring: + You will be awarded **40** points for correctly solving for **Ai** ≤ 100. You will be awarded another **30** points for correctly solving for **Ai** ≤ 10000. diff --git a/_problems/medium/NUMSUM.md b/_problems/medium/NUMSUM.md index 5d31f6db..a7ee2855 100644 --- a/_problems/medium/NUMSUM.md +++ b/_problems/medium/NUMSUM.md @@ -34,5 +34,4 @@ For each test case, output a number which represents the sum of the first 'n' na Explanation The sum of the first 3 numbers is 1+2+3 = 6 The sum of the first 5 numbers is 1+2+3+4+5 = 15 - \ No newline at end of file diff --git a/_problems/medium/NWAYS.md b/_problems/medium/NWAYS.md index 4ed3a2f0..bdd7dfd8 100644 --- a/_problems/medium/NWAYS.md +++ b/_problems/medium/NWAYS.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in Devu is learning Combinatorics in his college. He find it very interesting to calculate number of ways of going to point **(c,d)** from point **(a,b)** in co-ordinate plane. We can take horizontal and vertical steps only and can not visit at a point twice. In a step, you can move one unit only. We have to reach to the point **(c,d)** from the point **(a,b)** using **abs(a-c)+ abs(b-d)** steps only. -Devu has two sets of points. Set **A** contains points having **X** co-ordinate and **Y** co-ordinates varying from **1** to **N**(both inclusive). Set **B** contains points having **X** co-ordinate **K** and **Y** co-ordinates varying from **1** to **N**(both inclusive). Both sets contains **N** number of integral points. He wants to calculate the sum of number of ways to going to the each point of set **B** from the each point of set **A** . +Devu has two sets of points. Set **A** contains points having **X** co-ordinate 0 and **Y** co-ordinates varying from **1** to **N**(both inclusive). Set **B** contains points having **X** co-ordinate **K** and **Y** co-ordinates varying from **1** to **N**(both inclusive). Both sets contains **N** number of integral points. He wants to calculate the sum of number of ways to going to the each point of set **B** from the each point of set **A** . As the answer can be large, print it modulo **1000000007**. @@ -111,8 +111,8 @@ For each test case, print a single integer representing the answer of that test Output: 8 236 - ### Explanation + For the first sample case, ways\[(0,1)->(2,1)\]= 1 diff --git a/_problems/medium/ODDBIN.md b/_problems/medium/ODDBIN.md index 3c9f519d..1a030660 100644 --- a/_problems/medium/ODDBIN.md +++ b/_problems/medium/ODDBIN.md @@ -36,4 +36,5 @@ Output one line per test case, the value W( (1+x)a1 + (1+x)a2 + ... + (1+x)am ).
Input: 

4

1 1

1 3

2 1 3

3 1 2 3

Output:

2

4

2

2



### Explanation + `(1+x) + (1+x)3 = 2 + 4x + 3x2 + x3. Hence the output for "2 1 3" is 2. (2 odd coefficients)

(1+x) + (1+x)2 + (1+x)3 = 3 + 6x + 4x2 + x3. Hence the output for "3 1 2 3" is 2.

` diff --git a/_problems/medium/OLYMPIC.md b/_problems/medium/OLYMPIC.md index 66ad93f5..c1480413 100644 --- a/_problems/medium/OLYMPIC.md +++ b/_problems/medium/OLYMPIC.md @@ -104,8 +104,8 @@ Output **Q** lines, one for each query, the total number of different gift packs 10 2320 3 - + **Explanation:** In the last query, size of each box **S** = 12. diff --git a/_problems/medium/ONEKING.md b/_problems/medium/ONEKING.md index 4723c9cf..6239e701 100644 --- a/_problems/medium/ONEKING.md +++ b/_problems/medium/ONEKING.md @@ -107,7 +107,7 @@ Subtask 3 (50 points) : **1 ≤ T ≤ 20 , 1 ≤ N ≤ 105, 0 ≤ ai ≤ bi ≤ Output: 2 - ### Explanation + There are three kingdoms \[1,3\] ,\[2,5\] and \[6,9\]. You will need at least 2 bombs to destroy the kingdoms. In one of the possible solutions, you can place two bombs at x = 2 and x = 6 . diff --git a/_problems/medium/OPTSSET.md b/_problems/medium/OPTSSET.md index 5b79106f..61ee3dec 100644 --- a/_problems/medium/OPTSSET.md +++ b/_problems/medium/OPTSSET.md @@ -111,7 +111,7 @@ Your answer will be considered correct if it has an absolute error less then **1 - **1 ≤ T ≤ 10** - **3 ≤ n ≤ 105** - The sum of **n** over all test cases is at most **2.105** -- ≤ all coordinates ≤ **109** +- 0 ≤ all coordinates ≤ **109** - **1 ≤ wi ≤ 105** Subtask: @@ -147,5 +147,4 @@ Subtask: 1.274754878 0.606675824 1.355261854 - \ No newline at end of file diff --git a/_problems/medium/ORDERAAM.md b/_problems/medium/ORDERAAM.md index 86f270c1..fcf24507 100644 --- a/_problems/medium/ORDERAAM.md +++ b/_problems/medium/ORDERAAM.md @@ -121,8 +121,8 @@ For each test case, output a single line containing the minimum amount of penalt 0 147 - ### Explanation + **Example 1:** There is only 1 order and all of the items from this order can be served. So zero penalty **Example 2:** There are two orders and you cannot serve 5 items. You can select these 5 items from any order. diff --git a/_problems/medium/PAINTBOX.md b/_problems/medium/PAINTBOX.md index 9e2d96d9..93dc8da8 100644 --- a/_problems/medium/PAINTBOX.md +++ b/_problems/medium/PAINTBOX.md @@ -110,8 +110,8 @@ He wants to pick **W** adjacent boxes and give it to Suraj on his birthday. He w 3 2 2 - ### Explanation + After the first repaint the boxes are coloured (1,1,1,1), which means 3 ways to choose 2 adjacent boxes of the same colour. After the second repaint the boxes are coloured (2,1,1,1), which means 2 ways to select 2 adjacent boxes of the same colour. After the third repaint thee boxes are coloured (2,2,1,1), which means 2 ways to select 2 adjacent boxes of the same colour. diff --git a/_problems/medium/PAINTING.md b/_problems/medium/PAINTING.md index b2f81507..d923768f 100644 --- a/_problems/medium/PAINTING.md +++ b/_problems/medium/PAINTING.md @@ -95,8 +95,8 @@ R 200 120 10 99 - -**Explanation:** + +**Explanation:** R 100 : all 100 cells from (1,0) to (100,0) are painted white U 10 : all 10 cells from (100,1) to (100,10) are painted white diff --git a/_problems/medium/PAIRCLST.md b/_problems/medium/PAIRCLST.md index 62a4ebd5..21393741 100644 --- a/_problems/medium/PAIRCLST.md +++ b/_problems/medium/PAIRCLST.md @@ -115,6 +115,6 @@ Output the shortest pairwise distance between any two different special nodes. Output: 7 - ### Explanation + Nodes 1, 3 and 5 are special nodes. Shortest distance between nodes 1 and 3 is 7 and that between nodes 3 and 5 is 9. Shortest distance between nodes 1 and 5 is 16. Minimum of these distances is 7. Hence answer is 7. diff --git a/_problems/medium/PALIN3.md b/_problems/medium/PALIN3.md index d86cff12..9fd97615 100644 --- a/_problems/medium/PALIN3.md +++ b/_problems/medium/PALIN3.md @@ -102,6 +102,6 @@ Your output should contain the only integer, denoting the number of substrings o Output: 4 - ### Explanation + In the example you should count **S**\[2..2\] = "0", **S**\[5..5\] = "0", **S**\[6..6\] = "0" and **S**\[7..7\] = "3". diff --git a/_problems/medium/PALINDR.md b/_problems/medium/PALINDR.md index 0f791259..e1688162 100644 --- a/_problems/medium/PALINDR.md +++ b/_problems/medium/PALINDR.md @@ -106,8 +106,8 @@ abacaba 3 0 1 - ### Scoring + In all the subtasks, 1 <= **L** <= **R** <= **N**. Subtask 1 (33 points): 1 <= **N** <= 10, 1 <= **M** <= 1000 diff --git a/_problems/medium/PALIPALI.md b/_problems/medium/PALIPALI.md index 6111aaed..76b2ae3c 100644 --- a/_problems/medium/PALIPALI.md +++ b/_problems/medium/PALIPALI.md @@ -40,5 +40,4 @@ xxyyxxxxyyxx 0 0 2 - \ No newline at end of file diff --git a/_problems/medium/PARALLEL.md b/_problems/medium/PARALLEL.md index a046c6d9..ac92b279 100644 --- a/_problems/medium/PARALLEL.md +++ b/_problems/medium/PARALLEL.md @@ -90,8 +90,8 @@ Output the number of steps in your program. In the following lines describe thes 2 1+2=2 4+5=5 2 2+3=3 5+6=6 3 3+4=4 3+5=5 3+6=6 - ### Explanation + Lets name values in the array with letters from a to f. The table below describes contents of the array after each step: 123456initial values:abcdefafter step 1:aa+bcdd+efafter step 2:aa+ba+b+cdd+ed+e+fafter step 3:aa+ba+b+ca+b+c+da+b+c+d+ea+b+c+d+e+f diff --git a/_problems/medium/PARITREE.md b/_problems/medium/PARITREE.md index 120ce6bd..09dcbe5d 100644 --- a/_problems/medium/PARITREE.md +++ b/_problems/medium/PARITREE.md @@ -139,8 +139,8 @@ As the answer could be quite large, print your answer modulo **109 + 7**. 1 4 2 - ### Explanation + **In the first example**, You can only set the weight of each edge equal to 0 for satisfying the given condition. So, there is exactly one way of doing this. Hence answer is 1. diff --git a/_problems/medium/PARPOLY.md b/_problems/medium/PARPOLY.md index b7dfa5df..2873e985 100644 --- a/_problems/medium/PARPOLY.md +++ b/_problems/medium/PARPOLY.md @@ -114,8 +114,10 @@ If **D** ≠ 0, then **C****D** ≠ 0 3 1 1 3 1 2 3 4 ### Sample Output +
78
 4
 30
 
### Explanation + In the first case, the polynomial is **P**(**x**) = 2 · **x**2 + **x**. The answer is **P**(3**X**) = **P**(6) = 2 · 36 + 6 = 78. diff --git a/_problems/medium/PATTMATC.md b/_problems/medium/PATTMATC.md index 151d6db7..3e07cb72 100644 --- a/_problems/medium/PATTMATC.md +++ b/_problems/medium/PATTMATC.md @@ -118,8 +118,8 @@ abacaba Output: 1 3 3 5 5 7 7 2 6 6 6 6 -1 -1 - ### Explanation + **Example case 1.** Let us show that for every index **i** the value of **pi** is correct: - **p1** = 1. The corresponding substring **a** contains the string **a**. String **a** can be generated by replacing both asterisks with empty strings. diff --git a/_problems/medium/PDSNUM.md b/_problems/medium/PDSNUM.md index a77b6e90..12275d8f 100644 --- a/_problems/medium/PDSNUM.md +++ b/_problems/medium/PDSNUM.md @@ -90,5 +90,4 @@ For each test case, output on a line the respective PDS(N) calculated. Output: 1 66 - \ No newline at end of file diff --git a/_problems/medium/PEAKS.md b/_problems/medium/PEAKS.md index cd06de11..c7919a0a 100644 --- a/_problems/medium/PEAKS.md +++ b/_problems/medium/PEAKS.md @@ -134,8 +134,8 @@ Time limit for the first and the second subtasks is 2 s. Time limit for the thir 1023 14 - ### Explanation of the first two cases in the example test + In the first case, there is only one valid subsequence - the whole sequence **S**. In the second case, any non-empty sequence is valid, so the answer is **2N - 1**. diff --git a/_problems/medium/PEOPLOVE.md b/_problems/medium/PEOPLOVE.md index e8a5fcb9..cbe9a4ee 100644 --- a/_problems/medium/PEOPLOVE.md +++ b/_problems/medium/PEOPLOVE.md @@ -133,8 +133,8 @@ BOTH_SUBTASKS SMALL_SUBTASK 1 1 - ### Explanation + **Example case 1.** There are two persons. Person 1 and 2 love each other. Now, according to magician's suggestion, if person 1 loves person 2, then sadness of both the persons will be equal to 1. Same is the case with person 2 loving person 1. Hence answer is 1. **Example case 2.** There are three persons. Person 1 and 2 love each other. Person 2 and 3 love each other. Now, according to magician's suggestion, if person 1 loves person 2 and person 3 loves 1. Then, sadness of all three persons will be equal to 1. This is the best that they can do. For example, if the person 1 loves 2 and person 1 loves 3 too, then sadness of first person will be 2, which will be worse than previous case. Hence answer is 1. diff --git a/_problems/medium/PERMDIG.md b/_problems/medium/PERMDIG.md index cf3ec463..3827f545 100644 --- a/_problems/medium/PERMDIG.md +++ b/_problems/medium/PERMDIG.md @@ -45,8 +45,8 @@ For each test case, output a single line containing the number of possible permu 1 0 4 - ### Explanation + In the first case the appropriate ways are 01+10=11 and 10+01=11. In the third case the only appropriate way is 011+12=23. diff --git a/_problems/medium/PERSHFTS.md b/_problems/medium/PERSHFTS.md index 53714031..1d6a7382 100644 --- a/_problems/medium/PERSHFTS.md +++ b/_problems/medium/PERSHFTS.md @@ -139,8 +139,8 @@ For each test case, output a single line. It must contain **-1**, if permutation Output: 2 -1 - ### Explanation + **Example case 1.** Cyclic shift of segment of length **2** is swapping consecutive elements of the permutation. Using them, we are able to get any possible permutation. Permutation **Q** has index **2** in the list of all permutations of length **4**. **Example case 2.** We are able to get permutations **(1, 2, 3)**, **(2, 3, 1)** and **(3, 1, 2)**. Permutation **Q** doesn't belong to this list, so answer is **-1**. diff --git a/_problems/medium/PHOTOS.md b/_problems/medium/PHOTOS.md index 5f3d3e35..db217004 100644 --- a/_problems/medium/PHOTOS.md +++ b/_problems/medium/PHOTOS.md @@ -58,5 +58,4 @@ For each input you are to output a single line. If you are unable to take photos No Photos 1 12 - \ No newline at end of file diff --git a/_problems/medium/PHRASES.md b/_problems/medium/PHRASES.md index ae4acd68..295a2298 100644 --- a/_problems/medium/PHRASES.md +++ b/_problems/medium/PHRASES.md @@ -34,5 +34,4 @@ baba Output: 2 - -(in the example above, the longest substring which fulfills the requirements is 'ba') \ No newline at end of file +(in the example above, the longest substring which fulfills the requirements is 'ba') diff --git a/_problems/medium/POLYEVAL.md b/_problems/medium/POLYEVAL.md index 735e6ada..89ef3385 100644 --- a/_problems/medium/POLYEVAL.md +++ b/_problems/medium/POLYEVAL.md @@ -90,9 +90,9 @@ For each query, output a single line containing the answer to the corresponding ### Constraints and Subtasks -- ≤ **ai**, **xj** < **786433** -- **Subtask #1** (37 points): ≤ **N, Q** ≤ **1000** -- **Subtask #2** (63 points): ≤ **N, Q** ≤ **2.5 × 105** +- 0 ≤ **ai**, **xj** < **786433** +- **Subtask #1** (37 points): 0 ≤ **N, Q** ≤ **1000** +- **Subtask #2** (63 points): 0 ≤ **N, Q** ≤ **2.5 × 105** ### Example @@ -108,8 +108,8 @@ For each query, output a single line containing the answer to the corresponding 162 209 262 - ### Explanation + **Example case 1.** - Query 1: 1 + 2 × 7 + 3 × 7 × 7 = 162 diff --git a/_problems/medium/POSTAL.md b/_problems/medium/POSTAL.md index a4880b7a..e93e0dd0 100644 --- a/_problems/medium/POSTAL.md +++ b/_problems/medium/POSTAL.md @@ -40,5 +40,4 @@ For every query of a test case, you have to output the position of the postman n 23 2 -8 0 - \ No newline at end of file diff --git a/_problems/medium/POUR1.md b/_problems/medium/POUR1.md index 00bfe3d7..600bf50b 100644 --- a/_problems/medium/POUR1.md +++ b/_problems/medium/POUR1.md @@ -44,10 +44,9 @@ Sample input: 2 3 4 - Sample output: +
 2
 -1
-
 
\ No newline at end of file diff --git a/_problems/medium/POWERMUL.md b/_problems/medium/POWERMUL.md index 235951d5..265a41a8 100644 --- a/_problems/medium/POWERMUL.md +++ b/_problems/medium/POWERMUL.md @@ -115,8 +115,8 @@ For every test case , output **Q** lines , each line containing the answer.

Sample Output

8 8 - ### Explanation + f\[1\] = 1 f\[2\] = 4 diff --git a/_problems/medium/POWSUMS.md b/_problems/medium/POWSUMS.md index 4ea55f46..e0c84357 100644 --- a/_problems/medium/POWSUMS.md +++ b/_problems/medium/POWSUMS.md @@ -99,7 +99,7 @@ For each test case, print a single line containing **Q** space separate integers - **1** ≤ **n** ≤ **300** - **1** ≤ **Q** ≤ **30** -- ≤ **f(i)** 109 + 7 +- 0 ≤ **f(i)** 109 + 7 - **n** xi ≤ **1018** - It is guaranteed that given information is enough to restore the function **f** and that there exist exactly one such function. @@ -122,8 +122,8 @@ For each test case, print a single line containing **Q** space separate integers Output: 34 66 73741819 - ### Explanation + **Test case 1.** The initial **4** numbers Chef has are **1, 2, 0, 1**, so, the function **f** was defined as follows: **f(k) = (1k + 2k + 0k + 1k) mod (109 + 7) = (2k + 2) mod (109 + 7)**. So, the values given in the input are: **``` @@ -132,14 +132,12 @@ f(1) = (21 + 2) mod (109 + 7) = 4 f(2) = (22 + 2) mod (109 + 7) = 6 f(3) = (23 + 2) mod (109 + 7) = 10 f(4) = (24 + 2) mod (109 + 7) = 18 -
**
 And the values Chef asked you to calculate are: **```
 
 f(5) = (25 + 2) mod (109 + 7) = 34
 f(6) = (26 + 2) mod (109 + 7) = 66
 f(30) = (230 + 2) mod (109 + 7) = 1073741826  mod (109 + 7) = 73741819
-
 
** ### Note diff --git a/_problems/medium/PP.md b/_problems/medium/PP.md index 5fb28b92..a3c1ea25 100644 --- a/_problems/medium/PP.md +++ b/_problems/medium/PP.md @@ -108,6 +108,6 @@ abb Output: 2 - ### Explanation + ab|a and abb|a diff --git a/_problems/medium/PPERM.md b/_problems/medium/PPERM.md index f949183b..feaee066 100644 --- a/_problems/medium/PPERM.md +++ b/_problems/medium/PPERM.md @@ -97,8 +97,8 @@ For each test case, output a single line containing the number of prime permutat 2 6 18 - ### Constraints: + 1 ≤ T ≤ 500,000 1 ≤ N ≤ 5,000,000 Each input file will not be larger than 4 MB (4,000,000,000 bytes) in size. diff --git a/_problems/medium/PPLUCKY.md b/_problems/medium/PPLUCKY.md index 1446ca12..034f7c18 100644 --- a/_problems/medium/PPLUCKY.md +++ b/_problems/medium/PPLUCKY.md @@ -107,8 +107,8 @@ For each test case, output a single line containing the answer to the correspond Output: 4 20 - ### + ### Explanation **Example case 1.** In this case, there is just a single iteration. Since **P = {1, 3}**, the answer is **1 + 3 = 4**. diff --git a/_problems/medium/PPXOR.md b/_problems/medium/PPXOR.md index a68166a8..5ab8c5ce 100644 --- a/_problems/medium/PPXOR.md +++ b/_problems/medium/PPXOR.md @@ -89,7 +89,7 @@ For each test case, output a single line containing the total sum to the corresp - **1** ≤ **T** ≤ **100,000** - **1** ≤ **N** ≤ **100,000** -- ≤ **A\[i\]** ≤ **1,000,000,000 (10^9)** +- 0 ≤ **A\[i\]** ≤ **1,000,000,000 (10^9)** - The total sum of all **N** over all test cases will not exceed **100,000**. ### Example @@ -101,8 +101,8 @@ For each test case, output a single line containing the total sum to the corresp Output: 6 - ### Explanation + **Example case 1.** **F(1, 1) = A\[1\] = 1**, **F(2, 2) = A\[2\] = 2** and **F(1, 2) = A\[1\]** XOR **A\[2\] = 1** XOR **2 = 3**. Hence the answer is **1 + 2 + 3 = 6**. @@ -110,6 +110,6 @@ For each test case, output a single line containing the total sum to the corresp -[XOR operation](http://en.wikipedia.org/wiki/Exclusive_or) is a bitwise "Exclusive OR" operation performed on two integers in binary representation. First, the shorter number is prepended with leading zeroes until the numbers have equal size in binary. Then the resulting number (also in binary) contains in all positions where the corresponding bits coincide, and **1** on the rest of the positions. +[XOR operation](http://en.wikipedia.org/wiki/Exclusive_or) is a bitwise "Exclusive OR" operation performed on two integers in binary representation. First, the shorter number is prepended with leading zeroes until the numbers have equal size in binary. Then the resulting number (also in binary) contains 0 in all positions where the corresponding bits coincide, and **1** on the rest of the positions. For example, **3** XOR **5** = **0112** XOR **1012** = **1102** = **6**. diff --git a/_problems/medium/PREFIXOR.md b/_problems/medium/PREFIXOR.md index b53cb557..5d1d7280 100644 --- a/_problems/medium/PREFIXOR.md +++ b/_problems/medium/PREFIXOR.md @@ -110,5 +110,4 @@ For each query print the answer on a single line. 4 6 4 - \ No newline at end of file diff --git a/_problems/medium/PREPARE.md b/_problems/medium/PREPARE.md index bf16f9c6..a4330239 100644 --- a/_problems/medium/PREPARE.md +++ b/_problems/medium/PREPARE.md @@ -49,5 +49,4 @@ The output for each test case consists of a single integer t which is the minimu Output: 4 1 - \ No newline at end of file diff --git a/_problems/medium/PRIME1.md b/_problems/medium/PRIME1.md index 27b14ecd..fa3a8e40 100644 --- a/_problems/medium/PRIME1.md +++ b/_problems/medium/PRIME1.md @@ -36,5 +36,4 @@ For every test case print all prime numbers p such that m <= p <= n, one number 3 5 - -**Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)** \ No newline at end of file +**Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)** diff --git a/_problems/medium/PRMQ.md b/_problems/medium/PRMQ.md index 9e1c58b8..c109b426 100644 --- a/_problems/medium/PRMQ.md +++ b/_problems/medium/PRMQ.md @@ -132,8 +132,8 @@ F(L, R, X, Y) { Output: 4 5 - ### Explanation + **Query 1** : The first prime is 2. 2 divides the first element 1 time, 2 divides the second element 0 times and 2 divides the third element 2 times. Hence 2 contributes a total of 3 to the result ( 1 + 0 + 2 = 3 ) diff --git a/_problems/medium/PROPOSAL.md b/_problems/medium/PROPOSAL.md index 714edb0e..5bfd89c9 100644 --- a/_problems/medium/PROPOSAL.md +++ b/_problems/medium/PROPOSAL.md @@ -24,8 +24,8 @@ The figure below shows a simple multiplication problem. However, not all the dec * * * <-- partial product 2 ------- * * * * - -Digits can appear only in places marked by \*'. Of course, leading zeroes are not allowed. Write a program to help Prima that will find all solutions to this problem for any subset of digits from the set {1,2,3,4,5,6,7,8,9}. ### Input + +Digits can appear only in places marked by \*'. Of course, leading zeroes are not allowed. Write a program to help Prima that will find all solutions to this problem for any subset of digits from the set {1,2,3,4,5,6,7,8,9}. ### Input The first line contains N, the number of digits that will be used The second line contains N space separated digits @@ -42,8 +42,8 @@ A single line with the total number of unique solutions. Here is the single solu 4 4 4 --------- 4 8 8 4 - ### Example +
 Input:
 5
@@ -52,5 +52,4 @@ A single line with the total number of unique solutions. Here is the single solu
 
 Output:
 1
-
 
\ No newline at end of file diff --git a/_problems/medium/PSHTBRTH.md b/_problems/medium/PSHTBRTH.md index 32271ca3..96d676c2 100644 --- a/_problems/medium/PSHTBRTH.md +++ b/_problems/medium/PSHTBRTH.md @@ -95,7 +95,7 @@ Help Chef answer all of Lotsy's queries, and make Pishty's birthday the best bir The first line of the each description contains two integers **N** and **M**, denoting the number of cakes and the number of queries respectively. -The following **5 × N** lines contain information about the **N** cake-denoting matrices (four lines of strings of four chars (without spaces), followed by an empty line). An element of a matrix equals **1** if there is a burning candle and if there isn't anything. +The following **5 × N** lines contain information about the **N** cake-denoting matrices (four lines of strings of four chars (without spaces), followed by an empty line). An element of a matrix equals **1** if there is a burning candle and 0 if there isn't anything. Then the queries follow in one of the following formats: @@ -164,5 +164,4 @@ Lotsy Pishty Pishty Pishty - \ No newline at end of file diff --git a/_problems/medium/PSHTTR.md b/_problems/medium/PSHTTR.md index bd99358c..291788ac 100644 --- a/_problems/medium/PSHTTR.md +++ b/_problems/medium/PSHTTR.md @@ -138,5 +138,4 @@ The next **M** lines contain information about the requests. Each line contains 1 4 3 - \ No newline at end of file diff --git a/_problems/medium/PUPPYCT.md b/_problems/medium/PUPPYCT.md index 19a68c9f..f48618f4 100644 --- a/_problems/medium/PUPPYCT.md +++ b/_problems/medium/PUPPYCT.md @@ -88,11 +88,11 @@ For each test case, output a single line containing one integer - number of cell - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **106** -- ≤ **K** ≤ **105** +- 0 ≤ **K** ≤ **105** - **1** ≤ **xi**, **yi** ≤ **N** -- Subtask #1 \[22 points\]: **1** ≤ **N** ≤ **500**, ≤ **K** ≤ **104** -- Subtask #2 \[24 points\]: **1** ≤ **N** ≤ **1000**, ≤ **K** ≤ **105** -- Subtask #3 \[23 points\]: **1** ≤ **N** ≤ **106**, ≤ **K** ≤ **1** +- Subtask #1 \[22 points\]: **1** ≤ **N** ≤ **500**, 0 ≤ **K** ≤ **104** +- Subtask #2 \[24 points\]: **1** ≤ **N** ≤ **1000**, 0 ≤ **K** ≤ **105** +- Subtask #3 \[23 points\]: **1** ≤ **N** ≤ **106**, 0 ≤ **K** ≤ **1** - Subtask #4 \[31 points\]: no additional constraints ### Example @@ -105,6 +105,6 @@ For each test case, output a single line containing one integer - number of cell Output: 5 - ### Sample explanation + We have cells **(2, 1) (2, 3)** on the same diagonals with **(1, 2) or (3, 2)**. Thus 4 cells are occupied by cats and 5 are free of cats. diff --git a/_problems/medium/PUPPYPLM.md b/_problems/medium/PUPPYPLM.md index feb0d70f..f01492c6 100644 --- a/_problems/medium/PUPPYPLM.md +++ b/_problems/medium/PUPPYPLM.md @@ -91,7 +91,7 @@ For each test case, output a single line containing one integer: the answer for - **1** ≤ **T** ≤ **5** - **1** ≤ **N** ≤ **105** -- ≤ **K** ≤ **5** +- 0 ≤ **K** ≤ **5** ### Example @@ -103,8 +103,8 @@ For each test case, output a single line containing one integer: the answer for Output: 28 56 - ### Explanation + **Test case 1:** There are: diff --git a/_problems/medium/PUZZLES.md b/_problems/medium/PUZZLES.md index 224ff2b0..f3961d65 100644 --- a/_problems/medium/PUZZLES.md +++ b/_problems/medium/PUZZLES.md @@ -49,6 +49,6 @@ If an integer k between 1 and V does not have either k or -k appearing in a grou Output: TFF TFTFFTF - ### Explanation of Output + In the first case, the first two groups include 1 which is assigned 'T', and the last group contains -3 and 3 is assigned 'F' so all groups meet the criteria. In the second case, the first group has 1 which is assigned 'T' and the second group has 3 which is also assigned 'T' so all groups in this test case also meet the criteria. diff --git a/_problems/medium/QCHEF.md b/_problems/medium/QCHEF.md index 91448a62..1d27c6d6 100644 --- a/_problems/medium/QCHEF.md +++ b/_problems/medium/QCHEF.md @@ -120,11 +120,11 @@ For each group, output the integer denoting the maximum difference between numbe 1 1 6 - ### Explanation -**Group 1.** There is only one person in the group. Thus the maximum difference of numbers should be . -**Group 2.** There are two persons in the group. Their growth are **A5 = 5** and **A6 = 7**. Thus there is no pair of persons who have the same growth. Thus the answer for this group will also be . +**Group 1.** There is only one person in the group. Thus the maximum difference of numbers should be 0. + +**Group 2.** There are two persons in the group. Their growth are **A5 = 5** and **A6 = 7**. Thus there is no pair of persons who have the same growth. Thus the answer for this group will also be 0. **Group 3.** There are three persons in the group. Their growth are **A3 = 6**, **A4 = 6** and **A5 = 5**. Here person **3** and person **4** has the same growth. Thus the answer is **|4 − 3| = 1**. diff --git a/_problems/medium/QNUMBER.md b/_problems/medium/QNUMBER.md index 521805c3..50740800 100644 --- a/_problems/medium/QNUMBER.md +++ b/_problems/medium/QNUMBER.md @@ -108,8 +108,8 @@ For each of the **Q** lines you must output the result for corresponding query i 5 6 - ### Explanation + Numbers for each query: {1,2,3,6} {1,2} diff --git a/_problems/medium/QSET.md b/_problems/medium/QSET.md index e516b483..05273d7e 100644 --- a/_problems/medium/QSET.md +++ b/_problems/medium/QSET.md @@ -104,7 +104,7 @@ For each query of type 2, print the required answer in a single line. - **0 ≤ Ai ≤ 9** - **1** ≤ **Xi** ≤ **N** -- ≤ **Yi** ≤ **9** +- 0 ≤ **Yi** ≤ **9** - **1** ≤ **Ci** ≤ **Di** ≤ **N** ### Subtasks @@ -126,8 +126,8 @@ For each query of type 2, print the required answer in a single line. Output: 3 1 - ### Explanation + For first query, the sub-strings S\[1,1\]="0", S\[1,3\]="012" and S\[2,3\]="12" are divisible by 3. After second query, the string A becomes "01255". For third query, only sub-string S\[3,5\]="255" is divisible by 3. diff --git a/_problems/medium/QUEHEA.md b/_problems/medium/QUEHEA.md index 99d11e69..7fea367a 100644 --- a/_problems/medium/QUEHEA.md +++ b/_problems/medium/QUEHEA.md @@ -113,8 +113,8 @@ For each query, output the number of guilds after the execution. 4 2 3 - ### Explanation + Initially there is just one guild. After the executions of the first query the guilds will be **{ {1, 2}, {3, 4}, {5},{6} }**. diff --git a/_problems/medium/RAINFALL.md b/_problems/medium/RAINFALL.md index a93dae10..67caace4 100644 --- a/_problems/medium/RAINFALL.md +++ b/_problems/medium/RAINFALL.md @@ -124,8 +124,8 @@ For each test case, for each query, output a single line containing the smallest Output: 3 - ### Explanation + These are the following possible values of B:
@@ -136,5 +136,5 @@ These are the following possible values of B:
 2 5
 
 5 5
-
-
All these four values of **B** appear with same probability, 1/4. The expected number of houses submerged when X = 3 is (2 \* 1/4 + 1 \* 1/4 + 1 \* 1/4 + 0 \* 1/4) = 1.if rainfall is less than 3, then the expected number of submerged houses is less than 1. +All these four values of **B** appear with same probability, 1/4. The expected number of houses submerged when X = 3 is (2 \* 1/4 + 1 \* 1/4 + 1 \* 1/4 + 0 \* 1/4) = 1. +if rainfall is less than 3, then the expected number of submerged houses is less than 1. diff --git a/_problems/medium/REBXOR.md b/_problems/medium/REBXOR.md index 77fd411b..17184c44 100644 --- a/_problems/medium/REBXOR.md +++ b/_problems/medium/REBXOR.md @@ -94,7 +94,7 @@ Output a single integer denoting the **maximum possible** value of the given exp ### Constraints - **2** ≤ **N** ≤ **4\*105** -- ≤ **Ai** ≤ **109** +- 0 ≤ **Ai** ≤ **109** ### Subtasks @@ -110,6 +110,6 @@ Output a single integer denoting the **maximum possible** value of the given exp Output: 6 - ### Explanation + Choose (**l1**, **r1**, **l2**, **r2**) = (1, 2, 3, 3) or (1, 2, 4, 5) or (3, 3, 4, 5). diff --git a/_problems/medium/REDBLUE.md b/_problems/medium/REDBLUE.md index 82ebd5c1..c3cd47f7 100644 --- a/_problems/medium/REDBLUE.md +++ b/_problems/medium/REDBLUE.md @@ -122,5 +122,4 @@ For each test case, output a single line containing one integer denoting the min Output: 2 - \ No newline at end of file diff --git a/_problems/medium/REFUELS.md b/_problems/medium/REFUELS.md index 51571d69..98e7b373 100644 --- a/_problems/medium/REFUELS.md +++ b/_problems/medium/REFUELS.md @@ -131,6 +131,7 @@ For each of the **Q** races, in a separate line, print a single integer — the 30666666576 41111110788607 ### Explanation + Your car fits up to **N** = 3 units of fuel. Let's take a look at the first two races. **Race #1.** This race consists of **K** = 5 laps and you need **P** = 60 seconds to visit a pit stop. One optimal scenario is: diff --git a/_problems/medium/REGIONS.md b/_problems/medium/REGIONS.md index 462ec2d4..f1242cf8 100644 --- a/_problems/medium/REGIONS.md +++ b/_problems/medium/REGIONS.md @@ -107,7 +107,7 @@ The hash function is calculated this way: - **1** ≤ **T** ≤ **105** - **2** ≤ **N**, sum of **N** ≤ **5 × 106** -- ≤ **A, B, C, D** ≤ **104** +- 0 ≤ **A, B, C, D** ≤ **104** - **2** ≤ **E** ≤ **200** ### Example @@ -120,22 +120,22 @@ The hash function is calculated this way: Output: 99116027 515191750 - ### Explanation + **Example case 1.** The roads are: - Road connecting cities **1** and **2** with length **2**; -- Road connecting cities **2** and **3** with length ; +- Road connecting cities **2** and **3** with length 0; - Road connecting cities **3** and **4** with length **3**; - Road connecting cities **4** and **5** with length **1**. -If we remove the first road, then the inconveniences of the parts will be equal to and **4**. So **Q1 = 0, Q2 = 4**. +If we remove the first road, then the inconveniences of the parts will be equal to 0 and **4**. So **Q1 = 0, Q2 = 4**. If we remove the second road, the inconveniences will be equal to **2** and **4**. So **Q3 = 2, Q4 = 4**. If we remove the third road, the inconveniences will be equal to **2** and **1**. So **Q5 = 1, Q6 = 2**. -If we remove the fourth road, the inconveniences will be equal to **5** and . So **Q7 = 0, Q8 = 5**. +If we remove the fourth road, the inconveniences will be equal to **5** and 0. So **Q7 = 0, Q8 = 5**. So, we've obtained the sequence **Q = (0, 4, 2, 4, 1, 2, 0, 5)**. diff --git a/_problems/medium/REIGN2.md b/_problems/medium/REIGN2.md index 5c2a9a37..4be4056f 100644 --- a/_problems/medium/REIGN2.md +++ b/_problems/medium/REIGN2.md @@ -119,5 +119,4 @@ For each test case, output a single line containing **N** integers: the maximal 5 12 21 31 6 17 36 61 91 -
\ No newline at end of file
diff --git a/_problems/medium/REPSTR.md b/_problems/medium/REPSTR.md
index cfe83de9..23b8abad 100644
--- a/_problems/medium/REPSTR.md
+++ b/_problems/medium/REPSTR.md
@@ -41,8 +41,8 @@ abcd
 2 4
 6 3
 1 4
-
 
### Explanation + Case #1: **bcbc** occurs twice - at position 3 and position 5 (occurrences may overlap). Case #2: **bab** occurs 6 times. Case #3: **abcd** occurs 1 time. diff --git a/_problems/medium/RESN01.md b/_problems/medium/RESN01.md index 4f3854e8..1aaff862 100644 --- a/_problems/medium/RESN01.md +++ b/_problems/medium/RESN01.md @@ -34,5 +34,4 @@ Output T lines, one per test case. For each test case, output a space seperated Output: 0 0 0 1 1 1 1 1 - \ No newline at end of file diff --git a/_problems/medium/RESTEXP.md b/_problems/medium/RESTEXP.md index 37237526..b16df6c1 100644 --- a/_problems/medium/RESTEXP.md +++ b/_problems/medium/RESTEXP.md @@ -50,8 +50,8 @@ If there are several expansion plans that lead to the same maximum profit, you m 1 2 2 3 2 4 - -
**Output**```
+
+**Output**```
 
 11
 transfer 1 2 2
@@ -59,8 +59,8 @@ transfer 2 4 1
 nothing
 build 4
 build 2
-
 
### Constraints + - 1 <= N <= 30 - 1 <= C <= 30 - 1 <= D <= 30 diff --git a/_problems/medium/RESTOCK.md b/_problems/medium/RESTOCK.md index e1d9c9fb..6bdf5fe2 100644 --- a/_problems/medium/RESTOCK.md +++ b/_problems/medium/RESTOCK.md @@ -50,5 +50,4 @@ Output a line with a single integer, the cost of the cheapest assignment of work Output: 6 4 -
\ No newline at end of file diff --git a/_problems/medium/RESTPERM.md b/_problems/medium/RESTPERM.md index 636dde04..381c3da9 100644 --- a/_problems/medium/RESTPERM.md +++ b/_problems/medium/RESTPERM.md @@ -132,5 +132,4 @@ Please flush output buffer anytime you output a query. 2 1 2 > (FEEDBACK) Yes 3 1 2 - \ No newline at end of file diff --git a/_problems/medium/RIPPLE.md b/_problems/medium/RIPPLE.md index ea399535..46803302 100644 --- a/_problems/medium/RIPPLE.md +++ b/_problems/medium/RIPPLE.md @@ -20,8 +20,8 @@ while bi == 1 bi := 0 i := i+1 bi := 1 - This doesn't account for overflow when increasing from 2n-1 to 2n, but we'll ignore that error for this problem. + Each time a bit is changed from 0 to 1 or from 1 to 0 we say the bit is "flipped". In the worst case, we may have to flip every bit. However, a standard result says the average number of bits flipped per increment when counting from 0 to 2n-1 is less than 2. Being the curious sort, you decide to explore this result in a slightly more general setting. That is, you want to know how many bits are flipped when the counter is incremented from a number a to b where a < b. diff --git a/_problems/medium/RIVPILE.md b/_problems/medium/RIVPILE.md index caa8b78e..3bf4bfeb 100644 --- a/_problems/medium/RIVPILE.md +++ b/_problems/medium/RIVPILE.md @@ -142,8 +142,8 @@ For each test case, print the minimum cost to make it possible to move from **y 5 impossible - ### Explanation + The following figure indicates the optimal way for the first case. ![](//www.codechef.com/download/RIVPILE.png) diff --git a/_problems/medium/RNDGRID.md b/_problems/medium/RNDGRID.md index f86f0e5e..574b1540 100644 --- a/_problems/medium/RNDGRID.md +++ b/_problems/medium/RNDGRID.md @@ -136,8 +136,8 @@ RLLRDDLUUL Output: 2 3 - ### Explanation + **Test case 1.** We are given the grid of size **N** = 4, and a sequence of **L** = 3 moves. For each empty cell of the grid, below you can see the number of moves Limak would make:
@@ -145,8 +145,8 @@ RLLRDDLUUL
 # 3 1 0 
 1 1 0 # 
 0 0 # 0
-
 
The answer is 3 xor 3 xor 3 xor 1 xor 1 xor 1 = 2. + **Test case 2.** Again, below you can see the number of moves Limak would make from each cell:
@@ -154,5 +154,4 @@ RLLRDDLUUL
 0 # 2 0 
 2 0 # 0 
 0 # 0 #
-
 
\ No newline at end of file diff --git a/_problems/medium/ROBOTDAG.md b/_problems/medium/ROBOTDAG.md index 17d1fc41..2e034e81 100644 --- a/_problems/medium/ROBOTDAG.md +++ b/_problems/medium/ROBOTDAG.md @@ -138,8 +138,8 @@ The aim of the contest is to program your robots in such a manner that they trav 3 4 5 - ### Explanation + The graphs in all the three testcases are the same. Only the number of robots change. **Test Case 1:** There is only one robot, and it can take this sequence of edges: (1, 2), (2, 7), (7, 8). The maximum distance traveled among all the robot(s) is 3, and hence the answer is 3. This cannot be lowered. diff --git a/_problems/medium/ROTPTS.md b/_problems/medium/ROTPTS.md index 816e2313..9885b9e2 100644 --- a/_problems/medium/ROTPTS.md +++ b/_problems/medium/ROTPTS.md @@ -126,5 +126,4 @@ For each query of type 1, print a single line containing two space-separated int 0 1000000005 1000000003 6 - \ No newline at end of file diff --git a/_problems/medium/ROTSTRNG.md b/_problems/medium/ROTSTRNG.md index 8a4c43c1..d190bf58 100644 --- a/_problems/medium/ROTSTRNG.md +++ b/_problems/medium/ROTSTRNG.md @@ -43,5 +43,5 @@ Monkey : fAbcDe , Po : DefAbc, Monkey : cDefAb , Po : AbcDef Case 2 : Monkey : cabcab , Po : bcabca, Monkey : abcabc - -_Warning : Large input / output. You may have to use efficient input / output methods if you are using languages with heavy input / output overload. Eg: Prefer using scanf/printf to cin/cout for C/C++_ + +_Warning : Large input / output. You may have to use efficient input / output methods if you are using languages with heavy input / output overload. Eg: Prefer using scanf/printf to cin/cout for C/C++_ diff --git a/_problems/medium/RRBIGNUM.md b/_problems/medium/RRBIGNUM.md index bcdf5aa1..b098a405 100644 --- a/_problems/medium/RRBIGNUM.md +++ b/_problems/medium/RRBIGNUM.md @@ -68,7 +68,7 @@ time: current: 1493557884 layout: problem --- -All submissions for this problem are available.Given a binary represantation of number **N**. You are to find how many numbers from to **N** have **even** number of **ones** in their binary represantation. +All submissions for this problem are available.Given a binary represantation of number **N**. You are to find how many numbers from 0 to **N** have **even** number of **ones** in their binary represantation. There is also an update operation, update **(L,R)**, which means that all bits of **N** from **Lth** to **Rth** are flipped, i.e. ones to zeroes and vice versa. You have to also find the answer after each of these updates. @@ -103,6 +103,6 @@ Output the answer for initial value of **N** and also after each of the **M** up 2 1 4 - ### Explanation + After the final operation, **N** becomes 7. All numbers in range **\[0..7\]** that have even number of ones in their binary representation are: **0, 3, 5** and **6**. diff --git a/_problems/medium/RRDAG.md b/_problems/medium/RRDAG.md index 47fde67f..646e796f 100644 --- a/_problems/medium/RRDAG.md +++ b/_problems/medium/RRDAG.md @@ -97,5 +97,4 @@ The author is pretty lazy and he does not want to write checking program. So, if 2 1 3 2 3 - \ No newline at end of file diff --git a/_problems/medium/RRFRNDS.md b/_problems/medium/RRFRNDS.md index 880dfd4e..27afc5d3 100644 --- a/_problems/medium/RRFRNDS.md +++ b/_problems/medium/RRFRNDS.md @@ -95,6 +95,6 @@ Output a single integer — number of friendship suggestions Ilya has to send. Output: 6 - ### Explanation + Each of users **\[2, 3, 4\]** should receive two friendship suggestions, while user **1** does not need any, since he already has all other users in his friend-list. diff --git a/_problems/medium/RRJAM.md b/_problems/medium/RRJAM.md index 9faf6f68..947fac22 100644 --- a/_problems/medium/RRJAM.md +++ b/_problems/medium/RRJAM.md @@ -79,7 +79,7 @@ The first line of input contains single integer number **N**. Following line con ### Output -You should output the answer for each jar separated by space. If it already contains enough jam you should output as the answer, in case it doesn't even after all the operations output **-1** instead. +You should output the answer for each jar separated by space. If it already contains enough jam you should output 0 as the answer, in case it doesn't even after all the operations output **-1** instead. ### Constraints @@ -105,5 +105,4 @@ You should output the answer for each jar separated by space. If it already cont 1 2 0 3 -1 - \ No newline at end of file diff --git a/_problems/medium/RRPLAYER.md b/_problems/medium/RRPLAYER.md index 2e96be9f..b81dcd71 100644 --- a/_problems/medium/RRPLAYER.md +++ b/_problems/medium/RRPLAYER.md @@ -105,6 +105,6 @@ For each test case, output a single line containing the expected number of songs 5.5 - ### Explanation + **Example case 2** After playing the first song there is **1/2** chance to finish the album each time new song is played. So the expected number of songs is **2/2 + 3/4 + 4/8... = 3** diff --git a/_problems/medium/RRSERVER.md b/_problems/medium/RRSERVER.md index 30479188..664b33c1 100644 --- a/_problems/medium/RRSERVER.md +++ b/_problems/medium/RRSERVER.md @@ -94,6 +94,6 @@ Output single integer — minimal wire length required to connect all the server 1 3 Output: 2 - ### Explanation + One of the optimal arrangements is **\[2, 1, 3\]** diff --git a/_problems/medium/RRTREE.md b/_problems/medium/RRTREE.md index 8c537e0d..8729ab0e 100644 --- a/_problems/medium/RRTREE.md +++ b/_problems/medium/RRTREE.md @@ -109,5 +109,4 @@ For each test case, output **N-1** lines - the diameter after adding vertices ** 2 3 3 - ``` diff --git a/_problems/medium/RSRECIPE.md b/_problems/medium/RSRECIPE.md index c3b5b8d9..3aa691b2 100644 --- a/_problems/medium/RSRECIPE.md +++ b/_problems/medium/RSRECIPE.md @@ -52,8 +52,8 @@ If there is a solution output **N** space separated integer numbers - the sequen Output 2: -1 - ### Explanation + In the first test case the answer is not unique. Possible answers are also **{0, 3, -2, 0}**, **{2, 1, 0, -2}** and many others. In the second test case first two conditions imply **A\[1\] + A\[2\] + A\[3\] = 4** and **A\[4\] + A\[5\] = 6** and hence **A\[1\] + A\[2\] + A\[3\] + A\[4\] + A\[5\] = (A\[1\] + A\[2\] + A\[3\]) + (A\[4\] + A\[5\]) = 4 + 6 = 10**. And it contradicts to the third condition. Hence it is impossible to restore the recipe. diff --git a/_problems/medium/SANDWICH.md b/_problems/medium/SANDWICH.md index 129621f4..96da5d2f 100644 --- a/_problems/medium/SANDWICH.md +++ b/_problems/medium/SANDWICH.md @@ -110,8 +110,8 @@ For each test case, output a single line containing two space separated integers Output: 3 6 5 1 - ### Explanation + **Example case 1.** The minimum number of sandwiches is 3, and there are 6 ways to make 2 cuts: 1. positions: 1 4 diff --git a/_problems/medium/SBSTCNT.md b/_problems/medium/SBSTCNT.md index 8b4c85ca..378df4f1 100644 --- a/_problems/medium/SBSTCNT.md +++ b/_problems/medium/SBSTCNT.md @@ -89,9 +89,9 @@ For each query, output a single line containing the answer modulo **1000000007 ( - **1** ≤ **Q** ≤ **3 × 105** - **1** ≤ **Ai** ≤ **105** - **∑ 0 ≤ i < M Ai** ≤ **3 × 106** -- For each query, ≤ **l** ≤ **r** < **M** +- For each query, 0 ≤ **l** ≤ **r** < **M** - **1** ≤ **k** ≤ **105** -- ≤ **n** ≤ **105** +- 0 ≤ **n** ≤ **105** ### Example @@ -104,7 +104,7 @@ For each query, output a single line containing the answer modulo **1000000007 ( Output: 480 1 - ### Explanation + For the first query, the answer is 4 \* 5 \* 4 \* 6, because we just have to choose one coordinate from each dimension. For the second query, the array **B = \[4\]** and you have to pick two positive integers less than or equal to 4 such that the distance between them is 3 or more. There is only way to do this: pick 1 and 4. diff --git a/_problems/medium/SBSWAP.md b/_problems/medium/SBSWAP.md index 6e026baf..d6aad1e1 100644 --- a/_problems/medium/SBSWAP.md +++ b/_problems/medium/SBSWAP.md @@ -145,8 +145,8 @@ For each query of type 1, output the answer for such a query in a single line. M 7 -1 - ### Explanation + The input tree has 10 nodes and each of them has assigned value of 1 at the beginning. Initial tree can be drawn as follows: ![](https://codechef_shared.s3.amazonaws.com/download/Images/LTIME43/15750153_1301041666620483_2119272736_n.png) diff --git a/_problems/medium/SEABAL.md b/_problems/medium/SEABAL.md index e0b7a0bf..0ded99c6 100644 --- a/_problems/medium/SEABAL.md +++ b/_problems/medium/SEABAL.md @@ -115,6 +115,6 @@ For each test case, print **k** lines — the answers after every steps. 1 2 3 - **Update:** + You may assume that, y\[i\] <= n and k <= 100000 diff --git a/_problems/medium/SEABUB.md b/_problems/medium/SEABUB.md index 3c5a6f61..abd49af8 100644 --- a/_problems/medium/SEABUB.md +++ b/_problems/medium/SEABUB.md @@ -96,7 +96,7 @@ For each test case output the minimal possible expected value of **f(A)**. Your - **1** ≤ **T** ≤ **100** - **1** ≤ **n** ≤ **100** -- ≤ **k** ≤ **1018** +- 0 ≤ **k** ≤ **1018** - **1** ≤ **Ai** ≤ **n** ### Example @@ -112,5 +112,4 @@ For each test case output the minimal possible expected value of **f(A)**. Your 0.0000 1.5000 - \ No newline at end of file diff --git a/_problems/medium/SEADIV.md b/_problems/medium/SEADIV.md index d2654978..440a10bf 100644 --- a/_problems/medium/SEADIV.md +++ b/_problems/medium/SEADIV.md @@ -115,5 +115,4 @@ Output the answer in _7_-ary system. ### Constraints 3 3 13 - \ No newline at end of file diff --git a/_problems/medium/SEAGCD.md b/_problems/medium/SEAGCD.md index 3ba1f0e6..b1ee0434 100644 --- a/_problems/medium/SEAGCD.md +++ b/_problems/medium/SEAGCD.md @@ -105,5 +105,4 @@ For each test case output the required sum, modulo **109+7**. 3125 2 - \ No newline at end of file diff --git a/_problems/medium/SEAGCD2.md b/_problems/medium/SEAGCD2.md index 61d29422..347330bd 100644 --- a/_problems/medium/SEAGCD2.md +++ b/_problems/medium/SEAGCD2.md @@ -108,5 +108,4 @@ For each test case output required answer modulo **10^9 + 7**. 1 13 - \ No newline at end of file diff --git a/_problems/medium/SEAGM.md b/_problems/medium/SEAGM.md index 67c1beb4..cebba816 100644 --- a/_problems/medium/SEAGM.md +++ b/_problems/medium/SEAGM.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in Sereja and Dima play the game. The rules are as follows: Initially, there are **n** cards on the table, each card has a positive integer written on it. -At the beginning Sereja writes down the number on the sheet of paper. +At the beginning Sereja writes down the number 0 on the sheet of paper. Then players pick cards from the table alternately. When a player picks a card, he writes down the greatest common divisor of a number that is written on a card and a number that was last written on the sheet of paper. Then the player throws this card away, so it can never been taken again. A player loses if after his turn the number, written on the piece of the paper is **1**. @@ -123,5 +123,4 @@ Output the integer part of the answer to the first question and the answer to th 0 0.0000 1 0.5833 - \ No newline at end of file diff --git a/_problems/medium/SEAGM2.md b/_problems/medium/SEAGM2.md index 6e2f696b..d0a0b2ad 100644 --- a/_problems/medium/SEAGM2.md +++ b/_problems/medium/SEAGM2.md @@ -113,5 +113,4 @@ For each test case, output the probability Sereja is interested in, with 6 digit Output: 1.000000 0.500000 -
\ No newline at end of file
diff --git a/_problems/medium/SEAKAM.md b/_problems/medium/SEAKAM.md
index 4c5ffd1d..1dac98d0 100644
--- a/_problems/medium/SEAKAM.md
+++ b/_problems/medium/SEAKAM.md
@@ -87,7 +87,7 @@ For each test case, output one number — the answer for the problem modulo **10
 
 - **1** ≤ **T** ≤  **10**
 - **1** ≤ **N** ≤  **105**
-- ≤ **M** ≤  **7**
+- 0 ≤ **M** ≤  **7**
 
 ### Subtasks
 
@@ -111,5 +111,4 @@ For each test case, output one number — the answer for the problem modulo **10
 2
 0
 
-
 
\ No newline at end of file diff --git a/_problems/medium/SEAPAIR.md b/_problems/medium/SEAPAIR.md index 062502c5..501d29bd 100644 --- a/_problems/medium/SEAPAIR.md +++ b/_problems/medium/SEAPAIR.md @@ -94,9 +94,9 @@ First line of each test case contains integers **N** and **K**. Each of the next For each test case, output a single line containing the answer - number of possible numbers **A** modulo **(109+7)**. ### Constraints - **1** ≤ **T** ≤ **5** -- ≤ **K** ≤ **N** ≤ **105** +- 0 ≤ **K** ≤ **N** ≤ **105** - **1** ≤ **X\[i\]** ≤ **109** -- ≤ **D\[i\]** ≤ **109** +- 0 ≤ **D\[i\]** ≤ **109** ### Example @@ -114,5 +114,4 @@ For each test case, output a single line containing the answer - number of possi Output: 20 30 - \ No newline at end of file diff --git a/_problems/medium/SEAPERM2.md b/_problems/medium/SEAPERM2.md index 3649a28a..b2177a9d 100644 --- a/_problems/medium/SEAPERM2.md +++ b/_problems/medium/SEAPERM2.md @@ -104,5 +104,4 @@ For each test output permutation **p**. If there is more than one solution - out Output: 1 2 3 - \ No newline at end of file diff --git a/_problems/medium/SEAPROAR.md b/_problems/medium/SEAPROAR.md index 59b240f6..3be18e93 100644 --- a/_problems/medium/SEAPROAR.md +++ b/_problems/medium/SEAPROAR.md @@ -100,8 +100,8 @@ void generator1(int N, unsigned S, int A[]){ } /* ------------------ end here -----------------------*/ - The 2nd generator works as follows (C++ code): +
 /* ------------------ start here ---------------------*/
 unsigned x, y, z, w; // we assume that unsigned is a 32bit integer type
@@ -127,13 +127,13 @@ void generator2(int N, unsigned S, int A[]){
 }
 /* ------------------ end here -----------------------*/
 
-
 
Note that the LCG used in the 1st generator is the same one suggested in [ISO/IEC 9899 (pp. 346--347)](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf), and Xorshift used in the 2nd generator is the same one in [the paper by Marsaglia (July 2003)](http://www.jstatsoft.org/v08/i14/paper). + ### Input The first line of input contains an integer **T**, denoting the number of test cases. Then **T** test cases follow. -Each test case has only one line. The line contains the string of length **N**, denoting the array **A\[1\], A\[2\], ..., A\[N\]**, where the string consists of only characters '' and '**1**', and the **i**th character denotes **A\[i\]**. +Each test case has only one line. The line contains the string of length **N**, denoting the array **A\[1\], A\[2\], ..., A\[N\]**, where the string consists of only characters '0' and '**1**', and the **i**th character denotes **A\[i\]**. Note that the integer **N** is not given in the input explicitly. @@ -185,8 +185,8 @@ LCG Xorshift Xorshift Xorshift - ### Explanation + **Example 1.** **generator1(67, 5, A)** generates the given sequence. **Example 2.** **generator1(51, 8, A)** generates the given sequence. @@ -208,8 +208,8 @@ For example,
     X * 1103515245 + 12345
 
-
 
means that + **(X × 1103515245 + 12345) mod 232**, @@ -217,8 +217,8 @@ and
     (X / 65536) % 32768
-
 
means that + **(floor(X / 65536) mod 32768) mod 232**, @@ -230,8 +230,8 @@ For example,
     X << 15
-
 
means that + **(X × 215) mod 232**, @@ -239,8 +239,8 @@ and
     X >> 13
-
 
means that + **floor(X / 213)**. diff --git a/_problems/medium/SEASTONE.md b/_problems/medium/SEASTONE.md index 27e9c3ec..70341499 100644 --- a/_problems/medium/SEASTONE.md +++ b/_problems/medium/SEASTONE.md @@ -108,8 +108,8 @@ For each test case output a single integer corresponding to the answer of the pr Output: 0 21 - ### Explanation + **In test case 1**, there are 2 boxes and 4 stones. The energy of two empty boxes are 7 and 8 respectively. You can put 2 stones into each of the box. Contribution of both the boxes into the energy of the system will be zero. So, the answer will be zero. **In test case 2**, there are 4 boxes and 6 stones. You can distribute the stones into boxes as follows, \[0, 2, 2, 2\]. Contribution of the first box into total energy will be equal to 7 \* 3 and that of rest of the boxes will be zero. So, overall energy will be 21. You can enumerate all possible distributions of the stones into boxes and see that you can't obtain a system with less energy than this. diff --git a/_problems/medium/SEATR.md b/_problems/medium/SEATR.md index b20a4b31..28d5bc90 100644 --- a/_problems/medium/SEATR.md +++ b/_problems/medium/SEATR.md @@ -92,7 +92,7 @@ The first line of input contains the integer **N**. Next line contains **N** int Output answer in single line. ### Constraints - **1** ≤ **N** ≤ **80** -- ≤ **C\[i\]** ≤ **80** +- 0 ≤ **C\[i\]** ≤ **80** ### Example @@ -116,5 +116,4 @@ Output answer in single line. ### Constraints Output: 0 - \ No newline at end of file diff --git a/_problems/medium/SEATR2.md b/_problems/medium/SEATR2.md index db516bca..9cc91e8d 100644 --- a/_problems/medium/SEATR2.md +++ b/_problems/medium/SEATR2.md @@ -104,6 +104,6 @@ For each test case, output a single integer corresponding to the answer in separ Output: 5 100 - ### Explanation + In first test case there are five possible assigns of numbers: \[1, 1, 1\], \[1, 1, 2\], \[1, 2, 1\], \[1, 2, 2\], \[2, 2, 2\]. In second test case there are hundred possible assigns: \[1\], \[2\], \[3\], ..., \[100\]. diff --git a/_problems/medium/SEATSR.md b/_problems/medium/SEATSR.md index 07aaca01..6d09290d 100644 --- a/_problems/medium/SEATSR.md +++ b/_problems/medium/SEATSR.md @@ -92,7 +92,7 @@ For each test case on different lines print the answer to the problem - minimum - **1** ≤ **T** ≤ **10** - **1** ≤ **|s|, |w|** ≤ **100000** -- ≤ **a, b, k** ≤ **100** +- 0 ≤ **a, b, k** ≤ **100** ### Example @@ -117,5 +117,4 @@ bbbbbb 2 -1 - \ No newline at end of file diff --git a/_problems/medium/SEAVOTE.md b/_problems/medium/SEAVOTE.md index b139cb1b..03745379 100644 --- a/_problems/medium/SEAVOTE.md +++ b/_problems/medium/SEAVOTE.md @@ -93,7 +93,7 @@ For each test case, output **YES** or **NO** denoting the answer of the problem, - **1** ≤ **T** ≤ **50** - **1** ≤ **N** ≤ **10000** -- ≤ **Bi** ≤ **1000** +- 0 ≤ **Bi** ≤ **1000** ### Sub tasks @@ -114,8 +114,8 @@ For each test case, output **YES** or **NO** denoting the answer of the problem, NO YES YES - ### Explanation + - In test case 1, There can not be any **A** which could be rounded up to get **B**. Hence answer is NO. - In test case 2, In this case **A** = {25, 25, 25, 25}. After rounding we get {25, 25, 25, 25} which is equal to **B**. Hence answer is YES. - In test case 3, **A** = {49.5, 50.5}. After rounding up we get {50, 51} which is equal to **B**. Hence answer is YES. diff --git a/_problems/medium/SEEDLING.md b/_problems/medium/SEEDLING.md index d83697df..90f2bd4e 100644 --- a/_problems/medium/SEEDLING.md +++ b/_problems/medium/SEEDLING.md @@ -115,8 +115,8 @@ For each test case, output a single line containing the number of ways to buy se Output: 3 - ### Explanation + **Example case 1.** There are three possible options: - Buy one seedling of the first kind. diff --git a/_problems/medium/SEEDS.md b/_problems/medium/SEEDS.md index e3a1cbc8..4167851d 100644 --- a/_problems/medium/SEEDS.md +++ b/_problems/medium/SEEDS.md @@ -51,5 +51,4 @@ Finally, if there is only one way to assign values to the missing xi values, the multiple solutions no solution - \ No newline at end of file diff --git a/_problems/medium/SEGPROD.md b/_problems/medium/SEGPROD.md index 456ebf02..5b5b001f 100644 --- a/_problems/medium/SEGPROD.md +++ b/_problems/medium/SEGPROD.md @@ -96,8 +96,8 @@ After each test-case you have to print one number - the value of x after the the - **1** ≤ **N** ≤ **106** - **1** ≤ **Q** ≤ **2 \* 107** - **2** ≤ **P** ≤ **109** -- ≤ **A i** ≤ **109** -- ≤ **B i** ≤ **n - 1** +- 0 ≤ **A i** ≤ **109** +- 0 ≤ **B i** ≤ **n - 1** - The sum of **N** over all testcases does not exceed 106 and sum of **Q** over all testcases does not exceed 2 \* 107 ### Subtasks @@ -121,5 +121,4 @@ After each test-case you have to print one number - the value of x after the the Output: 8 21 - \ No newline at end of file diff --git a/_problems/medium/SEGTREE2.md b/_problems/medium/SEGTREE2.md index 29d37015..3e0e499e 100644 --- a/_problems/medium/SEGTREE2.md +++ b/_problems/medium/SEGTREE2.md @@ -81,12 +81,12 @@ A segment tree is usually created with the following routine. currentNode->rightSon = createTree(middle + 1, right) return currentNode - The routine is called as: + ``` root = init(1, N) -
Consider the following segment tree operations:
+
 
changeSegtree(currentNode, left, right): currentNode->tag = 1 @@ -102,8 +102,8 @@ A segment tree is usually created with the following routine. change(left, right): changeSegtree(root, left, right) -
Finally, an in-order traversal of the tree can be done with the following routine:
+
 
traverse(currentNode): if (currentNode->leftSon != NULL) traverse(currentNode->leftSon) @@ -113,8 +113,8 @@ change(left, right): traverse(root) -
You are given the value of **N**, denoting the length of the array on which the segment tree is built on (i.e. the second parameter to the init routine). You are also given **M** integers **T1**, **T2**, ..., **TM**. Here, **M** is the number of nodes in the segment tree and you'll have calculate it by yourself.
+
 Your task is to find the minimum number of **non-overlapping** segments, so that after calling the **change** routine for each of these segments successively, on a newly created segment tree, the **traverse** routine will output **T1**, **T2**, ..., **TM**, or state that such a set of segments doesn't exist.
 
 Two segments **(l1,r1)** and **(l2,r2)** are considered **overlapping** if there is some **i** such that **l1 ≤ i ≤ r1** and **l2 ≤ i ≤ r2**.
@@ -149,8 +149,8 @@ For each test case, output a single line containing the minimum number of segmen
 Output:
 2
 -1
-
 
### Explanation
+
 **Example case 1.** We can call **change(1, 1)** and **change(2, 2)**.
 
 **Example case 2.** There is no set of segments that would give the tree with such configuration of tags.
diff --git a/_problems/medium/SELECT.md b/_problems/medium/SELECT.md
index 86a18a95..2f2d8073 100644
--- a/_problems/medium/SELECT.md
+++ b/_problems/medium/SELECT.md
@@ -135,30 +135,30 @@ Output **T** lines. A line can contain -1 if you are not able to find the corres
 
 Output:
 w
-
 
### Example 2
+
 
Input: 1 2 79 Output: js -
### Example 3
+
 
Input: 1 8 48768961 Output: anupklby -
### Example 4
+
 
Input: 1 7 2342822 Output: adurysk -
### Explanation
+
 **Example case 3.** One possible black money holder for this encrypted name can be "anupklby".
diff --git a/_problems/medium/SEQLCS.md b/_problems/medium/SEQLCS.md
index 143c1a3f..3ad68238 100644
--- a/_problems/medium/SEQLCS.md
+++ b/_problems/medium/SEQLCS.md
@@ -105,8 +105,8 @@ For each test case output the number of ways to construct B as described above.
 3
 11
 
-
 
### Explanation + **First Example** : There are total three possible valid sequences **B** : \[1, 1\], \[2, 2\] and \[2, 1\]. LCS of these sequences with sequence **A** is equal to 1. Note that \[1, 2\] is not a valid sequence as LCS of this and sequence **A** is equal to 2. **Second Example**: The 11 ways are: \[1, 1, 2\], \[1, 2, 1\], \[1, 2, 3\], \[1, 3, 2\], \[2, 1, 2\], \[2, 2, 1\], \[2, 2, 2\], \[2, 2, 3\], \[2, 3, 2\], \[3, 1, 2\], \[3, 2, 2\]. diff --git a/_problems/medium/SEQUAT2.md b/_problems/medium/SEQUAT2.md index a7924370..f3fea5b9 100644 --- a/_problems/medium/SEQUAT2.md +++ b/_problems/medium/SEQUAT2.md @@ -110,16 +110,16 @@ Output a **T** line containing two space separated integers **X** and **Y**. Output: 12 12 -
### Example 2
+
 
Input: 1 1 1 3 5 Output: 7 7 -
### Explanation
+
 **Example 1.**
 
 There are two solutions - (3, 9) and (9, 3). For example, (9, 3) is a solution because: 9 | 3 = 11 and 9 & 3 = 1, so 9 \* 3 = 11 \* 1 + 1 \* 9 + 1 \* 3 + 4.
diff --git a/_problems/medium/SEQUENCE.md b/_problems/medium/SEQUENCE.md
index 4fc4bbc7..928172e4 100644
--- a/_problems/medium/SEQUENCE.md
+++ b/_problems/medium/SEQUENCE.md
@@ -39,5 +39,4 @@ The output for each test case is a single line consisting of a sequence of 2n in
 0 1 3 2 6 7 5 4
 1 3 7 6 2 0 4 5
 
-
 
\ No newline at end of file diff --git a/_problems/medium/SEREJA.md b/_problems/medium/SEREJA.md index 3380e9bf..d6e3f7ee 100644 --- a/_problems/medium/SEREJA.md +++ b/_problems/medium/SEREJA.md @@ -105,8 +105,8 @@ All test cases, except Example, are created by the method described in Test Case Output 2: 0 -
### Explanation + In **Input 1**, we should consider 3 segments **\[i, j\]** = **\[1, 2\]**, **\[2, 3\]**, **\[1, 3\]**. The range of segment **\[1, 2\]** is max(1,2) - min(1,2) = 1. The range of segment **\[2, 3\]** is max(2,4) - min(2,4) = 2. diff --git a/_problems/medium/SHAIKHGN.md b/_problems/medium/SHAIKHGN.md index 04421140..f3c23e10 100644 --- a/_problems/medium/SHAIKHGN.md +++ b/_problems/medium/SHAIKHGN.md @@ -98,22 +98,22 @@ In the second line, print these ids (numbering) of these gnomes in increasing or - **1** ≤ **N** ≤ **500** - **1** ≤ **M** ≤ **500** -- ≤ **k** ≤ **109** +- 0 ≤ **k** ≤ **109** - **1** ≤ **x** ≤ **N** -- ≤ **g\[i\]\[j\]** ≤ **1** +- 0 ≤ **g\[i\]\[j\]** ≤ **1** ### Subtasks **Subtask #1 : (10 points)** - **1** ≤ **N** ≤ **50** - **1** ≤ **M** ≤ **50** -- ≤ **k** ≤ **50** +- 0 ≤ **k** ≤ **50** **Subtask #2 : (15 points)** - Original constraints - Every gnome has exactly one friend (for every i there is exactly one j such that g\[i\]\[j\] = 1. Note that j can be equal to i) **Subtask #3 : (30 points)** - **1** ≤ **N** ≤ **75** - **1** ≤ **M** ≤ **75** -- ≤ **k** ≤ **109** +- 0 ≤ **k** ≤ **109** **Subtask #4 : (45 points)** - Original constraints @@ -141,5 +141,4 @@ In the second line, print these ids (numbering) of these gnomes in increasing or 5 0 -1 -
\ No newline at end of file diff --git a/_problems/medium/SHDWCMP.md b/_problems/medium/SHDWCMP.md index de27b3c9..162f134c 100644 --- a/_problems/medium/SHDWCMP.md +++ b/_problems/medium/SHDWCMP.md @@ -74,7 +74,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [mandarin chinese](http://www.codechef.com/download/translated/LTIME49/mandarin/SHDWCMP.pdf), [russian](http://www.codechef.com/download/translated/LTIME49/russian/SHDWCMP.pdf) and [vietnamese](http://www.codechef.com/download/translated/LTIME49/vietnamese/SHDWCMP.pdf) as well. -You are working in a company with **N** employees numbered from to **N - 1**, and employee is the director. Each employee, except the director, has a supervisor. The director doesn't have a supervisor. Let's call employee **v**, an ancestor of employee **u** if and only if **v** is the supervisor of **u** or **v** is an ancestor of the supervisor of **u**. +You are working in a company with **N** employees numbered from 0 to **N - 1**, and employee 0 is the director. Each employee, except the director, has a supervisor. The director doesn't have a supervisor. Let's call employee **v**, an ancestor of employee **u** if and only if **v** is the supervisor of **u** or **v** is an ancestor of the supervisor of **u**. Also, each employee belongs to exactly one club at any moment. Employee **i** belongs to club number **Ci** initially. The company has assemblies for which all the employees of the company gather. During an assembly, the employees introduce each other, in a particular fashion. Employee **v** introduces employee **a** to employee **b** if **a, b, v** are from the same club, **a** is ancestor of **v** and **v** is ancestor of **b**. @@ -97,9 +97,9 @@ You have to output **Q + 1** lines. Line number **i + 1** should contain the ans - **1** ≤ **N** ≤ **500000** - **1** ≤ **Q** ≤ **500000** -- ≤ **Pi** i -- ≤ **Ci** N -- ≤ **Xi** N +- 0 ≤ **Pi** i +- 0 ≤ **Ci** N +- 0 ≤ **Xi** N ### Subtasks @@ -121,8 +121,8 @@ You have to output **Q + 1** lines. Line number **i + 1** should contain the ans 6 3 2 - ### Explanation + We represent employee **v** introducing employee **a** to employee **b**, by the triplet (**a, v, b**). Initially, before any change, there are a total of 6 introduces. They are: diff --git a/_problems/medium/SHGAME.md b/_problems/medium/SHGAME.md index 7ac8dc24..18600c53 100644 --- a/_problems/medium/SHGAME.md +++ b/_problems/medium/SHGAME.md @@ -94,8 +94,8 @@ For each test case, output a single line containing the number of ways to choose Output: 40 42 - ### Scoring + **T** = 100, 1 <= **N**, **M** <= 10 : 25 points. **T** = 100, 1 <= **N**, **M** <= 1000 : 36 points. diff --git a/_problems/medium/SHOOTING.md b/_problems/medium/SHOOTING.md index b1e37afc..2648bae6 100644 --- a/_problems/medium/SHOOTING.md +++ b/_problems/medium/SHOOTING.md @@ -118,5 +118,4 @@ L.. Possible Possible Impossible - \ No newline at end of file diff --git a/_problems/medium/SHTARR.md b/_problems/medium/SHTARR.md index a5fd9cce..ca99bba1 100644 --- a/_problems/medium/SHTARR.md +++ b/_problems/medium/SHTARR.md @@ -101,7 +101,7 @@ After each query of the second type, output in a single line the number of segme - **1** ≤ **T** ≤ **100** - **1** ≤ **N** ≤ **106** - **1** ≤ **Q** ≤ **105** -- +- 0 - **1** ≤ **i** ≤ **N** - **1** ≤ **Ai** ≤ **109** - **1** ≤ **L ≤ R** ≤ **109** @@ -131,5 +131,4 @@ After each query of the second type, output in a single line the number of segme 3 3 - \ No newline at end of file diff --git a/_problems/medium/SHUFFL.md b/_problems/medium/SHUFFL.md index 73d0d879..2a6debcb 100644 --- a/_problems/medium/SHUFFL.md +++ b/_problems/medium/SHUFFL.md @@ -87,13 +87,13 @@ Output in a single line the value of bitwise XOR of two elements that remain in - **1** ≤ **T** ≤ **1000** - **1** ≤ **M** ≤ **106** - **M** is even -- ≤ **X** Y ≤ **106** +- 0 ≤ **X** Y ≤ **106** - Sum of **M** over all test cases ≤ **5\*106** ### Subtasks - **Subtask #1: (30 points)** Sum of **M** over all test cases ≤ **104** -- **Subtask #2: (10 points)** **X** = +- **Subtask #2: (10 points)** **X** = 0 - **Subtask #3: (60 points)** Original constraints ### Example @@ -104,6 +104,6 @@ Output in a single line the value of bitwise XOR of two elements that remain in Output: 4 - ### Explanation + **Example case 1.** Initially we have A = {1, 2, 3, 4, 5, 6}. After splitting in two arrays we will have A' = {1, 3, 5} and B' = {2, 4, 6}. Let's erase from 0-indexed A' and B' elements with index = \[3\*1/2\]=1(3 and 4 respectively). After that merge A' and B' -> A = {1, 5, 2, 6}, split A once again in A' = {1, 2} and B' = {5, 6} and erase elements with index = \[2\*1/2\]=1(2 and 6 respectively), merge arrays A' and B' -> A = {1, 5}. Answer is bitwise XOR of 1 and 5 = 4. diff --git a/_problems/medium/SKIING.md b/_problems/medium/SKIING.md index b1d5dde9..57df62cd 100644 --- a/_problems/medium/SKIING.md +++ b/_problems/medium/SKIING.md @@ -129,8 +129,8 @@ Should contain all the constraints on the input data that you may have. Format i Output: 2 1 - ### Explanation + **Example case 1.** Hasan has to select at least two cells to be in **S** so that he guarantee he can reach all other cells starting from anyone of them, example of cells to choose (2,1) and (1,2) **Example case 2.** if Hasan chose cell (1,1) to be in **S** then he can reach any cell starting from it and thus guarantee winning diff --git a/_problems/medium/SMARKET.md b/_problems/medium/SMARKET.md index 0d8518e5..904af87f 100644 --- a/_problems/medium/SMARKET.md +++ b/_problems/medium/SMARKET.md @@ -139,8 +139,8 @@ For each test case, print answers to all queries in the test case, one per line. 3 1 1 - ### Explanation + There are two test cases to handle **Test case #1:** @@ -151,7 +151,7 @@ The first query asks for the number of stable blocks of order **2** in range **\ The second query asks for the number of stable blocks of order **2** in range **\[3, 6\]**, which corresponds to prices **10 10 7 7**. The answer is **2** because there are two such blocks: **10 10** and **7 7**. -The third query asks for the number of stable blocks of order **3** in range **\[3, 6\]**, which corresponds to prices **10 10 7 7**. The answer is because there is no stable block of order **3** there (maximum order of a stable block is **2**). +The third query asks for the number of stable blocks of order **3** in range **\[3, 6\]**, which corresponds to prices **10 10 7 7**. The answer is 0 because there is no stable block of order **3** there (maximum order of a stable block is **2**). The fourth query asks for the number of stable blocks of order **3** in range **\[3, 8\]**, which corresponds to prices **10 10 7 7 7 10**. The answer is **1** because the only stable block of order **3** here is **7 7 7**. diff --git a/_problems/medium/SNCK01.md b/_problems/medium/SNCK01.md index 96c073c1..8878be11 100644 --- a/_problems/medium/SNCK01.md +++ b/_problems/medium/SNCK01.md @@ -63,8 +63,8 @@ Time limit : 2 seconds. 3 2 3 2 - ### Sample Output: +
SECOND
 FIRST
 SECOND
diff --git a/_problems/medium/SNCK05.md b/_problems/medium/SNCK05.md
index 2f8da32b..fe7ad2e5 100644
--- a/_problems/medium/SNCK05.md
+++ b/_problems/medium/SNCK05.md
@@ -94,5 +94,4 @@ For test case print the solution mod 1000000007 on a new line.
 1
 3
 8
-
 
\ No newline at end of file diff --git a/_problems/medium/SNDISCUS.md b/_problems/medium/SNDISCUS.md index e8db589d..8fe9bf78 100644 --- a/_problems/medium/SNDISCUS.md +++ b/_problems/medium/SNDISCUS.md @@ -115,8 +115,8 @@ For each test case output a single integer corresponding to the answer of the pr 0 1 1 - ### Explanation + **Example 1**. The snakes have a common cell at coordinates (1, 1). So, they will be able to talk to each other. There is no need to move them. **Example 2**. Move the horizontal snake (i.e. 2, 1, 3, 1) to the left by 1 unit. It will now be (1, 1, 2, 1). Now, the first and second snakes will have at least one common cell and will be able to talk to each other. Hence, because you spent one second, the answer is 1. diff --git a/_problems/medium/SNGRAPH.md b/_problems/medium/SNGRAPH.md index 4b53bf1b..ada8f17c 100644 --- a/_problems/medium/SNGRAPH.md +++ b/_problems/medium/SNGRAPH.md @@ -109,8 +109,8 @@ For each test case, output **n** space separated integers corresponding to answe Output 0 3 4 4 4 - ### Explanation + **Example 1**. The degree of the nodes are \[1, 3, 1, 2, 1\]. For d = 0, all the vertices and edges are the present in the graph. The snakes can talk to each other already, and there is no need to add more edges. So, the answer is zero for d = 0. diff --git a/_problems/medium/SOCIAL.md b/_problems/medium/SOCIAL.md index ecf7c60b..43ebb693 100644 --- a/_problems/medium/SOCIAL.md +++ b/_problems/medium/SOCIAL.md @@ -30,14 +30,14 @@ For each test case, output on a single line the expected number of guests who wi 2 2 4 2 5 3 - ### Sample Output +
0.00000
 2.00000
 1.33333
 1.36364
-
 
### Constraints + T≤300 2≤N≤50 1≤R≤1000000 diff --git a/_problems/medium/SOLDIER.md b/_problems/medium/SOLDIER.md index 592882b8..af8f922b 100644 --- a/_problems/medium/SOLDIER.md +++ b/_problems/medium/SOLDIER.md @@ -42,5 +42,4 @@ Output the total quality. Note: If there is no answer, output 0. There can be less than 6 items. - \ No newline at end of file diff --git a/_problems/medium/SORTING.md b/_problems/medium/SORTING.md index 24c35c15..2275ef82 100644 --- a/_problems/medium/SORTING.md +++ b/_problems/medium/SORTING.md @@ -100,7 +100,7 @@ Output the number of comparisons on the first and only line of the output. Output: 11 - ### Scoring + Subtask 1 (32 points): 1 N Subtask 2 (9 points): 1 N 5, the permutation is generated randomly. Subtask 3 (45 points): 1 N Subtask 4 (14 points): 1 N 5. diff --git a/_problems/medium/SPCLN.md b/_problems/medium/SPCLN.md index eb2c140c..a530ad18 100644 --- a/_problems/medium/SPCLN.md +++ b/_problems/medium/SPCLN.md @@ -108,8 +108,8 @@ print a single real number which is the maximum average energy, rounded to two d Output: 50.00 - ### Explanation + One way the spacecraft can destroy the space debris is : Destroy the first space debris by pressing the second button. diff --git a/_problems/medium/SPOONS.md b/_problems/medium/SPOONS.md index c3036df0..999e2d29 100644 --- a/_problems/medium/SPOONS.md +++ b/_problems/medium/SPOONS.md @@ -100,8 +100,8 @@ All submissions for this problem are available. Lo and Behold! For you may be su Output: 2 3 - ### Explanation + **Example case 1.** Each spoon caters to a different city. Since there are two spoons, two cities are sufficient. /> diff --git a/_problems/medium/SQNUMBF.md b/_problems/medium/SQNUMBF.md index 11481c0f..260b9fc0 100644 --- a/_problems/medium/SQNUMBF.md +++ b/_problems/medium/SQNUMBF.md @@ -110,6 +110,6 @@ For each test case, output a single integer **P** deoting the answer for this te Output: 3 - ### Explanation + **Example case 1.** **X = 21 \* 11 \* 6 = 1386**. It's divisible by 9 which is a square number, as **9 = 32**. So **P = 3**. diff --git a/_problems/medium/SQUAGAME.md b/_problems/medium/SQUAGAME.md index d394739b..97aacd86 100644 --- a/_problems/medium/SQUAGAME.md +++ b/_problems/medium/SQUAGAME.md @@ -47,5 +47,4 @@ For each test case print "Fat x", where x - is the number of square which needs Fat 2 Fit - \ No newline at end of file diff --git a/_problems/medium/SQUIRREL.md b/_problems/medium/SQUIRREL.md index 2a9b390e..1ea053ed 100644 --- a/_problems/medium/SQUIRREL.md +++ b/_problems/medium/SQUIRREL.md @@ -39,12 +39,12 @@ For each test cases, output in a single line an integer which is the shortest ti 3 2 5 5 1 2 1 1 1 - **Output:** +
4
 3
-
 
_\* Explain (case #1): 2 squirrels waiting below the trees 2 and 3._ + ### Limitations - 0Output 1: fd 2 -
Input 2:
 adsyufsfdsfdsf
 bbbbbbbbb
 
 Output 2:
 0
-
 
Input 3:
 abcdef
 defabc
@@ -138,8 +136,8 @@ defabc
 Output 3:
 def
 3
-
 
### Explanation + **Example case 1.**The longest life event is **"fd"** whose length is 2. **Example case 2.**The girls will follow separate lives. diff --git a/_problems/medium/STABLEMP.md b/_problems/medium/STABLEMP.md index e6247c67..a7dfb664 100644 --- a/_problems/medium/STABLEMP.md +++ b/_problems/medium/STABLEMP.md @@ -65,5 +65,4 @@ For each test case print _n_ lines, where each line contains two numbers _m_ and 6 6 7 2 - -**Warning: large Input/Output data, be careful with certain languages** \ No newline at end of file +**Warning: large Input/Output data, be careful with certain languages** diff --git a/_problems/medium/STADIUM.md b/_problems/medium/STADIUM.md index 012929af..eb337849 100644 --- a/_problems/medium/STADIUM.md +++ b/_problems/medium/STADIUM.md @@ -41,10 +41,9 @@ Sample input: 9 7 15 6 9 3 - Sample output: +
 3
 
-
 
\ No newline at end of file diff --git a/_problems/medium/STDPRGS.md b/_problems/medium/STDPRGS.md index d5a4e799..081a40b7 100644 --- a/_problems/medium/STDPRGS.md +++ b/_problems/medium/STDPRGS.md @@ -95,13 +95,13 @@ For each query, output one integer — the result of the progress analysis for t ### Constraints - **1** ≤ **N, M** ≤ **5\*104** -- ≤ **A\[i\]** ≤ **106** +- 0 ≤ **A\[i\]** ≤ **106** ### Subtasks - Subtask 1 (19 points) **1** ≤ **N, M** ≤ **200**, **time limit = 2 sec** - Subtask 2 (31 points) **1** ≤ **N, M** ≤ **10 000**, **time limit = 2 sec** -- Subtask 3 (26 points) ≤ **A\[i\]** ≤ **100**, **time limit = 5 sec** +- Subtask 3 (26 points) 0 ≤ **A\[i\]** ≤ **100**, **time limit = 5 sec** - Subtask 4 (24 points) no additional constraints, , **time limit = 5 sec** ### Example @@ -123,7 +123,7 @@ For each query, output one integer — the result of the progress analysis for t 0 5 - -**Explanation**The first query: sorted array looks like **(1, 2, 3, 4, 5)** and the answer is calculated as **(2-1)2 + (3-2)2 + (4-3)2 + (5-4)2 = 4** +**Explanation** +The first query: sorted array looks like **(1, 2, 3, 4, 5)** and the answer is calculated as **(2-1)2 + (3-2)2 + (4-3)2 + (5-4)2 = 4** The second query: sorted array looks like **(1, 2, 3, 4)** and the answer is calculated as **(2-1)2 + (3-2)2 + (4-3)2 = 3** The last query: sorted array looks like **(2, 4, 5)** and the answer is calculated as **(4-2)2 + (5-4)2 = 5** diff --git a/_problems/medium/STETSKLX.md b/_problems/medium/STETSKLX.md index 5c85d118..3be8d33b 100644 --- a/_problems/medium/STETSKLX.md +++ b/_problems/medium/STETSKLX.md @@ -133,8 +133,8 @@ For each test case, output a single line containing the shortest Chef length amo Output: 1 2 - ### Explanation + **Test #1** Let's look at all correct simple paths: diff --git a/_problems/medium/STRAB.md b/_problems/medium/STRAB.md index 594d5e6a..decde54a 100644 --- a/_problems/medium/STRAB.md +++ b/_problems/medium/STRAB.md @@ -112,6 +112,6 @@ B Output: 24 - ### Explanation + **Example case 1.** Out of all **26** possible messages in this case only two are invalid (i.e. "A" and "B"). Thus, the answer is **26 - 2 = 24**. diff --git a/_problems/medium/STREGGS.md b/_problems/medium/STREGGS.md index 3209b658..88edd010 100644 --- a/_problems/medium/STREGGS.md +++ b/_problems/medium/STREGGS.md @@ -37,10 +37,12 @@ For each test case, print the minimal number of taps for the worst-case. 3 2 1 2 3 ### Sample Output +
8
 10
 5
 
### Output details + In the first case, if a egg isn't broken after 5 taps, she should continue to tap the same egg. In the second case, if a egg isn't broken after 5 taps, she should tap another egg 5 times. diff --git a/_problems/medium/STRINGRA.md b/_problems/medium/STRINGRA.md index 708cb70b..f88aeba1 100644 --- a/_problems/medium/STRINGRA.md +++ b/_problems/medium/STRINGRA.md @@ -129,8 +129,8 @@ For each testcase, output a single line which contains **N** positive integers w Output: 1 2 1 1 3 -1 - ### Explanation + **Testcase 1**: Let us consider the sequence A = (1, 2, 1, 1, 3). diff --git a/_problems/medium/SUBARR.md b/_problems/medium/SUBARR.md index 00de4efe..1bafe6bb 100644 --- a/_problems/medium/SUBARR.md +++ b/_problems/medium/SUBARR.md @@ -98,8 +98,8 @@ The first line should contain an integer, denoting the number of perfect subarra 1 2 3 -1 Output: 4 - ### Explanation + In the test case **N** equals to 4, **K** equals to 2, **A** equals to {1, 2, 3, -1}. The following subarrays are perfect: \[2..2\], \[3..3\], \[2..3\], \[1..3\]. ### Scoring diff --git a/_problems/medium/SUBARRAY.md b/_problems/medium/SUBARRAY.md index 17454d44..145da22d 100644 --- a/_problems/medium/SUBARRAY.md +++ b/_problems/medium/SUBARRAY.md @@ -116,8 +116,8 @@ For each test case, output the maximum sum obtained using the constraints above. 7 1 0 - ### Explanation + For first test case take last 2 elements: 3 + 4 = 7. For second test case take the middle 2 elements: -2 + 3 = 1 diff --git a/_problems/medium/SUBINVER.md b/_problems/medium/SUBINVER.md index 2f9d6560..a1ae2ef6 100644 --- a/_problems/medium/SUBINVER.md +++ b/_problems/medium/SUBINVER.md @@ -116,13 +116,13 @@ Output a single line containing one binary string - the lexicographically larges Output: 1111100011 - ### Explanation + Let us see what happens in each operation:
-
-
12. S0 = 000000000013. After the update, \[9, 10\], it becomes S1 = 0000000011 +12. S0 = 0000000000 +13. After the update, \[9, 10\], it becomes S1 = 0000000011 14. After the update, \[6, 10\], it becomes S2 = 0000011100 15. After the update, \[9, 10\], it becomes S3 = 0000011111 16. After the update, \[1, 8\], it becomes S4 = 1111100011 diff --git a/_problems/medium/SUBLCM.md b/_problems/medium/SUBLCM.md index 9c266e37..3d208bc8 100644 --- a/_problems/medium/SUBLCM.md +++ b/_problems/medium/SUBLCM.md @@ -111,8 +111,8 @@ For each testcase, print the required answer in one line. 2 2 -1 - ### Explanation + **Example case 1.**LCM(2,7)=2\*7. Therefore, subarray A1 to A2 satisfies. **Example case 2.**The subarrays A2 to A3 and A3 to A4 are the maximum size possible. diff --git a/_problems/medium/SUBSEG2.md b/_problems/medium/SUBSEG2.md index cb4658cc..bc31cefe 100644 --- a/_problems/medium/SUBSEG2.md +++ b/_problems/medium/SUBSEG2.md @@ -119,6 +119,7 @@ Output **Q** lines - each containing an integer corresponding to the maximum num 0
### Explanation
+
 **Plan #1.** Chef stays on the campus from the first day till the sixth day. During this time, he can complete maximum two courses. He can complete either the **1**st and the **2**nd or the **2**nd and the **3**rd courses..
 
 **Plan #2.** Chef can complete no more than one course and this course can be only the first one.
diff --git a/_problems/medium/SUBSGM.md b/_problems/medium/SUBSGM.md
index c0b93b37..832ad9c9 100644
--- a/_problems/medium/SUBSGM.md
+++ b/_problems/medium/SUBSGM.md
@@ -107,8 +107,8 @@ Anytime **ai** <= 2 \* **N** holds.
 5
 2
 2
-
 
### Scoring + 1 <= **N** <= 100, 1 <= **M** <= 1000 : 20 points. 1 <= **N**, **M** <= 5000 : 26 points. diff --git a/_problems/medium/SUBTREE.md b/_problems/medium/SUBTREE.md index 1919aad8..cf73efd8 100644 --- a/_problems/medium/SUBTREE.md +++ b/_problems/medium/SUBTREE.md @@ -120,8 +120,8 @@ For each question, output on a separate line two space-separated integers **A** Output: 5 2 8 3 - ### Explanation + **Example question 1.** The only ideal path is between 2 and 5. This path contains two roads: (5, 1) and (1, 2); and (5, 1) is the shortest road among them. **Example question 2.** The ideal paths are between the following pairs: (3 and 4), (4 and 6), (5 and 3), and (5 and 6). Only road (1, 2) belongs to each ideal path. diff --git a/_problems/medium/SUMCUBE.md b/_problems/medium/SUMCUBE.md index 2d6a0641..ba02a766 100644 --- a/_problems/medium/SUMCUBE.md +++ b/_problems/medium/SUMCUBE.md @@ -98,7 +98,7 @@ For each test case, output one line containing one integer, the answer modulo (* - **1** ≤ **T** ≤ **100** - **2** ≤ **n** ≤ **105** -- ≤ **m** ≤ **105** +- 0 ≤ **m** ≤ **105** - Sum of each of **n, m** over all test cases ≤ **3 \* 105** - **1** ≤ **u, v** ≤ **n**. - **1** ≤ **k** ≤ **3**. @@ -145,8 +145,8 @@ For each test case, output one line containing one integer, the answer modulo (* 56 194 - ### Explanation + **Example case 1.** **f**(emptyset) = **f**({1}) = **f**({2}) = **f**({3}) = 0; diff --git a/_problems/medium/SUMPP.md b/_problems/medium/SUMPP.md index d7968aaa..ba1b98a0 100644 --- a/_problems/medium/SUMPP.md +++ b/_problems/medium/SUMPP.md @@ -104,8 +104,8 @@ Output a single line containing the productivity value of the kingdom. Output: 504 - ### Explanation + Here are all the provinces: Province **1**, population **4**: @@ -113,12 +113,15 @@ Province **1**, population **4**:
1 2
 3 4
 
Province **2**, population **3**: +
1 2
 3 4
 
Province **3**, population **6**: +
1 2
 3 4
 
Province **4**, population **7**: +
1 2
 3 4
-
Since the productivity number is a product of all the populations, we get **4 × 3 × 6 × 7 = 504**. \ No newline at end of file +Since the productivity number is a product of all the populations, we get **4 × 3 × 6 × 7 = 504**. diff --git a/_problems/medium/SUMSLOPE.md b/_problems/medium/SUMSLOPE.md index 3a8eb676..e58c84c6 100644 --- a/_problems/medium/SUMSLOPE.md +++ b/_problems/medium/SUMSLOPE.md @@ -28,17 +28,14 @@ Sample Input : 1 100 100 150 -
 Sample Output :
 1
 0
 19
 
-
 
 Constraints :
 1 <= T <= 50000
 1 <= A <= B <= 1000000000000000 (10^15)
-
 
\ No newline at end of file diff --git a/_problems/medium/SVNTR.md b/_problems/medium/SVNTR.md index 4abaade3..09172bd4 100644 --- a/_problems/medium/SVNTR.md +++ b/_problems/medium/SVNTR.md @@ -119,8 +119,8 @@ For each testcase, output a single line containing one integer - the number of r Output: 11 27 - ### Explanation + **Test case 1**: we have the following matrix **A**: 1 2 3 4 5 6 diff --git a/_problems/medium/SWARM.md b/_problems/medium/SWARM.md index fc2c8118..01f354a1 100644 --- a/_problems/medium/SWARM.md +++ b/_problems/medium/SWARM.md @@ -42,5 +42,4 @@ For each test case output the number of k-gons that can be formed modulo 1000000 328836201 - \ No newline at end of file diff --git a/_problems/medium/SWINDOW.md b/_problems/medium/SWINDOW.md index 5c543678..cff14456 100644 --- a/_problems/medium/SWINDOW.md +++ b/_problems/medium/SWINDOW.md @@ -108,8 +108,8 @@ After each update, output an integer in one line denoting the smallest contiguou 4 3 - ### Explanation + After first update, the array is **\[1, 3, 1, 1, 1\]**. No valid subarray exists at this stage. After next update, the array is **\[1, 3, 1, 1, 2\]**. Here you can observe that contiguous subarray **\[A2, A3, ..., A5\]** consists of all types of objects. After next update, the array is **\[1, 3, 2, 1, 2\]**. Now, contiguous subarray **\[A1, A2, A3\]** is the smallest valid subarray. diff --git a/_problems/medium/TAACUTE.md b/_problems/medium/TAACUTE.md index 1064dfea..3cbf97e9 100644 --- a/_problems/medium/TAACUTE.md +++ b/_problems/medium/TAACUTE.md @@ -84,7 +84,7 @@ Output a single line containing the number of acute triangles. ### Constraints - **3** ≤ **N** ≤ **2000** -- The **x**, **y** coordinate of each point satisfies ≤ **x**, **y** ≤ **10,000** +- The **x**, **y** coordinate of each point satisfies 0 ≤ **x**, **y** ≤ **10,000** - All points are distinct. ### Example @@ -114,6 +114,6 @@ Output a single line containing the number of acute triangles. 3 4 Output3: 2 - ### Explanation + **Example case 3.** Two acute triangles are {(1, 1), (3, 2), (1, 3)} and {(3, 2), (1, 3), (3, 4)} diff --git a/_problems/medium/TAAND.md b/_problems/medium/TAAND.md index 28f28ca5..b14514c1 100644 --- a/_problems/medium/TAAND.md +++ b/_problems/medium/TAAND.md @@ -87,12 +87,12 @@ Contains a single integer which is the largest value of **Au** and **Av** where 50 points: - **2** ≤ **N** ≤ **5000** -- ≤ **Ai** ≤ **109** +- 0 ≤ **Ai** ≤ **109** 50 points: - **2** ≤ **N** ≤ **3 × 105** -- ≤ **Ai** ≤ **109** +- 0 ≤ **Ai** ≤ **109** ### Example @@ -106,8 +106,8 @@ Contains a single integer which is the largest value of **Au** and **Av** where Output: 8 - ### Explanation + - 2 and 4 = 0 - 2 and 8 = 0 - 2 and 10 = 2 diff --git a/_problems/medium/TABLECOV.md b/_problems/medium/TABLECOV.md index 159446e6..42536fb4 100644 --- a/_problems/medium/TABLECOV.md +++ b/_problems/medium/TABLECOV.md @@ -137,8 +137,8 @@ Time limit for the first subtask is 2 s. Time limit for the second and the third 6 8 - ### Explanation of the example test + In the first case, the following set of valid Ghariyal-paths is one of the optimal ones: 25. (1, 1), (1, 2), (1, 3), (1, 4), (2, 4), (3, 4), (4, 4), (5, 4) diff --git a/_problems/medium/TABUS.md b/_problems/medium/TABUS.md index 35871628..a12d2df3 100644 --- a/_problems/medium/TABUS.md +++ b/_problems/medium/TABUS.md @@ -74,7 +74,7 @@ All submissions for this problem are available.According to many researches, peo Let's consider the bus system with **N** bus stations (numbered from **1** to **N**) and **M** buses (numbered from **1** to **M**). Each bus is represented by 4 integer numbers **U, V, S, E** which means it will start at the bus station **U** at the time **S** and arrive at the bus station **V** at the time **E** with no intermediate bus stations. If passenger arrives at the bus station **U** at the time **X** ≤ **S**, he has to wait for **S − X** units of time to catch this bus. Note, that if he arrives at the bus station **U** exactly at time **S** he can catch this bus with no waiting time. -The Chef starts at the time in the bus station **1**, and he wants to arrive at the bus station **N** in a way that the longest period that he spends for waiting for a bus is as small as possible. Besides, he must be at the bus station **N** before or at the time **T** for a specially important meeting. Note, that he may wait for a meeting if he arrives at the bus station **N** early but that period is not our concern here, since he doesn't wait for any bus at that time. +The Chef starts at the time 0 in the bus station **1**, and he wants to arrive at the bus station **N** in a way that the longest period that he spends for waiting for a bus is as small as possible. Besides, he must be at the bus station **N** before or at the time **T** for a specially important meeting. Note, that he may wait for a meeting if he arrives at the bus station **N** early but that period is not our concern here, since he doesn't wait for any bus at that time. ### Input @@ -92,7 +92,7 @@ If Chef cannot arrive at the bus station **N** before or at the time **T**, outp - **1** ≤ **U** ≤ **N** - **1** ≤ **V** ≤ **N** - **U** ≠ **V** -- ≤ **S** < **E** ≤ **109** +- 0 ≤ **S** < **E** ≤ **109** ### Example @@ -107,8 +107,8 @@ If Chef cannot arrive at the bus station **N** before or at the time **T**, outp Output: 2 - ### Explanation + There are three different traveling plans: - **bus 1 → bus 3 → bus 5**. His waiting time for each bus is 1, 2, 1, respectively. diff --git a/_problems/medium/TACHEMIS.md b/_problems/medium/TACHEMIS.md index 1c69a3bb..f13c0042 100644 --- a/_problems/medium/TACHEMIS.md +++ b/_problems/medium/TACHEMIS.md @@ -112,8 +112,8 @@ A 11 9 66 - ### Explanation + **Example case 1:** The original string is AABB so the sub-strings (represented by positions of the first and the last character) which are palindromes are (1, 1), (1, 2), (2, 2), (3, 3), (3, 4) and (4, 4). diff --git a/_problems/medium/TACNTSTR.md b/_problems/medium/TACNTSTR.md index 88a22a7d..f0a40ba8 100644 --- a/_problems/medium/TACNTSTR.md +++ b/_problems/medium/TACNTSTR.md @@ -105,8 +105,8 @@ XYZ Output 2: 5 - ### Explanation + **Test #1:** To make a valid string **t**, you can just replace the letter A in **S** by any other letter, e.g. by replacing 'A' by 'B', we get **t = ZBZ**. Note that ZBZ is lexicographically larger than ZAZ. Reverse of **t** (i.e. ZBZ) is also lexicographically larger than reverse of **s** (i.e. ZAZ). **Test #2:** there are 5 valid strings: YYZ, ZYZ, XZZ, YZZ, ZZZ diff --git a/_problems/medium/TADELIVE.md b/_problems/medium/TADELIVE.md index 349fe907..c90d32c9 100644 --- a/_problems/medium/TADELIVE.md +++ b/_problems/medium/TADELIVE.md @@ -112,6 +112,6 @@ Please find out the maximum possible amount of total tip money after processing Output: 21 - ### Explanation + Bob will take the first three orders (or the first two) and Andy will take the rest (of course). diff --git a/_problems/medium/TAEDITOR.md b/_problems/medium/TAEDITOR.md index 9a543a91..01769e7e 100644 --- a/_problems/medium/TAEDITOR.md +++ b/_problems/medium/TAEDITOR.md @@ -75,7 +75,7 @@ All submissions for this problem are available.### Read problems statements in In this problem you will have to implement a simple editor. The editor maintains the content of a string **S** and have two following functions: -"**+ i x**": insert a string **x** into the current string **S** after the **i**'th character of the **S** (we use 1-indexing in this problem). When **i** equals to it mean we add **x** at the beginning of **S**. +"**+ i x**": insert a string **x** into the current string **S** after the **i**'th character of the **S** (we use 1-indexing in this problem). When **i** equals to 0 it mean we add **x** at the beginning of **S**. "**? i len**": Print the sub-string of length **len** starting at position **i**'th of **S**. @@ -121,8 +121,8 @@ For each query of the second type, print out the answer sub-string in one line. Output: acb acddb - ### Explanation + - "+ 0 ab": S = "ab" - "+ 1 c": S = "acb" - "+ 2 dd": S = "acddb" diff --git a/_problems/medium/TAKEAWAY.md b/_problems/medium/TAKEAWAY.md index 5f941b06..a288d58b 100644 --- a/_problems/medium/TAKEAWAY.md +++ b/_problems/medium/TAKEAWAY.md @@ -47,8 +47,8 @@ For each test case, print the winners name "Nancy" or "Zeta" ( without quotes ). Nancy Zeta Nancy - -**Explanation:** + +**Explanation:** Case 1 : Only one pile of 3 stones and K = 1. At most 1 stone can be removed in each step ( and of course at least 1 stone must be removed, if possible). Nancy removes 1 stone, then Zeta removes 1 stone and finally Nancy removes the last stone and wins ! Case 2 : Two piles of stones with 3 stones in each and K = 2. Initial pile sizes are {3,3} and after Nancy takes either 1 or 2 stones from one of them, the piles will be one of {2,3} or {1,3}. If its {2,3}, Zeta can remove a stone from the 2nd pile to make it {2,2} and win eventually. If its {1,3}, Zeta can remove two stones from the2nd pile to make it {1,1} and win in its next turn. So, no matter what step Nancy takes in her first turn, Zeta always has a winning strategy ! diff --git a/_problems/medium/TALCA.md b/_problems/medium/TALCA.md index 2f0174f3..c5842ae7 100644 --- a/_problems/medium/TALCA.md +++ b/_problems/medium/TALCA.md @@ -114,7 +114,7 @@ For each query, write out the answer on a single line. Output: 1 2 - ### Explanation + - "1 4 2": if 1 is the root, it is parent of both 2 and 4 so LCA of 2 and 4 is 1. - "2 4 2": the root of the tree is at 2, according to the definition, LCA of any vertex with 2 is 2. diff --git a/_problems/medium/TANGDIV.md b/_problems/medium/TANGDIV.md index 6d6c159c..4f60eb4d 100644 --- a/_problems/medium/TANGDIV.md +++ b/_problems/medium/TANGDIV.md @@ -112,8 +112,8 @@ For each test case, output a single line containing either "Yes" or "No" (withou Output: Yes No - ### Explanation + **Example case 1:** To achieve his goal Chef should divide the first part (1-5) in two by separating segments 4 and 5 one from another. **Example case 2:** The boy didn't left the tangerine as it was (though you may thought that way), he separated segments 1 and 10 one from another. But segments 1 and 10 are in one part in Chef's division, so he is unable to achieve his goal. diff --git a/_problems/medium/TANGLED.md b/_problems/medium/TANGLED.md index 5cca0e91..9d338e11 100644 --- a/_problems/medium/TANGLED.md +++ b/_problems/medium/TANGLED.md @@ -138,6 +138,7 @@ xyzab 5 3 1 0

### Explanation + **Example case 2.** Common substrings of length 1 are (a,b,c,d) = (0,0,1,1), (2,2,1,1), (1,1,0,0), (1,1,2,2), (3,3,0,0), (3,3,2,2). Common substrings of length 2 are (0, 1, 1, 2), (1, 2, 0, 1), (2, 3, 1, 2). diff --git a/_problems/medium/TAPOINT.md b/_problems/medium/TAPOINT.md index a30b2261..b71a560f 100644 --- a/_problems/medium/TAPOINT.md +++ b/_problems/medium/TAPOINT.md @@ -104,6 +104,6 @@ For each test case print the answer in a separate line — two integer coordinat Output 1: 9 4 -1 - ### Explanation + **test #1:** Jem's house must be at most 16 centimeters - which is equal to 0.16 metres away from the border. The distance from the point (9, 4) to the border is: 10 - sqrt(92 + 42) ~ 0.15 diff --git a/_problems/medium/TAQTREE.md b/_problems/medium/TAQTREE.md index 55c464e5..ad6c3518 100644 --- a/_problems/medium/TAQTREE.md +++ b/_problems/medium/TAQTREE.md @@ -125,7 +125,7 @@ Your target is to handle the queries of the following two types: 8 6 - ### Explanation + The path from 5 to 3 is 5 -> 4 -> 2 -> 3. Initially this path has the length of 1 + 3 + 4 = 8. After the weight of the edge connect 4 and 2 was changed to 1, the new length of the path is 1 + 1 + 4 = 6. diff --git a/_problems/medium/TARPRACT.md b/_problems/medium/TARPRACT.md index 04355b83..054f2b39 100644 --- a/_problems/medium/TARPRACT.md +++ b/_problems/medium/TARPRACT.md @@ -30,15 +30,15 @@ For each test case, output the expected number of shots to hit all targets, roun 3 10 10 80 5 25 50 25 8 30 35 35 - ### Sample Output +
4.666667
 10.361111
 7.541667
 13.107725
 
-
 
In the first example, Chef shoots at the center target until any 2 targets have been hit, then he shoots at the remaining target. + ### Constraints - T≤30 diff --git a/_problems/medium/TASHIFT.md b/_problems/medium/TASHIFT.md index c8e075e5..6f09c109 100644 --- a/_problems/medium/TASHIFT.md +++ b/_problems/medium/TASHIFT.md @@ -105,5 +105,4 @@ bddcc Output: 3 - \ No newline at end of file diff --git a/_problems/medium/TASTR.md b/_problems/medium/TASTR.md index 2b666206..6e976e37 100644 --- a/_problems/medium/TASTR.md +++ b/_problems/medium/TASTR.md @@ -107,6 +107,6 @@ cdaa Output: 8 - ### Explanation + Example is explained in the problem statement above. diff --git a/_problems/medium/TASTRMAT.md b/_problems/medium/TASTRMAT.md index 240656dc..998ccf6b 100644 --- a/_problems/medium/TASTRMAT.md +++ b/_problems/medium/TASTRMAT.md @@ -74,7 +74,7 @@ In this problem we will have a few definitions as described below: - **Binary string**: A string containing only characters '0' and '1'. - **Hamming distance** of the two binary string of the same length is the number of the positions where the two strings have - different characters. eg. the hamming distance of "0**10**1011" and + different characters. eg. the hamming distance of "0**10**10101" and "0**01**101**1**1" is 3, the hamming distance of a binary string with itself is 0. - **Sub-string** of a string is a segment of contiguous characters of that string. @@ -132,8 +132,8 @@ So overall, your output should be **K** lines, each containing the hash value co 300003 993599731 400004 - ### Explanation: + **First test case:** **A** = "10101", **B** = "101". The Hamming distances sequence will be (0, 3, 0) and the hash value of this sequence is 300003. diff --git a/_problems/medium/TASTYD.md b/_problems/medium/TASTYD.md index e62a2252..b3ef84ee 100644 --- a/_problems/medium/TASTYD.md +++ b/_problems/medium/TASTYD.md @@ -91,21 +91,21 @@ Output should consist of a single integer - the answer for the problem. 1 ≤ K ≤ 109 1 ≤ beauty value ≤ 109 - ### Example: + **Input:**
 4 2
 1 2 3 4
 
-
 
**Output:** +
 2
 
-
 
### Scoring: + 1 ≤ **N** ≤ 1000, this subtask is worth **21** point. 1 ≤ **K** ≤ 100, this subtask is worth **39** points. diff --git a/_problems/medium/TASUMOBC.md b/_problems/medium/TASUMOBC.md index 99a3407a..5d58ec57 100644 --- a/_problems/medium/TASUMOBC.md +++ b/_problems/medium/TASUMOBC.md @@ -124,5 +124,4 @@ Since S(**n**) can be very large, please print it modulo **(109 + 7)**. 4 8 - \ No newline at end of file diff --git a/_problems/medium/TAUT.md b/_problems/medium/TAUT.md index 4917becf..be824e24 100644 --- a/_problems/medium/TAUT.md +++ b/_problems/medium/TAUT.md @@ -23,8 +23,8 @@ D - or I - implies E - if, and only if N - not - The variables will be lowercase letters (a-z). There will be no more than 16 different letters in the expression. The length of the expression will not exceed 111 characters. + ### Output For each expression write one word: YES if it is a tautology, NO in other case. @@ -50,5 +50,4 @@ NO YES YES YES - \ No newline at end of file diff --git a/_problems/medium/TCP.md b/_problems/medium/TCP.md index f0d00017..b3c34702 100644 --- a/_problems/medium/TCP.md +++ b/_problems/medium/TCP.md @@ -79,13 +79,13 @@ As for us, all we know is: Chef's velocity at 4 time instances. And we are inter ### Input -The first line contains an integer **N** denoting the number of test cases. The first line of each testcase contains an integer **T**, the time up to which we want to know the distance covered by Chef from time . Then **4** lines follow, each containing two integers: **ct** and **cv**. Here **ct** is the time instant and **cv** is the velocity at time **ct**. +The first line contains an integer **N** denoting the number of test cases. The first line of each testcase contains an integer **T**, the time up to which we want to know the distance covered by Chef from time 0. Then **4** lines follow, each containing two integers: **ct** and **cv**. Here **ct** is the time instant and **cv** is the velocity at time **ct**. **Please note**, that we pick **ct** in such a way that **cv** comes out to be integer. In general the velocity of Chef is real number. ### Output -For each test case output a single line containing a real number – the distance covered by the Chef in time interval to **T**. Your answer will be considered as correct if it has **relative error less than 10-10**. +For each test case output a single line containing a real number – the distance covered by the Chef in time interval 0 to **T**. Your answer will be considered as correct if it has **relative error less than 10-10**. ### Constraints @@ -113,5 +113,4 @@ For each test case output a single line containing a real number – the distanc Output: 173.750000 80.000000 - \ No newline at end of file diff --git a/_problems/medium/TEAMSIZE.md b/_problems/medium/TEAMSIZE.md index fc912083..65387312 100644 --- a/_problems/medium/TEAMSIZE.md +++ b/_problems/medium/TEAMSIZE.md @@ -92,8 +92,8 @@ For each test case, output **Q** lines containing the optimal team size for the ### Constraints -**1** ≤ **T** ≤ **5****1** ≤ **N** ≤ **500000** ≤ **C** < **230****1** ≤ **Q** ≤ **1000** - ≤ **A**, **B**, **D** < **230** ≤ **skill\[i\]** < **230** for **1** ≤ **i** ≤ **X****1** ≤ **M** ≤ **N** +**1** ≤ **T** ≤ **5****1** ≤ **N** ≤ **500000**0 ≤ **C** < **230****1** ≤ **Q** ≤ **1000** +0 ≤ **A**, **B**, **D** < **230**0 ≤ **skill\[i\]** < **230** for **1** ≤ **i** ≤ **X****1** ≤ **M** ≤ **N** ### Example @@ -112,8 +112,8 @@ For each test case, output **Q** lines containing the optimal team size for the 3 3 1 6 2 0 - ### Explanation + **Case 1.** With team size 2, we have 4 candidate teams: {2, 4}, {4, 5}, {5, 6}, and {6, 3}. Here numbers denote the cooks' skills. With any other team size, the number of candidate teams is either less than 4 or greater than 4. Similarly, with team size 3, we have 3 candidate teams, which are {2, 4, 5}, {4, 5, 6} and {5, 6, 3}. With team size 1, we have 6 candidate teams with one member in each team. diff --git a/_problems/medium/TELEPORT.md b/_problems/medium/TELEPORT.md index f82b233a..3b4cc6a9 100644 --- a/_problems/medium/TELEPORT.md +++ b/_problems/medium/TELEPORT.md @@ -116,8 +116,8 @@ For each operation, output a single line containing "DA" (without quotes) if we Output: DA NET - ### Explanation + The first two operations make us add teleports at the locations (2, 2) and (3, 3). Then, we need to find if the 2nd teleport can be reached from the 1st teleport. From teleport at (2, 2) we can reach the point (2, 3) (because |2-2|+|2-3| diff --git a/_problems/medium/TERM.md b/_problems/medium/TERM.md index 2dcaa02c..fa046a45 100644 --- a/_problems/medium/TERM.md +++ b/_problems/medium/TERM.md @@ -66,5 +66,4 @@ p prime number 8 1 - \ No newline at end of file diff --git a/_problems/medium/TETRA.md b/_problems/medium/TETRA.md index 54bfb964..f2d66066 100644 --- a/_problems/medium/TETRA.md +++ b/_problems/medium/TETRA.md @@ -31,5 +31,4 @@ t lines, each consisting of a real number given with four digits decimal precisi Output: 0.2041 1.4189 - \ No newline at end of file diff --git a/_problems/medium/TFOSS.md b/_problems/medium/TFOSS.md index ccfd8701..a28fbd43 100644 --- a/_problems/medium/TFOSS.md +++ b/_problems/medium/TFOSS.md @@ -31,10 +31,11 @@ xn xn [input for the next test cases...]

### Output +
o1 [the square of the maximal distance in the first set]
 on [output for the next test cases...]
-
 
### Example +
 Input:
 5
@@ -86,5 +87,4 @@ on [output for the next test cases...]
 101
 722
 98
-
 
\ No newline at end of file diff --git a/_problems/medium/THEGAME.md b/_problems/medium/THEGAME.md index 6985c3be..c28ef472 100644 --- a/_problems/medium/THEGAME.md +++ b/_problems/medium/THEGAME.md @@ -126,6 +126,6 @@ oo 1.166666667 1.000000000 - ### Explanation + **Example case 1.** With 5/6 chance, the first click you'll make will be on the only path from the start to the goal. With 1/6 chance, you'll click on the top right cell before that. The expected number of clicks is therefore 5/6\*1+1/6\*2. diff --git a/_problems/medium/THREECOL.md b/_problems/medium/THREECOL.md index a4884c51..311e9ebc 100644 --- a/_problems/medium/THREECOL.md +++ b/_problems/medium/THREECOL.md @@ -86,7 +86,7 @@ The only line of the input contains a single integer **N**, denoting the dimensi ### Output -In the first line, output a single integer **K** (between and **100,000**, inclusive), denoting the number of moves. +In the first line, output a single integer **K** (between 0 and **100,000**, inclusive), denoting the number of moves. Then print **K** lines. The **i**-th of them should contain four integers **r1**, **c1**, **r2** and **c2**, meaning that in the **i**-th move, you choose cells **(r1, c1)** and **(r2, c2)**. These two cells must be adjacent. All coordinates must be between **1** and **N**, inclusive. Here, **(i, j)** denotes a cell at the intersection of the **i**-th row and the **j**-th column. @@ -116,8 +116,8 @@ The task will be graded by a custom checker. Your program will be judged AC (acc 3 2 2 2 4 3 4 4 1 4 1 3 - ### Explanation + The provided output isn't correct because it doesn't solve all possible initial grids. Its only purpose is to show you a valid format. Below you can see how one example grid would change. Here we assume that columns are numbered from top to bottom, and rows are numbered from left to right. In every new grid two previously chosen cells are marked bold. Note that some moves don't affect the grid. AAAB **AA**AB AA**C**B AACB AACB AACB AA**AA** diff --git a/_problems/medium/TKCHOCS.md b/_problems/medium/TKCHOCS.md index e3c86aea..519744a7 100644 --- a/_problems/medium/TKCHOCS.md +++ b/_problems/medium/TKCHOCS.md @@ -41,8 +41,8 @@ For each case, output the maximum number of choco chips Po and Mantis can collec Output: 3 11 - - **Explanation:** + + **Explanation:** Case 2 : Po can visit (1,1) -> (2,2) -> (3,1) and Mantis can visit (3,3) -> (3,2) -> (3,1). Note that if both step in to a same cell, we must count the choco chips in it only once in the final answer. The cell (3,1) is reached by both, but the 1 choco chip in it must be added only once ( of course :) ). _Warning : Large input / output. You may have to use efficient input / output methods if you are using languages with heavy input / output overload. Eg: Prefer using scanf/printf to cin/cout for C/C++_ diff --git a/_problems/medium/TMRATING.md b/_problems/medium/TMRATING.md index e726fc11..67439ee0 100644 --- a/_problems/medium/TMRATING.md +++ b/_problems/medium/TMRATING.md @@ -88,8 +88,8 @@ for K = 1 to Q Output R1 R2 VK = Update array V(K-1) by changing V(K-1) [ ( B * R1 + D ) % N ] = ( C * R2 + D ) % M end-for - -Note: Take care of potential overflows in intermediate calculations in the equations mentioned above. The authors algorithm doesn't depend on the values of A B C D M, they are just used to generate some values. + +Note: Take care of potential overflows in intermediate calculations in the equations mentioned above. The authors algorithm doesn't depend on the values of A B C D M, they are just used to generate some values. ### Input First line contains 6 integers N M A B C D and the second line contains N integers, the initial ratings of N players in order ( 2 ≤ N, A, B, C, D ≤ 100,000 ; 0 ≤ V0\[i\] , M < 1,000,000,000 ; M ≥ 2 ). Next line contains Q ( number of queries 1 ≤ Q ≤ 100,000 ), followed by Q lines. The Kth line in this has the query number K, and has two integers qi qj ( 0 ≤ qi < qj < N ). @@ -115,8 +115,8 @@ For each query, output the top-2 maximum ratings R1 R2 ( R1 ≥ R2 ) in a new li 4 3 12 4 12 8 - -**Explanation:** + +**Explanation:** V0 = { 1, 2, 3, 4, 5, 6 } diff --git a/_problems/medium/TOMJERGA.md b/_problems/medium/TOMJERGA.md index f6cf5e51..2b823e60 100644 --- a/_problems/medium/TOMJERGA.md +++ b/_problems/medium/TOMJERGA.md @@ -134,8 +134,8 @@ For each test case, output a single integer corresponding to time at which Tom w Output: 2 1 - ### Explanation + **Example case 1.** In first query, Tom is in room 1, whereas Jerry is in room 2. In first second, Jerry first moves from 2 to 3 followed by Tom moving from 1 to 2. In the next second, if Jerry moves from 3 to 2, Tom will stay at his position and attack Jerry. If Jerry decides to stay in room 3 itself, then Tom will move to room 3, and kill it. Overall, Tom is going to take 2 seconds to kill Jerry. **Example case 2.** In the first second itself, Tom will kill Jerry, regardless whether Jerry decides to stay put or move from room 3 to 2. diff --git a/_problems/medium/TOOLS.md b/_problems/medium/TOOLS.md index 43c94eb4..c023cc86 100644 --- a/_problems/medium/TOOLS.md +++ b/_problems/medium/TOOLS.md @@ -47,8 +47,8 @@ The output for each test case consists of a single line. This line should displa 4 10 6 - ### Notes + In the second case, the Chef dropped of the first tool to the first cook and then picked up the tool for the third cook. In the last test case, there are three different cooks requesting three different tools. It just so happens that all three tools are at the same location. Still, the Chef can only carry two of the tools from this location at once. diff --git a/_problems/medium/TR2.md b/_problems/medium/TR2.md index e266e9f6..9e54c574 100644 --- a/_problems/medium/TR2.md +++ b/_problems/medium/TR2.md @@ -66,5 +66,4 @@ For each test case output M space separated integers, where the ith integer deno Output: 2 2 1 5 1 - \ No newline at end of file diff --git a/_problems/medium/TRAINING.md b/_problems/medium/TRAINING.md index cebce268..7dddfbfc 100644 --- a/_problems/medium/TRAINING.md +++ b/_problems/medium/TRAINING.md @@ -101,8 +101,8 @@ For each case, output K, the total number of teams formed, in the first line. In 1 2 4 1 2 1 2 - -**Explanation:** + +**Explanation:** Case 1 : There are 3 kids initially in the line, (3,4) (5,5) (4,3) In the first round, only (5,5) comes forward and he leaves. (3,4) and (4,3) are both afraid of (5,5). diff --git a/_problems/medium/TRANSFIG.md b/_problems/medium/TRANSFIG.md index 37e75d0a..3ae904bc 100644 --- a/_problems/medium/TRANSFIG.md +++ b/_problems/medium/TRANSFIG.md @@ -131,8 +131,8 @@ K=2. \ 1 : (1.children = [null, null], 2.children = [null, 1]) -
-
### Input +
### Input
+
 The first line contains **T**, the number of test-cases. 
 
 Each test-case, begins with a line consisting of two integers **N** and **K**, **N** is the number of nodes of the tree, and **K** is the maximum number of children of each node. 
@@ -175,8 +175,8 @@ For each testcase, output the possible number of rooted **K**-ary trees having t
 0
 1
 0
-
 ### Explanation
+
 The first case has two possibilities:
 
 
diff --git a/_problems/medium/TRAVELAL.md b/_problems/medium/TRAVELAL.md
index 89a0ee18..e911c819 100644
--- a/_problems/medium/TRAVELAL.md
+++ b/_problems/medium/TRAVELAL.md
@@ -119,8 +119,8 @@ For each test case, output a single line containing the answer.
 
 Output:
 9
-
 ### Explanation
+
 We can start at some point and travel to all of the points if **D** ≤ 9, but not if **D** is greater than 9. Hence the answer is 9.
 
 Let us take an example when **D** is 9. You can start at (1, 7) and move to (8, 5) because |1 - 8| + |7 - 5| = 9 ≥ 9. From (8, 5) you can move back to (1, 7) and then to (10, 3). From there you can go to (6, 10) and then to (5, 2). You then go to (1, 7) and then to (6, 3). Hence, we have visited all the special points.
diff --git a/_problems/medium/TRAVTREE.md b/_problems/medium/TRAVTREE.md
index 6f1f7fdc..0b1bbc0f 100644
--- a/_problems/medium/TRAVTREE.md
+++ b/_problems/medium/TRAVTREE.md
@@ -120,9 +120,9 @@ For each day output one integer on a separate line - the number of previous rout
 1
 2
 2
-
 ### Explanation
-**Day 1**. As there is no previous route, the route from **4** to **5** can't intersect with any round. Hence answer is .
+
+**Day 1**. As there is no previous route, the route from **4** to **5** can't intersect with any round. Hence answer is 0.
 
 **Day 2**. Route from **4** to **2** intersects with route 1 (at vertices **3** and **4**), So the answer is **1**.
 
diff --git a/_problems/medium/TREE.md b/_problems/medium/TREE.md
index f7e2f846..e44572fa 100644
--- a/_problems/medium/TREE.md
+++ b/_problems/medium/TREE.md
@@ -71,7 +71,7 @@ layout: problem
 ---
 All submissions for this problem are available.Let's define a good tree:
 
-1. It is a tree with **k \* n** nodes labeled from  to **k \* n - 1**
+1. It is a tree with **k \* n** nodes labeled from 0 to **k \* n - 1**
 2. Node **i** and node **j** are not adjacent, for all **0 <= i, j < k \* n** such that **i div k = j div k** (here **div** means integer division. E.g. 7 **div** 2 = 3)
 
 Given **n** and **k**, how many different good trees are there?
@@ -105,5 +105,4 @@ Output the number of different good trees. As the result may be very large, just
 Output 3:
 16
 
-
 
\ No newline at end of file
diff --git a/_problems/medium/TREEDIAM.md b/_problems/medium/TREEDIAM.md
index 72e3d766..24db0381 100644
--- a/_problems/medium/TREEDIAM.md
+++ b/_problems/medium/TREEDIAM.md
@@ -133,8 +133,8 @@ On the **i**th line, output the product of the diameters of all the trees after
 6
 9
 6
-
 ### Explanation
+
 The diameter of the initial tree is **6** (node **2** to node **1** to node **3**).
 
 After the first day (the deletion of the **2**nd edge, i.e. **1 3**), we get two trees, both with diameters 3.
diff --git a/_problems/medium/TREEFUN.md b/_problems/medium/TREEFUN.md
index dd01a581..40a987be 100644
--- a/_problems/medium/TREEFUN.md
+++ b/_problems/medium/TREEFUN.md
@@ -59,8 +59,8 @@ For each test case output **M** lines containing a single integer each -- the an
 2
 1
 0
-
 ### Explanation
+
 In the first query, vertex 1 is such a vertex. If you remove vertex 1 and all the edges that connect 1 to other vertices, then vertices 2 and 5 will belong to separate connected components. Similarly, vertex 4 is also valid.
 
 In the second query, vertex 1 is the only valid vertex. If you remove vertex 1 and all the edges that connect 1 to other vertices, then the connected components will be {2}, {3} and {4, 5}. It's easy to see that vertices 2 and 3 will belong to separate components, vertices 3 and 4 will belong to separate components, and vertices 2 and 4 will belong to separate components.
diff --git a/_problems/medium/TREEP.md b/_problems/medium/TREEP.md
index 68942b48..8abccf3d 100644
--- a/_problems/medium/TREEP.md
+++ b/_problems/medium/TREEP.md
@@ -142,8 +142,8 @@ _Subtask 3 (60 points):_ Original constraints
 1
 3
 1
-
 ### Explanation
+
 In first test case, period of strings "a", "aa" is "a", and period of "ab" is "ab". 
 In second test case, the only period of string "aba" is "aba" itself. Note that not "ab" is not a period, as "aba" is a prefix of "abab", but is not the same.
 
diff --git a/_problems/medium/TREEPROD.md b/_problems/medium/TREEPROD.md
index 3dcf1e25..71ffc9af 100644
--- a/_problems/medium/TREEPROD.md
+++ b/_problems/medium/TREEPROD.md
@@ -107,6 +107,6 @@ A single integer denoting the number of pair of houses. ### Constraints
 
 Output:
 6
-
 ### Explanation
+
 If we multiply the lengths of the roads on the path between any pair of the vertices, it will be divisible by 2.
diff --git a/_problems/medium/TREERGB.md b/_problems/medium/TREERGB.md
index cf6c2adb..8a4b2e88 100644
--- a/_problems/medium/TREERGB.md
+++ b/_problems/medium/TREERGB.md
@@ -94,7 +94,7 @@ Output the answer to the problem on the first line.
 ### Constraints
 
 - **1** ≤ **N** ≤ **300**
-- ≤ **R**, **G**, **B** ≤ **300**
+- 0 ≤ **R**, **G**, **B** ≤ **300**
 
 ### Example
 
@@ -105,7 +105,6 @@ Output the answer to the problem on the first line.
 
 Output #1:
 12
-
 
Input #2:
 8 2 1 3
 1 2
@@ -118,5 +117,4 @@ Output the answer to the problem on the first line.
 
 Output #2:
 613
-
 
\ No newline at end of file diff --git a/_problems/medium/TREEROOT.md b/_problems/medium/TREEROOT.md index 1e75541b..105c14fd 100644 --- a/_problems/medium/TREEROOT.md +++ b/_problems/medium/TREEROOT.md @@ -98,12 +98,12 @@ For each test case, output on a line a space separated list of all possible valu 4 0 5 5 6 5 - ### Sample Output +
4
 6
-
 
### Explanation + In the first sample test case, there is only one node, which is clearly the root. In the second test case, there are two non-isomorphic trees that satisfy the constraints, as seen in the following picture:
  6           6
diff --git a/_problems/medium/TREES.md b/_problems/medium/TREES.md
index 65325e0e..ecf7779d 100644
--- a/_problems/medium/TREES.md
+++ b/_problems/medium/TREES.md
@@ -35,18 +35,15 @@ Sample Input :
 2 4
 3 5
 
-
 
 Sample Output :
 5
 23
 
-
 
 Constraints :
 1 <= T <= 2000
 2 <= N <= 60
 0 <= ai,bi < N
 1 <= K <= N - 1
-
 
\ No newline at end of file diff --git a/_problems/medium/TRIPCOST.md b/_problems/medium/TRIPCOST.md index 6ca306c2..2a2f946f 100644 --- a/_problems/medium/TRIPCOST.md +++ b/_problems/medium/TRIPCOST.md @@ -68,8 +68,8 @@ time: current: 1493557950 layout: problem --- -All submissions for this problem are available.Chef has decided to take a break, and go for a ride. He is currently in city , and he wants to get to city **N**. -The cities along the road from to **N** are numbered **0, 1, 2, 3, ... N-1, N** in increasing order of distance from city . +All submissions for this problem are available.Chef has decided to take a break, and go for a ride. He is currently in city 0, and he wants to get to city **N**. +The cities along the road from 0 to **N** are numbered **0, 1, 2, 3, ... N-1, N** in increasing order of distance from city 0. The distance between cities **i** and **i-1** is denoted by **di**. However, as is always the case, it is unsafe to travel at night, so he will have to break his journey over multiple days. @@ -81,9 +81,9 @@ Let **L** be the minimum number of days in which he can reach city **N**. Chef knows the cost of overnight stay in each city. The cost of overnight stay in city **i** is **ci**. Chef will need to get all his hotel bills re-embersed, and his boss might get suspicious if cost for any single day exceeds a threshold. -Chef knows that his boss wants him to reach as soon as possible. Thus, if it is possible for Chef to go from to **N** in **L** days with no restriction on where Chef stays, then his boss will want him to reach in exactly **L** days. However, if the boss puts a threshold value **i** then we know that the Chef may not be able to reach in **L** days (since he may not be allowed to stay at some hotels). Help him him find the minimum threshold value **C** such that if he only stays in hotels of cost <= **C**, it is possible for him to reach the destination **N** in exactly **L** days (remember, here **L** is the minimum number of days needed by Chef if there were absolutely no restrictions on where he stays). +Chef knows that his boss wants him to reach as soon as possible. Thus, if it is possible for Chef to go from 0 to **N** in **L** days with no restriction on where Chef stays, then his boss will want him to reach in exactly **L** days. However, if the boss puts a threshold value **i** then we know that the Chef may not be able to reach in **L** days (since he may not be allowed to stay at some hotels). Help him him find the minimum threshold value **C** such that if he only stays in hotels of cost <= **C**, it is possible for him to reach the destination **N** in exactly **L** days (remember, here **L** is the minimum number of days needed by Chef if there were absolutely no restrictions on where he stays). -Formally, let **L** be the minimal number of days it takes Chef to get from city to city **N**. Let **F(i)** be the minimal number of days it takes Chef to get from city to city **N** if it's not allowed to pay more than **i** for a single stay in hotel. Find the smallest **C** that will still allow Chef to get to city **N** without losing time. In other words **F(C)=L**. Find and output **L** as well. +Formally, let **L** be the minimal number of days it takes Chef to get from city 0 to city **N**. Let **F(i)** be the minimal number of days it takes Chef to get from city 0 to city **N** if it's not allowed to pay more than **i** for a single stay in hotel. Find the smallest **C** that will still allow Chef to get to city **N** without losing time. In other words **F(C)=L**. Find and output **L** as well. ### Input @@ -154,7 +154,7 @@ Example: ### Explanation -For test case# 1, the optimal trip is → **2** → **4** +For test case# 1, the optimal trip is 0 → **2** → **4** -For test case# 2, the optimal trip is → **1** → **3** → **5** +For test case# 2, the optimal trip is 0 → **1** → **3** → **5** />/> diff --git a/_problems/medium/TRIQUERY.md b/_problems/medium/TRIQUERY.md index 2273eafd..60781f57 100644 --- a/_problems/medium/TRIQUERY.md +++ b/_problems/medium/TRIQUERY.md @@ -120,5 +120,4 @@ For each query, output one integer on a line which denotes the number of the giv 1 0 - \ No newline at end of file diff --git a/_problems/medium/TSHIRTS.md b/_problems/medium/TSHIRTS.md index b3337da7..010beb6b 100644 --- a/_problems/medium/TSHIRTS.md +++ b/_problems/medium/TSHIRTS.md @@ -105,6 +105,6 @@ For each test case, print in single line the required number of ways modulo **10 Output: 4 4 - ### Explanation + For the first case, **4** possible ways are **(3,8)**, **(3,100)**, **(5,8)** and **(5,100)**.For the second case, **4** possible ways are **(5,2,100)**, **(100,2,5)**, **(1,2,100)**, and **(1,2,5)**. diff --git a/_problems/medium/TWINRO.md b/_problems/medium/TWINRO.md index 81198eda..5f2df477 100644 --- a/_problems/medium/TWINRO.md +++ b/_problems/medium/TWINRO.md @@ -109,5 +109,4 @@ A single integer, the maximum combined score that the two robots can achieve. . Output: 56 - \ No newline at end of file diff --git a/_problems/medium/TWOCHEFS.md b/_problems/medium/TWOCHEFS.md index 1d72a596..17c6a977 100644 --- a/_problems/medium/TWOCHEFS.md +++ b/_problems/medium/TWOCHEFS.md @@ -30,9 +30,11 @@ Output on a single line the minimum amount of time (in minutes) for both chefs t 40 10 10 40 **Ouput 1:** +
100
  
 
One way to finish in 100 minutes is for the one chef to cook all his dishes in one oven, and the other chef to cook all his dishes in the other oven. Note that although the dishes could be cooked in only 95 minutes, they cannot be completed in the correct order in only 95 minutes. + **Input 2:**
3 1
@@ -40,9 +42,11 @@ Output on a single line the minimum amount of time (in minutes) for both chefs t
 10
  
 
**Output 2:** +
31
  
 
One oven will cook the 10 minute and 21 minute dishes, the other the 15 and 16 minute dishes. The first chef's third dish enters an oven before his second dish, but the dishes finish cooking at the same time and therefore are still considered to have completed in the correct order. + ### Constraints: 1 ≤ N1 ≤ 50 diff --git a/_problems/medium/TWOCOINS.md b/_problems/medium/TWOCOINS.md index db8bb9cf..b811954d 100644 --- a/_problems/medium/TWOCOINS.md +++ b/_problems/medium/TWOCOINS.md @@ -127,8 +127,8 @@ For each test case, output a single integer corresponding to the minimum number Output 3 4 - ### Explanation + **Example case 1**. ![](https://discuss.codechef.com/upfiles/twocoins_first_sample.jpg) diff --git a/_problems/medium/TWONIM.md b/_problems/medium/TWONIM.md index 10e1bedd..e2444eb9 100644 --- a/_problems/medium/TWONIM.md +++ b/_problems/medium/TWONIM.md @@ -113,5 +113,4 @@ For each test case, output one string on a separate line - "First" (without quot First Second Second - \ No newline at end of file diff --git a/_problems/medium/TWTCLOSE.md b/_problems/medium/TWTCLOSE.md index 5604a16f..696a7dd2 100644 --- a/_problems/medium/TWTCLOSE.md +++ b/_problems/medium/TWTCLOSE.md @@ -105,8 +105,8 @@ CLICK 1 2 0 1 - -**Explanation:** + +**Explanation:** Let open\[x\] = 1 if the xth tweet is open and 0 if its closed. Initially open\[1..3\] = { 0 , 0 , 0 }. Here is the state of open\[1..3\] after each click and corresponding count of open tweets. diff --git a/_problems/medium/TYTACTIC.md b/_problems/medium/TYTACTIC.md index 023d57b0..1db9bddf 100644 --- a/_problems/medium/TYTACTIC.md +++ b/_problems/medium/TYTACTIC.md @@ -98,7 +98,7 @@ For each "**Q S**" query, output the sum of skill values of all the soldiers und - **1** ≤ **N** ≤ **105** - **1** ≤ **M** ≤ **105** -- All skill values given with be in the range \[, **20,000**\] +- All skill values given with be in the range \[0, **20,000**\] - **1** ≤ **S** ≤ **N** for all queries - All soldiers will have soldier **1** (Tywin) as their superior @@ -128,5 +128,4 @@ Q 2 9 19 9 - \ No newline at end of file diff --git a/_problems/medium/UNFRIEND.md b/_problems/medium/UNFRIEND.md index 55231419..a8d9bdd7 100644 --- a/_problems/medium/UNFRIEND.md +++ b/_problems/medium/UNFRIEND.md @@ -96,8 +96,8 @@ Print T lines, one for each test case. Output either "YES" if Chef's dream can b 2 ≤ N ≤ 50 1 ≤ M ≤ 200 1 ≤ W ≤ M - ### Sample Input +
2
 3 3
 1 2
@@ -115,10 +115,10 @@ Print T lines, one for each test case. Output either "YES" if Chef's dream can b
 1 2
 2
 2 4
-
 
### Sample Output +
YES
 NO
-
 
### Explanation + In the first Sample Input, warping either one of Road 1 or Road 2 is sufficient. In the second Sample Input, warping both of Road 1 and Road 2 create a road that connects a house to itself and all other possibilities of warping roads are insufficient to fulfil Chef's dream. diff --git a/_problems/medium/UNIQUE.md b/_problems/medium/UNIQUE.md index 64ecde89..119ad8b1 100644 --- a/_problems/medium/UNIQUE.md +++ b/_problems/medium/UNIQUE.md @@ -102,8 +102,8 @@ abcab 3 2 3 3 - ### Explanation + **Example case 1.** i = 1, shortest unique substring is "abc" diff --git a/_problems/medium/UNPAIR.md b/_problems/medium/UNPAIR.md index 4c873596..1f003e8e 100644 --- a/_problems/medium/UNPAIR.md +++ b/_problems/medium/UNPAIR.md @@ -103,7 +103,7 @@ For each test case, print the minimum sum of entries, possible for **P**. If it - Subproblem 1 (30 points): **1** ≤ **N** ≤ **5** - Subproblem 2 (70 points): **1** ≤ **N** ≤ **100** -- ≤ **Mi, j** ≤ **109** +- 0 ≤ **Mi, j** ≤ **109** ### Example @@ -119,8 +119,8 @@ For each test case, print the minimum sum of entries, possible for **P**. If it Output: -1 2 - **Explanation:** + In the first sample case, there are only two choices of choosing P, one is a zero-matrix, for a zero matrx, we will never be able to make **P + P2 + ... + PS** all positive. Another choice is to chose P = M, for this case also, we can never make the sum with all positive values for any S. In the second case, if one selects P such that we eliminate diagonal elements from M, we get all sum positive for S=2 itself. One can check that this is the minimum sum value for P possible to satisfy all constraints. diff --git a/_problems/medium/URBANDEV.md b/_problems/medium/URBANDEV.md index 83a746c0..b5620a50 100644 --- a/_problems/medium/URBANDEV.md +++ b/_problems/medium/URBANDEV.md @@ -116,5 +116,4 @@ The output consists of two lines. The first line contains a single integer indic Output: 3 2 2 1 1 - \ No newline at end of file diff --git a/_problems/medium/VISITALL.md b/_problems/medium/VISITALL.md index 1768aa4b..6ad6400e 100644 --- a/_problems/medium/VISITALL.md +++ b/_problems/medium/VISITALL.md @@ -122,5 +122,4 @@ For each test case, output a single line containing the answer to the correspond Output: DUR RRDLDL - \ No newline at end of file diff --git a/_problems/medium/VOTING.md b/_problems/medium/VOTING.md index 0a4d5f75..a525d080 100644 --- a/_problems/medium/VOTING.md +++ b/_problems/medium/VOTING.md @@ -55,10 +55,9 @@ Where D is the sum of the distances between the optimum ranking and the input ra 2 1 3 1 2 3 3 2 1 - ### Output: +
 0: 1 2 3
 4: 2 1 3
-
-
(note that in the second case that the ranking 1 2 3 also has total distance 4, but 2 1 3 is output based on the rules outlined in the output specification) \ No newline at end of file +(note that in the second case that the ranking 1 2 3 also has total distance 4, but 2 1 3 is output based on the rules outlined in the output specification) diff --git a/_problems/medium/WALL.md b/_problems/medium/WALL.md index a557a700..d0acd696 100644 --- a/_problems/medium/WALL.md +++ b/_problems/medium/WALL.md @@ -172,5 +172,4 @@ Also, do not add any newlines between different testcases. Output: 25.0 140.0 - \ No newline at end of file diff --git a/_problems/medium/WEAPONS.md b/_problems/medium/WEAPONS.md index 1989e7b3..acbd79bb 100644 --- a/_problems/medium/WEAPONS.md +++ b/_problems/medium/WEAPONS.md @@ -107,8 +107,8 @@ For each stage, output a single integer in new line, which should be the maximum Output: 5 5 - ### Explanation + **Example case 1:** The initial state is (3, 3, 1, 4). The Chef can fuse the first two weapons and get (4, 1, 4). Then he can fuse the first and last weapons to get (5, 1). Now, he can't do anything else. He has gotten a weapon of level 5, and you can show that there is no way to get a weapon of a higher level. Hence the answer is 5. **Example case 2:** The initial state is (2, 3, 3, 3, 1, 1). The Chef can fuse the last two weapons and get the state (2, 3, 3, 3, 2). He can then fuse the first and fifth weapons and get (3, 3, 3, 3). Now, he can fuse the first and second to get (4, 3, 3). Then he fuses the second and third to get (4, 4). Finally, he fuses the first and second to get (5). You can check that nothing better can be achieved, and hence the answer is 5. diff --git a/_problems/medium/WEASELTX.md b/_problems/medium/WEASELTX.md index df8b2dce..67934abe 100644 --- a/_problems/medium/WEASELTX.md +++ b/_problems/medium/WEASELTX.md @@ -76,7 +76,7 @@ layout: problem --- All submissions for this problem are available.### Read problems statements in [mandarin chinese](http://www.codechef.com/download/translated/SEPT17/mandarin/WEASELTX.pdf), [russian](http://www.codechef.com/download/translated/SEPT17/russian/WEASELTX.pdf) and [vietnamese](http://www.codechef.com/download/translated/SEPT17/vietnamese/WEASELTX.pdf) as well. -A tree is an undirected graph in which each pair of vertices is connected to each other by exactly one path. Weasel has a tree with **N** nodes. The indexing of the nodes is -based and the tree is rooted at node . Every node **i** has an initial value **X0i**. +A tree is an undirected graph in which each pair of vertices is connected to each other by exactly one path. Weasel has a tree with **N** nodes. The indexing of the nodes is 0-based and the tree is rooted at node 0. Every node **i** has an initial value **X0i**. Every day **d > 0**, he performs the following operations, starting from the root: @@ -102,9 +102,9 @@ You should print **Q** lines, each containing **XΔ0**. ### Constraints - **1** ≤ **N, Q** ≤ **2 \* 105** -- ≤ **X0i** ≤ **1018** for every ≤ **i** ≤ **N − 1**. -- ≤ **Δ** ≤ **1018** -- ≤ **u, v** ≤ **N − 1** +- 0 ≤ **X0i** ≤ **1018** for every 0 ≤ **i** ≤ **N − 1**. +- 0 ≤ **Δ** ≤ **1018** +- 0 ≤ **u, v** ≤ **N − 1** ### Subtasks @@ -129,11 +129,11 @@ You should print **Q** lines, each containing **XΔ0**. 11 9 3 - ### Explanation + Initially **X0 = \[1, 5, 8, 7\]**. -Weasel performs his operation on node : **X10** = **X00** xor **X01** xor **X02** xor **X03** = **1** xor **5** xor **8** xor **7** = **11**. +Weasel performs his operation on node 0: **X10** = **X00** xor **X01** xor **X02** xor **X03** = **1** xor **5** xor **8** xor **7** = **11**. **X11** = **X01** xor **X02** = **5** xor **8** = **13**. diff --git a/_problems/medium/WORDS1.md b/_problems/medium/WORDS1.md index 79814e4b..8c52c472 100644 --- a/_problems/medium/WORDS1.md +++ b/_problems/medium/WORDS1.md @@ -47,5 +47,4 @@ Sample output: The door cannot be opened. Ordering is possible. The door cannot be opened. - -**Warning: large Input/Output data, be careful with certain languages** \ No newline at end of file +**Warning: large Input/Output data, be careful with certain languages** diff --git a/_problems/medium/WORKCHEF.md b/_problems/medium/WORKCHEF.md index 7be023a9..61e72bcc 100644 --- a/_problems/medium/WORKCHEF.md +++ b/_problems/medium/WORKCHEF.md @@ -93,19 +93,19 @@ For each question, output an integer in a separate line containing the answer of **Subtask 1 : \[10 points\]** - **1** ≤ **Q** ≤ **3** - **1** ≤ **L** ≤ **R** ≤ **106** -- ≤ **K** ≤ **9** +- 0 ≤ **K** ≤ **9** **Subtask 2 : \[20 points\]** - **1** ≤ **Q** ≤ **3** - **1** ≤ **L** ≤ **R** ≤ **109** -- ≤ **K** ≤ **9** +- 0 ≤ **K** ≤ **9** **Subtask 3 : \[70 points\]** - **1** ≤ **Q** ≤ **3** - **1** ≤ **L** ≤ **R** ≤ **1018** -- ≤ **K** ≤ **9** +- 0 ≤ **K** ≤ **9** ### Example @@ -120,6 +120,6 @@ For each question, output an integer in a separate line containing the answer of 1 1 11 - ### Explanation + **Example case 1 and 2**. 48 is both **1** and **2** special as explained in the problem statement. Hence answer is 1. diff --git a/_problems/medium/WPLAY.md b/_problems/medium/WPLAY.md index bd4eeff1..b187e691 100644 --- a/_problems/medium/WPLAY.md +++ b/_problems/medium/WPLAY.md @@ -87,8 +87,8 @@ The alphabets need not be adjacent in any way. IBC DEF AJN - In the above configuration, **"CAN"**, is a valid word. + **Note 2:** Consider a **2 \* 2** of the grid @@ -96,13 +96,13 @@ Consider a **2 \* 2** of the grid
 BE
 ED
-
 
Let the dictionary be: +
 BED
 BEE
-
 
Say a player made the word **"BED"**. This word can be make in two ways: +
 --
 E-
@@ -111,13 +111,13 @@ or
 
 -E
 --
-
 
Note that after making **"BED"**, not all the **E**(s) are inactive. However, after **"BEE"** is created, both **E**s are inactive, namely the board will be +
 --
 -D
-
 
### Input + The first line of input contains **D** denoting the number of words in the dictionally. The next **D** lines contain words in the dictionally. Then the next line contains 2 space-separated integers denoting **r** and **c**. @@ -170,5 +170,4 @@ RAN Bob Alice -
\ No newline at end of file diff --git a/_problems/medium/WPROB.md b/_problems/medium/WPROB.md index a41ff94d..1a5c8ccb 100644 --- a/_problems/medium/WPROB.md +++ b/_problems/medium/WPROB.md @@ -118,8 +118,8 @@ rgbr 0 0 2 -
### Explanation + **Example case 1.**We can move the second container to the beginning of the line. This will take one second. **Example case 2.**Containers are already in desired way. diff --git a/_problems/medium/WSC.md b/_problems/medium/WSC.md index 93271ddc..a73e957e 100644 --- a/_problems/medium/WSC.md +++ b/_problems/medium/WSC.md @@ -99,8 +99,8 @@ For each test case, output a single line containing either "YES" or "NO" - the a ### Constraints - **1** ≤ **T** ≤ **100000** -- Subtask 1: **1** ≤ **N** ≤ **5**, ≤ **M** ≤ **10** - 73 points. -- Subtask 2: **1** ≤ **N** ≤ **10**, ≤ **M** ≤ **20** - 27 points. +- Subtask 1: **1** ≤ **N** ≤ **5**, 0 ≤ **M** ≤ **10** - 73 points. +- Subtask 2: **1** ≤ **N** ≤ **10**, 0 ≤ **M** ≤ **20** - 27 points. ### Example @@ -117,8 +117,8 @@ For each test case, output a single line containing either "YES" or "NO" - the a Output: YES NO -
### Explanation + The first example is the original version of the problem. The second example would have a solution if a boat could seat an additional animal/item. diff --git a/_problems/medium/WSCAGAIN.md b/_problems/medium/WSCAGAIN.md index 4eadc74e..557e3474 100644 --- a/_problems/medium/WSCAGAIN.md +++ b/_problems/medium/WSCAGAIN.md @@ -98,9 +98,9 @@ For each test case, output a single line containing a single integer - the minim - **1** ≤ **T** ≤ **20** - **1** ≤ **K** ≤ **N** -- Subtask 1: **1** ≤ **N** ≤ **3**, ≤ **M** ≤ **3** - 22 points. -- Subtask 2: **1** ≤ **N** ≤ **6**, ≤ **M** ≤ **15** - 34 points. -- Subtask 3: **1** ≤ **N** ≤ **13**, ≤ **M** ≤ **78** - 44 points. +- Subtask 1: **1** ≤ **N** ≤ **3**, 0 ≤ **M** ≤ **3** - 22 points. +- Subtask 2: **1** ≤ **N** ≤ **6**, 0 ≤ **M** ≤ **15** - 34 points. +- Subtask 3: **1** ≤ **N** ≤ **13**, 0 ≤ **M** ≤ **78** - 44 points. ### Example @@ -117,6 +117,6 @@ For each test case, output a single line containing a single integer - the minim Output: 7 3 -
### Explanation + The first example is the original version of the problem. diff --git a/_problems/medium/WW2.md b/_problems/medium/WW2.md index 62c5610a..2917a16c 100644 --- a/_problems/medium/WW2.md +++ b/_problems/medium/WW2.md @@ -114,8 +114,8 @@ For each testcase, print the required answer in one line. Output: 5 8 - ### Explanation + **Example case 1.**You can start at any of the 5 cells available. **Example case 2.** diff --git a/_problems/medium/XOR.md b/_problems/medium/XOR.md index 58410993..ca6c397b 100644 --- a/_problems/medium/XOR.md +++ b/_problems/medium/XOR.md @@ -97,10 +97,10 @@ In the only line of output print space separated sequence of **K** numbers, the Output: 0 2 2 5 5 - ### Explanation + In the sample input we have **4** numbers: **1, 1, 3, 4**. Therefore, there are **(4\*3)/2 = 6** pairwise XOR's. These XOR's are: -**1** xor **1** = (**A\[1\]** xor **A\[2\]**) +**1** xor **1** = 0 (**A\[1\]** xor **A\[2\]**) **1** xor **3** = **2** (**A\[1\]** xor **A\[3\]**) **1** xor **4** = **5** (**A\[1\]** xor **A\[4\]**) **1** xor **3** = **2** (**A\[2\]** xor **A\[3\]**) diff --git a/_problems/medium/XORGRID.md b/_problems/medium/XORGRID.md index 2a39d5af..f9e99cd2 100644 --- a/_problems/medium/XORGRID.md +++ b/_problems/medium/XORGRID.md @@ -89,7 +89,7 @@ Print a single integer denoting maximum energy a minion can achieve at the end o ### Constraints - **2** ≤ **N** ≤ **18** -- ≤ **B\[i\]\[j\]** ≤ **109** +- 0 ≤ **B\[i\]\[j\]** ≤ **109** ### Example @@ -101,13 +101,12 @@ Print a single integer denoting maximum energy a minion can achieve at the end o Output: 4 - ### Explanation +
 There are 6 different possible journeys of the minion, and energy at the end of them are --
 One journey -- 1 ^ 3 ^ 2 ^ 3 ^ 7 = 4
 Four journeys -- 1 ^ 3 ^ 4 ^ 3 ^ 7 = 2
 One journeys -- 1 ^ 3 ^ 5 ^ 3 ^ 7 = 3
 So the maximum energy achieved by a minion is 4.
-
 
\ No newline at end of file diff --git a/_problems/medium/XORPATH.md b/_problems/medium/XORPATH.md index 69627f99..2a5ef7cf 100644 --- a/_problems/medium/XORPATH.md +++ b/_problems/medium/XORPATH.md @@ -96,7 +96,7 @@ Output **Q** lines, one for each query. The **jth** line must contain a single i - **1** ≤ **N**, **E**, **Q** ≤ **105** - **1** ≤ **ai**, **bi**, **xj**, **yj** ≤ **N** -- ≤ **ci** ≤ **109** +- 0 ≤ **ci** ≤ **109** - Parallel edges or self-loops may appear. ### Example @@ -122,6 +122,6 @@ Output **Q** lines, one for each query. The **jth** line must contain a single i 13 0 XIT - ### Explanation + The sample input is illustrated by the image above. diff --git a/_problems/medium/XORSUMS.md b/_problems/medium/XORSUMS.md index 10d966a9..54a821f4 100644 --- a/_problems/medium/XORSUMS.md +++ b/_problems/medium/XORSUMS.md @@ -108,6 +108,6 @@ Print one integer — the xor of sums of all non-empty segments of the sequence. Output2: 14 - ### Explanation + In the first example test, there are six non-empty segments. Their sums of elements are: 7, 7+5=12, 7+5+13=25, 5, 5+13=18, 13. The answer is 7 xor 12 xor 25 xor 5 xor 18 xor 13 = 8. diff --git a/_problems/medium/XRGRD.md b/_problems/medium/XRGRD.md index 090c1652..a21a6bfe 100644 --- a/_problems/medium/XRGRD.md +++ b/_problems/medium/XRGRD.md @@ -114,6 +114,6 @@ For each test case, output a single integer ― the **xor sum** of all the numbe 1 6 4 - ### Explanation + **Example case 1.** First row is filled with ones, so our rectangle contains **23** ones and their **xor sum** is one. **Example case 2.** Here we have a rectangle that consists of one cell **G\[23959042, 1\] = 23959042**. **Example case 3.** The rectangle contains four numbers: **1 1 2 3** and their **xor sum** is **1**. diff --git a/_problems/medium/YALOP.md b/_problems/medium/YALOP.md index e3855301..382ddd79 100644 --- a/_problems/medium/YALOP.md +++ b/_problems/medium/YALOP.md @@ -52,6 +52,6 @@ YES YES NO - ### Explanation + In the first test case Johnny can pass the trial making the following steps: South-east, North, West, East, West, South-east, out. In the second test case: East, West, South, East, out. It's impossible to pass the trial in the third test case. diff --git a/_problems/medium/ZENCALC.md b/_problems/medium/ZENCALC.md index 4ea290e0..ad2afcf6 100644 --- a/_problems/medium/ZENCALC.md +++ b/_problems/medium/ZENCALC.md @@ -152,8 +152,8 @@ NOT OK 10 ! 6 -1 720 15 ^ 341 12 2062435601 NOT OK - ### Explanation + **Example case 1.** The expression is: @@ -185,7 +185,7 @@ NOT OK -6 + * 167 164 - 257 + 190 720 - / 272 0 ^ 341 12 18 ! -6 + * 167 164 - 257 + 190 720 - / 272 0 2062435601 18 ! NOT OK - -Here at first two steps the first rule (with factorials) was applied. At the 3rd and the 4th step the 3rd rule was applied. +Here at first two steps the first rule (with factorials) was applied. + At the 3rd and the 4th step the 3rd rule was applied. Since quotient **272 / 0** is undefined (see the definition) we stop evaluation. So the expression is incorrect and we output **"NOT OK"**. diff --git a/_problems/school/ADACRA.md b/_problems/school/ADACRA.md index 6ce56a61..a1eb5e15 100644 --- a/_problems/school/ADACRA.md +++ b/_problems/school/ADACRA.md @@ -98,6 +98,6 @@ UUDDDUUU Output: 1 - ### Explanation + **Example case 1.** In one step we can flip all the crayons pointing downwards diff --git a/_problems/school/ALEXTASK.md b/_problems/school/ALEXTASK.md index a45f5112..27d22504 100644 --- a/_problems/school/ALEXTASK.md +++ b/_problems/school/ALEXTASK.md @@ -117,8 +117,8 @@ For each test case, output a single line containing the number of milliseconds u 6 7 4 - ### Explanation + **Case 1: in 6 milliseconds, the third reading will be attempted from the 1st sensor and the second reading will be attempted from the 2nd sensor**. **Case 2: in 7 milliseconds the seventh reading will be attempted from the 1st sensor and the first reading will be attempted from the 3rd sensor**. diff --git a/_problems/school/ALPHABET.md b/_problems/school/ALPHABET.md index 271b24fe..b8387497 100644 --- a/_problems/school/ALPHABET.md +++ b/_problems/school/ALPHABET.md @@ -115,8 +115,8 @@ dog Output: Yes No - ### Explanation + The first word can be read. The second word contains the letters d, o and g that aren't known by Jeff. diff --git a/_problems/school/ALTARAY.md b/_problems/school/ALTARAY.md index 41b6e8f7..56c2d705 100644 --- a/_problems/school/ALTARAY.md +++ b/_problems/school/ALTARAY.md @@ -107,8 +107,8 @@ For each test case, output one line with **N** space-separated integers - the le 1 1 1 1 4 3 2 1 1 1 3 2 1 1 - ### Explanation + **Example case 1.** No two elements have different signs, so any alternating subarray may only consist of a single number. **Example case 2.** Every subarray is alternating. diff --git a/_problems/school/AMR15A.md b/_problems/school/AMR15A.md index a982c473..07c465a1 100644 --- a/_problems/school/AMR15A.md +++ b/_problems/school/AMR15A.md @@ -57,40 +57,40 @@ Generate one line output saying "READY FOR BATTLE", if the army satisfies the co Output: NOT READY - ### Example 2 +
Input:
 1
 2
 
 Output:
 READY FOR BATTLE
-
 
### Example 3 +
Input:
 4
 11 12 13 14
 
 Output:
 NOT READY
-
 
### Example 4 +
Input:
 3
 2 3 4
 
 Output:
 READY FOR BATTLE
-
 
### Example 5 +
Input:
 5
 1 2 3 4 5
 
 Output:
 NOT READY
-
 
### Explanation + - **Example 1**: For the first example, **N = 1** and the array **A = \[1\]**. There is only 1 soldier and he is holding 1 weapon, which is odd. The number of soldiers holding an even number of weapons = 0, and number of soldiers holding an odd number of weapons = 1. Hence, the answer is "NOT READY" since the number of soldiers holding an even number of weapons is not greater than the number of soldiers holding an odd number of weapons. - **Example 2**: For the second example, **N = 1** and the array **A = \[2\]**. There is only 1 soldier and he is holding 2 weapons, which is even. The number of soldiers holding an even number of weapons = 1, and number of soldiers holding an odd number of weapons = 0. Hence, the answer is "READY FOR BATTLE" since the number of soldiers holding an even number of weapons is greater than the number of soldiers holding an odd number of weapons. - **Example 3**: For the third example, **N = 4** and the array **A = \[11, 12, 13, 14\]**. The 1st soldier is holding 11 weapons (which is odd), the 2nd soldier is holding 12 weapons (which is even), the 3rd soldier is holding 13 weapons (which is odd), and the 4th soldier is holding 14 weapons (which is even). The number of soldiers holding an even number of weapons = 2, and number of soldiers holding an odd number of weapons = 2. Notice that we have an **equal** number of people holding even number of weapons and odd number of weapons. The answer here is "NOT READY" since the number of soldiers holding an even number of weapons is **not strictly greater than** the number of soldiers holding an odd number of weapons. diff --git a/_problems/school/ANKTRAIN.md b/_problems/school/ANKTRAIN.md index 3936ac80..0f3beb4d 100644 --- a/_problems/school/ANKTRAIN.md +++ b/_problems/school/ANKTRAIN.md @@ -133,5 +133,4 @@ The output should contain exactly **T** lines each containing the berth of the n 4LB 2MB 6UB - \ No newline at end of file diff --git a/_problems/school/BOOKCHEF.md b/_problems/school/BOOKCHEF.md index 0325eca5..cc77d8f5 100644 --- a/_problems/school/BOOKCHEF.md +++ b/_problems/school/BOOKCHEF.md @@ -112,7 +112,7 @@ WhoDoesntLoveChefBook TheseViolentDelightsHaveViolentEnds ComeAtTheKingBestNotMiss - ### Explanation + First we should show posts created by friends with identifiers **1** and **2**. Among the posts by these friends, the one with more popularity should be shown first. Among remaining posts, we show those which are more popular first. diff --git a/_problems/school/BRACKETS.md b/_problems/school/BRACKETS.md index 460b6819..3dc84e63 100644 --- a/_problems/school/BRACKETS.md +++ b/_problems/school/BRACKETS.md @@ -91,8 +91,8 @@ All submissions for this problem are available.### Read problems statements in END RETURN max_balance END - In other words, **F(S)** is equal to the maximal balance over all prefixes of **S**. + Let's denote **A** as Mike's current parentheses sequence, and **B** as a candidate for a new one. Mike is willing to replace **A** with **B** if **F(A)** is equal to **F(B)**. He would also like to choose **B** with the minimal possible length amongst ones satisfying the previous condition. If there are several such strings with the minimal possible length, then Mike will choose the least one lexicographically, considering '**(**' to be less than '**)**'. Help Mike! @@ -122,5 +122,4 @@ All submissions for this problem are available.### Read problems statements in Output: ((())) - \ No newline at end of file diff --git a/_problems/school/BRLADDER.md b/_problems/school/BRLADDER.md index 0fa29981..a25124b5 100644 --- a/_problems/school/BRLADDER.md +++ b/_problems/school/BRLADDER.md @@ -119,8 +119,8 @@ YES YES YES NO - ### Explanation + In the example test, the answer is "YES" for pairs (4, 3), (10, 12), (1, 3) and (999999999, 1000000000). Roads 3-4 and 1-3 you can see on the drawing in the statement. The answer is "NO" for example for a pair (1, 4), because there is no road between cities 1 and 4. diff --git a/_problems/school/BUGCAL.md b/_problems/school/BUGCAL.md index 945616f2..8b742db1 100644 --- a/_problems/school/BUGCAL.md +++ b/_problems/school/BUGCAL.md @@ -106,5 +106,4 @@ Subtasks: Output: 11 40 - \ No newline at end of file diff --git a/_problems/school/C00K0FF.md b/_problems/school/C00K0FF.md index 28f8d4b1..3d8dd853 100644 --- a/_problems/school/C00K0FF.md +++ b/_problems/school/C00K0FF.md @@ -156,6 +156,6 @@ Yes No Yes - ### Explanation + **Example case 2:** There are neither problems of "medium-hard" level nor "hard" level, so it's impossible to form a Cook-Off contest. diff --git a/_problems/school/CANDY123.md b/_problems/school/CANDY123.md index e13e1afd..9e6ec46e 100644 --- a/_problems/school/CANDY123.md +++ b/_problems/school/CANDY123.md @@ -116,8 +116,8 @@ Limak Bob Bob Bob - ### Explanation + **Test case 1.** We have **A** = 3 and **B** = 2. Limak eats 1 candy first, and then Bob eats 2 candies. Then Limak is supposed to eat 3 candies but that would mean 1 + 3 = 4 candies in total. It's impossible because he can eat at most **A** candies, so he loses. Bob wins, and so we print "Bob". **Test case 2.** Now we have **A** = 4 and **B** = 2. Limak eats 1 candy first, and then Bob eats 2 candies, then Limak eats 3 candies (he has 1 + 3 = 4 candies in total, which is allowed because it doesn't exceed **A**). Now Bob should eat 4 candies but he can't eat even a single one (he already ate 2 candies). Bob loses and Limak is the winner. diff --git a/_problems/school/CATSDOGS.md b/_problems/school/CATSDOGS.md index 0f2535a1..56235f18 100644 --- a/_problems/school/CATSDOGS.md +++ b/_problems/school/CATSDOGS.md @@ -119,8 +119,8 @@ For each test case, output a single line containing a string "yes" or "no" (both yes yes no - ### Explanation + **Example 1.** There is one cat and one dog. The number of legs of these animals on the ground are 8, it can be possible when both cat and dog are standing on the ground. **Example 2.** There is one cat and one dog. The number of legs of these animals on the ground are 4, it can be possible if the cat will ride on the dog, so its legs won't be counted by Chef, only the dog's legs will be counted. diff --git a/_problems/school/CFRTEST.md b/_problems/school/CFRTEST.md index 972d4b2d..5a5119f7 100644 --- a/_problems/school/CFRTEST.md +++ b/_problems/school/CFRTEST.md @@ -102,8 +102,8 @@ Print a single line corresponding to the answer of the problem. Output: 2 1 - ### Explanation + **Example case 1.** Devu can give party to second friend on day 2 and first friend on day 3, so he can save both his friendships. **Example case 2.** Both the friends want a party on day 1, and as the Devu can not afford more than one party a day, so he can save only one of the friendships, so answer is 1. diff --git a/_problems/school/CHCHCL.md b/_problems/school/CHCHCL.md index c371e9dc..d6873af3 100644 --- a/_problems/school/CHCHCL.md +++ b/_problems/school/CHCHCL.md @@ -112,8 +112,8 @@ For each test case, output a single line containing one word "Yes" (without quot Output: Yes No - ### Explanation + **Example case 1.** There is only one possible move, so the second player even won't have a chance to make move. **Example case 2.** There are only two ways first player can make first move, after each of them only one move left, so the first player cannot win. diff --git a/_problems/school/CHEFAPAR.md b/_problems/school/CHEFAPAR.md index 977a5fb9..e6cf901b 100644 --- a/_problems/school/CHEFAPAR.md +++ b/_problems/school/CHEFAPAR.md @@ -122,8 +122,8 @@ For each test case, output a single integer denoting the total amount including 2200 2300 1200 - ### Explanation + **Example case 1.** Chef paid maintenance fees for both the months. So, he does not have any dues left. **Example case 2.** Chef did not pay the maintenance fees for any of the months. For the first month, he has to pay 1000Rs, and 100Rs fine as a late payment. For second month payments, he just have to pay 1100Rs. So, in total he has a due of 1100 + 1100 = 2200 Rs. diff --git a/_problems/school/CHEFARRP.md b/_problems/school/CHEFARRP.md index eb96f4c8..d51fe458 100644 --- a/_problems/school/CHEFARRP.md +++ b/_problems/school/CHEFARRP.md @@ -62,6 +62,6 @@ For each test case, output a single line with the answer for the instance. ### C 4 5 9 - ### Explanation: + **Example case 1.** There are 4 such subarrays: **A**\[1..1\], **A**\[2..2\], **A**\[3..3\], **A**\[1..3\]. Consider **A**\[1..3\], sum = 1 + 3 + 2 = 6, product = 1 \* 3 \* 2 = 6. diff --git a/_problems/school/CHEFDETE.md b/_problems/school/CHEFDETE.md index 0f63f623..5cee25cd 100644 --- a/_problems/school/CHEFDETE.md +++ b/_problems/school/CHEFDETE.md @@ -79,7 +79,7 @@ Chef arrived in Frangton to find out that the mafia was involved in the case. Ch There are **N** people in the clan, for simplicity indexed from **1** to **N**, and Chef knows who each of them report to. Member **i** reports to member **Ri**. -Now, Chef needs to identfy all potential killers to continue his investigation. Having considerable knowledge about the mafia's activities, Chef knows that the killer must be a minor criminal, that is, one of the members who nobody reports to. Please find the list of potential killers for Chef. Since Don reports to nobody, his **Ri** will be equal to . +Now, Chef needs to identfy all potential killers to continue his investigation. Having considerable knowledge about the mafia's activities, Chef knows that the killer must be a minor criminal, that is, one of the members who nobody reports to. Please find the list of potential killers for Chef. Since Don reports to nobody, his **Ri** will be equal to 0. ### Input @@ -94,7 +94,7 @@ Output a list of space-separated integers in ascending order — the indices of ### Constraints - **1** ≤ **N** ≤ **105** -- **1** ≤ **Ri** ≤ **N** except for Don, whose **Ri** equals to . +- **1** ≤ **Ri** ≤ **N** except for Don, whose **Ri** equals to 0. - It is guaranteed that there are no cycles in the reporting structure. ### Subtasks @@ -110,8 +110,8 @@ Output a list of space-separated integers in ascending order — the indices of Output: 4 5 6 - ### Explanation + The reporting structure: ![](https://lh3.googleusercontent.com/UrdUW05iT_LOZiLTYN51Khch-mIuc8NjhtOISQZZ1y_N24kkUZxFvGGNGKSE9sh_Qxxa3MqcI0o6ppT0J8YsQ9UYMP7GGA9mrASzAhErKZq5ALY5doBsDUGxndatF2dNKxpJdvD4xKpEpmhl_yLGjfU_cLPf4ylKSH01v_-w_xv7b5H_DokIRpIJSW7sUmLkVG7uYCVSR9Es8QwFZO5FBJpC-DPo4liLZYhHPpcWt1rZq2afrajg6gwrKzMYlDVT1TcXa2IUGZSfXL_jqgkGOEVIHweFh9nouuqEfPfapchv_hFxa3CqeXcK9sa8HEvr4EUW3kx0cmDAGjWH4xDzMzEsWiVyZINbQeocOKaledrfspyXZyaL1Pls7vKKH5OkUwKuzMG0jc24iCuq2M7kJgLoVmld5Wn-AsYTpaGYpn3oMnudnfJG5jUkdZ0rC7Ak_n-N5G2MuyH93gA_MGLMf-ko3s22LFGqTnSf1dTipyEgU1KiX9k5c2hyjfHVP6WMtoITZk0usFiKPbqkh0EDKa-fl5KYuWoMVr9ag5lPxQk=w412-h416-no) diff --git a/_problems/school/CHEFKEY.md b/_problems/school/CHEFKEY.md index ced14247..825b7036 100644 --- a/_problems/school/CHEFKEY.md +++ b/_problems/school/CHEFKEY.md @@ -107,8 +107,8 @@ For each test case, output a single line containing the answer for the test case Output: 3 0 - ### Explanation + **Test case 1.** Possible pairs of dimensions are **(2, 6)**, **(3, 4)** and **(4, 3)**. Note that the rectangular section of dimension **(1, 12)** can't be painted as it can't fit into the screen, because 12 > 6. **Test case 2.** There does not exist any rectangle of desired dimensions which can have 10 different pixels painted. diff --git a/_problems/school/CHEFROUT.md b/_problems/school/CHEFROUT.md index 2b488a9e..ada8594a 100644 --- a/_problems/school/CHEFROUT.md +++ b/_problems/school/CHEFROUT.md @@ -111,8 +111,8 @@ yes yes no no - ### Explanation + **Example case 1.** "CES" can correspond to a possible record of activities of Chef. He starts the day with cooking, then eating and then sleeping. **Example case 2.** "CS" can also correspond to a possible record of activities of Chef. He starts the day with cooking, then eating and then sleeping. Robot recorded his cooking and sleeping in order. He might not have recorded his eating activity. diff --git a/_problems/school/CHEFSQ.md b/_problems/school/CHEFSQ.md index dc22a052..40b0d40d 100644 --- a/_problems/school/CHEFSQ.md +++ b/_problems/school/CHEFSQ.md @@ -97,5 +97,4 @@ Print "Yes" if the sequence contains the favourite sequence int it otherwise pri Output: Yes No - -
(f)(n)<1000>
\ No newline at end of file
+
(f)(n)<1000>
diff --git a/_problems/school/CHEFSTLT.md b/_problems/school/CHEFSTLT.md
index dd8fb70b..025457a6 100644
--- a/_problems/school/CHEFSTLT.md
+++ b/_problems/school/CHEFSTLT.md
@@ -115,10 +115,10 @@ aba?w
 1 3
 0 3
 3 5
-
 
### Explanation + **Example case 1**. You can change the question marks in the strings so that you obtain **S1** = abc and **S2** = abb. Then **S1** and **S2** will differ in one position. On the other hand, you can change the letters so that **S1** = abc and **S2** = bab. Then, the strings will differ in all three positions. -**Example case 2**. Change the question marks this way: **S1** = dcba, **S2** = dcba, then the strings will differ in positions. You can also change the question marks so that **S1** = aaaa, **S2** = dcba, then the strings will differ in **3** positions. +**Example case 2**. Change the question marks this way: **S1** = dcba, **S2** = dcba, then the strings will differ in 0 positions. You can also change the question marks so that **S1** = aaaa, **S2** = dcba, then the strings will differ in **3** positions. **Example case 3**. Change the question marks this way: **S1** = aabac, **S2** = abaaw, then the strings will differ in **3** positions. Then, change the question marks this way: **S1** = xabac, **S2** = abayw, then they will differ in **5** positions. diff --git a/_problems/school/CHEFSTUD.md b/_problems/school/CHEFSTUD.md index b2212c5b..0cf70bca 100644 --- a/_problems/school/CHEFSTUD.md +++ b/_problems/school/CHEFSTUD.md @@ -114,8 +114,8 @@ For each test case, output a single integer denoting the number of pairs of stud 0 1 2 -
### Explanation + **Example case 1.** The updated configuration will be . No students are talking to each other, so no one will be punished. **Example case 2 and 3.** These examples are already explained in the problem statement. diff --git a/_problems/school/CHEFSUM.md b/_problems/school/CHEFSUM.md index ea73aece..4740fa51 100644 --- a/_problems/school/CHEFSUM.md +++ b/_problems/school/CHEFSUM.md @@ -116,16 +116,16 @@ For each test case, output a single line containing the answer. Output: 1 2 - ### Explanation + **Example case 1.** Let's calculate prefixSum(i) + suffixSum(i) for all indexes **i** in the sample case.
 prefixSum(1) + suffixSum(1) = 1 + 6 = 7
 prefixSum(2) + suffixSum(2) = 3 + 5 = 8
 prefixSum(3) + suffixSum(3) = 6 + 3 = 9
-
 
The minimum value of the function is 7, which is attained at index 1, so the answer would be 1. + **Example case 2.** Let's calculate prefixSum(i) + suffixSum(i) for all indexes **i** in the sample case.
@@ -133,5 +133,4 @@ prefixSum(1) + suffixSum(1) = 2 + 7 = 9
 prefixSum(2) + suffixSum(2) = 3 + 5 = 8
 prefixSum(3) + suffixSum(3) = 6 + 4 = 10
 prefixSum(4) + suffixSum(4) = 7 + 1 = 8
-
-
The minimum value of the function is 8, which is achieved for indices 2 and 4. The minimum of these two indices 2, 4 is index 2. Hence, the answer will be 2. \ No newline at end of file +The minimum value of the function is 8, which is achieved for indices 2 and 4. The minimum of these two indices 2, 4 is index 2. Hence, the answer will be 2. diff --git a/_problems/school/CHN08.md b/_problems/school/CHN08.md index 3c8637f5..3a0d3040 100644 --- a/_problems/school/CHN08.md +++ b/_problems/school/CHN08.md @@ -57,8 +57,8 @@ She'll give an integer **N**, and you have to find out what **f(N)** is. Output Output: 7 1000000001 - ### Explanation + In the first test case, **f(3)** = 7, and so that is the output. In the second test case, **f(3)** = -6 and the answer modulo **109+7** is 1000000001. diff --git a/_problems/school/CHN09.md b/_problems/school/CHN09.md index 2973b725..6687e5bb 100644 --- a/_problems/school/CHN09.md +++ b/_problems/school/CHN09.md @@ -54,8 +54,8 @@ baaba 1 0 2 - ### Explanation + **In the first example**, you can change amber to brass or brass to amber. In both the cases, both the balloons will have same colors. So, you will need to paint 1 balloon. So the answer is 1. diff --git a/_problems/school/CHNGOR.md b/_problems/school/CHNGOR.md index 80907228..f4bd0e47 100644 --- a/_problems/school/CHNGOR.md +++ b/_problems/school/CHNGOR.md @@ -104,8 +104,8 @@ For each test case, output answer in a separate line. Output: 3 - ### Explanation + **Example case 1.** We can first remove **1** from the list and then **2**. Thus, the total cost comes out to **3**. diff --git a/_problems/school/CHOPRT.md b/_problems/school/CHOPRT.md index b3f100f6..8153d18e 100644 --- a/_problems/school/CHOPRT.md +++ b/_problems/school/CHOPRT.md @@ -100,6 +100,6 @@ For each line of input produce one line of output. This line contains any one of ≺ ≻ = - ### Explanation + **Example case 1.** In this example 1 as 10 is lesser than 20. diff --git a/_problems/school/CHRL2.md b/_problems/school/CHRL2.md index 5d33c295..9c29d580 100644 --- a/_problems/school/CHRL2.md +++ b/_problems/school/CHRL2.md @@ -93,14 +93,13 @@ CHEFCHEFFFF Output: 2 -
Input:
 CHHHEEEFFCC
 
 Output:
 1
 
-
 
### Scoring + Subtask 1 (25 points): **|S|** ≤ 2000 Subtask 2 (75 points): See the constraints. diff --git a/_problems/school/CHRL4.md b/_problems/school/CHRL4.md index 4fd2c041..01947f29 100644 --- a/_problems/school/CHRL4.md +++ b/_problems/school/CHRL4.md @@ -95,8 +95,8 @@ Please output the value of the minimal possible product, modulo **1000000007**. Output: 8 - ### Scoring + Subtask 1 (30 points): **N** <= 80 Subtask 2 (70 points): See the constraints. diff --git a/_problems/school/CIELRCPT.md b/_problems/school/CIELRCPT.md index 50e39c08..7aaa805c 100644 --- a/_problems/school/CIELRCPT.md +++ b/_problems/school/CIELRCPT.md @@ -98,11 +98,13 @@ There exists combinations of menus whose total price is exactly **p**. 255 4096 ### Sample Output +
2
 1
 8
 2
 
### Explanations + In the first sample, examples of the menus whose total price is 10 are the following: 1+1+1+1+1+1+1+1+1+1 = 10 (10 menus) 1+1+1+1+1+1+1+1+2 = 10 (9 menus) diff --git a/_problems/school/CK87MEDI.md b/_problems/school/CK87MEDI.md index 5445cd06..a63e4c35 100644 --- a/_problems/school/CK87MEDI.md +++ b/_problems/school/CK87MEDI.md @@ -120,8 +120,8 @@ For each test case output a single line, containing a single integer, indicating 7 9 1 - ### Explanation + **Example case 1.** One of the possible solutions is to add **9** making the array **\[4, 7, 9\]**, whose median is **7** **Example case 3.** No matter what elements you add to this array, the median will always be **1** diff --git a/_problems/school/COLOR.md b/_problems/school/COLOR.md index 1c0498d4..e50edbb9 100644 --- a/_problems/school/COLOR.md +++ b/_problems/school/COLOR.md @@ -117,14 +117,14 @@ RGR RRR 3 RGB - **Output** +
 1
 0
 2
-
 
### Explanation: + - **Test 1:** Chef prefers to paint room 2 with blue color such that the resulting color will be red and all the rooms have same color i.e red. - **Test 2:** Given configuration has all the rooms painted with red color and therefore, chef does not need to do painting work at all. - **Test 3:** One possible way of renovation is to paint room 1 with green color, room 2 with red color such that all rooms have same color i.e blue. diff --git a/_problems/school/COMM3.md b/_problems/school/COMM3.md index 8c3e4251..13901d11 100644 --- a/_problems/school/COMM3.md +++ b/_problems/school/COMM3.md @@ -106,5 +106,4 @@ To be clear, we say that two transceivers are close enough to communicate direct yes yes no - \ No newline at end of file diff --git a/_problems/school/COOK82A.md b/_problems/school/COOK82A.md index 878d28ce..cc000a9a 100644 --- a/_problems/school/COOK82A.md +++ b/_problems/school/COOK82A.md @@ -103,8 +103,8 @@ Eibar 6 Output: RealMadrid Barcelona - ### Explanations + In the first scenario, Barcelona wins against Eibar, because they scored more goals (2 > 0). But Real Madrid draws against Malaga, because they both score 1 goal each. So, Real Madrid wins the league title. In the second scenario, Barcelona wins against Eibar (8 > 6). And Real Madrid loses against Malaga (2 diff --git a/_problems/school/COOMILK.md b/_problems/school/COOMILK.md index 76b22031..0f152ec2 100644 --- a/_problems/school/COOMILK.md +++ b/_problems/school/COOMILK.md @@ -119,6 +119,7 @@ NO YES NO ### Explanation + **Test case 1.** Limak is in the kitchen for 7 minutes. He eats three cookies and after each of them he indeed drinks milk in the next minute. The answer is "YES". **Test case 2.** Limak is in the kitchen for 5 minutes. In the first minute he eats a cookie and in the second minute he eats a cookie again, instead of drinking milk. The answer is "NO". diff --git a/_problems/school/COPS.md b/_problems/school/COPS.md index 7c94c476..3c7202a9 100644 --- a/_problems/school/COPS.md +++ b/_problems/school/COPS.md @@ -111,8 +111,8 @@ For each test case, output a single line containing the number of houses which a 0 18 9 - ### Explanation + **Example 1 :** Cops in house 12 can cover houses 1 to 68, and cops in house 52 can cover the rest of the houses. So, there is no safe house. **Example 2 :** Cops in house 21 can cover houses 1 to 41, and cops in house 75 can cover houses 55 to 95, leaving houses numbered 42 to 54, and 96 to 100 safe. So, in total 18 houses are safe. diff --git a/_problems/school/DEVARRAY.md b/_problems/school/DEVARRAY.md index a7188e5b..396106e2 100644 --- a/_problems/school/DEVARRAY.md +++ b/_problems/school/DEVARRAY.md @@ -134,8 +134,8 @@ Yes Yes Yes No - ### Explanation + **In the first example**, Devu can't apply any operation. So the final element in the array will be 1 itself. **In the second example**, Devu can replace 1 and 3 with any of the numbers among 1, 2, 3. Hence final element of the array could be 1, 2 or 3. diff --git a/_problems/school/DEVUGRAP.md b/_problems/school/DEVUGRAP.md index b6f239a5..e5ac2dab 100644 --- a/_problems/school/DEVUGRAP.md +++ b/_problems/school/DEVUGRAP.md @@ -114,8 +114,8 @@ For each test case, print a single integer representing the answer of that test Output: 2 8 - ### Explanation + For the first test case, add or remove 1 grape in each of the bucket. For the second test case, remove three grapes in the first bucket, remove two grapes from the second bucket and add three grapes in the third bucket. diff --git a/_problems/school/DWNLD.md b/_problems/school/DWNLD.md index 99dc1f51..301df653 100644 --- a/_problems/school/DWNLD.md +++ b/_problems/school/DWNLD.md @@ -95,7 +95,7 @@ For each test case output a single integer in separate line, the amount that Che - **1** ≤ **TC** ≤ **1,000** - **1** ≤ **N** ≤ **10** -- ≤ **K** ≤ **T1 + T2 + ... + TN** +- 0 ≤ **K** ≤ **T1 + T2 + ... + TN** - **1** ≤ **Ti**, **Di** ≤ **10** ### Example @@ -116,8 +116,8 @@ For each test case output a single integer in separate line, the amount that Che 6 3 110 - ### Explanation + **Example case 1.** For the first two minutes, internet data of usage of Chef is free. He has to pay for last 2 minutes only, for which he will be charged at 3 dollars per minute, i.e. total 6 dollars. **Example case 2.** For the first two minutes, internet data of usage of Chef is free. He has to pay for last 1 minute only, for which he is being charged at 3 dollars per minute. So, in total he has to pay 3 dollars. diff --git a/_problems/school/EGRANDR.md b/_problems/school/EGRANDR.md index 4380fd71..bf59691b 100644 --- a/_problems/school/EGRANDR.md +++ b/_problems/school/EGRANDR.md @@ -127,8 +127,8 @@ For each of the **T** test cases, output a single line - "Yes" (without quotes) Output: No Yes - ### Explanation + **Example case 1.** Student's average grade point score is 3.8 which makes him/her unqualified for obtaining the stipend. **Example case 2.** Student satisfies all the criteria for getting stipend. diff --git a/_problems/school/ELEVSTRS.md b/_problems/school/ELEVSTRS.md index 38807857..341f74f7 100644 --- a/_problems/school/ELEVSTRS.md +++ b/_problems/school/ELEVSTRS.md @@ -106,5 +106,4 @@ For each test case, output a single line with string **Elevator** or **Stairs**, Elevator Stairs Stairs - \ No newline at end of file diff --git a/_problems/school/ENTEXAM.md b/_problems/school/ENTEXAM.md index 183ec4bd..490d3b4d 100644 --- a/_problems/school/ENTEXAM.md +++ b/_problems/school/ENTEXAM.md @@ -74,7 +74,7 @@ All submissions for this problem are available.### Read problems statements in The faculty of application management and consulting services (FAMCS) of the Berland State University (BSU) has always been popular among Berland's enrollees. This year, **N** students attended the entrance exams, but no more than **K** will enter the university. In order to decide who are these students, there are series of entrance exams. All the students with score strictly greater than at least **(N-K)** students' total score gets enrolled. -In total there are **E** entrance exams, in each of them one can score between and **M** points, inclusively. The first **E-1** exams had already been conducted, and now it's time for the last tribulation. +In total there are **E** entrance exams, in each of them one can score between 0 and **M** points, inclusively. The first **E-1** exams had already been conducted, and now it's time for the last tribulation. Sergey is the student who wants very hard to enter the university, so he had collected the information about the first **E-1** from all **N-1** enrollees (i.e., everyone except him). Of course, he knows his own scores as well. @@ -113,6 +113,6 @@ For each test case, output a single line containing the minimum score Sergey sho Output: 4 - ### Explanation + **Example case 1.** If Sergey gets 4 points at the last exam, his score will be equal to 9+9+4=22. This will be the second score among all the enrollees - the first one will get 21, the second one will get 20 and the third will have the total of 26. Thus, Sergey will enter the university. diff --git a/_problems/school/FBMT.md b/_problems/school/FBMT.md index 6a7af52a..0f6563ee 100644 --- a/_problems/school/FBMT.md +++ b/_problems/school/FBMT.md @@ -120,5 +120,4 @@ yyy Draw yyy - \ No newline at end of file diff --git a/_problems/school/FCTRL.md b/_problems/school/FCTRL.md index 4cab1e87..585011ae 100644 --- a/_problems/school/FCTRL.md +++ b/_problems/school/FCTRL.md @@ -70,7 +70,7 @@ All submissions for this problem are available.The most important part of a GSM The technicians faced a very interesting problem recently. Given a set of BTSes to visit, they needed to find the shortest path to visit all of the given points and return back to the central company building. Programmers have spent several months studying this problem but with no results. They were unable to find the solution fast enough. After a long time, one of the programmers found this problem in a conference article. Unfortunately, he found that the problem is so called "Traveling Salesman Problem" and it is very hard to solve. If we have N BTSes to be visited, we can visit them in any order, giving us N! possibilities to examine. The function expressing that number is called factorial and can be computed as a product -1\.2.3.4....N. The number is very high even for a relatively small N. +1.2.3.4....N. The number is very high even for a relatively small N. The programmers understood they had no chance to solve the problem. But because they have already received the research grant from the government, they needed to continue with their studies and produce at least _some_ results. So they started to study behavior of the factorial function. @@ -96,8 +96,8 @@ Sample Input: 1024 23456 8735373 - Sample Output: +
 0
 14
@@ -105,5 +105,4 @@ Sample Input:
 253
 5861
 2183837
-
 
\ No newline at end of file diff --git a/_problems/school/FCTRL2.md b/_problems/school/FCTRL2.md index 34d9c4e1..72cc5bb3 100644 --- a/_problems/school/FCTRL2.md +++ b/_problems/school/FCTRL2.md @@ -86,12 +86,11 @@ Sample input: ``` 2 5 3 -
Sample output:
+
 
1 2 120 6 -
\ No newline at end of file
diff --git a/_problems/school/FLOW001.md b/_problems/school/FLOW001.md
index 2e45ea10..af2cc776 100644
--- a/_problems/school/FLOW001.md
+++ b/_problems/school/FLOW001.md
@@ -99,5 +99,4 @@ Add **A** and **B** and display it.
 300
 50
 
-
 
\ No newline at end of file diff --git a/_problems/school/FLOW002.md b/_problems/school/FLOW002.md index 25fd1d25..dfd0cae1 100644 --- a/_problems/school/FLOW002.md +++ b/_problems/school/FLOW002.md @@ -94,5 +94,4 @@ Find remainder when **A** is divided by **B**. 1 100 10 - \ No newline at end of file diff --git a/_problems/school/FLOW004.md b/_problems/school/FLOW004.md index de133956..3c9bae90 100644 --- a/_problems/school/FLOW004.md +++ b/_problems/school/FLOW004.md @@ -94,5 +94,4 @@ Display the sum of first and last digit of **N**. 5 5 5 - \ No newline at end of file diff --git a/_problems/school/FLOW005.md b/_problems/school/FLOW005.md index 523a286b..1b34a129 100644 --- a/_problems/school/FLOW005.md +++ b/_problems/school/FLOW005.md @@ -95,5 +95,4 @@ Display the smallest number of notes that will combine to give **N**. 12 5 7 - \ No newline at end of file diff --git a/_problems/school/FLOW006.md b/_problems/school/FLOW006.md index 0c4f05c4..bf4c8ee2 100644 --- a/_problems/school/FLOW006.md +++ b/_problems/school/FLOW006.md @@ -93,5 +93,4 @@ All submissions for this problem are available.You're given an integer **N**. Wr 15 9 8 - \ No newline at end of file diff --git a/_problems/school/FLOW007.md b/_problems/school/FLOW007.md index 2b2d66b5..8475da0b 100644 --- a/_problems/school/FLOW007.md +++ b/_problems/school/FLOW007.md @@ -93,5 +93,4 @@ All submissions for this problem are available.If an Integer **N**, write a prog 54321 30213 3212 - \ No newline at end of file diff --git a/_problems/school/FLOW008.md b/_problems/school/FLOW008.md index d458215d..14da7cfc 100644 --- a/_problems/school/FLOW008.md +++ b/_problems/school/FLOW008.md @@ -93,5 +93,4 @@ Output the given string or -1 depending on conditions. What an obedient servant you are! -1 What an obedient servant you are! - \ No newline at end of file diff --git a/_problems/school/FLOW009.md b/_problems/school/FLOW009.md index 689fcb1c..5477b8a1 100644 --- a/_problems/school/FLOW009.md +++ b/_problems/school/FLOW009.md @@ -97,5 +97,4 @@ Output the total expenses while purchasing items. 12000.000000 200.000000 21600.000000 - \ No newline at end of file diff --git a/_problems/school/FLOW010.md b/_problems/school/FLOW010.md index d7d815ed..d9a0b5b8 100644 --- a/_problems/school/FLOW010.md +++ b/_problems/school/FLOW010.md @@ -94,5 +94,4 @@ D BattleShip Cruiser Destroyer - \ No newline at end of file diff --git a/_problems/school/FLOW011.md b/_problems/school/FLOW011.md index 5aa905a5..9bf9c156 100644 --- a/_problems/school/FLOW011.md +++ b/_problems/school/FLOW011.md @@ -99,5 +99,4 @@ Output the gross salary of the employee. 2406 20383.2 2624 - \ No newline at end of file diff --git a/_problems/school/FLOW013.md b/_problems/school/FLOW013.md index 5241e510..e0f32739 100644 --- a/_problems/school/FLOW013.md +++ b/_problems/school/FLOW013.md @@ -96,5 +96,4 @@ Display 'YES' or 'NO' if the triangle is Valid or not respectively. YES YES NO - \ No newline at end of file diff --git a/_problems/school/FLOW014.md b/_problems/school/FLOW014.md index 96a3c842..420ba189 100644 --- a/_problems/school/FLOW014.md +++ b/_problems/school/FLOW014.md @@ -113,5 +113,4 @@ Print Grade of the steel depending on Conditions. 10 6 6 - \ No newline at end of file diff --git a/_problems/school/FLOW015.md b/_problems/school/FLOW015.md index b2e816b0..89851850 100644 --- a/_problems/school/FLOW015.md +++ b/_problems/school/FLOW015.md @@ -97,5 +97,4 @@ Display the day on the 1st January of that year in lowercase letter. saturday tuesday wednesday - \ No newline at end of file diff --git a/_problems/school/FLOW016.md b/_problems/school/FLOW016.md index d8b7d78e..cdb9a4eb 100644 --- a/_problems/school/FLOW016.md +++ b/_problems/school/FLOW016.md @@ -96,5 +96,4 @@ Display the GCD and LCM of **A** and **B** separated by space respectively. 1 3186456 1 30 - \ No newline at end of file diff --git a/_problems/school/FLOW017.md b/_problems/school/FLOW017.md index 86caa87e..b2b88af2 100644 --- a/_problems/school/FLOW017.md +++ b/_problems/school/FLOW017.md @@ -95,5 +95,4 @@ Display the second largest among **A**, **B** and **C**. 120 312 10 - \ No newline at end of file diff --git a/_problems/school/FLOW018.md b/_problems/school/FLOW018.md index d99c8e79..b977dfc9 100644 --- a/_problems/school/FLOW018.md +++ b/_problems/school/FLOW018.md @@ -95,5 +95,4 @@ Display the factorial of the given number **N** . 6 24 120 - \ No newline at end of file diff --git a/_problems/school/FRGTNLNG.md b/_problems/school/FRGTNLNG.md index 799e321d..ec988bac 100644 --- a/_problems/school/FRGTNLNG.md +++ b/_problems/school/FRGTNLNG.md @@ -114,5 +114,4 @@ kssdy tjzhy ljzym kegqz YES YES NO NO NO NO YES - \ No newline at end of file diff --git a/_problems/school/FRUITS.md b/_problems/school/FRUITS.md index 326e6c5e..f51bd898 100644 --- a/_problems/school/FRUITS.md +++ b/_problems/school/FRUITS.md @@ -100,7 +100,7 @@ For each test case, output the minimum possible difference between the number of 0 2 0 -
### Explanation
+
 - **Test 1:** Chef will buy 1 apple by paying 1 gold coin and will have equal number of apples and oranges.
 - **Test 2:** Chef will buy 1 orange by paying 1 gold coin and will have 5 apples and 3 oranges.
diff --git a/_problems/school/FSQRT.md b/_problems/school/FSQRT.md
index 8bc27100..5a2124b6 100644
--- a/_problems/school/FSQRT.md
+++ b/_problems/school/FSQRT.md
@@ -92,5 +92,4 @@ For each line of input output the square root of the input integer.
 3
 2
 100
-
 
\ No newline at end of file diff --git a/_problems/school/GDOG.md b/_problems/school/GDOG.md index 599573a0..17415881 100644 --- a/_problems/school/GDOG.md +++ b/_problems/school/GDOG.md @@ -100,8 +100,8 @@ For each test case output one integer - the maximum possible number of coins Tuz Output: 1 2 - ### Explanation + In the **first example** he should call two people. Each of them will take 2 coins and they will leave 1 coin for Tuzik. In the **second example** he should call 3 people. diff --git a/_problems/school/GIT01.md b/_problems/school/GIT01.md index e2aae089..59027282 100644 --- a/_problems/school/GIT01.md +++ b/_problems/school/GIT01.md @@ -116,5 +116,4 @@ GGR 0 8 - \ No newline at end of file diff --git a/_problems/school/GOODSET.md b/_problems/school/GOODSET.md index 5762042b..70250066 100644 --- a/_problems/school/GOODSET.md +++ b/_problems/school/GOODSET.md @@ -107,8 +107,8 @@ For each test case, output a single line containing **n** integers denoting the 1 2 4 1 2 4 16 3 2 15 6 10 - ### Explanation + **Example 1 and 2.** Any set of size less than or equal to 2 is good by definition. **Example 3 onwards.** For each pair of elements in the set, you can see that their sum doesn't exist in the set. diff --git a/_problems/school/HEADBOB.md b/_problems/school/HEADBOB.md index 4f023727..acf49a76 100644 --- a/_problems/school/HEADBOB.md +++ b/_problems/school/HEADBOB.md @@ -84,7 +84,7 @@ Each person is described in two lines. First line of the description contains a For each person, print "INDIAN" if he/she is from India, "NOT INDIAN" if not from India, and "NOT SURE" if the information is insufficient to make a decision.### Constraints -``12. **For 30 points:** 1 ≤ T,N ≤ 100 +
12. **For 30 points:** 1 ≤ T,N ≤ 100
 13. **For 70 points:** 1 ≤ T,N ≤ 1000### Example
   
   **Input:**`3

5

NNNYY

6

NNINNI

4

NNNN

` diff --git a/_problems/school/HS08TEST.md b/_problems/school/HS08TEST.md index ae5ca3b5..fde4e769 100644 --- a/_problems/school/HS08TEST.md +++ b/_problems/school/HS08TEST.md @@ -78,21 +78,20 @@ Output the account balance after the attempted transaction, given as a number wi Output: 89.50 - ### Example - Incorrect Withdrawal Amount (not multiple of 5) +
 Input:
 42 120.00
 
 Output:
 120.00
-
 
### Example - Insufficient Funds +
 Input:
 300 120.00
 
 Output:
 120.00
-
 
\ No newline at end of file diff --git a/_problems/school/ICPC16A.md b/_problems/school/ICPC16A.md index a69b2fe1..0bb5fa37 100644 --- a/_problems/school/ICPC16A.md +++ b/_problems/school/ICPC16A.md @@ -38,7 +38,7 @@ For each test case, output a single line containing **"left"** or **"right"** or ### Constraints - **1 ≤ T ≤ 5000** -- ≤ **x1, y1, x2, y2**. ≤ **100** +- 0 ≤ **x1, y1, x2, y2**. ≤ **100** - It's guaranteed that the initial position of robot is not his home. ### Example @@ -53,6 +53,6 @@ For each test case, output a single line containing **"left"** or **"right"** or right up sad - ### Explanation + **Test case 1.** If you give Bunny the command to move to the right, it will reach its home. diff --git a/_problems/school/ICPC16B.md b/_problems/school/ICPC16B.md index 4447f376..73245ad1 100644 --- a/_problems/school/ICPC16B.md +++ b/_problems/school/ICPC16B.md @@ -61,8 +61,8 @@ For each test case, output a single line containing "yes" or "no" (without quote yes yes no - ### Explanation + **Test case 1.** If you multiply 0 with 1, you get 0, we see that **a0 = 0**. So, the array is _beautiful_. **Test case 3.** If you multiply 5 with 6, you get 30, there does not exist an **k** such that **ak = 30**. So, the array is not _beautiful_. diff --git a/_problems/school/INTEST.md b/_problems/school/INTEST.md index 530d8642..39d4fe33 100644 --- a/_problems/school/INTEST.md +++ b/_problems/school/INTEST.md @@ -90,5 +90,4 @@ Write a single integer to output, denoting how many integers ti are divisible by Output: 4 - \ No newline at end of file diff --git a/_problems/school/KOL16B.md b/_problems/school/KOL16B.md index 16ce305c..ffbba047 100644 --- a/_problems/school/KOL16B.md +++ b/_problems/school/KOL16B.md @@ -23,7 +23,7 @@ time: current: 1492506692 layout: problem --- -All submissions for this problem are available.Lajuk is a little girl who loves playing with array. In her 10th birthday, she got two arrays as presents. Let’s call them **A** and **B**. Both arrays have the same size **n** and contains integers between to **30000**. +All submissions for this problem are available.Lajuk is a little girl who loves playing with array. In her 10th birthday, she got two arrays as presents. Let’s call them **A** and **B**. Both arrays have the same size **n** and contains integers between 0 to **30000**. Lajuk’s hard-drive is almost full of presents and she barely has any space to keep the arrays. She discovered a brilliant function to merge the array into one: @@ -39,8 +39,8 @@ void encodeArray(int *A, int *B, int n){ A[i] = encodeInteger(A[i], B[i]); } } - Lajuk passed **A** and **B** into the encodeArray function. After that she discarded array **B** and saved the modified version of array **A** in the hard-drive. + Now in her 15th birthday Lajuk wants to play with those arrays again. She found the modified version of array A in the hard-drive but she forgot how to recover the original arrays from it. Being upset, she asked for your help. Can you help her to recover the original arrays? ### Input @@ -66,5 +66,4 @@ For each case print the case number in the first line. In the second line, print Case 1: 5 10 12 7 3 10 3 2 - \ No newline at end of file diff --git a/_problems/school/KOL16J.md b/_problems/school/KOL16J.md index f590b2f0..21f3ded6 100644 --- a/_problems/school/KOL16J.md +++ b/_problems/school/KOL16J.md @@ -65,6 +65,6 @@ yes no no no - ### Explanation + All the examples are explained in the problem statement. diff --git a/_problems/school/KTTABLE.md b/_problems/school/KTTABLE.md index d659509d..5435a375 100644 --- a/_problems/school/KTTABLE.md +++ b/_problems/school/KTTABLE.md @@ -75,7 +75,7 @@ All submissions for this problem are available.### Read problems statements in There are **N** students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with a timetable for kitchen's usage in order to avoid the conflicts: -- The first student starts to use the kitchen at the time and should finish the cooking not later than at the time **A1**. +- The first student starts to use the kitchen at the time 0 and should finish the cooking not later than at the time **A1**. - The second student starts to use the kitchen at the time **A1** and should finish the cooking not later than at the time **A2**. - And so on. - The **N**-th student starts to use the kitchen at the time **AN-1** and should finish the cooking not later than at the time **AN** @@ -104,7 +104,7 @@ Should contain all the constraints on the input data that you may have. Format i - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **104** -- < **A1** < **A2** < ... < **AN** < **109** +- 0 < **A1** < **A2** < ... < **AN** < **109** - **1** ≤ **Bi** ≤ **109** ### Example @@ -121,8 +121,8 @@ Should contain all the constraints on the input data that you may have. Format i Output: 2 1 - ### Explanation -**Example case 1.** The first student has **1** unit of time - the moment . It will be enough for her to cook. The second student has **9** units of time, but wants to cook for **10** units of time, and won't fit in time. The third student has **5** units of time and will fit in time, because needs to cook only for **3** units of time. + +**Example case 1.** The first student has **1** unit of time - the moment 0. It will be enough for her to cook. The second student has **9** units of time, but wants to cook for **10** units of time, and won't fit in time. The third student has **5** units of time and will fit in time, because needs to cook only for **3** units of time. **Example case 2.** Each of students has **10** units of time, but only the second one will be able to fit in time. diff --git a/_problems/school/LADDU.md b/_problems/school/LADDU.md index b71f0316..5a76c53f 100644 --- a/_problems/school/LADDU.md +++ b/_problems/school/LADDU.md @@ -132,8 +132,8 @@ CONTEST_HOSTED Output: 3 1 - ### Explanation + **In the first example**, - For winning contest with rank 1, user gets 300 + 20 - 1 = 319 laddus. diff --git a/_problems/school/LCH15JAB.md b/_problems/school/LCH15JAB.md index 6eebd4f4..3015afbf 100644 --- a/_problems/school/LCH15JAB.md +++ b/_problems/school/LCH15JAB.md @@ -103,5 +103,4 @@ YES YES NO YES - \ No newline at end of file diff --git a/_problems/school/LCOLLIS.md b/_problems/school/LCOLLIS.md index 31ef41d8..e79f3024 100644 --- a/_problems/school/LCOLLIS.md +++ b/_problems/school/LCOLLIS.md @@ -109,8 +109,8 @@ For each test case output a single line containing an integer corresponding to t Output: 4 0 - ### Explanation + **Example Case 1.** All three boys like the first girl, so there are **(1, 2, 1), (1, 3, 1), (2, 3, 1)** collisions with her. Boys **1** and **3** both like the second girl so this is one more collision. Only one boy likes the third girl, so there are no collisions with her and thus we have **4** collisions total. **Example Case 2.** For each girl there is only one boy who likes her, so there are no collisions at all. diff --git a/_problems/school/LIKECS01.md b/_problems/school/LIKECS01.md index 27fce59f..d1234c49 100644 --- a/_problems/school/LIKECS01.md +++ b/_problems/school/LIKECS01.md @@ -104,23 +104,23 @@ For each test case, output **"yes"** or **"no"** (without quotes) as the solutio
 1 ≤ T ≤ 1000
 1 ≤ length of S ≤ 100
-
 
### Sample Input +
 4
 likecs
 venivedivici
 bhuvan
 codechef
-
 
### Sample Output +
 no
 yes
 no
 yes
-
 
### Explanation + In test case **2**, one of the possible equal subsequence is **"vi"** and **"vi"**. (one at position **{0, 3}** and other at **{4, 7}**, assuming 0-based indexing). In test case **4**, one of the possible equal subsequence is **"ce"** and **"ce"**. (one at position **{0, 3}** and other at **{4, 6}**, assuming 0-based indexing). diff --git a/_problems/school/LISDIGIT.md b/_problems/school/LISDIGIT.md index 09395740..fce7adb7 100644 --- a/_problems/school/LISDIGIT.md +++ b/_problems/school/LISDIGIT.md @@ -118,9 +118,9 @@ For each test case, output a single **n**-digit number (without leading zeroes) 54 1531 1730418 - ### Explanation -**Example case 1.** All one-digit numbers have the same **LIS** array, so any answer from to **9** will be accepted. + +**Example case 1.** All one-digit numbers have the same **LIS** array, so any answer from 0 to **9** will be accepted. **Example cases 2 & 3.** For a two digit number we always have **LIS1 = 1**, but the value of **LIS2** depends on whether the first digit is strictly less than the second one. If this is the case (like for number **36**), **LIS2 = 2**, otherwise (like for numbers **54** or **77**) the values of **LIS2** is **1**. @@ -128,4 +128,4 @@ For each test case, output a single **n**-digit number (without leading zeroes) **Example case 5.** **7**-digit number **1730418** has **LIS** array **\[1, 2, 2, 1, 3, 2, 4\]**: - index LIS length 1 **1**730418 1 2 **17**30418 2 3 **1**7**3**0418 2 4 173418 1 5 **1**7**3**0**4**18 3 6 1734**1**8 2 7 **1**7**3**0**4**1**8** 4 + index LIS length 1 **1**730418 1 2 **17**30418 2 3 **1**7**3**0418 2 4 1730418 1 5 **1**7**3**0**4**18 3 6 17304**1**8 2 7 **1**7**3**0**4**1**8** 4 diff --git a/_problems/school/LONGSEQ.md b/_problems/school/LONGSEQ.md index 00a83c05..5770c814 100644 --- a/_problems/school/LONGSEQ.md +++ b/_problems/school/LONGSEQ.md @@ -102,8 +102,8 @@ Each test case contain a number made of only digits 1's and 0's on newline Output: Yes No - ### Explanation + **Example case 1.** In 101, the 0 can be flipped to make it all 1.. **Example case 2.** No matter whichever digit you flip, you will not get the desired string. diff --git a/_problems/school/LOSTMAX.md b/_problems/school/LOSTMAX.md index 021e5248..f4b37f07 100644 --- a/_problems/school/LOSTMAX.md +++ b/_problems/school/LOSTMAX.md @@ -105,8 +105,8 @@ He wants to find the largest of the **N** numbers. Help him find this. 1 8 4 - ### Explanation + **Test case 1:** **N** = 2 and the numbers are {1, 1}. The maximum among these 2 numbers is 1, and hence the output is 1. diff --git a/_problems/school/LTM40AB.md b/_problems/school/LTM40AB.md index a9a15eb5..bf6dae8b 100644 --- a/_problems/school/LTM40AB.md +++ b/_problems/school/LTM40AB.md @@ -111,5 +111,4 @@ For each test case, output a single number each in separate line denoting number Output: 499998500001 - \ No newline at end of file diff --git a/_problems/school/LUCKFOUR.md b/_problems/school/LUCKFOUR.md index e5cb85bb..b3320b4d 100644 --- a/_problems/school/LUCKFOUR.md +++ b/_problems/school/LUCKFOUR.md @@ -98,8 +98,8 @@ Output **T** lines. Each of these lines should contain the number of occurences ### Constraints - **1** ≤ **T** ≤ **105** -- (Subtask 1): ≤ Numbers from the list ≤ **9** - 33 points. -- (Subtask 2): ≤ Numbers from the list ≤ **109** - 67 points. +- (Subtask 1): 0 ≤ Numbers from the list ≤ **9** - 33 points. +- (Subtask 2): 0 ≤ Numbers from the list ≤ **109** - 67 points. ### Example @@ -117,5 +117,4 @@ Output **T** lines. Each of these lines should contain the number of occurences 1 1 0 - \ No newline at end of file diff --git a/_problems/school/MATPAN.md b/_problems/school/MATPAN.md index 4dc2601d..03662792 100644 --- a/_problems/school/MATPAN.md +++ b/_problems/school/MATPAN.md @@ -119,8 +119,8 @@ thequickbrownfoxjumpsoverthelazydog Output: 63 0 - ### Explanation +
 First test
 There are three letters missing from the original string: n (price 14), x (price 24), and y (price 25).
@@ -128,5 +128,4 @@ Therefore the answer is 14 + 24 + 25 = 63.
 
 Second test
 No letter is missing so there is no point in buying something. The answer is 0.
-
 
\ No newline at end of file diff --git a/_problems/school/MISSP.md b/_problems/school/MISSP.md index 28b12493..9921a3ab 100644 --- a/_problems/school/MISSP.md +++ b/_problems/school/MISSP.md @@ -95,7 +95,6 @@ Find the type of doll that doesn't have a pair

Output: 2 -
Input:
 1
 5
@@ -106,5 +105,4 @@ Find the type of doll that doesn't have a pair
 3
 Output:
 3
-
 
\ No newline at end of file diff --git a/_problems/school/MNMX.md b/_problems/school/MNMX.md index cadd2160..7fd94cbc 100644 --- a/_problems/school/MNMX.md +++ b/_problems/school/MNMX.md @@ -111,6 +111,6 @@ For each test case, print the minimum cost required for the transformation. Output 3 4 - ### Explanation + **Test 1 :** Chef will make only 1 move: pick up both the elements (that is, 3 and 4), remove the larger one (4), incurring a cost equal to the smaller one (3). diff --git a/_problems/school/MOVIEWKN.md b/_problems/school/MOVIEWKN.md index 4f7f22af..e23c40da 100644 --- a/_problems/school/MOVIEWKN.md +++ b/_problems/school/MOVIEWKN.md @@ -109,8 +109,8 @@ For each test case, output a single integer **i** denoting the index of the movi Output: 1 2 - ### Explanation + In the first example case, both films have the same value of **L × R**, but the first film has a better rating. In the second example case, the second and the fourth movies are equally good, but the second movie has a smaller index. diff --git a/_problems/school/MUFFINS3.md b/_problems/school/MUFFINS3.md index b3145c33..e4a4742d 100644 --- a/_problems/school/MUFFINS3.md +++ b/_problems/school/MUFFINS3.md @@ -88,10 +88,10 @@ For each test case, output the package size that will maximize the number of lef
2
 2
 5
-
 
### Sample Output +
2
 3
-
 
### Explanation + In the first test case, there will be no leftover cupcakes regardless of the size Chef chooses, so he chooses the largest possible size. In the second test case, there will be 2 leftover cupcakes. diff --git a/_problems/school/MXZERO.md b/_problems/school/MXZERO.md index 115d4594..e532ca76 100644 --- a/_problems/school/MXZERO.md +++ b/_problems/school/MXZERO.md @@ -88,7 +88,7 @@ For each test case, output a single line containing the number of ways to erase - **1** ≤ **T** ≤ **20** - **2** ≤ **N** ≤ **105** -- ≤ **Ai** ≤ **1** +- 0 ≤ **Ai** ≤ **1** ### Example @@ -102,8 +102,8 @@ For each test case, output a single line containing the number of ways to erase Output: 1 5 - ### Explanation + **Example case 1.** If you erase the first number on the blackboard, then the XOR of the rest of numbers will be equal to zero. **Example case 2.** You can erase any of the given 5 numbers, it will make the XOR of the rest equal to zero. diff --git a/_problems/school/NITIKA.md b/_problems/school/NITIKA.md index a5083c96..8ebbce72 100644 --- a/_problems/school/NITIKA.md +++ b/_problems/school/NITIKA.md @@ -123,6 +123,6 @@ Mohndas KaramChand gandhi Gandhi M. Gandhi M. K. Gandhi - ### Explanation + The examples are already explained in the problem statement. diff --git a/_problems/school/NOTINCOM.md b/_problems/school/NOTINCOM.md index f0c740f3..109328db 100644 --- a/_problems/school/NOTINCOM.md +++ b/_problems/school/NOTINCOM.md @@ -117,8 +117,8 @@ For each test case, output a single line containing the minimal amount of number Output: 1 0 - ### Explanation + **Example case 1.** If Alice throws away the number **3** from her collection, she would obtain **{1, 2}** which is disjoint with **{3, 4, 5, 6}**. **Example case 2.** Girls don't have any number in common initially. So there is no need to throw away any number. diff --git a/_problems/school/NW1.md b/_problems/school/NW1.md index 4ae87471..5280b577 100644 --- a/_problems/school/NW1.md +++ b/_problems/school/NW1.md @@ -115,6 +115,6 @@ For each query, print seven space-separated integers denoting the number of occu 4 4 4 4 4 4 4 4 4 5 5 5 4 4 - ### Example + **Example case 2:** There are 4 Mondays, 4 Tuesdays, 5 Wednesdays, 5 Thursdays, 5 Fridays, 4 Saturdays and 4 Sundays. diff --git a/_problems/school/OMWG.md b/_problems/school/OMWG.md index a4f32c96..0d1924a0 100644 --- a/_problems/school/OMWG.md +++ b/_problems/school/OMWG.md @@ -107,12 +107,12 @@ For each test case, output a single line containing an integer corresponding to Output: 4 - ### Explanation + Leha can obtain total score 4 in the following way. -- In the first step, he colors down left cell, all the neighboring cells of this cell are uncolored. So, it adds to total score. -- In second step, he can color upper right cell, it also adds total to the score. +- In the first step, he colors down left cell, all the neighboring cells of this cell are uncolored. So, it adds 0 to total score. +- In second step, he can color upper right cell, it also adds total 0 to the score. - In third step, he can color top left cell. There are two neighboring cell of this cell, both of which are colored. So, this add **2** to the score. - In the last step, he can choose the remaining down right cell. There are two neighboring cell of this cell, both of which are colored. So, this also add **2** to the score. diff --git a/_problems/school/ONP.md b/_problems/school/ONP.md index 29c87776..7117c9b2 100644 --- a/_problems/school/ONP.md +++ b/_problems/school/ONP.md @@ -74,8 +74,8 @@ Followed by t lines, containing an expression to be translated to RPN form, wher
 The expressions in RPN form, one per line.
-
 
### Example +
 Input:
 3
@@ -87,5 +87,4 @@ Output:
 abc*+
 ab+zx+*
 at+bac++cd+^*
-
 
\ No newline at end of file diff --git a/_problems/school/PALL01.md b/_problems/school/PALL01.md index e19d812b..8cab500d 100644 --- a/_problems/school/PALL01.md +++ b/_problems/school/PALL01.md @@ -93,5 +93,4 @@ For each input output "wins" if the number is a palindrome and "losses" if not. losses wins wins - \ No newline at end of file diff --git a/_problems/school/PERFCONT.md b/_problems/school/PERFCONT.md index 134352e1..5bff59e2 100644 --- a/_problems/school/PERFCONT.md +++ b/_problems/school/PERFCONT.md @@ -129,8 +129,8 @@ no yes no no - ### Explanation + **Example case 1.**: The problems are of hard, hard and cakewalk difficulty. There is 1 cakewalk and 2 hard problems, so the contest is balanced. **Example case 2.**: The second problem is hard and the third is cakewalk. There is 1 cakewalk and 1 hard problem, so the contest is not balanced. diff --git a/_problems/school/PERMUT2.md b/_problems/school/PERMUT2.md index e764a831..563eda7c 100644 --- a/_problems/school/PERMUT2.md +++ b/_problems/school/PERMUT2.md @@ -88,10 +88,9 @@ For each test case output whether the permutation is ambiguous or not. Adhere to 1 1 0 - ### Sample Output +
ambiguous
 not ambiguous
 ambiguous
-
 
\ No newline at end of file diff --git a/_problems/school/PPSUM.md b/_problems/school/PPSUM.md index 888cccbc..37aa5643 100644 --- a/_problems/school/PPSUM.md +++ b/_problems/school/PPSUM.md @@ -102,8 +102,8 @@ For each testcase, output one integer on a separate line. Output: 10 21 - ### Explanation: + The first test case: sum(1, 4) = sum(4) = 1 + 2 + 3 + 4 = 10. The second test case: sum(2, 3) = sum(sum(3)) = sum(1 + 2 + 3) = sum(6) = 1 + 2 + 3 + 4 + 5 + 6 = 21. diff --git a/_problems/school/PRB01.md b/_problems/school/PRB01.md index 96a4ca88..6c0bbba7 100644 --- a/_problems/school/PRB01.md +++ b/_problems/school/PRB01.md @@ -100,5 +100,4 @@ yes no no yes - \ No newline at end of file diff --git a/_problems/school/RAINBOWA.md b/_problems/school/RAINBOWA.md index d517ccdf..b896e91e 100644 --- a/_problems/school/RAINBOWA.md +++ b/_problems/school/RAINBOWA.md @@ -129,8 +129,8 @@ Help Chef in finding out if the given array is a Rainbow Array or not. yes no no - ### Explanation + The first example satisfies all the conditions. The second example has **1** element of value **1** at the beginning and **2** elements of value **1** at the end. diff --git a/_problems/school/RECIPE.md b/_problems/school/RECIPE.md index 52ab5598..3710de5c 100644 --- a/_problems/school/RECIPE.md +++ b/_problems/school/RECIPE.md @@ -82,13 +82,13 @@ For each test case, output exactly N space-separated integers on a line, giving 2 4 4 3 2 3 4 4 3 15 9 6 - ### Sample Output +
1 1
 2 3 4
 1 5 3 2
-
 
### Constraints + T≤100 2≤N≤50 All ingredient quantities are between 1 and 1000, inclusive. diff --git a/_problems/school/RECTSQ.md b/_problems/school/RECTSQ.md index d0b7ce80..dbd17ee0 100644 --- a/_problems/school/RECTSQ.md +++ b/_problems/school/RECTSQ.md @@ -92,5 +92,4 @@ Output is a single line which denotes the minimum number of square plots that ca Output: 6 6 - \ No newline at end of file diff --git a/_problems/school/REMISS.md b/_problems/school/REMISS.md index b9e92929..4dc971fa 100644 --- a/_problems/school/REMISS.md +++ b/_problems/school/REMISS.md @@ -90,7 +90,7 @@ For each test case, output a single line containing two space separated integers ### Constraints - **1** ≤ **T** ≤ **100** -- ≤ **A, B** ≤ **1000000** +- 0 ≤ **A, B** ≤ **1000000** ### Example @@ -100,5 +100,4 @@ For each test case, output a single line containing two space separated integers Output: 19 36 - \ No newline at end of file diff --git a/_problems/school/RGAME.md b/_problems/school/RGAME.md index 01367d28..dec9114b 100644 --- a/_problems/school/RGAME.md +++ b/_problems/school/RGAME.md @@ -116,6 +116,6 @@ Princess Rupsa wants to find out the sum of scores obtained by all possible diff Output: 4 14 - ### Explanation + - There are **2** possible gameplays. **A0A1** which gives score of **2** and **A1A0** which also gives score of **2**. So the answer is **2 + 2 = 4** diff --git a/_problems/school/RNDPAIR.md b/_problems/school/RNDPAIR.md index 3cfd9e58..25943d26 100644 --- a/_problems/school/RNDPAIR.md +++ b/_problems/school/RNDPAIR.md @@ -121,5 +121,4 @@ For each test-case output a single line containing a single number denoting the 1.00000000 0.20000000 0.33333333 - \ No newline at end of file diff --git a/_problems/school/RRJOKE.md b/_problems/school/RRJOKE.md index 3c3fdc4a..40079a2a 100644 --- a/_problems/school/RRJOKE.md +++ b/_problems/school/RRJOKE.md @@ -86,7 +86,7 @@ Output the answer for every test case in a separate line. The answer for every t - **1** ≤ **T** ≤ **10** - **1** ≤ **N** ≤ **40** -- ≤ **absolute value of each coordinate** ≤ **1000** +- 0 ≤ **absolute value of each coordinate** ≤ **1000** - **1** ≤ sum over all **N** in a single test file ≤ **120** ### Example @@ -103,7 +103,7 @@ Output the answer for every test case in a separate line. The answer for every t Output: 3 0 - ### Explanation + For the first test case permutation **\[1, 2\]** is optimal. **1 xor 2 = 3**. For the second one both **\[2, 3, 1\]** and **\[1, 3, 2\]** lead us to the shortest walk, but the second one is lexicographically smaller. So the answer is **H(\[1, 3, 2\]) = 1 xor 3 xor 2 = 0** . diff --git a/_problems/school/SEBIHWY.md b/_problems/school/SEBIHWY.md index 3224756b..413518f5 100644 --- a/_problems/school/SEBIHWY.md +++ b/_problems/school/SEBIHWY.md @@ -101,8 +101,8 @@ For each test case, output a single line containing "SEBI", "FATHER" or "DRAW" ( ### Constraints - **1** ≤ **T** ≤ **10000** -- ≤ **S** ≤ **130** -- ≤ **SG, FG** ≤ **300** +- 0 ≤ **S** ≤ **130** +- 0 ≤ **SG, FG** ≤ **300** - **1** ≤ **D** ≤ **30** - **1** ≤ **T** ≤ **300** - The other car speed doesn't exceed 300 kph. @@ -117,8 +117,8 @@ For each test case, output a single line containing "SEBI", "FATHER" or "DRAW" ( Output: SEBI FATHER - ### Explanation + **Example case 1.** There are total **20 - 1 = 19** markers in between the Sebi's car and the other car. So, the distance between those cars at time **T** is 20 \* 50 = 1000 meters = 1 km. diff --git a/_problems/school/SEGM01.md b/_problems/school/SEGM01.md index 08384ee7..17c40869 100644 --- a/_problems/school/SEGM01.md +++ b/_problems/school/SEGM01.md @@ -113,8 +113,8 @@ NO YES NO NO - ### Explanation + The answer is "YES" for strings 001111110 and 1111. The answer is "NO" for 00110011 because the '1' digits form two disjoint segments (while they should all be consecutive, with no '0' digits between them). diff --git a/_problems/school/SIMDISH.md b/_problems/school/SIMDISH.md index bf93acf9..cd60988e 100644 --- a/_problems/school/SIMDISH.md +++ b/_problems/school/SIMDISH.md @@ -114,8 +114,8 @@ similar dissimilar similar dissimilar - ### Explanation + **Test case 1.** The first dish consists of ingredients: eggs, sugar, flour, salt, while the second dish consists of: sugar, eggs, milk, flour. Three of four ingredients are present in both dishes (eggs, sugar, flour) so the two dishes are similar. **Test case 2.** This example shows that strings in the input don't necessarily represent real food. The answer is again "similar", because two ingredients are present in both dishes ("ac" and "ad"). diff --git a/_problems/school/SIMPSTAT.md b/_problems/school/SIMPSTAT.md index b063b735..fb4c6407 100644 --- a/_problems/school/SIMPSTAT.md +++ b/_problems/school/SIMPSTAT.md @@ -96,7 +96,7 @@ Your answer will be considered correct, in case it has absolute or relative erro - **1** ≤ **T** ≤ **100** - **1** ≤ **N** ≤ **104** -- ≤ **2K** N +- 0 ≤ **2K** N - **-106** ≤ **Ai** ≤ **106** ### Subtasks @@ -119,8 +119,8 @@ Your answer will be considered correct, in case it has absolute or relative erro 4.000000 5.400000 1.000000 - ### Explanation + **Example case 1.** After removing **1** greatest and **1** lowest measurement, we get the set **{2, 9, 1}**. The average value in this set is **(2+9+1)/3=4**. **Example case 2.** The average value in the set **{2, 9, -10, 25, 1}** is **(2+9-10+25+1)/5=5.4**. diff --git a/_problems/school/SMPAIR.md b/_problems/school/SMPAIR.md index 037f3dff..fb08b9ea 100644 --- a/_problems/school/SMPAIR.md +++ b/_problems/school/SMPAIR.md @@ -101,6 +101,6 @@ For each test case, output a single line containing a single integer - the small Output: 4 - ### Explanation + Here we pick **a2** and **a3**. Their sum equals to 1 + 3 = 4. diff --git a/_problems/school/SMRSTR.md b/_problems/school/SMRSTR.md index caef2086..9991e049 100644 --- a/_problems/school/SMRSTR.md +++ b/_problems/school/SMRSTR.md @@ -112,6 +112,6 @@ For every test case in single line output **Q** integers - for each **Xi** outpu Output: 0 16 1 2 1 -
### Explanation
+
 **Example case 1.** \[\[5 / 2\] / 3\] = 0, \[\[100 / 2\] / 3\] = 16, \[\[8 / 2\] / 3\] = 1
diff --git a/_problems/school/SNAKPROC.md b/_problems/school/SNAKPROC.md
index 8e475731..15f30cbd 100644
--- a/_problems/school/SNAKPROC.md
+++ b/_problems/school/SNAKPROC.md
@@ -116,8 +116,8 @@ Invalid
 Valid
 Invalid
 Invalid
-
 
### Explanation + "H..H..T..T" is invalid because the second snake starts before the first snake ends, which is not allowed. ".T...H..H.T" is invalid because it has a 'T' before a 'H'. A tail can come only after its head. diff --git a/_problems/school/SNAPE.md b/_problems/school/SNAPE.md index 7798d804..6e6ee17d 100644 --- a/_problems/school/SNAPE.md +++ b/_problems/school/SNAPE.md @@ -107,5 +107,4 @@ Output **T** lines, each containing minimum value of **RS** and maximum value of 3.0 6.40312 6.63325 15.6205 17.3205 22.3607 - \ No newline at end of file diff --git a/_problems/school/SNELECT.md b/_problems/school/SNELECT.md index 3c77f0ae..43105ab3 100644 --- a/_problems/school/SNELECT.md +++ b/_problems/school/SNELECT.md @@ -109,8 +109,8 @@ mongooses tie tie snakes - ### Explanation + **Example 1**. The mongoose will eat the snake. Only the mongoose will be left. So, on the election day, there is one mongoose and zero snakes. So mongooses will win. **Example 2**. The mongoose will eat the snake at position 2 (1-based indexing). One mongoose and one snake will be left. Hence, there will be a tie. diff --git a/_problems/school/SPALNUM.md b/_problems/school/SPALNUM.md index 9277cc54..95b610d4 100644 --- a/_problems/school/SPALNUM.md +++ b/_problems/school/SPALNUM.md @@ -102,8 +102,8 @@ For each test case, output a single line containing the sum of all the palindrom 45 272 - ### Explanation + **Example case 1.** The palindromic numbers between **1** and **10** are all numbers except the number **10**. Their sum is 45. **Example case 2.** The palindromic numbers between **123** and **150** are **131** and **141** and their sum is **272**. diff --git a/_problems/school/START01.md b/_problems/school/START01.md index 398f1717..ad852421 100644 --- a/_problems/school/START01.md +++ b/_problems/school/START01.md @@ -43,9 +43,8 @@ Output the answer in a single line.
 123
-
 
### Sample Output +
 123
-
 
\ No newline at end of file diff --git a/_problems/school/STICKS.md b/_problems/school/STICKS.md index e7d8bd65..1fe994dd 100644 --- a/_problems/school/STICKS.md +++ b/_problems/school/STICKS.md @@ -107,8 +107,8 @@ For each test case, output a single line containing an integer representing the Output: 2 -1 - ### Explanation + **Example case 1.** Chef's brother can choose sticks of lengths 1, 2, 1, 2. He can create a rectangle with area 1 \* 2 = 2. **Example case 2.** It's impossible to choose 4 sticks so that they form a rectangle. diff --git a/_problems/school/STRPALIN.md b/_problems/school/STRPALIN.md index cf542fd7..3a441160 100644 --- a/_problems/school/STRPALIN.md +++ b/_problems/school/STRPALIN.md @@ -115,14 +115,14 @@ b abba baab - **Output** +
 Yes
 No
 Yes
-
 
### Explanation + - **Test 1:** One possible way of choosing **s1 & s2** is **s1 = "ab"**, **s2 = "a"** such that **s1 + s2** i.e **"aba"** is a palindrome. - **Test 2:** There is no possible way to choose **s1 & s2** such that **s1 + s2** is a palindrome. - **Test 3:** You can figure it out yourself. diff --git a/_problems/school/STUDVOTE.md b/_problems/school/STUDVOTE.md index 2fc8f0b7..48ca78d6 100644 --- a/_problems/school/STUDVOTE.md +++ b/_problems/school/STUDVOTE.md @@ -114,8 +114,8 @@ For each test case, output a single line containing an integer corresponding to Output: 1 0 - ### Explanation + In **first test case**, there are **3** students. A student must receive at least **2**votes to be part of the student government. Student **1** votes for student **2**, student **2** votes for student **1** and student **3** votes for student **2**. Thus, Student **2** receives **2** votes and is the only one eligible for student government. -In **second test case**, although both students receive the required amount of votes, they are both disqualified as they had voted for themselves. Thus, size of the student government is . +In **second test case**, although both students receive the required amount of votes, they are both disqualified as they had voted for themselves. Thus, size of the student government is 0. diff --git a/_problems/school/SUBINC.md b/_problems/school/SUBINC.md index b258949d..c90a9022 100644 --- a/_problems/school/SUBINC.md +++ b/_problems/school/SUBINC.md @@ -113,8 +113,8 @@ For each test case, output in a single line the required answer. Output: 6 1 - ### Explanation + **Example case 1.** All valid subarrays are **A\[1, 1\], A\[1, 2\], A\[2, 2\], A\[3, 3\], A\[3, 4\], A\[4, 4\]**. Note that singleton subarrays are identically non-decreasing. diff --git a/_problems/school/SUMTRIAN.md b/_problems/school/SUMTRIAN.md index a6b514d6..6fa54ca1 100644 --- a/_problems/school/SUMTRIAN.md +++ b/_problems/school/SUMTRIAN.md @@ -97,5 +97,5 @@ For each test case write the determined value in a separate line. Output: 5 9 - -**Warning: large Input/Output data, be careful with certain languages** + +**Warning: large Input/Output data, be careful with certain languages** diff --git a/_problems/school/TALAZY.md b/_problems/school/TALAZY.md index e97d1f12..0c6b3008 100644 --- a/_problems/school/TALAZY.md +++ b/_problems/school/TALAZY.md @@ -104,8 +104,8 @@ For each test case output a single line containing an integer represent how much Output: 45 131351258112 - ### Explanation + In the first test case, Jem will proceed as below: - Initially, Jem has 9 problems to solve. since it is an odd number, Jem will finish the first (9 + 1) / 2 = 5 problems with speed of 2 minutes/problem. diff --git a/_problems/school/TEAMFORM.md b/_problems/school/TEAMFORM.md index cc376e7d..e936cf13 100644 --- a/_problems/school/TEAMFORM.md +++ b/_problems/school/TEAMFORM.md @@ -113,8 +113,8 @@ yes yes no no - ### Explanation + **Example 1**. Persons 1 and 2 have already formed the team. No other person is left. So, the answer is yes. **Example 2**. Persons 1 and 3 have already formed the team. Persons 2 and 4 can form their own team. No other person is left. So, the answer is yes. diff --git a/_problems/school/TEMPLELA.md b/_problems/school/TEMPLELA.md index 9dd6d425..e2c450c8 100644 --- a/_problems/school/TEMPLELA.md +++ b/_problems/school/TEMPLELA.md @@ -123,8 +123,8 @@ no yes no no - ### Explanation + In the first strip, all the conditions are satisfied, hence it is valid. In the second strip, it does not start with a 1, and hence is invalid. diff --git a/_problems/school/TEST.md b/_problems/school/TEST.md index 2b906c87..91610f78 100644 --- a/_problems/school/TEST.md +++ b/_problems/school/TEST.md @@ -92,5 +92,4 @@ Your program is to use the brute-force approach in order to _find the Answer to 1 2 88 - \ No newline at end of file diff --git a/_problems/school/TICKETS5.md b/_problems/school/TICKETS5.md index 6db758f2..d34d7b21 100644 --- a/_problems/school/TICKETS5.md +++ b/_problems/school/TICKETS5.md @@ -112,5 +112,4 @@ ABC Output: YES NO - \ No newline at end of file diff --git a/_problems/school/TLG.md b/_problems/school/TLG.md index a00899b8..3e019476 100644 --- a/_problems/school/TLG.md +++ b/_problems/school/TLG.md @@ -83,8 +83,8 @@ Consider the following score sheet for a game with 5 rounds: 3 90 110 4 112 106 5 88 90 - The total scores of both players, the leader and the lead after each round for this game is given below: +
     Round      Player 1       Player 2     Leader     Lead
 
@@ -93,8 +93,8 @@ Consider the following score sheet for a game with 5 rounds:
       3               319           	326       Player 2      7
       4               431           	432       Player 2      1
       5               519           	522       Player 2      3
-
 
The winner of this game is Player 1 as he had the maximum lead (58 at the end of round 1) during the game. + Your task is to help the Manager find the winner and the winning lead. You may assume that the scores will be such that there will always be a single winner. That is, there are no ties. Input @@ -116,9 +116,8 @@ Input: 90 110 112 106 88 90 -
Output: +
 1 58
-
 
\ No newline at end of file diff --git a/_problems/school/TRICOIN.md b/_problems/school/TRICOIN.md index c2aef640..f460c893 100644 --- a/_problems/school/TRICOIN.md +++ b/_problems/school/TRICOIN.md @@ -119,8 +119,8 @@ For each test case, output a single line containing an integer corresponding to 2 2 3 - ### Explanation + - **Test 1:** Chef can't form a triangle with height > 2 as it requires atleast 6 gold coins. - **Test 2:** Chef can't form a triangle with height > 2 as it requires atleast 6 gold coins. - **Test 3:** Chef can't form a triangle with height > 3 as it requires atleast 10 gold coins. diff --git a/_problems/school/TRISQ.md b/_problems/school/TRISQ.md index ceba1184..c7bde35f 100644 --- a/_problems/school/TRISQ.md +++ b/_problems/school/TRISQ.md @@ -119,5 +119,4 @@ Output exactly T lines, each line containing the required answer. 6 10 10 - \ No newline at end of file diff --git a/_problems/school/TSORT.md b/_problems/school/TSORT.md index f7e831d7..8e7fd395 100644 --- a/_problems/school/TSORT.md +++ b/_problems/school/TSORT.md @@ -82,13 +82,12 @@ Output given numbers in non decreasing order. 6 7 1 - **Output:** +
 1
 3
 5
 6
 7
-
 
\ No newline at end of file diff --git a/_problems/school/TTENIS.md b/_problems/school/TTENIS.md index 34857e05..e345cb04 100644 --- a/_problems/school/TTENIS.md +++ b/_problems/school/TTENIS.md @@ -94,8 +94,8 @@ For each test case, output on a separate line a string describing who won the ma Output: WIN LOSE - ### Explanation + **Example case 1.** Chef won the match 11:2, his opponent won just two points, the first and the third of the match. **Example case 2.** Chef lost this match 11:3, however he started very well the match, he won the first three points in a row, but maybe he got tired and after that lost 11 points in a row. diff --git a/_problems/school/TWEED.md b/_problems/school/TWEED.md index 38587bd7..f0ea35bc 100644 --- a/_problems/school/TWEED.md +++ b/_problems/school/TWEED.md @@ -106,6 +106,6 @@ For each test case, output a single line containing either "Dee" if Twedle-Dee w Output: Dum - ### Explanation + Tweedle-Dee takes two stones from any of the heaps leaving just one non empty heap, next Tweedle-Dum takes one stone and the game finishes. diff --git a/_problems/school/TWONMS.md b/_problems/school/TWONMS.md index a185ca87..cc83a570 100644 --- a/_problems/school/TWONMS.md +++ b/_problems/school/TWONMS.md @@ -109,8 +109,8 @@ For each test case output a new line with a single integer which should be the a 1 3 2 - ### Explanation + In the first testcase, the initial numbers are (**A** = 1, **B** = 2). There is only one turn. In this turn Alice multiplies her number by 2. Hence, we get (**A** = 2, **B** = 2). Therefore **C** = 2, and **D** = 2. max(**C**, **D**)/min(**C**, **D**) = 2/2 = 1. Hence the first output is 1. In the second testcase, the initial numbers are (**A** = 3, **B** = 2). There three turns. In the first turn Alice multiplies her number by 2. Hence, we get (**A** = 6, **B** = 2). In the second turn Bob multiplies his number by 2. Hence, we get (**A** = 6, **B** = 4). In the third turn Alice multiplies her number by 2. Hence, we get (**A** = 12, **B** = 4). Therefore **C** = 12, and **D** = 4. max(**C**, **D**)/min(**C**, **D**) = 12/4 = 3. Hence the second output is 3. diff --git a/_problems/school/TWOSTR.md b/_problems/school/TWOSTR.md index 6a7764e0..15b9de3d 100644 --- a/_problems/school/TWOSTR.md +++ b/_problems/school/TWOSTR.md @@ -102,8 +102,8 @@ sco?? Output: Yes No - ### Explanation + **First Example:** There are several ways the two strings can be matched, one of those is "score". **Second Example:** There is no way to match the strings. diff --git a/_problems/school/UTMOPR.md b/_problems/school/UTMOPR.md index 55e53f78..7b73d7da 100644 --- a/_problems/school/UTMOPR.md +++ b/_problems/school/UTMOPR.md @@ -103,10 +103,9 @@ Thus, at the end of the **K** operations, the array will have **N** + **K** elem 1 2 3 5 7 - **Sample Output:** +
 even
 
-
 
\ No newline at end of file diff --git a/_problems/school/VCS.md b/_problems/school/VCS.md index eb9d3bcf..ea46c125 100644 --- a/_problems/school/VCS.md +++ b/_problems/school/VCS.md @@ -118,8 +118,8 @@ For each test case, output a single line containing two integers: the number of 4 1 1 1 - ### Explanation + In the first test case, the source files {1, 4, 6, 7} are both tracked and ignored, the source file {5} is both untracked and unignored. In the second test case, the source file {4} is both tracked and ignored, the source file {2} is both untracked and unignored. diff --git a/_problems/school/VILTRIBE.md b/_problems/school/VILTRIBE.md index 82f483f6..056e6439 100644 --- a/_problems/school/VILTRIBE.md +++ b/_problems/school/VILTRIBE.md @@ -113,5 +113,4 @@ A....A 1 0 6 0 0 7 - \ No newline at end of file diff --git a/_problems/school/WDTBAM.md b/_problems/school/WDTBAM.md index 9c85f8b3..3590db40 100644 --- a/_problems/school/WDTBAM.md +++ b/_problems/school/WDTBAM.md @@ -76,7 +76,7 @@ Chef is going to participate in a new quiz show: "Who dares to be a millionaire? According to the rules of the game, contestants must answer **N** questions. The quiz being famous for its difficulty, each question has **26** candidate answers, but only one of which is correct. Answers are denoted by capital Latin letters from A to Z. Chef knows all the questions that can be asked, and for each of them he knows the answer candidate he will choose (some of them can be incorrect). For each question, we'll tell you Chef's answer to it. -The game goes on as follows. First, all the questions are shuffled randomly. Then, a contestant is asked these questions one-by-one in the new shuffled order. If the contestant answers any question incorrectly, the game is over. Total winnings of the contestant are calculated as follows. Let **X** denote the number of questions answered correctly by the contestant. Depending on this value, the winnings are determined: **W0** dollars is the amount won for **X = 0**, **W1** dollars is for **X = 1**, and so on till **X = N**. Note that the game was invented by a twisted mind, and so a case where **Wi** ≥ **Wi + 1** for some ≤ **i** ≤ **N − 1** is possible. Chef is interested in finding the maximum possible winnings that he can amass. +The game goes on as follows. First, all the questions are shuffled randomly. Then, a contestant is asked these questions one-by-one in the new shuffled order. If the contestant answers any question incorrectly, the game is over. Total winnings of the contestant are calculated as follows. Let **X** denote the number of questions answered correctly by the contestant. Depending on this value, the winnings are determined: **W0** dollars is the amount won for **X = 0**, **W1** dollars is for **X = 1**, and so on till **X = N**. Note that the game was invented by a twisted mind, and so a case where **Wi** ≥ **Wi + 1** for some 0 ≤ **i** ≤ **N − 1** is possible. Chef is interested in finding the maximum possible winnings that he can amass. ### Input @@ -88,7 +88,7 @@ Next line contains **N** capital Latin letters denoting the correct answers to t Next line contains **N** capital Latin letters denoting answers given by Chef to these questions. -Next line contains **N + 1** space-separated integers **W0**, **W1**, ..., **WN** denoting the winnings for , **1**, ..., **N** correct answers. +Next line contains **N + 1** space-separated integers **W0**, **W1**, ..., **WN** denoting the winnings for 0, **1**, ..., **N** correct answers. ### Output @@ -98,7 +98,7 @@ For each test case, output a single line containing the value of maximum possibl - **1** ≤ **T** ≤ **500** - **1** ≤ **N** ≤ **1000** -- ≤ **Wi** ≤ **109** +- 0 ≤ **Wi** ≤ **109** ### Subtasks @@ -132,8 +132,8 @@ ABABABAB 4 100 - ### Explanation + **Example case 1.** If questions will be placed in order: **2nd** (Chef's answer is B, which is correct), **3rd** (Chef's answer is C, and it is correct as well), **4th** (Chef's answer is D, and he is right), **5th** (Chef's answer is A but correct answer is E and the game is over), **1st**, Chef will correctly answer **3** questions, and therefore win **30** dollars. **Example case 2.** Chef's answers for all questions are incorrect, so his winnings are **W0** dollars. diff --git a/_problems/school/XENTASK.md b/_problems/school/XENTASK.md index ca2454d8..39f1b29f 100644 --- a/_problems/school/XENTASK.md +++ b/_problems/school/XENTASK.md @@ -116,8 +116,8 @@ For each testcase, print a single line containing the minimum total time in seco Output: 5 - ### Explanation + Let's say Xenny does the 1st task. Then Yana would do the 2nd task and Xenny would do the 3rd task. Hence, the total time taken would be: 2 + 2 + 2 = 6 seconds. Another possibility is that Yana does the 1st task, Xenny does the 2nd task and then Yana does the 3rd task. The total time taken in this case would be 5 seconds. diff --git a/composer.lock b/composer.lock index 87b93186..498ae39e 100644 --- a/composer.lock +++ b/composer.lock @@ -1,37 +1,37 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "bc39c5a624eadba37ac6d410d93fb3a6", "packages": [ { "name": "consolidation/annotated-command", - "version": "2.4.8", + "version": "2.8.3", "source": { "type": "git", "url": "https://github.com/consolidation/annotated-command.git", - "reference": "6672ea38212f8bffb71fec7eadc8b3372154b17e" + "reference": "8f8f5da2ca06fbd3a85f7d551c49f844b7c59437" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/6672ea38212f8bffb71fec7eadc8b3372154b17e", - "reference": "6672ea38212f8bffb71fec7eadc8b3372154b17e", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/8f8f5da2ca06fbd3a85f7d551c49f844b7c59437", + "reference": "8f8f5da2ca06fbd3a85f7d551c49f844b7c59437", "shasum": "" }, "require": { - "consolidation/output-formatters": "^3.1.5", + "consolidation/output-formatters": "^3.1.12", "php": ">=5.4.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", "psr/log": "^1", - "symfony/console": "^2.8|~3", - "symfony/event-dispatcher": "^2.5|^3", - "symfony/finder": "^2.5|^3" + "symfony/console": "^2.8|^3|^4", + "symfony/event-dispatcher": "^2.5|^3|^4", + "symfony/finder": "^2.5|^3|^4" }, "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", "phpunit/phpunit": "^4.8", - "satooshi/php-coveralls": "^1.0", + "satooshi/php-coveralls": "^1.0.2 | dev-master", "squizlabs/php_codesniffer": "^2.7" }, "type": "library", @@ -56,29 +56,84 @@ } ], "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2017-04-03T22:37:00+00:00" + "time": "2018-02-23T16:32:04+00:00" + }, + { + "name": "consolidation/config", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/consolidation/config.git", + "reference": "34ca8d7c1ee60a7b591b10617114cf1210a2e92c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/config/zipball/34ca8d7c1ee60a7b591b10617114cf1210a2e92c", + "reference": "34ca8d7c1ee60a7b591b10617114cf1210a2e92c", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "grasmash/expander": "^1", + "php": ">=5.4.0" + }, + "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", + "phpunit/phpunit": "^4", + "satooshi/php-coveralls": "^1.0", + "squizlabs/php_codesniffer": "2.*", + "symfony/console": "^2.5|^3|^4", + "symfony/yaml": "^2.8.11|^3|^4" + }, + "suggest": { + "symfony/yaml": "Required to use Consolidation\\Config\\Loader\\YamlConfigLoader" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\Config\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Provide configuration services for a commandline tool.", + "time": "2017-12-22T17:28:19+00:00" }, { "name": "consolidation/log", - "version": "1.0.3", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/consolidation/log.git", - "reference": "74ba81b4edc585616747cc5c5309ce56fec41254" + "reference": "dbc7c535f319a4a2d5a5077738f8eb7c10df8821" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/log/zipball/74ba81b4edc585616747cc5c5309ce56fec41254", - "reference": "74ba81b4edc585616747cc5c5309ce56fec41254", + "url": "https://api.github.com/repos/consolidation/log/zipball/dbc7c535f319a4a2d5a5077738f8eb7c10df8821", + "reference": "dbc7c535f319a4a2d5a5077738f8eb7c10df8821", "shasum": "" }, "require": { "php": ">=5.5.0", "psr/log": "~1.0", - "symfony/console": "~2.5|~3.0" + "symfony/console": "^2.8|^3|^4" }, "require-dev": { "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "dev-master", "squizlabs/php_codesniffer": "2.*" }, "type": "library", @@ -103,37 +158,43 @@ } ], "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", - "time": "2016-03-23T23:46:42+00:00" + "time": "2017-11-29T01:44:16+00:00" }, { "name": "consolidation/output-formatters", - "version": "3.1.8", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/consolidation/output-formatters.git", - "reference": "0b50ba1134d581fd55376f3e21508dab009ced47" + "reference": "da889e4bce19f145ca4ec5b1725a946f4eb625a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/0b50ba1134d581fd55376f3e21508dab009ced47", - "reference": "0b50ba1134d581fd55376f3e21508dab009ced47", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/da889e4bce19f145ca4ec5b1725a946f4eb625a9", + "reference": "da889e4bce19f145ca4ec5b1725a946f4eb625a9", "shasum": "" }, "require": { "php": ">=5.4.0", - "symfony/console": "^2.8|~3", - "symfony/finder": "~2.5|~3.0" + "symfony/console": "^2.8|^3|^4", + "symfony/finder": "^2.5|^3|^4" }, "require-dev": { - "phpunit/phpunit": "^4.8", - "satooshi/php-coveralls": "^1.0", + "g-1-a/composer-test-scenarios": "^2", + "phpunit/phpunit": "^5.7.27", + "satooshi/php-coveralls": "^2", "squizlabs/php_codesniffer": "^2.7", + "symfony/console": "3.2.3", + "symfony/var-dumper": "^2.8|^3|^4", "victorjonsson/markdowndocs": "^1.3" }, + "suggest": { + "symfony/var-dumper": "For using the var_dump formatter" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { @@ -152,54 +213,57 @@ } ], "description": "Format text by applying transformations provided by plug-in formatters.", - "time": "2017-03-01T20:54:45+00:00" + "time": "2018-03-20T15:18:32+00:00" }, { "name": "consolidation/robo", - "version": "1.0.6", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/consolidation/Robo.git", - "reference": "de6225256b2ed88822af1cd8cc3a01bf933add8c" + "reference": "54a13e268917b92576d75e10dca8227b95a574d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/Robo/zipball/de6225256b2ed88822af1cd8cc3a01bf933add8c", - "reference": "de6225256b2ed88822af1cd8cc3a01bf933add8c", + "url": "https://api.github.com/repos/consolidation/Robo/zipball/54a13e268917b92576d75e10dca8227b95a574d9", + "reference": "54a13e268917b92576d75e10dca8227b95a574d9", "shasum": "" }, "require": { - "consolidation/annotated-command": "^2.2", + "consolidation/annotated-command": "^2.8.2", + "consolidation/config": "^1.0.1", "consolidation/log": "~1", - "consolidation/output-formatters": "^3.1.5", - "dflydev/dot-access-data": "^1.1.0", - "grasmash/yaml-expander": "^1.1", + "consolidation/output-formatters": "^3.1.13", + "grasmash/yaml-expander": "^1.3", "league/container": "^2.2", "php": ">=5.5.0", - "squizlabs/php_codesniffer": "^2.8", - "symfony/console": "~2.8|~3.0", - "symfony/event-dispatcher": "~2.5|~3.0", - "symfony/filesystem": "~2.5|~3.0", - "symfony/finder": "~2.5|~3.0", - "symfony/process": "~2.5|~3.0" + "symfony/console": "^2.8|^3|^4", + "symfony/event-dispatcher": "^2.5|^3|^4", + "symfony/filesystem": "^2.5|^3|^4", + "symfony/finder": "^2.5|^3|^4", + "symfony/process": "^2.5|^3|^4" }, "replace": { "codegyre/robo": "< 1.0" }, "require-dev": { - "codeception/aspect-mock": "~1", - "codeception/base": "^2.2.6", + "codeception/aspect-mock": "^1|^2.1.1", + "codeception/base": "^2.3.7", "codeception/verify": "^0.3.2", - "henrikbjorn/lurker": "~1", - "natxet/cssmin": "~3", + "g-1-a/composer-test-scenarios": "^2", + "goaop/framework": "~2.1.2", + "goaop/parser-reflection": "^1.1.0", + "natxet/cssmin": "3.0.4", + "nikic/php-parser": "^3.1.5", "patchwork/jsqueeze": "~2", "pear/archive_tar": "^1.4.2", "phpunit/php-code-coverage": "~2|~4", - "satooshi/php-coveralls": "~1" + "satooshi/php-coveralls": "^2", + "squizlabs/php_codesniffer": "^2.8" }, "suggest": { "henrikbjorn/lurker": "For monitoring filesystem changes in taskWatch", - "natxet/CssMin": "For minifying JS files in taskMinify", + "natxet/CssMin": "For minifying CSS files in taskMinify", "patchwork/jsqueeze": "For minifying JS files in taskMinify", "pear/archive_tar": "Allows tar archives to be created and extracted in taskPack and taskExtract, respectively." }, @@ -209,13 +273,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "1.x-dev", + "dev-state": "1.x-dev" } }, "autoload": { - "classmap": [ - "scripts/composer/ScriptHandler.php" - ], "psr-4": { "Robo\\": "src" } @@ -231,7 +293,7 @@ } ], "description": "Modern task runner", - "time": "2017-03-31T18:23:36+00:00" + "time": "2018-04-06T05:27:37+00:00" }, { "name": "container-interop/container-interop", @@ -323,29 +385,76 @@ ], "time": "2017-01-20T21:14:22+00:00" }, + { + "name": "grasmash/expander", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/grasmash/expander.git", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/grasmash/expander/zipball/95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "php": ">=5.4" + }, + "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", + "phpunit/phpunit": "^4|^5.5.4", + "satooshi/php-coveralls": "^1.0.2|dev-master", + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Grasmash\\Expander\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Grasmick" + } + ], + "description": "Expands internal property references in PHP arrays file.", + "time": "2017-12-21T22:14:55+00:00" + }, { "name": "grasmash/yaml-expander", - "version": "1.1.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/grasmash/yaml-expander.git", - "reference": "95f9c876ca31f31bf5bfd9c8e89cc1f065c45528" + "reference": "3f0f6001ae707a24f4d9733958d77d92bf9693b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/grasmash/yaml-expander/zipball/95f9c876ca31f31bf5bfd9c8e89cc1f065c45528", - "reference": "95f9c876ca31f31bf5bfd9c8e89cc1f065c45528", + "url": "https://api.github.com/repos/grasmash/yaml-expander/zipball/3f0f6001ae707a24f4d9733958d77d92bf9693b1", + "reference": "3f0f6001ae707a24f4d9733958d77d92bf9693b1", "shasum": "" }, "require": { "dflydev/dot-access-data": "^1.1.0", "php": ">=5.4", - "symfony/console": "^2.8.11|^3", - "symfony/yaml": "^2.8.11|^3" + "symfony/yaml": "^2.8.11|^3|^4" }, "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", "phpunit/phpunit": "^4.8|^5.5.4", - "satooshi/php-coveralls": "^1.0", + "satooshi/php-coveralls": "^1.0.2|dev-master", "squizlabs/php_codesniffer": "^2.7" }, "type": "library", @@ -369,7 +478,7 @@ } ], "description": "Expands internal property references in a yaml file.", - "time": "2017-03-24T20:31:04+00:00" + "time": "2017-12-16T16:06:03+00:00" }, { "name": "kzykhys/yaml-front-matter", @@ -415,16 +524,16 @@ }, { "name": "league/container", - "version": "2.4.0", + "version": "2.4.1", "source": { "type": "git", "url": "https://github.com/thephpleague/container.git", - "reference": "5ec434f4760d83c2a479266b618fb3e3be24c974" + "reference": "43f35abd03a12977a60ffd7095efd6a7808488c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/container/zipball/5ec434f4760d83c2a479266b618fb3e3be24c974", - "reference": "5ec434f4760d83c2a479266b618fb3e3be24c974", + "url": "https://api.github.com/repos/thephpleague/container/zipball/43f35abd03a12977a60ffd7095efd6a7808488c0", + "reference": "43f35abd03a12977a60ffd7095efd6a7808488c0", "shasum": "" }, "require": { @@ -476,20 +585,20 @@ "provider", "service" ], - "time": "2017-03-06T15:24:06+00:00" + "time": "2017-05-10T09:20:27+00:00" }, { "name": "league/html-to-markdown", - "version": "4.4.1", + "version": "4.6.2", "source": { "type": "git", "url": "https://github.com/thephpleague/html-to-markdown.git", - "reference": "82ea375b5b2b1da1da222644c0565c695bf88186" + "reference": "3af14d8f44838257a75822819784e83819b34e2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/82ea375b5b2b1da1da222644c0565c695bf88186", - "reference": "82ea375b5b2b1da1da222644c0565c695bf88186", + "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/3af14d8f44838257a75822819784e83819b34e2e", + "reference": "3af14d8f44838257a75822819784e83819b34e2e", "shasum": "" }, "require": { @@ -508,7 +617,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.5-dev" + "dev-master": "4.7-dev" } }, "autoload": { @@ -540,153 +649,7 @@ "html", "markdown" ], - "time": "2017-03-16T00:45:59+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2015-12-27T11:43:31+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "shasum": "" - }, - "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30T07:12:33+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.2.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "shasum": "" - }, - "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "time": "2016-11-25T06:54:22+00:00" + "time": "2018-01-07T19:45:06+00:00" }, { "name": "psr/container", @@ -784,84 +747,6 @@ ], "time": "2016-10-10T12:19:37+00:00" }, - { - "name": "squizlabs/php_codesniffer", - "version": "2.8.1", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "bin": [ - "scripts/phpcs", - "scripts/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2017-03-01T22:17:45+00:00" - }, { "name": "sunra/php-simple-html-dom-parser", "version": "v1.5.2", @@ -912,39 +797,44 @@ }, { "name": "symfony/console", - "version": "v3.2.7", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c30243cc51f726812be3551316b109a2f5deaf8d" + "reference": "3e820bc2c520a87ca209ad8fa961c97f42e0b4ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c30243cc51f726812be3551316b109a2f5deaf8d", - "reference": "c30243cc51f726812be3551316b109a2f5deaf8d", + "url": "https://api.github.com/repos/symfony/console/zipball/3e820bc2c520a87ca209ad8fa961c97f42e0b4ae", + "reference": "3e820bc2c520a87ca209ad8fa961c97f42e0b4ae", "shasum": "" }, "require": { - "php": ">=5.5.9", - "symfony/debug": "~2.8|~3.0", + "php": "^7.1.3", "symfony/polyfill-mbstring": "~1.0" }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" }, "suggest": { - "psr/log": "For using the console logger", + "psr/log-implementation": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -971,88 +861,34 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-04-04T14:33:42+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.2.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "56f613406446a4a0a031475cfd0a01751de22659" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/56f613406446a4a0a031475cfd0a01751de22659", - "reference": "56f613406446a4a0a031475cfd0a01751de22659", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/class-loader": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2017-03-28T21:38:24+00:00" + "time": "2018-04-30T01:23:47+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.2.7", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "154bb1ef7b0e42ccc792bd53edbce18ed73440ca" + "reference": "63353a71073faf08f62caab4e6889b06a787f07b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/154bb1ef7b0e42ccc792bd53edbce18ed73440ca", - "reference": "154bb1ef7b0e42ccc792bd53edbce18ed73440ca", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/63353a71073faf08f62caab4e6889b06a787f07b", + "reference": "63353a71073faf08f62caab4e6889b06a787f07b", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.1.3" + }, + "conflict": { + "symfony/dependency-injection": "<3.4" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/expression-language": "~3.4|~4.0", + "symfony/stopwatch": "~3.4|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -1061,7 +897,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1088,29 +924,29 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-04-04T07:26:27+00:00" + "time": "2018-04-06T07:35:43+00:00" }, { "name": "symfony/filesystem", - "version": "v3.2.7", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "64421e6479c4a8e60d790fb666bd520992861b66" + "reference": "5d2d655b2c72fc4d9bf7e9bf14f72a447b940f21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/64421e6479c4a8e60d790fb666bd520992861b66", - "reference": "64421e6479c4a8e60d790fb666bd520992861b66", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/5d2d655b2c72fc4d9bf7e9bf14f72a447b940f21", + "reference": "5d2d655b2c72fc4d9bf7e9bf14f72a447b940f21", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1137,29 +973,29 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-03-26T15:47:15+00:00" + "time": "2018-02-22T10:50:29+00:00" }, { "name": "symfony/finder", - "version": "v3.2.7", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "b20900ce5ea164cd9314af52725b0bb5a758217a" + "reference": "ca27c02b7a3fef4828c998c2ff9ba7aae1641c49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/b20900ce5ea164cd9314af52725b0bb5a758217a", - "reference": "b20900ce5ea164cd9314af52725b0bb5a758217a", + "url": "https://api.github.com/repos/symfony/finder/zipball/ca27c02b7a3fef4828c998c2ff9ba7aae1641c49", + "reference": "ca27c02b7a3fef4828c998c2ff9ba7aae1641c49", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1186,20 +1022,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-03-20T09:32:19+00:00" + "time": "2018-04-04T05:10:37+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.3.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + "reference": "3296adf6a6454a050679cde90f95350ad604b171" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", + "reference": "3296adf6a6454a050679cde90f95350ad604b171", "shasum": "" }, "require": { @@ -1211,7 +1047,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -1245,29 +1081,29 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/process", - "version": "v3.2.7", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "57fdaa55827ae14d617550ebe71a820f0a5e2282" + "reference": "d7dc1ee5dfe9f732cb1bba7310f5b99f2b7a6d25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/57fdaa55827ae14d617550ebe71a820f0a5e2282", - "reference": "57fdaa55827ae14d617550ebe71a820f0a5e2282", + "url": "https://api.github.com/repos/symfony/process/zipball/d7dc1ee5dfe9f732cb1bba7310f5b99f2b7a6d25", + "reference": "d7dc1ee5dfe9f732cb1bba7310f5b99f2b7a6d25", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1294,27 +1130,30 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-03-27T18:07:02+00:00" + "time": "2018-04-03T05:24:00+00:00" }, { "name": "symfony/yaml", - "version": "v3.2.7", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" + "reference": "275ad099e4cbe612a2acbca14a16dd1c5311324d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", - "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "url": "https://api.github.com/repos/symfony/yaml/zipball/275ad099e4cbe612a2acbca14a16dd1c5311324d", + "reference": "275ad099e4cbe612a2acbca14a16dd1c5311324d", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^7.1.3" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -1322,7 +1161,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1349,57 +1188,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-03-20T09:45:15+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-04-08T08:49:08+00:00" } ], "packages-dev": [],