IahubistrainingfortheIOI.WhatisabetterwaytotrainthanplayingaZuma-likegame?Thereare n ballsputinarow.Eachballiscoloredinoneof k colors.Initiallytherowdoesn'tcontainthreeormorecontiguousballswiththesamecolor.Iahubhasasingleballofcolor x.Hecaninserthisballatanypositionintherow(probably,betweentwootherballs).Ifatanymomenttherearethreeormorecontiguousballsofthesamecolorintherow,theyare...
Iahubisn'twellpreparedongeometryproblems,butheheardthatthisyeartherewillbealotofgeometryproblemsontheIOIselectioncamp.Scared,Iahublockedhimselfinthebasementandstartedthinkingofnewproblemsofthiskind.Oneofthemisthefollowing.Iahubwantstodraw n distinctpointsand m segmentsonthe OX axis.Hecandraweachpointwitheitherredorblue.Thedrawingisgoodifandonlyifthefollowingrequirementismet:forea...
Thepolicedepartmentofyourcityhasjuststarteditsjourney.Initially,theydon’thaveanymanpower.So,theystartedhiringnewrecruitsingroups.Meanwhile,crimeskeepsoccurringwithinthecity.Onememberofthepoliceforcecaninvestigateonlyonecrimeduringhis/herlifetime.Ifthereisnopoliceofficerfree(isn'tbusywithcrime)duringtheoccurrenceofacrime,itwillgountreated.Giventhechronologicalorderofcrimeoccurrencesandrecru...
Serejahaspainted n distinctpointsontheplane.Thecoordinatesofeachpointareintegers.Nowheiswondering:howmanysquaresaretherewithsidesparalleltothecoordinateaxesandwithpointspaintedinallitsfourvertexes?Helphim,calculatethisnumber.InputThefirstlinecontainsinteger n (1 ≤ n ≤ 105).Eachofthenext n linescontainstwointegers xi, yi (0 ≤ xi, yi ≤ 105),theintegersrepresentthecoordin...
Asusual,Serejahasarray a,itselementsareintegers: a[1], a[2], ..., a[n].Let'sintroducenotation:Aswapoperationisthefollowingsequenceofactions:choosetwoindexes i, j (i ≠ j);performassignments tmp = a[i], a[i] = a[j], a[j] = tmp.Whatmaximumvalueoffunction m(a) canSerejagetifheisallowedtoperformatmost k swapoperations?InputThefirstlinecontainstwointegers n and k (1 ...
近期评论