Olympiads in Informatics, 2016, Vol. 10, 87–98 87 © 2016 IOI, Vilnius University DOI: 10.15388/ioi.2016.06

Understanding Unsolvable Problem

Jonathan Irvin GUNAWAN Undergraduate Student School of Computing, National University of Singapore Computing 1, 13 Computing Drive, Singapore 117417 e-mail: [email protected]

Abstract. In recent IOIs, there are several problems that seem unsolvable, until we realise that there is a special case to the problem that makes it tractable. In IOI 2014, the problem ‘Friend’ appears to be a standard NP-hard Maximum Independent Set problem. However, the graph is gen- erated in a very special way, hence there is a way to solve the problem in polynomial time. There were several contestants who didn’t identify the special case in this problem, and hence were stuck at the problem. In this paper, we will study a well-known technique called reduction to show that a problem we are currently tackling is intractable. In addition, we introduce techniques to identify special cases such that contestants will be prepared to tackle these problems. Keywords: special case, unsolvable, NP-hard.

1. Introduction

The problem ‘Friend’ in IOI 2014 required contestants to find a set of vertices with maxi- mum total weight, such that no two vertices in the set are sharing a common edge. This is a classical Weighted Maximum Independent Set problem. We can show that Weight- ed Maximum Independent Set problem is NP-hard by reduction from 3-SAT (Cormen et al., 2009). Since the formulation of NP-completeness 4 decades ago, no one has been able to propose a solution to any NP-hard problem in polynomial time. Clearly, it is not expected that a high school student can solve the problem in 5 hours. None of the Indo- nesian IOI 2014 team solved this problem during the contest. After returning from the competition, I asked the Indonesian team about this problem. None of the team members were aware of the fact that Maximum Independent Set is an NP-hard problem, and thus were stuck trying to solve a general Maximum Independent Set problem. A similar problem also occurred in IOI 2008. The problem ‘Island’ required contes- tants to find a longest path in a graph with 1,000,000 vertices. The longest path problem is a classic NP-hard problem which can be reduced from the Hamiltonian path problem. If a contestant is not aware that the longest path problem is difficult to solve, the con- testant may spend a lot of his/her time just to tackle the general longest path problem, without realising that there is a special case to the given graph. 88 J.I. Gunawan

Generally, some contestants spend too much thinking time trying to solve something that is believed to be unsolvable. If only they realise that their attempt is intractable, they may try a different approach and find a special case of this problem. In section 2 of this paper, we will introduce a classic reduction technique often used in theoretical research. In the context of , we may find out that a problem which we are attempting is unlikely to be solvable. After realizing that a problem is intractable, we are going to discuss how to proceed to solve the problem in section 3. Finally, in section 4 we will take a look at some common special cases in competitive programming that can be used to solve these kind of problems.

Fig. 1. The result of Indonesian team in IOI 2014, taken from http://stats.ioinformat- ics.org. The red squared column highlights the ‘Friend’ problem.

Fig. 2. IOI 2014 tasks statistics, taken from http://stats.ioinformatics.org. ‘Friend’ problem is the second least accepted problem in IOI 2014. It may be because some contes- tants (at least all the Indonesians) were stuck at trying to solve a general case of Maximum Independent Set.

Fig. 3. The result of Indonesian team in IOI 2008, taken from http://stats.ioinformat- ics.org. The red squared column highlights the ‘Island’ problem. Understanding Unsolvable Problem 89

2. Identifying Intractability of a Problem through Reduction 22 Identifying Identifying Intractability Intractability of of a a Problem Problem through through Reduction Reduction 22 Identifying Identifying Intractability Intractability2 Identifying2 Identifying of of Intractability a a Problem Problem Intractability through through of a Problem Reduction Reduction of a through Problem Reduction through Reduction 2 Identifying Intractability2 Identifying of a2 Problem Identifying2 Intractability Identifying through IntractabilityWe would Intractability of Reduction22 alike Identifying ProblemIdentifying to know that of the a through of problem Problem Intractability Intractability a Problem that we Reduction throughare attempting through of of is Reduction aunlikely a Problem Problem Reduction to have an through through Reduction Reduction 2 Identifying Intractability22 Identifying Identifying of Intractability Intractability a Problem2 through Identifying of of a a Problem Problem Reduction IntractabilityWeWe would throughwould through like like to to know know Reduction Reduction that that of the the a problem problem Problem that that we we are are through attempting attempting is is Reduction unlikely unlikely to to have have an an immediate immediate solution. solution. The The 2 Identifying Intractability of a Problem through ReductionWeWeimmediate would would like like solution. to to know know The that that most theWe the common problem would problem like way that that to is we know weto are apply are that attempting attempting a thewell-known problem is is unlikely unlikely thattechnique we to to haveare havecalled attempting an an immediate immediate is unlikely solution. solution. to haveThe The an immediate solution. The We would like to know that the problem2We that would Identifying we are like attempting to know that isWe Intractability unlikely the would problem to like have to that know an we immediate thatare of attempting theWeWe a solution.problem would would Problem is like like that unlikely The to to we know know areto through have thatattempting thatmostmost anthe the immediate common problemcommon problem is Reduction unlikelyWe that waythat wouldway solution. toweis weis liketo have to are are apply applyThe to attempting attempting an know immediate a a well-known well-known that is is the unlikely unlikely solution. problem technique technique to to The have havethat called called anwe an immediate areimmediate reduction. reduction. attempting solution. solution. Suppose Suppose is unlikely The The we we toknow know have that that an problemimmediate problem X X solution.is is The We would like to know thatmost themostreduction. problem common commonWe wouldSuppose that way way like we is we is are toto know knowapply attempting applymost that that a a well-known problem common well-known the is unlikely problem X way techniqueis technique to isthatimpossible have to we apply calledan are called immediateto a attempting solve, well-knownreduction. reduction. and solution. iswe Suppose technique unlikely Supposealso Theknow to we wecalled have know know an reduction. that immediatethat problem problem Suppose solution. X X is is we The know that problem X is We would like to know thatWeWe the would would problem like like that to to know know we are that that attempting the the problem problem is unlikely that that we we to are are have attempting attempting an immediate is is unlikely unlikely solution. to to have have The an anmost immediate immediate common solution. solution. way is1 toThe The apply a well-known technique called reduction. Suppose we know11 that problem X is We wouldmost like commonto know that way the is to problem apply a that well-known wemost are attempting techniquecommon way iscalled unlikely is to reduction. applymost to have commona well-known Suppose an immediate way we techniqueis know tothat solution. apply we thatmost most calledcan a problem The well-known solve common common reduction. problem X is way way technique Suppose is isX to toby apply applyimpossibleimpossible calledusing we aknow aproblem reduction. well-known well-known to to that solve, solve, Y problem Supposeas andtechnique andtechnique a black-box we we X also alsowe is called called know know. Ifreduction. reduction. thatwe that can weproblem we cansolve can Suppose Suppose solve solve X is problem problem we we know know X X11 1 by by that that using using problem problem problem problem X X Y is Y is as as a a black-box black-box1 .. If If we we can can most common way is to applyimpossibleimpossibleimpossible a well-knownmost to to to solve,common solve, solve, technique and and and way we we we also also is alsoimpossible called to know know knowapply reduction. that that thata to well-known wesolve, we we can can Supposecan and solve solve solve we technique problem problem alsowe problem know know X Xcalled Xthat by by that by using using usingreduction.problem we can problem problem problem solve X Suppose is Y Y problem Y as as as a a a black-box black-box we black-box X knowby using.. that. If If Ifproblem we we weproblem can can can Y as X ais black-box . If we can 1 most common wayWe is towould applymostmost like a tocommon commonwell-known know that way way technique the is is to to problem apply apply called a athat well-known well-known reduction. we are attempting technique technique Suppose1 iswe called called unlikely know reduction. reduction. that to have problem Suppose Supposean immediate X is we weimpossible know know solution.1 that that toproblemThe solve,problem and X X we is is also know1 that we can solve problem11 X by using problem Y as a black-box . If we can most commonimpossible way to is solve, to apply and a we well-known also know technique thatimpossible we can called solve to solve, reduction. problem and weX Supposeimpossible by also using know weproblem to that know solve, we Y that and can asproblem a weproblemsolve black-box alsoimpossible problemimpossible Y know X , then. is If that X we we to by to can we solve,can using solve, can solve problemand and solve problem we we problemsolvesolve also also Y as problem know problem knowX a X black-boxas by that thatwell. using Y, Y, we we then thenTherefore,. problem can can If we we we solve solve can can can Yproblem problem problemsolve assolve a black-box problem problem 1Y X X byis by also using using X X. as Ifasim problemwe well. problem well.- can Therefore, Therefore, Y Y as as a a black-box black-box problem problem1 Y Y.. Ifis Ifis we also we also can can impossible impossible to to solve. solve. impossible to solve, and wesolve alsosolvesolve know problem problem problemimpossible that Y, Y, we Y, then then canthento solve, we wesolve we can can can and problemsolve solve solve solve we1 problem also problem problem X problem by know using Y, X X Xthat then as as problemas well. well. we well. we can canTherefore, Therefore, Therefore, Y solve as solve a11 problemblack-box problem problem problem problem X X. byY Y Ifas Y is is using we is well. also also also can problem impossible impossibleTherefore, impossible Y as to toproblem to a solve. solve. black-boxsolve. Y is also. If impossible we can to solve. impossiblesolve to solve, problem and Y, we then alsoimpossible we know can that solve to we solve, problem canmostsolve and solve X we common problem as problem alsoimpossibleimpossible well. know Y, way Therefore, X then by that to tois using tosolve, solve, we we apply problemcansolve canproblem and and solve solve a problem we we well-known Y Y problemalso also problem is as also knowY,a know black-box then impossible X X technique that that2 as by wepossible well. using we we1 can Identifying. canIf canto Therefore,solvecalled problemsolve we to solve. solve solve cansolve. problem problem reduction. problem problem Y problem as a Y, XY, black-box X asX thenIntractability then Suppose Y by by well. is using usingwe we also Therefore, can. can we Ifproblemimpossible problem solvewe solve know can problem problem Y Y thatsolve as toas a solve.a problem problemblack-box black-box ofX XY as asis aalsowell. well. X Y, Problem. isimpossible. Therefore, then Therefore,If If we we we can can can to problem problem solve.solve through problem Y Y is is also also X impossible impossible Reductionas well. Therefore, to to solve. solve. problem Y is also impossible to solve. solve problem Y, then we can solvesolve problem problem X as well.Y, then Therefore, we can solve problem problem Y is also X1 as impossible well. Therefore, to solve. problem Y is also impossible to solve. solve problem Y, then we cansolve solve problem problem Y, X asthenimpossible well. we Therefore, cansolvesolve to solve solve, problem problem problem problem and Y, Y, we X then Ythen also as is well. also we we know can can impossible Therefore, that solve solve we problem problem can to problem solve. solveWe X X asproblem Yasare is well. well. using also Therefore, XTherefore, impossible NP-hard by using problems problem problem problem to solve. Y Yfor isWe isasWe illustration. also also a are are black-box impossible impossible using using NP-hard NP-hardRecall. If to to we that solve. solve. problems problems can NP-hard for for problems illustration. illustration. have Recall Recall that that NP-hard NP-hard problems problems have have yet yet to to be be solved solved in in polynomial polynomial WeWe wouldWe are are likeusing using to NP-hard knowNP-hard that problems problems the problemWe for for are illustration. illustration. using that NP-hard we Recallare Recall attempting problems that that NP-hard NP-hard for is illustration. unlikely problems problems to haveRecall have have yet an yetthat to immediate to NP-hardbe be solved solved problemssolution. in in polynomial polynomial have The yet to be solved in polynomial We are using NP-hard problems for illustration.solveWe problem are Recall using Y, that NP-hardthen NP-hard we canproblems problemssolveWe are for problem using illustration. have NP-hard yetX as toyet well. beRecall problems to solved Therefore,be that solved inWeWe forNP-hard polynomial are areillustration. in problem using usingpolynomial problems NP-hard NP-hard Y Recall is alsohavetime problems problemstime thattime impossible yetfor NP-hard forto formore be for morefor more solved illustration.thanillustration. to problems than than solve.We 4 in decades. are 4polynomial 4 decades. decades. usinghave Recall Recall MIN-VERTEX-COVER yet NP-hard that that MIN-VERTEX-COVER MIN-VERTEX-COVERto be NP-hard NP-hard solved problems problemsin problems polynomial for illustration. have have is is a a yet yet graph graph to Recallto be be problem problem solved solved that NP-hard in thatin that polynomial polynomial involves involves problems finding finding have a a yet minimum minimum to be solved subset subset in polynomial We are using NP-hard22 problemstimemosttime Identifying Identifying2time for for common for Identifyingfor more more more illustration.We than than areway than using 4 4 is 4 decades. decades.Intractability Intractability Recall todecades. NP-hard apply Intractability thattime MIN-VERTEX-COVER MIN-VERTEX-COVER aMIN-VERTEX-COVER problemsNP-hardwell-known for more problems for than illustration. technique of 4of decades. have a a is is of isyet a acalledProblem Problem Recall a graph graph tographMIN-VERTEX-COVERa be Problemreduction. that problem problem solved problem NP-hard in through throughthat that polynomial thatSuppose problems involves involves through involves is we a havefinding finding graph knowfinding Reduction Reduction yet problemthat a a toReduction a minimum minimum minimum be problem solved that subset subsetininvolves subset X polynomial is finding a minimum subset We aretime using for NP-hard more than problems 4 decades.We for are illustration. MIN-VERTEX-COVER using NP-hardtime Recall for problems that more NP-hardWeWe is than for are are a graphillustration. using using42 problems decades. problemNP-hard NP-hardtime Identifying have Recall MIN-VERTEX-COVER for that problems problems moreyet that2 involves2 to than be NP-hard for for Identifying Identifyingsolved 4 illustration.illustration. findingIntractability decades.is problems ina graph polynomial a istime minimumtime a MIN-VERTEX-COVER RecallRecall graphproblem have for for2 yetthatIntractabilitymorethat problemIntractabilitymore subset that to Identifying NP-hard NP-hard than bethan involves solvedthat of 4 4 decades. decades.problems problems involves a in isfindingof polynomialProblem aof graph nodes nodes MIN-VERTEX-COVER finding haveMIN-VERTEX-COVER have a Intractability problemof suchofminimum such yet yettime2 a to to minimuma thata that be bethrough for thatProblemIdentifying Problemsubset solved solvedfor for more involves every every subset of inin than polynomialisnodes polynomial is edge, edge, a findinga 4 graphReduction graph decades. through throughsuchof at at least aleast problemIntractabilitythat problem a minimum MIN-VERTEX-COVER Problem onefor one every that ofthat of Reduction Reductionsubset its its involves involves endpoint endpoint through finding finding is is inof in is thea athe minimum graphminimum a subset. subset. Problem Reduction problem subsetMAX-INDEPENDENT-SET subsetMAX-INDEPENDENT-SET that throughinvolves finding Reductiona minimum is is a a subset time for more than 4 decades.ofimpossibleof nodes MIN-VERTEX-COVER nodestime suchsuch to for solve, that that more for and for than every weevery is 4 also edge,aof decades. edge, graph nodes know at at problemleast thatsuch MIN-VERTEX-COVER least we one that one that can of for ofits solve involves its every endpoint endpoint problem edge, finding is is atis aX in graphina byleast the minimum the using subset. one problem subset. problem of subset its MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETthat endpoint Y involves as a black-box isin finding the1 subset.. a If minimum weis canMAX-INDEPENDENT-SET is a a subset is a time for moreof nodes than such 4 decades. that fortime MIN-VERTEX-COVER every for edge, more thanat least 4of decades. nodesWe one is are of atimetime2such graph itsusing MIN-VERTEX-COVERendpoint for for Identifyingthat NP-hardproblem more more for than thanis every thatproblems inof 4the 4 nodesedge, involves decades. decades. subset. for isat suchIntractability illustration.a findingleast MIN-VERTEX-COVERgraph MIN-VERTEX-COVER MAX-INDEPENDENT-SET thatWeWe one aproblem forwould would minimum ofWeedge, Recallevery its would like like endpoint thatat edge, thatof ofto toleast subset nodeslike involves nodesknow know NP-hard atone of isto is least a asuchthat inthat knowsuchof graph graph findinga theits isproblems one thethat theProblem athatendpoint that subset. problem problemof problem problem a for for itsthe minimum have every everyendpoint MAX-INDEPENDENT-SETis problem that thatgraphingraph thatyet that edge,the edge, involvestosubsetthrough involves we wesubset. problem isproblembe that at inatare are solved leastof theleast we findingattempting findingattemptingMAX-INDEPENDENT-SET nodes of areofsubset. in one one finding finding polynomial attempting aReduction a suchof of minimum minimum MAX-INDEPENDENT-SETits its is is a a that is endpointunlikely maximumunlikelyendpoint maximum a isfor subset subset unlikely every to to is is subset havesubset have in in edge, the tois the an ana have of ofsubset.graph subset. atimmediate immediate nodes nodes least an is immediate MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETsuch suchaone solution. solution. ofthat that its forsolution. for endpoint Theevery The every edge,The edge, is in theat at is most is most subset. a a one one MAX-INDEPENDENT-SET of of its its endpoint endpoint is is in in is a of nodes such that for everygraphgraph edge, problem at problemof least nodes of one of such finding finding of that its a endpoint a formaximum maximumgraph every isproblem edge, insubset subset the at ofsubset. of least of finding nodes nodes one MAX-INDEPENDENT-SET such a of such maximum its that that endpoint for for subset every every is in edge, of edge, the nodes subset.at isat most sucha most MAX-INDEPENDENT-SET one that one of for of its its every endpoint endpoint edge, is at is in inmost is one a of its endpoint is in of nodes such thattime for every for moreofof edge, nodes nodes than at such such least 4We decades. that that one would for forof MIN-VERTEX-COVER its likeevery every endpoint to edge, edge,WeWe know wouldmost would at isat that in least leastsolve common likethe2 likeproblem the one one problemtosubset. toproblem is Identifying know knowaof of wayof graph its its finding MAX-INDEPENDENT-SET Y,that endpointthat endpointisWe problemthen to the thewewould applya we problemare problemmaximum is is canthat likein ainattempting Intractability well-known the the solve involvesto that that subset. subset.knowsubset problem we we isfinding that areof aretechniqueunlikelyMAX-INDEPENDENT-SET MAX-INDEPENDENT-SET isnodes Xattempting theaattempting aasWegraph minimumproblemsuch well.to would called have problemthat Therefore,of is is that likeanfor reduction.unlikelysubset unlikely a immediate toevery ofwe Problem know finding areproblem to toedge, attemptinghave Supposehaveis is that solution.a aat maximumY an anthemost is immediate immediate wealso problemthrough isone The knowunlikely impossible subsetof that that solution. solution. toof we problem nodestohave Reduction are solve. The The an attempting such X immediate is that for is solution.unlikely every edge, to The have at most an immediate one of its endpointsolution. isThe in of nodesgraph such that problem for every of finding edge, a at maximum least one subset ofgraph its endpoint of problem nodes issuch of in finding thegraph that subset. for aproblemgraph maximum every MAX-INDEPENDENT-SET problem edge, of finding subset at ofmost most finding a of maximum common nodesmost one a of maximum common such itsgraphgraph waysubset endpoint that is is aproblem problem way subsettoof for nodesapply isevery in to of of suchaapply findingnodesedge, finding well-known that aat such a awell-knownthethe most maximum formaximum that subset. subset. every technique one for of edge, Supposesubseteverytechnique Supposesubset its called endpoint at edge, of of most we we nodes nodes called reduction.at already already one is most such insuch reduction. of know oneknowits that that Suppose endpoint of that forthat for its Suppose every every endpointMIN-VERTEX-COVER MIN-VERTEX-COVER we is knowin edge, edge, we is thatatknow atin most most problem that one one problem isof is of X a a its its isNP-hard NP-hard endpoint endpoint X is problem. problem. is is in in Therefore, Therefore, we we can can show show We would like to know that themostmost problem common commonthethethe that subset. subset. subset. way waygraph we is isSupposeare Suppose Suppose to to problem attemptingmost apply apply we we commonwe a of a already already well-known well-knownalready finding isthe unlikely way know know subset. knowa maximum is techniquetechnique that thatto to that haveSuppose apply MIN-VERTEX-COVER MIN-VERTEX-COVER MIN-VERTEX-COVER subset anmost called acalled immediate we well-known ofcommon already reduction. reduction. nodes solution. know suchtechnique way Suppose is isSuppose that isthat a a ato TheNP-hard NP-hard NP-hardMIN-VERTEX-COVER for applycalled we weevery knowaknow problem.reduction. problem. problem. well-known edge, that that at Therefore, Therefore, problem Therefore, problemmost Suppose technique is11 one a X NP-hardX we we weof we is is canits can calledknow can endpoint show show problem. show that reduction. problem is Therefore,in Suppose X is we we can know show that problem X is graph problem of finding a maximumgraph problem subset of of finding nodesof nodes such a maximumgraph suchgraph that that problem problem for subsetfor everymost every of of edge, ofthe findingcommon finding edge,nodes subset. at amost aat such maximumway maximum least Suppose one that isimpossibleimpossible one to of for applysubset itssubset weofimpossible everyits itsendpoint already endpoint ato toendpoint of of edge,well-known solve, solve,the nodesthe nodes know to is subset. subset. atis andin solve,and is such such mostin that in we wethe technique the Suppose andthat Supposethat MIN-VERTEX-COVERone also alsosubset. subset. we for for of know know also itsevery everywe weSupposecalled MAX-INDEPENDENT-SETendpoint that thatalready know already edge, edge, reduction. we we thatwe canknow canat know atis already we inmost most solve solveis thatthe canthat a Suppose NP-hard one one problemknow problemsubset. solve MIN-VERTEX-COVER MIN-VERTEX-COVER of of that itsproblem its we problem. Suppose X X endpoint endpointMIN-VERTEXCOVER is knowby by a using using Xthatwe by Therefore, is is problem problem using already in in problem is is problem a a Yknowwe YNP-hard NP-hard as asX can ais a thatis Y black-box black-box show as problem. problem. MIN-VERTEX-COVER a black-box.. Therefore,If If Therefore, we we1. can can If we we we can can can is a show show NP-hard problem. Therefore, we can show the subset. Suppose we already know thatthe MIN-VERTEX-COVER subset. Suppose we already is a NP-hard know that problem. MIN-VERTEX-COVERWe Therefore, would like we can to knowis show a NP-hard that the problem. problemthatthat MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET Therefore, that we are we attempting can show is is is unlikely also also a a NP-hard toNP-hard have an problem problem immediate111 by by reducing reducing solution. a a MIN-VERTEX-COVER MIN-VERTEX-COVERThe 1 problem problem into into a a1 most commonthe subset. way is Suppose to applyimpossibleimpossible we a well-known alreadythatthatthat to toknow solve, MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETsolve, MAX-INDEPENDENT-SETthe technique that and and subset. weMIN-VERTEX-COVER weimpossible also called also Suppose know know reduction. to we thatthat that solve, already is is we MAX-INDEPENDENT-SET we is also also and Supposealsocan can is know a wea a solvea solve NP-hard NP-hard NP-hard NP-hard also that we problem problemimpossible know know MIN-VERTEX-COVER problem problem problem. problem that X Xthat by toby we by by using solve, problemusingby Therefore, canis reducing reducing reducing also solveproblem problemand a XNP-hard we problema awe is a MIN-VERTEX-COVERis MIN-VERTEX-COVER1 also Y MIN-VERTEX-COVER Ycan a as as NP-hard know show aproblem X a black-box black-box by that using problem. by we problem reducing.. can If If we Therefore,we solveproblem problem problem can canY a as problemMIN-VERTEX-COVER a into into black-box weinto acan a X a by show using. If we problem can problem Y as into a black-box a . If we can the subset. Supposegraph we already problemthethe subset. knowsubset. of finding that Suppose Supposeimpossible MIN-VERTEX-COVER a maximum we we to already already solve, subsetimpossible knowand knowsolvesolve of we that that is nodesproblem problemsolve also a to WeNP-hard MIN-VERTEX-COVERNP-hard MIN-VERTEX-COVER solve, know problemsuch are Y, Y, using and that that then thenproblem. problem. Y, we weNP-hard for we we then also can every can can Therefore, Therefore, knowwe solve solve solveproblems edge, can is is problemthat a a problem problem solve NP-hard NP-hard atwe we wefor mostcan problemcan illustration.can X X Xshow by oneproblem. problem.show as solveas using well. well. of Xthatthat problem itsas problem Recall Therefore,MAX-INDEPENDENT-SET Therefore, Therefore, Therefore,well. endpoint MAX-INDEPENDENT-SET Xthat Therefore, Y by as isNP-hard problem problem weusing wein a can black-boxcan problem show showproblems Y Y is is also also. Y If as isis haveimpossible impossiblewe isalsoalso a canalso black-box yet impossiblea toa NP-hard tobe to solve.solved solve.. If to we problem solve. in can polynomial by reducing a MIN-VERTEX-COVER problem into a the subset.that Suppose MAX-INDEPENDENT-SET we already know that is MIN-VERTEX-COVER also athat NP-hard MAX-INDEPENDENT-SET problem isthat a by NP-hard reducing MAX-INDEPENDENT-SETthat problem. MAX-INDEPENDENT-SET a is MIN-VERTEX-COVER also Therefore,a NP-hardmost we problem is cancommon alsothatthat problem show isa by MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETNP-hard also reducing way intoa NP-hard is problem a to a MIN-VERTEX-COVERapply problem by aMAX-INDEPENDENT-SET reducingMAX-INDEPENDENT-SET well-known by reducingis is aalso also MIN-VERTEX-COVER technique a a problem NP-hard a NP-hard MIN-VERTEX-COVER called into problem problem1 problem. aproblem. reduction. by by problem reducing reducing Suppose problem into a a MIN-VERTEX-COVER aMIN-VERTEX-COVER into we know a that problem problem problem X is into into a a the subset.thatthatimpossible Suppose MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET to we solve, already and know we also thatsolvesolvesolve know is isMIN-VERTEX-COVER problem problemalso problem also thatMAX-INDEPENDENT-SETtimeMAX-INDEPENDENT-SET a aNP-hard NP-hard NP-hard we forY, Y, Y,that canthen more then then problem solve MAX-INDEPENDENT-SETproblem problem we we wethansolve can can can problem is 4by asolve decades.bysolve problemsolveby NP-hardreducing reducing reducing X problem problem problem problem. byMAX-INDEPENDENT-SET problem. Y, MIN-VERTEX-COVER using problem.a then aMIN-VERTEX-COVER a X MIN-VERTEX-COVER XMIN-VERTEX-COVER X problemas as as we well. well.is well. Therefore, can alsoTherefore, Ysolve Therefore, Therefore,MAX-INDEPENDENT-SETsolve a as NP-hard a problem we problem black-box is can a problem problemproblem. problem graphproblem problem problem show X Y, as. then problem If Ywell. Y Yinto we byinto is into is is we also canalsoreducing also Therefore,a a a can thatMAX-INDE impossible impossible impossibleproblem. solve involves a MIN-VERTEX-COVER problem problem- to to tofinding solve. solve. solve. Y X is asa also minimum well. impossible Therefore, problem subset to problem solve. into a Y is also impossible to solve. that MAX-INDEPENDENT-SETMAX-INDEPENDENT-SETthat is MAX-INDEPENDENT-SET also problem. a NP-hardMAX-INDEPENDENT-SET problem by is reducing alsosolve a NP-hard a MIN-VERTEX-COVERMAX-INDEPENDENT-SET problem problem. problem Y, then by we reducing can problem solve a problem.MIN-VERTEX-COVERMAX-INDEPENDENT-SET problemMAX-INDEPENDENT-SET into a X as well. Therefore, problem problem. problem. problem into a Y is also impossible to solve. 1 2 Identifyingsolve problemMAX-INDEPENDENT-SET Intractability Y, then we can solve problemof problem.ofimpossiblePENDENT-SET nodes aXMAX-INDEPENDENT-SET as such Problem well. to that solve, Therefore, problem. for and every through we problem edge, also know at problem. Y least is that alsoReduction one we impossible of can its solve endpoint to problem solve. is in X the by using subset. problem MAX-INDEPENDENT-SET Y as a black-box . If we is can a MAX-INDEPENDENT-SET problem.MAX-INDEPENDENT-SETthat MAX-INDEPENDENT-SETMAX-INDEPENDENT-SETMAX-INDEPENDENT-SET problem. is also problem. problem. a NP-hardWeWe are are problemWe using using are NP-hard NP-hard using by reducing NP-hard problems problems a problemsMIN-VERTEX-COVER for for illustration. illustration. forWe illustration.We will will Recall Recall first first problem Recallthat that prove prove NP-hard NP-hard that the the into followingNP-hard following a problems problems problems two two have have lemmas. lemmas. yet yet have to to be yetbe solved solved to be solvedin in polynomial polynomial in polynomial solveWeWe problemwill will first first Y,prove prove then the the we following followingcan solveWe two will two problem lemmas. first lemmas. prove X as well.the following Therefore, two problem lemmas. Y is also impossible to solve. MAX-INDEPENDENT-SETWe problem.are using NP-hardWeWetime are areproblemsgraph for using using more2We problem NP-hard NP-hard for will than Identifying illustration.2 first 4 of problems decades.problems Identifying findingproveWe Recallare the fora MIN-VERTEX-COVERfor using maximumfollowing illustration. illustration. that Intractability NP-hard NP-hard subsettwo Intractability Recall Recall problems lemmas. problems of that that nodes is forWe NP-harda NP-hard have graph illustration. such arewill yet ofusing first that problem problems problemsto a provebeNP-hard for of Recall Problemsolved every that havethe havea that problems in involvesProblemfollowing edge, yet yet polynomial NP-hard to to at be be forfinding throughmost two solved solved illustration. problems lemmas. one a through in in minimum polynomialof polynomial have its Recall Reductionendpoint yet subset thatto Reduction be NP-hardis solved in in problems polynomial have yet to be solved in polynomial We will first prove the followingWe two would lemmas.We like will to first know prove that theWe the following willproblemWe first will provethat two first lemmas. wetime the prove are following for attemptingtime the more following for two than moreWe lemmas. isWe 4 twounlikelythan decades. will will lemmas. 4first first decades. to proveMIN-VERTEX-COVER prove have the anMIN-VERTEX-COVERthe immediate following following two two solution. is lemmas. lemmas. a graph is The a problemgraph problem that involves that involves finding finding a minimum a minimum subset subset We will first prove the followingWeWe willare will two using first first lemmas. prove prove NP-hard the the problems following following2timetimetime Identifying for for for two two moreillustration. morethe more lemmas. lemmas. subset. than than than 4 4 4We RecallSuppose decades. decades. decades. Intractabilitywilltime that first we for MIN-VERTEX-COVER MIN-VERTEX-COVER MIN-VERTEX-COVER NP-hard alreadyprove more thethan problems know followingLemma2 4Lemma decades. that have Identifying of MIN-VERTEX-COVER two 1. 1. is isyet is MIN-VERTEX-COVERatime aIf aIf alemmas. tographS graph graphS Problem be for solvedVV problemmore problem problemisis an an inthan Intractability INDEPENDENT-SETpolynomial INDEPENDENT-SET that that that is through4 a decades. involves involves involves NP-hardis a graph finding MIN-VERTEX-COVERfinding finding problem. problem Reduction a a a of of minimum minimum minimum of Therefore,graph thatgraph a involvesGG subsetProblem subset( subset(V,EV,E we is finding) can) a,, then graph then show aVV problem minimum throughSS isis athat a subset VERTEX-COVER VERTEX-COVER involves Reduction findinga of of minimum the the subset We will first prove2 the following Identifying two lemmas.most Intractability common way is to applytime for a of well-known more a than Problem 4 techniqueof decades.of nodes nodesLemmaofLemmaLemma nodessuch calledsuchMIN-VERTEX-COVERthrough 1. that that 1. such1. reduction.IfIf IfIf forS for thatS every everyV Reduction forVisis Suppose is edge,is edge,every an an anan INDEPENDENT-SETis INDEPENDENT-SET Lemma INDEPENDENT-SET at atedge,a we graph least least know at 1.one oneproblem leastIf that of ofS one its its problem that endpoint endpointVof ofof is its involves⊆ of⊆ graph an graph endpoint graph X INDEPENDENT-SET is is inG infindingG(( the theV,E( isV,E insubset. subset.)) a, ,) the minimum, then then then subset. MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETVV subset ofS MAX-INDEPENDENT-SETS is graphisis a a a VERTEX-COVER VERTEX-COVER VERTEX-COVERG(V,E), then is isVa ofa of of the theS is theis a−− a VERTEX-COVER of the time for more than 4 decades. MIN-VERTEX-COVERS V WeWe would areWe using like wouldof is⊆⊆ NP-harda nodes to graph likeknow such to problem problems that know that the that for for problem every illustration.G theinvolvesV,E problem edge,⊆ thatLemma finding we at Recall that least areV 1.awethat minimumattemptingIf oneS areS NP-hard of attempting itsV subsetis endpoint is problems an unlikely INDEPENDENT-SET is− isunlikely− haveto in have the yet to subset. an to have be immediate solved anMAX-INDEPENDENT-SET of immediate graphin solution. polynomial−G( solution.V,E The), then TheV is aS is a VERTEX-COVER of the Lemma 1. If S V is an INDEPENDENT-SETLemmaWe will 1. of firstIf graphS proveVGof the(isV,E nodes an followingLemma) INDEPENDENT-SET,such thenS 1.that twoV ofofIfV lemmas. forS nodes nodesis every athatsuch VERTEX-COVER suchis edge, an of MAX-INDEPENDENT-SET that that graph INDEPENDENT-SET atLemmaLemma for for leastG every every(V,E one 1. 1. of edge, edge,) ofIfIf, the thenS itsS at at endpointV leastV least ofisisG graph isS anone an onegraphV,E alsographis is INDEPENDENT-SET INDEPENDENT-SET ofa ofin a VERTEX-COVER its( theitsG NP-hardG(( endpointV,E endpointV,E subset.)of,V1) then) nodes problemS MAX-INDEPENDENT-SET is is in suchin thethe of byof of thatis the subset.graph reducing subset.graph⊆ a VERTEX-COVERforGG every MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET(( aV,EV,E MIN-VERTEX-COVER edge,)),, then then atisV aV least of theSS oneisis a ofa VERTEX-COVER VERTEX-COVER its problem is is endpoint a a into is a inthe of of the the subset.− MAX-INDEPENDENT-SET is a ⊆ impossible2 Identifying to solve, and⊆ weLemma Intractability alsoSS knowVV 1. If that we− canisgraphgraph⊆ an solvegraph INDEPENDENT-SET ofgraph problem problemVERTEX-COVER problem aG problemGLemma((V,E Problem( of ofV,E X finding finding)) by) of 1. using findingofIf a a GG maximumSthe maximum problem of(V,EV,E throughgraph⊆ graph⊆ aV maximumgraph)is− Y an subset subset as(WeG INDEPENDENT-SETV aV(V,E black-box subsetwould of) of ,.Reduction SS thennodes) nodes like of nodessuch. such to If knowweG that thatis suchV,E can− a ofthat forfor VERTEX-COVER that graph every every the for problemG edge, edge,every(V,E at atedge,), that most mostthen of at thewe oneV one most are−− of ofS attempting one its itsis a endpoint endpointof VERTEX-COVER its endpoint is isunlikely is in in is to in ofhave the an immediate solution. The Lemmagraph 1. If SG(V,EV Weis) an would INDEPENDENT-SETLemma like to 1. knowIf S thatgraphV the ofis graph an problemGLemma( INDEPENDENT-SETLemmaofV,EG nodes()V,E that 1. 1. such) we,IfIf then are thatgraphV attempting forisisS ofeveryG an anis( graphWeV,E⊆ INDEPENDENT-SETa INDEPENDENT-SETgraph edge,graph VERTEX-COVER is would) unlikelyG(V,E at problem problem like leastMAX-INDEPENDENT-SET)time, to to thenmost onehave knowof of for findinggraphV findingofgraphmorecommon ofanmost thatits of of the immediateS graphendpointG graphG thangraph ais athe( common(V,E maximumV,Emaximum a wayproblemVERTEX-COVER 4 problem) decades.)(⊆ is solution. wayto in problem. subset) subset thatthe, apply, of thenis then MIN-VERTEX-COVER subset. findingto Thewe of ofa apply are well-knownnodes nodes of aMAX-INDEPENDENT-SET attempting the amaximumisis such well-knownsuch a agraph VERTEX-COVER VERTEX-COVER− thattechnique that problemis subset for(for isunlikely technique a every every graph) ofcalled of nodes to edge, findingedge, problem have of reduction.of called suchthe istheat at aan a most most maximum reduction. that thatimmediate oneSuppose one involves for of everyof subset− itsSuppose its solution. finding we endpoint endpointedge, ofknow nodeswe aat The minimum that mostis knowis in such in problem one that that subset of problem itsfor X endpoint everyis X edge, is is in at most one of its endpoint is in ⊆ solve⊆ problem Y, then2 wegraph cangraph Identifying solve⊆⊆G problem(V,E− problem) of finding X asthe Intractabilitythe well. subset. subset.a maximumthe Therefore, subset. Suppose Supposegraph subset− Suppose problemG we we(V,Eof already already nodes)of we Y is already knowa knowalso such Problem impossible that that knowthatmost MIN-VERTEX-COVER MIN-VERTEX-COVER for that−− common every to MIN-VERTEX-COVER solve. through edge, way at is most to applyis is oneReduction a a NP-hard NP-hard of ais itswell-known a NP-hard endpoint problem. problem. problem. technique is Therefore, inTherefore, Therefore, called we we can can reduction. we show show can show Suppose we know that problem X is G(V,E) most commongraph G way(V,E is) to applyLemma a well-known 1.graphgraphIf SGG problem((V,EV,EV techniqueis)) ofan finding INDEPENDENT-SET called amost maximum reduction.thethe common subset. subset.Proof. subset SupposeofProof. Suppose Suppose of wayimpossible nodes graph ofLet isLet nodes we tosuchusimpossible we weusG apply knowassume ( already toassumealreadyV,Ethe suchthat solve, subset.) athat, forthat towell-known thatthenknowthat know and every solve, problem for V SupposeV thatweV that every edge, and alsoSS MIN-VERTEX-COVER MIN-VERTEX-COVERS techniqueXisProof.isis weProof.edge, knowat we is not anotnot alsoleast VERTEX-COVER already a at a thatLet LetVERTEX-COVER. know VERTEX-COVER. VERTEX-COVER. most onecalled usthe weus know ofthat assume oneassume can subset. reduction. its that weof solve endpoint isitsis can thatthat ofMIN-VERTEX-COVER Suppose a a problemendpoint NP-hard the NP-hardsolve Therefore,V SupposeTherefore,V Therefore, is in problem weSS X the is problem.is problem.is byalready inwe not notsubset.there using there there X know a a by know VERTEX-COVER.are VERTEX-COVER.Therefore, problem Therefore, are are using MAX-INDEPENDENT-SET isthattwo atwo two that NP-hard problem problem Y vertices vertices MIN-VERTEX-COVER we aswe a can canproblem. Y black-box XA, as show showTherefore,A,is Therefore, B a B black-box / / Therefore,1V.V Ifwe thereS isthereS1 a. canis If awe are are we NP-hard can two can two show vertices vertices problem.A,A, B Therefore,B / / VV SS we can show graph We would like to know⊆ thatthe the subset. problem Suppose thatthe we wethatthat subset. are already MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET attemptingProof. Suppose knowLet that we usis unlikely alreadyassume MIN-VERTEX-COVER knowto that have is isProof. that also− also an MIN-VERTEX-COVER aimmediate aLetis NP-hard NP-hard not is us a a assume NP-hard VERTEX-COVER. problemsolution. problemProof. that problem.Let by by TheV isreducing reducing us a assumeS NP-hard Therefore,is Therefore,−− not a a MIN-VERTEX-COVER MIN-VERTEX-COVER that aproblem. VERTEX-COVER. weV there canS Therefore, show areis not two a vertices VERTEX-COVER. we problemTherefore, problem can show into into there a a are Therefore, two vertices thereA, are B two / V1 vertices∈∈S −−A, B / V S Proof. Let us assume that V S is notProof. a VERTEX-COVER.GLet(V,E us) assume that Therefore,Proof.V SLet thereis usnot areassume a VERTEX-COVER. twothatgraphthat vertices MAX-INDEPENDENT-SETV problemProof. Proof.A,S BisLet / Therefore,notLetofV finding us usa VERTEX-COVER.S assume assume and1 a there maximum −− that that there are isandimpossibleand alsoVV two theresubset isthere a SS vertices Therefore, NP-hardis anis is tois notof not an an solve, edge nodesA, a edge a edge problem VERTEX-COVER. VERTEX-COVER. B there and such connecting/ connectingV− we are bythat alsoS two reducing for knowA verticesA every andand Therefore, Therefore, thata MIN-VERTEX-COVERB edge,BA,. .. we Since Since B Since can at / there theremostVA,A, solve B B1 areSone are / problem/VV two two of itsSS vertices verticesproblem,, Xendpoint we we by∈ have∈ have usingA,A, into−−A, B isA,B problem inaB / B / VV SS.. YSS As As asAA aand black-boxandBB∈areare.− connected connected If we can impossible to solve, and wegraph also knowthe that subset. weProof. can Suppose solveLet problem we us already assumeimpossible Xthatthatthat by know that MAX-INDEPENDENT-SET usingMAX-INDEPENDENT-SET MAX-INDEPENDENT-SET to thatandVand problemsolve,We theresolve MIN-VERTEX-COVERS there willisProof. and− notproblemis Ysolve isfirst anwe as an aLetedgea alsothat proveVERTEX-COVER. problemedge black-box Y, us know MAX-INDEPENDENT-SETconnecting then assumetheconnecting is is is Y, thatfollowingalso alsowe also. is thenand If acanthat awe a awe NP-hardA NP-hard thereNP-hard NP-hard weA cansolve canandV twoTherefore,and can solve isB lemmas.problemSB problem. solvean.. problem problem problemis. Since Since problem edgeSince notthat thereproblem X isA, a connecting byTherefore,A, byas by alsoVERTEX-COVER. MAX-INDEPENDENT-SET B X are reducingBwell. reducing reducing by/ X a / twoV usingNP-hardasV Therefore, well. verticesweAS a aS, a, problemand MIN-VERTEX-COVER, wecan weMIN-VERTEX-COVER MIN-VERTEX-COVER weTherefore, problem have haveB show haveA, problem. Therefore, YSince BA, asA, /by B− problem aV BA, reducing Y black-box is BisS∈ there alsoS.. also /. As AsY AsV a− aA impossibleproblemareis problem NP-hardproblemA. MIN-VERTEX-COVER alsoandS Ifand two, we weB impossibleB vertices caninto haveinto intoare problem toare connecteda solve.a aA, connectedA, B to by B solve. reducingS /.V problem As AS aand MIN-VERTEX-COVER intoB aare connected problem∈ into− a Proof. Let− usmost assume common that Proof.VProof. wayS isWeLetisLet to not would usapply usthat a assume assume VERTEX-COVER. MAX-INDEPENDENT-SET like a well-known to− that that knowVV that techniqueSSMAX-INDEPENDENT-SETMAX-INDEPENDENT-SETis theis Therefore, not not problemMAX-INDEPENDENT-SET− a a called VERTEX-COVER. VERTEX-COVER. is there also that reduction. a weare NP-hard∈ are two− attempting Suppose vertices problem. problem. problemTherefore, Therefore, problem.A, we byis B know unlikely there therereducing / −V− that are are toS a two two problemand have MIN-VERTEX-COVER vertices vertices there an∈ immediateX∈ is isA,A,− an− B B edge / / solution.VV connecting problemSS ∈ The∈A into−and a B.∈ Since∈ −−A, B / V S,∈ we∈ ∈∈ have−− A, B S. As A and B are connected Proof. Letand us there assume is ansolve that edge problemV connectingS is Y, not thenA a VERTEX-COVER.and weWe canBand. are solveSince there using problemA, is NP-hard− B an Therefore, / edgeV X problems as connectingS well., we thereand Therefore, have for there areillustration.AA,solveand two is B− an− problemB vertices problemS edge.. Since Recall As connecting YAtheA, Y,A, isthatand BA subset.thenBalso / NP-hardB /andandV impossibleV weareAB thereSuppose there canandS connectedS , problems, we wesolveB is is . tohave an haveA,an we Since problemsolve. edgeB edge already haveA, /A,V Bconnecting connecting yet B X knowS /toS asbysolveby .V.∈be well.−As Asan an that solved problemSA−A edge,A edge,, Therefore, and MIN-VERTEX-COVERweandandA, in have weB weB polynomialB Y,. .are noteare notethenSince SinceA,S problemconnected connected B∈that we thatA,A,AS− can B B.S YS As/∈ /∈is solveisis VbyVA alsonotBis not −an− aand problemSSNP-hard an impossible an,edge,, weB we INDEPENDENT-SET. INDEPENDENT-SET.are have havewe X∈ problem.connected asnoteA, toA,∈ well.B solve. B − Therefore, Therefore,SS.. As AsAA This Thisandand problem we∈ B iscanB is−are aare a∈ show contradiction.Y contradiction.∈ connected connected is also− impossible Therefore Therefore∈ to solve.VV SS isis a a − impossible to solve,andthat there MAX-INDEPENDENT-SET and∈most we isand−MAX-INDEPENDENT-SET common an also there edge knowV is connecting way anS that edgeis weMAX-INDEPENDENT-SET toMAX-INDEPENDENT-SET∈ connectingcanapplyAA isand also solveby abyBB aproblem.well-knownan problem. NP-hard an Since edge,∈and edge,∈ A,A, X there−we− problem B. techniquebyBwe SinceMAX-INDEPENDENT-SET note// using noteisVV problem. problem. an by that problem thatedgeSS reducingcalled, weSSby connectingisis haveisreduction. Yan not not∈ not aas∈A,edge,A, MIN-VERTEX-COVER, an aan we an B Bblack-box− INDEPENDENT-SET. INDEPENDENT-SET.A have INDEPENDENT-SET. we SupposeSandS problem.. note AsMAX-INDEPENDENT-SETB1..AA,A Ifthat Since weand Bwe. /know canSBBA, AsV∈is problemare B not thatS /and connected This∈ This∈V This an problem into−− INDEPENDENT-SET.is isSare is, a a awe a contradiction.connected contradiction.S contradiction.problem.X have is A, B ∈∈S Therefore Therefore. Therefore As ThisA isandV aVB contradiction.SareSisisis connected a a a Therefore V S is−− a V S and thereby is an an edge, edge connecting we noteand thatA thereandS is isB not. antime Since edge anProof. forby INDEPENDENT-SET.A, connecting more an B /Let edge,andV than us there weSA 4assume, decades.and we note is haveB an2 that that. Thisedge Since MIN-VERTEX-COVERA,by IdentifyingS B anisconnectingisA, a notedge,S B contradiction..is/ As notanV weA INDEPENDENT-SET. aandS note VERTEX-COVER.and, weBLemma Intractability thatthat isthat haveare Therefore. a Since graph connected MAX-INDEPENDENT-SETSA, 1.byisisby B not If probleman anVS Sanedge, Therefore, anedge,. This INDEPENDENT-SET.S AsV INDEPENDENT-SET. thatis weisAwe is a anand, a involvesnote note we there∈ contradiction.of INDEPENDENT-SETB have that thatare− a are finding isVERTEX-COVER.VERTEX-COVER. connected ProblemSS two alsoisis This notverticesaa not Therefore This minimum NP-hard. anis anAsby a is INDEPENDENT-SET. INDEPENDENT-SET. ancontradiction. of a∈ throughand problem subsetcontradiction.graph edge,V Sare weGis by(∈V,E connectednote a reducingTherefore)− Reduction, Thereforethat then This Thisa V MIN-VERTEX-COVERis is is notVS a a isis contradiction. contradiction. an S aa VERTEX-COVER∈ INDEPENDENT-SET.is a Therefore problemTherefore−− of into theVV This a SS isisis a a a contradiction.− Therefore is a ∈ MAX-INDEPENDENT-SET− by an edge,−∈ we∈ note problem.− that VERTEX-COVER.SVERTEX-COVER.is notbyWe an an are INDEPENDENT-SET.∈ edge,We using∈⊆∈ are weNP-hard−− using note NP-hardVERTEX-COVER. problems that S Thisproblemsis for not∈∈ isillustration. a an for contradiction. INDEPENDENT-SET. illustration. Recall∈ that− Recall Therefore NP-hard that1 ThisNP-hardV problems is−S ais problems contradiction.−have a yet have to be yet solved Therefore to be in solved polynomialV in−− polynomialS is a − by an edge, wesolve noteand problem that thereSbyby Y, isis anthen an not edge,impossibleedge edge, we an can connecting INDEPENDENT-SET. we we solve note note to solve, problem that thatA and SS isis X weB not not.as also Since well. ThisWe anWe an know INDEPENDENT-SET. INDEPENDENT-SET.A,will willTherefore, isWe B a that first first/ contradiction. willV weprove prove first problem canS,− the provethe we solve followinghave following Ythe Therefore problem is This ThisA, also following B two twois isimpossible X a aSV bylemmas. lemmas. contradiction.. contradiction. two As usingSA lemmas.is toand problem a solve.VERTEX-COVER.B are Therefore Therefore Y connected as− a black-boxVV SS .isis If a a we− can − by an edge,VERTEX-COVER. we note thatWeS areis not using an NP-hard INDEPENDENT-SET.of nodes problemsVERTEX-COVER. such for that illustration. for This every is Recall aedge, contradiction.VERTEX-COVER. thatat least NP-hard oneWe Therefore of areproblems its usinggraph endpointMAX-INDEPENDENT-SETVERTEX-COVER. NP-hardV haveG∈(VERTEX-COVER.V,EVERTEX-COVER.S yet istime−is in) toproblems athe be for solvedsubset. more for thanin illustration. MAX-INDEPENDENT-SET polynomial problem. 4∈ decades.− RecallWe MIN-VERTEX-COVER are that using NP-hard NP-hard is problems a problems−− is have a forgraph yet illustration. to problem be solved thatRecall in involves polynomial that NP-hard finding problems a minimum have subset yet to be solved in polynomial solveVERTEX-COVER. problemWeWe would will Y, likefirst then to prove we know canWeWe the that solvewill will following first the first problemtime problem prove− proveVERTEX-COVER. twofor X morethe thelemmas. as that following followingwell. thanWe we Therefore, will 4are decades. two two attemptingfirst lemmas. lemmas. prove problem MIN-VERTEX-COVERLemmaLemma the is unlikely following Y 2. 2. isIf alsoIf S toSWetwo impossible have willVV lemmas.isis an isfirst a a a immediate VERTEX-COVER VERTEX-COVER graph to prove solve. problem the solution. following that of of The involves two graph graph lemmas.GG finding((V,EV,E)), a, then thenminimumVV S subsetS isis an an INDEPENDENT-SET INDEPENDENT-SET of of the the VERTEX-COVER. VERTEX-COVER.graphby problem an edge,VERTEX-COVER.VERTEX-COVER. of findingwe note a that maximumS is not subset an of INDEPENDENT-SET. nodesLemmaLemma such that 2. 2.If forIfIfS everyS ThisVV edge,is isis a a a VERTEX-COVER VERTEX-COVER contradiction. at VERTEX-COVERLemma mosttime one 2. offorIf Therefore itsS more of of endpoint of graph graphV than graphisV a 4G isVERTEX-COVERG decades.((V,E in(SV,Eis)),, a), then then MIN-VERTEX-COVERthenVV ofSSis graphisis an an an INDEPENDENT-SET INDEPENDENT-SETG INDEPENDENT-SET(V,E is) a, graphthen V problemS of ofis ofthat thean the the INDEPENDENT-SET involves finding a minimum of the subset time for more than 4 decades. MIN-VERTEX-COVERWe will firstmost prove common is a the graph followingtime way problem for isLemmaLemma tomore two thatapplyLemmaLemma lemmas. than 1. 1.of involves aIfIf nodes 4 well-knownSS decades. 1.2.of If findingIf such nodesV VS⊆isis⊆ thatMIN-VERTEX-COVER an an technique aVsuch minimum INDEPENDENT-SET INDEPENDENT-SETisis for anathat everyVERTEX-COVER INDEPENDENT-SET calledfor subset edge, every reduction. at edge, least is a of of at graphLemma onegraph graph graph Supposeleast of⊆⊆ problem oneits graphGG− 2.(( endpointV,EV,E we ofIf GS itsthat know)),( ,V,E endpointthen thenV involves is that) is, inVV then a the− problem VERTEX-COVER− is findingSS subset.V inisisthe aan aS VERTEX-COVER VERTEX-COVERX aIN subset.is MAX-INDEPENDENT-SETminimum is- a VERTEX-COVER MAX-INDEPENDENT-SET of subset graph of ofG the( theV,E of−−) the, then is a V isS a is an INDEPENDENT-SET of the Lemma 2. If S V is a VERTEX-COVERtheWe subset.VERTEX-COVER.Lemma areusing of Suppose graph 2. NP-hardIf SG we(V,E alreadyLemmaV problems)is, thenaLemma know VERTEX-COVER 2. forVIf illustration.thatSS 2. MIN-VERTEX-COVERisIfV anSis INDEPENDENT-SET aRecallV of VERTEX-COVERProof.is graphthat a VERTEX-COVERGLetG NP-hardLemmaV,ELemma(V,E us⊆⊆ is assume) a, problems NP-hard2.of⊆then 2. of graphIfIf the thatVSS of have problem.G graphVSVV(V,ESisis yetisS an a aG) toisgraphofV, VERTEX-COVERgraph( VERTEX-COVER INDEPENDENT-SETTherefore,V,E thenbe not nodes solved)G aG,V( VERTEX-COVER.( thenV,E suchV,E⊆ in weS) polynomialV) thatis can anS offorshow of INDEPENDENT-SETis graph graph every an of the INDEPENDENT-SET Therefore,⊆G edge,G((V,EV,E at)),−,− least then then thereG oneof−VV,EV are the ofSS two ofitsisis theendpoint an vertices anV INDEPENDENT-SET INDEPENDENT-SETSA, is Bin− the / V subset.S MAX-INDEPENDENT-SETof of the the− is a ⊆ ⊆ − SofLemma nodesLemmaV ⊆ such 1.graph 1.graph thatIfIfIfSWeSGGLemma for((V,E will(VV,EV everyis first)is)is) an anLemma an 2. edge, prove INDEPENDENT-SET INDEPENDENT-SET INDEPENDENT-SETIf S at the 1.−⊆ least⊆V followingIfgraphis− one aG VERTEX-COVERG ofV,E( twoV,Eis its an ofendpointlemmas. of of) INDEPENDENT-SET graph graph graphLemmaV G isG−( of( in(V,ESV,E1. graphthe)))If,,, subset. then thenS thenG(V,EVVV of MAX-INDEPENDENT-SETis graph),SS an thenisisis1 INDEPENDENT-SET a a aV VERTEX-COVER( VERTEX-COVER VERTEX-COVER−−S),is then an INDEPENDENT-SET ofis of of ofis a the the the graph a∈ VERTEX-COVERG−(V,E of), the then ofV theS is a VERTEX-COVER of the Lemma 2. If SG V,EV ofis anodes VERTEX-COVERLemma such that 2. forIf S every of graphV edge,is aGG VERTEX-COVER( atLemmaLemmaV,EV,E least), then one 2. 2.WeLemmaIf ofIfimpossibleV areSS its usinggraphS of endpointVVis graph 1.isis an NP-hard toGIf a a INDEPENDENT-SET( solve, VERTEX-COVERV,E VERTEX-COVERG⊆ is(V,E in) problems and thegraphgraphis), subset.anwe thenandgraphGG INDEPENDENT-SET alsoDEPENDENT-SET for((VV,EV,E theregraph illustration. MAX-INDEPENDENT-SETknow of ofG⊆⊆))Sgraph(graph graph graphisV,E of problemisgraph that an the an)G edgeGGG INDEPENDENT-SETwe(( RecallproblemV,E((V,EV,EV,E of canof connecting finding) )the))that solveof⊆,, then thenofgraph graph NP-hard finding aproblemVV maximumA ⊆ isand(SS a a problems X maximumisisB of by) an an. ,.subset the Since then using INDEPENDENT-SET INDEPENDENT-SET− havegraph subsetofA, problem yet nodes BG( /toV,Eis ofV be Y sucha nodes) as VERTEX-COVERsolvedS a,⊆ that we black-box such inof of have− for− polynomial the the that everyA,. for B If edge, every we of−S the can. at As edge, mostA and at one− mostB ofare oneits connected endpoint of its endpoint is in is in − graph ( ) thattime⊆ MAX-INDEPENDENT-SET forgraph more( thanLemma) 4 decades. 1.graphIf S MIN-VERTEX-COVER⊆⊆G( isVV,E alsois) an aNP-hard INDEPENDENT-SET⊆graphgraphGG problem(((V,EV,E is a))) graph− bygraph reducing problem ofG graph(graphV,E a that) MIN-VERTEX-COVERG((V,E involves)), then− finding−graphV problemaS minimumis problem agraph VERTEX-COVER of− findingG subset into(V,E a a) maximum of the subset of nodes such that for every edge, at most one of its endpoint is in ⊆ graph problemgraph G of(V,E finding) aLemma maximum 2.graphgraph subsetIf SGG((V,EV,E ofVgraph nodesis)) − a⊆ VERTEX-COVERG such(V,E that)graph for every problem of edge, graph ofthe atfindingG subset. most(V,Ethe a) one subset., maximum Suppose then of itsV Supposeendpoint we subsetS alreadyiswe an of isProof. alreadyINDEPENDENT-SETProof.nodes know in − thatThe suchThe know proofMIN-VERTEX-COVER proof that that isfor is MIN-VERTEX-COVER actually∈ actually every of− the edge, similar similar at toto is most the athe NP-hard previous oneprevious is∈ a of NP-hard itsproblem. lemma. lemma. endpoint problem. Let LetTherefore, isus us in assume assume Therefore, we that thatcan weV showV canSSisis show not not a a INDEPENDENT-SET. INDEPENDENT-SET. graph G(V,E) of nodes such that fortime⊆ every forsolve edge, more problem thanat least 4 Y, decades. one then of we its MIN-VERTEX-COVERProof.by can endpointProof.LemmaProof. an solve edge,The The problem is1. proof proof inproofweIf theS note is is X subset.actually actually asV that is well.is a− an graphS MAX-INDEPENDENT-SETsimilar similarProof. Therefore, INDEPENDENT-SETis not problem to toThe an the the problemINDEPENDENT-SET. proofprevious thatprevious previous involvesis actually Y lemma. lemma. is of also finding graph is similar Let impossibleLet a Let us Gus a us to(assume ThisminimumassumeV,E assume the to) is previous,that thensolve. athat that subsetcontradiction. VVV lemma.SSisis isisis not not not Let a a VERTEX-COVERa Therefore aus INDEPENDENT-SET. INDEPENDENT-SET. INDEPENDENT-SET. assumeV that VS ofisS the ais− not− a INDEPENDENT-SET. MAX-INDEPENDENT-SETgraph G(V,E) problem.Proof. The proofProof.Proof. is actuallyProof.LetLet us us similarLet assume assume us to assume the that that⊆ previousVV thatSS lemma.Visis not notStheis a Leta VERTEX-COVER.not VERTEX-COVER. subset. us a assume VERTEX-COVER. SupposeProof. thatTheV we Therefore, Therefore, proof alreadyS is not isTherefore, actually know a there there INDEPENDENT-SET. that similar are arethere MIN-VERTEX-COVER− two− twoto are vertices verticestheV twoV previousSS verticesA,A, B B lemma. / /A,VV isB− a /LetS NP-hardSV− us assumeS problem. that V Therefore,S is not we a INDEPENDENT-SET. can show Proof. The proofthe subset.is actually Suppose similar we tothe alreadygraphProof. previous knowGThe(V,E lemma. that proof) MIN-VERTEX-COVER LetisProof. actually us assumeThe similar proof that totheV is theProof.Proof. actually subset. isS previous ais NP-hard notLetLetTherefore, similarSuppose a us lemma.us INDEPENDENT-SET.that assume problem.assume toProof. we MAX-INDEPENDENT-SETProof. the thereLetthat already previousthat that us Therefore,Proof. MAX-INDEPENDENT-SETThe areThe assumeVV knowtwo proof proof lemma.LetSS verticesthat−−is thatwe is is us notactually notactually canV Let assume MIN-VERTEX-COVER− aA, a showusSA, VERTEX-COVER.Therefore, VERTEX-COVER.Therefore, Bis assumesimilar similarB is not that alsoV aV toV INDEPENDENT-SET. tothat aisS therethe NP-hardtherethe alsoSProof.andSV previous previousis a are thereareS NP-hardnot Therefore,Let is Therefore,is problemtwo two a not a is lemma.usNP-hard lemma. VERTEX-COVER. vertices anvertices a assume problem INDEPENDENT-SET. edge by there there Let Let reducing problem.A,A, connecting that us us byB areB are assume assume reducingV two twoV aV Therefore, MIN-VERTEX-COVER Therefore,S vertices verticesA thatS thatSAisand aandV not MIN-VERTEX-COVERB there wethereA,SA, aB.. there VERTEX-COVER.B Sincecan SinceBis is is notis/ not/ show anV an areVA, a∈∈ aA, edge INDEPENDENT-SET.edge INDEPENDENT-SET.B twoS BS problem−−∈ connecting connectingVverticesV problem−S Therefore, intoS,, A, aA BA intoandand / V there aBB..−S Since Since are twoA,A, B verticesB VV A,SS,, B / V S Proof. The proofgraph is actually problemProof. similarProof. of findingof toTheThe nodesthe aproof proofProof. previousmaximum such is isLet actually actually that lemma. us subset for assume similar similar everyLetProof.− ofandand usnodes tothat to edge, assume theLet thethere thereVERTEX-COVER.andTherefore,Vgraph suchnot previous previousus at is isthattherea leastassumeS thatINDEPENDENT-SET. an anProof.Gis(V edge edgeV,Elemma. notlemma.one is forthere an thatSThe) aevery of connecting connectingis edge VERTEX-COVER. are its not Let Letproof edge,endpoint two connecting aus us INDEPENDENT-SET. is assume assume verticesis actuallyatAATherefore, notTherefore,and mostand is−that ainthatABBthat VERTEX-COVER.similar onetheand.. Therefore,VV Since Sincetheresubset. MAX-INDEPENDENT-SETofthereBS toS its.isA,is SinceA, the are endpoint not notTherefore, B B MAX-INDEPENDENT-SET there previousandtwo / a/ aA,V INDEPENDENT-SET.V INDEPENDENT-SET. vertices Bthere vertices are Therefore, is /SS lemma.− inthere twoV,, is we we anA, verticesS have haveare, Bedge Let therewe two isA,A, us haveVconnecting alsoA, Bassume Bvertices are∈ B∈SA, a two SS is/and NP-hardand B..−− aV that As AsA, vertices thereSA BAS.andandand As problem is−V−A anBBis.and notSinceSareedgeare byandB aconnected connected reducingconnecting INDEPENDENT-SET.are there connected is a an MIN-VERTEX-COVERA edgeand, connectingB. Since A,A Band problemVB.∈ Since∈S, into−−A, a B V S, Proof. TheTherefore, proof is actuallytherethat are MAX-INDEPENDENT-SET similar two vertices to the previousA, B Therefore, lemma.V S isand Letalso there thereus a assumeNP-hard are is antwo that edge problem verticesTherefore,V connectingS byA,isthat notBreducing there aMAX-INDEPENDENT-SETAV INDEPENDENT-SET. areand aS two MIN-VERTEX-COVERBand.− verticesMAX-INDEPENDENT-SET Since thereTherefore,Therefore,A,MAX-INDEPENDENT-SET isA, B an B edgeV thereV there−− is connectingS alsoproblem,S are areand a two two NP-hard there intoproblem. verticesA verticesweweand a is∈ have have problem problem.∈anBA,A,. edge−A,A,− Since B B− B B by connecting /V /VA,− reducingSS.. BS AsS AsandandAVAA aandand there there MIN-VERTEX-COVERandS,BBB is∈are isare. an an Since connected connected− edge edge∈A,− connecting connecting B− by byV an probleman− edge,S edge,AA, andand∈∈ into we weBB note.− note a.− Since Since∈ that that∈ A,A,−S−S B Bisis not notVV a aS∈ VERTEX-COVER.S VERTEX-COVER.,, − ∈ − This This is is a a ∈ − the subset.∈ − SupposeProof.graph weLet alreadyTherefore, us problem assumeWe know are− thereof that using that finding areV MIN-VERTEX-COVER NP-hardandand∈ two aS there maximumthere −is vertices problemsnotwewe is isis have an aan haveA, VERTEX-COVER.subset edgeedge edgeTherefore, BA,forA, B illustration.connecting− connectingB ofV is / / anodesand∈SS. NP-hard∈.S there. As As thereand− As such −AA RecallA are there Therefore,and and isand problem.and that two anweB thatB isB edge haveare for.vertices an..are SinceSince NP-hardSince Since everyconnectededgeTherefore, there connectingA, connected −− BA,A, connecting edge, are B/ problems BS / two/ .and bywe∈ atV∈ byAsVA∈∈∈ an canmost verticesand thereanA− have−SAS edge,and−,− edge,show, ,andB we∈ weone we is yet.B A,havewe Sinceanhave haveBthere of−we toare. B edgenote its Sincebe note A, /A,connectedA, is endpointsolvedV B thatBconnecting anB thatA, / edgeS BSSV in.∈∈S. ..isis polynomialAsAsisby As Asis connectingV not notS in notA anA,A∈ we and a aand∈Sand edge,and a VERTEX-COVER. VERTEX-COVER., have VERTEX-COVER.∈B B−BA we.areareA,− Sinceand note connectedB connectedBA, that.S Since. B AsS / This ThisAVis ThisA, notandB is isS is a, aB∈ a we∈ VERTEX-COVER.Vare have−−S connected, A, B S. As ThisA isand a B are connected∈ − Therefore,A, B thereV S areWeProof. two will vertices firstTheTherefore,Therefore, prove proofA, Bisthe actually there thereand followingV thereare areweS similarand two twohave two isA antherevertices vertices to lemmas.A, edge the B− isB previous/ anbyA, connectingbyA,S. Bedge Ban an AsLemmaby edge, edge,A, lemma.AVV connecting anand BASS edge,we we 2.andBandVand Let∈ note noteareIfB us∈there weSthereA∈. connected− assumethat SincethatandA, noteA,V is is B BBisS anS anA, that/. / that aisis SinceSedge edgeS B VERTEX-COVERby not notSV / an connectingV connectingisA, an anAA edge,S not B INDEPENDENT-SET.MAX-INDEPENDENT-SET INDEPENDENT-SET.isS, not an weBVB a INDEPENDENT-SET. haveAnoteA∈ INDEPENDENT-SET.Sandand of,∈∈we thatA, graphBB haveB−−..S Since SinceGisSA,(. notV,E BAs ThisA, ThisA, a/ BA) B, VERTEX-COVER.S problem. isand isthen.∈ This AsV aV aB contradiction. contradiction.V−A∈ is∈∈SareSand, a, S contradiction.∈connected−Bis anare−S ThisS INDEPENDENT-SET connected Therefore Therefore is a Therefore byV∈V anS edge,SV∈isis a aof we−S theis note∈ a that− S is not∈ a VERTEX-COVER. This is a Therefore,we there have areA, B twoMAX-INDEPENDENT-SET / verticesS. As A and B are connectedandwe problem. have there byandA, is an B an there edge, / edgeS. iswe∈we As connectingtime an have noteA− edgeand forA, that more connectingB BareS /andMAX-INDEPENDENT-SET thanisS connected.by notby As 4 an. anA aA decades. Since VERTEX-COVER.and edge,and edge,contradiction.contradiction.∈∈ byProof.BB an.we weare− MIN-VERTEX-COVERare− Since edge, note noteconnectedwe connectedLetweA, have havewethat us that BTherefore Thereforeby,assumenoteA, This problem. / SSbyV Ban byis is thatisan / edge,an not notaS thatVedge,, edge,VS. we. an anis As∈is weAsVS we haveaAS− INDEPENDENT-SET.not INDEPENDENT-SET.is weis graph note −note an anSandandcontradiction. a notecontradiction.A,∈is VERTEX-COVER.INDEPENDENT-SET. INDEPENDENT-SET.B thatthat Bproblem not that−areare S a . connectedVERTEX-COVER.S connectedisis Asby that isnot not ThereforeA notThereforean a involvesand an∈ VERTEX-COVER. edge, a This This byINDEPENDENT-SET.VERTEX-COVER. ThisbyB an anareVwe isV findingis∈ is edge, a edge, a connectednote a∈∈S contradiction.Therefore,S contradiction.isis a we we−that− an anminimum note noteINDEPENDENT-SET. INDEPENDENT-SET.ThisS This thereisthat thatis not subsetThisa Therefore isS Therefore con are a anisis- is two not INDEPENDENT-SET.not a contradiction. vertices aV aV VERTEX-COVER. VERTEX-COVER.SS−−isA,is a Ba − / ThereforeV ThisS This This isV is is a a a contradiction.S is a Therefore V S is a ∈ we have A,∈ Bthat− / S.Therefore, MAX-INDEPENDENT-SET As A andwewe thereB have haveare∈the areA, connectedA, subset. Btwo Bby / / an verticesSS.. Suppose edge, is Asby As also anAAA, weandand edge, a B we NP-hard noteBbyB already∈V weareareVERTEX-COVER. anVERTEX-COVER. that note connectedS connectededge, problem knowandVERTEX-COVER.Scontradiction. thatis we there that notS∈ bywe note by byis reducingan MIN-VERTEX-COVERis have notan− an anthat INDEPENDENT-SET. edge, edge, aTherefore edge⊆ VERTEX-COVER. a we weisMIN-VERTEX-COVER connecting∈∈ not note note. As ancontradiction. that that INDEPENDENT-SET.−andisA isSS anand ais Thisis This NP-hard INDEPENDENT-SET. not notBare. is is aTherefore a Sinceconnected a problem VERTEX-COVER. aVERTEX-COVER.contradiction. problem. contradiction.A, BV into by This Therefore,V an aS is edge, Therefore−S− an Thereforea, This This contradiction. INDEPENDENT-SET. we we is is note canV a− a V show thatS isS anThereforeisis aINDEPENDENT-SET. not a VERTEX-COVER.is a ∈ − This is a we have contradiction.A, B / S. As A Thereforeand B areV connectedS is an INDEPENDENT-SET. bycontradiction. an edge, we note Therefore that∈SVcontradiction.is notS is a∈ an VERTEX-COVER. INDEPENDENT-SET. ThereforegraphandV thereG ThisWe(contradiction.SV,Econtradiction.is willis is) an anWe a first INDEPENDENT-SET.∈ edge will prove−∈ connectingfirst Therefore Therefore the− prove− following theVVA and followingSS twois∈isB an. an lemmas. Since INDEPENDENT-SET. INDEPENDENT-SET. twoA, lemmas. B− / V S, we have A,− B S. As A and−− B are connected − − ∈ − LemmaMAX-INDEPENDENT-SET∈ 1. If byS anVthat edge,is ancontradiction. MAX-INDEPENDENT-SETof we INDEPENDENT-SET∈ problem. nodes note− such that Therefore thatSVERTEX-COVER.∈VERTEX-COVER.is for not− everyV of an graph istradiction.S INDEPENDENT-SET. edge, alsois− ancontradiction.G a at( INDEPENDENT-SET. NP-hardV,E leastTherefore)VERTEX-COVER., one then problem of ThereforeV its This endpointS by isis reducing is V aan a VERTEX-COVER INDEPENDENT-SET. contradiction.−− isS inis athe anMIN-VERTEX-COVER INDEPENDENT-SET. subset.VERTEX-COVER. Therefore of MAX-INDEPENDENT-SET∈ the∈ −−V problemS is a − into a ∈ is a contradiction. Thereforewe haveV A,contradiction.contradiction.S B⊆is / anS. INDEPENDENT-SET. AsVERTEX-COVER.A Therefore Thereforeand B areVV connectedSS isis an an INDEPENDENT-SET. INDEPENDENT-SET.− byTheorem an edge, 1. weS noteV that −S is not aTheorem−Theorem VERTEX-COVER.We will 1. 1. firstIfIfSS proveV ThisV theisis a ais following MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET aG−(V,E two) lemmas.V S of of graph graphGG((V,EV,E)),, then thenVV SS isis a a MIN-VERTEX-COVER MIN-VERTEX-COVER contradiction. Therefore VWe willS is first an INDEPENDENT-SET. provegraph the followingG(V,E−)VERTEX-COVER. two∈ lemmas.graph problem−− ofWe findingLemmaLemma will aTheorem firstTheorem maximumby 2. 2. prove anIfIf edge,SS 1. the 1. subsetIfIfVV followingIfweSSisis noteof a aV VERTEX-COVER VERTEX-COVERV nodesisis that twois a a a MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETsuchlemmas.TheoremS is that not foran 1. of of everyINDEPENDENT-SET.If graph graphS Theorem edge,VGG((isV,EV,E⊆⊆at a of ofG MAX-INDEPENDENT-SET of most))1. graph graph,,V,E graph then thenIf oneS VVG( This of(VV,E itsSSis)V is,,is a)is endpoint then, then a MAX-INDEPENDENT-SET an thenan contradiction.S INDEPENDENT-SET INDEPENDENT-SETV is ofS inisis graphis a a a MIN-VERTEX-COVER MIN-VERTEX-COVER MIN-VERTEX-COVER ThereforeG(V,E) of, of ofV then the the graphVS isGS a(V,Eis−− a) MIN-VERTEX-COVER, then V S is a MIN-VERTEX-COVER Theorem 1. If S −V is a MAX-INDEPENDENT-SETcontradiction.Theorem 1. If Therefore ofMAX-INDEPENDENT-SETS graphV isGV a(TheoremV,E MAX-INDEPENDENT-SETS )is, then an 1. INDEPENDENT-SET.VIf SS problem.isVProof. aLemmaTheoremis MIN-VERTEX-COVERLemma a MAX-INDEPENDENT-SETThe ofTheoremTheorem 2. graph Lemma proof 1.If 1. IfIfG is⊆ S(⊆ 1.actually 1.V,E 1.IfIfisIfV)SS, a Sis thenissimilar VERTEX-COVER anVV aV Vis INDEPENDENT-SETis MAX-INDEPENDENT-SETis aofto aofof an MAX-INDEPENDENT-SETS MAX-INDEPENDENT-SET graph the the theis INDEPENDENT-SET previousa graph graph MIN-VERTEX-COVERG(V,E of⊆GG lemma.graph()(V,E,V,E then of)).. LetV( graph usof ofS ) assumeof, ofGis graph graph then( graph a graphV,E MIN-VERTEX-COVER thatG),GG(V,E then((V,EV,EV is) V,)S )− an, then,− then thenis then INDEPENDENT-SETS not VisVV a a INDEPENDENT-SET. VERTEX-COVERSSSisisis a a a VERTEX-COVERMIN-VERTEX-COVER MIN-VERTEX-COVER− of− the of the of the Theorem 1. If S LemmaLemmaV is⊆ a MAX-INDEPENDENT-SET2.of 2.ofVERTEX-COVER. theIfIfIf theSS graphTheorem graphVV⊆⊆GisisisG(( aV,E aLemma( aV,E VERTEX-COVER⊆ VERTEX-COVER1. VERTEX-COVER))..If). S 2.⊆⊆ ofIfVof graphSis the a MAX-INDEPENDENT-SETV graphG of of of(isV,E graph graph graph aG VERTEX-COVER)(,V,EG thenGLemma(((V,EV,E).V ))),,, thenS 2.then thenisIf− aVVS of MIN-VERTEX-COVER of graph⊆ graphSSV−−isisisis anG an an aG((− VERTEX-COVERV,E INDEPENDENT-SET INDEPENDENT-SETV,E INDEPENDENT-SET)−),, then then V −−S ofisis grapha an of ofMIN-VERTEX-COVER of INDEPENDENT-SET the the theG(V,E), then V S ofis the an− INDEPENDENT-SET of the ⊆ Theorem 1. If SWeV willis afirst MAX-INDEPENDENT-SETTheoremTheorem prove the⊆ 1. 1.Lemma followingtheIfIf SS subset.−VV 2. twoisisIf Suppose a a lemmas.S MAX-INDEPENDENT-SET ofMAX-INDEPENDENT-SET⊆ graphV−graph wegraphisG aalready( VERTEX-COVERV,EgraphGG((V,EV,E), know thenG⊆⊆))(V,E thatV ) of MIN-VERTEX-COVERofS ofgraphis graph⊆ a graph MIN-VERTEX-COVERG⊆G((V,E⊆V,EG(V,E)⊆),,− thenLemma then), thenVV is aV 1. NP-hardSS ofisisIfS a aStheis MIN-VERTEX-COVER MIN-VERTEX-COVER− anproblem.graphV INDEPENDENT-SETis anG(V,E INDEPENDENT-SETTherefore,−−⊆ ). we can of show− the of− graph− G(V,E), then V S is− a VERTEX-COVER of the Theoremof 1. theIf graphS VGLemmais(V,E a MAX-INDEPENDENT-SET). 1. If S V is an⊆of INDEPENDENT-SET the of graph graphG(GV,E(V,E).V)S, of thenof⊆⊆ graphSV theV G graphG(SV,ELemma(V,Eis⊆ aG) MIN-VERTEX-COVER)(,V,E then 1.)Therefore,.IfVSgraphSV ofisofisisGthere graph athea the( anMIN-VERTEXCOVER VERTEX-COVERV,E− graphgraph INDEPENDENT-SET areGG) (V,E twoV,EGG((V,E vertices)V,E)).. V ofA, theof BS the ofV graph graph−− A,S− BandG( /V,E⊆ thereV ) ,. S isthen anV edgeS connectingis a VERTEX-COVERA and B. Since of theA, B V S, − ⊆ ⊆ Proof. Let usofLemma assume theS graph that 2.ofVgraphIfthatGG the(V,EV,E graphMAX-INDEPENDENT-SETG()isV,E. is not− a) VERTEX-COVER agraphgraph VERTEX-COVER.. GG(((V,EV,E−)))⊆ ofisof also graphthe Therefore, graphagraph NP-hardG (V,EG there(V,E)(, problem then) are.) V two byProof.Proof.S vertices reducing∈isG anWeWe−V,E INDEPENDENT-SET a knowgraph know MIN-VERTEX-COVER that thatG(V,EVV ) SS isis− a of a vertex vertex the problem cover cover into by by a lemma lemma 1. 1. The The only only∈ thing thing− that that remains remains for for us us to to prove prove is is its its of the graph G(V,E).graph Gof(V,E the) graph G(V,ETheorem). of 1. theIf graphWeis will( a−⊆ MAX-INDEPENDENT-SET first). provegraph the followingG(V,EProof.weProof.Lemma) have twoWe of lemmas.WeA, graph 2. knowB know / S that.( that AsVVA)V,and thenSSProof.isBisis a aare a vertex− vertexgraph vertexWe connectedis aknow cover cover MIN-VERTEX-COVER cover( that by by) by an∈ lemma lemmaV lemma edge,−SG 1. 1.(isV,E we1. aThe The Thenote vertex) only only only that cover thing thingV thingS is byS that that not that lemma a remains remains remainsVERTEX-COVER. 1. The for for for us us only us to to to thing prove prove prove This that is is is its its aits remains for us to prove is its andLemma there 1. isIf angraphS edgeVG connectingis(⊆V,E an INDEPENDENT-SET) A and B. SinceProof.Proof.A, of BProof. graphProof.TheThe / V proof proofG TheWe(SV,E, isknow is weproofIf actually actually), have thenthat is actuallyA, similar similarVis B− aS VERTEX-COVER similarS to toisis.the the Asaa− vertex VERTEX-COVER topreviousA previous theand cover previousB lemma. lemma.are Proof.by of connected graphlemma lemma. Let Let ofWe us usthe 1. knowLet assume assumeThe−− us only that, assume thenthat that thingVVV that thatSSSisVisis remainsis a not not anvertexS a ais INDEPENDENT-SET INDEPENDENT-SET. INDEPENDENT-SET. not cover a INDEPENDENT-SET. by lemma 1. of The the only thing that remains for us to prove is its Proof. We know that V S is a vertexofProof. cover the graphWe by lemma knowG(V,E that 1.).MAX-INDEPENDENT-SET TheV Proof. onlyS is thing aWe vertex thatknow cover remains that byV problem.∈ lemma forProof.S− usProof.isProof. toProof. 1.aLet vertex prove∈ The usWeWe⊆Let assume only isknow cover know itsus thing− assume− that by∈that lemma thatVV thatminimality.minimality. remainsSS 1.isVis The a anot vertex vertexS for only ais SupposeSupposeus VERTEX-COVER. not cover thing cover to a− prove VERTEX-COVER. by thatV byV lemma lemma is remainsSS itsisis not not1. Therefore,1. forThe minimumThe minimum− us− Therefore, only only to there prove thing thing vertex vertex are there is that that cover. its cover.two remains areremains vertices Then,two Then, for vertices forA, there there us us B to to / isA, is proveV prove another Banother /S is isV its its vertex vertexS cover cover VV SS wherewhere ⊆ Proof. We know thatProof.Proof.V TheTheminimality.contradiction.Sminimality.graphis proof proof− a vertexProof.G is is( actuallyV,E actually Suppose Suppose cover ThereforeWe)Proof. similar similarknow byVV lemmaTheV thatto− toS proofS the theminimality.isisSVis 1. not notpreviousis previous not is The− an−Sactually minimum minimum minimum INDEPENDENT-SET.is only alemma. lemma. Suppose vertexsimilar thing vertex vertexProof. vertex Let Let cover that toV us us cover.the cover.The cover.assume remains assumebyS previousis lemmaproof Then,not Then, Then, that that for is minimum lemma. 1. actuallyV us there thereV there The toSS−− prove isLet isis onlyis similaris vertex not another another not not anotherus thing isa− assumea a INDEPENDENT-SET. to INDEPENDENT-SET.its INDEPENDENT-SET.cover.the vertex vertex that vertex that previous Then, remains cover coverV cover lemma.thereSVis forV not isusSS Let a another towhere INDEPENDENT-SET.where us prove assume vertex is its that coverV VS isS not where a INDEPENDENT-SET. Proof.− We knowbygraph an thatG edge,(VV,E we)SProof.Proof.is note aLemma vertexWeWe that know knowProof.S cover 1.is− that that notIfThe bySVV an lemma proofV INDEPENDENT-SET.SSis isisis 1. an actually a aTherefore,Therefore, The vertex INDEPENDENT-SET vertex− onlyTherefore, similarfor cover cover thingus there there to by by theprove thatare Thisare there lemma lemma previous two two remains is are ofits avertices 1.vertices 1.two contradiction.graphminimality. Thelemma. The− for vertices onlyA, onlyA,G us( B BLetV,E to thing thing SupposeA,− prove usProof.V)V, B Thereforeassume then that thatSS is−V Letandand itsV remains remains that usSminimality. there thereVSand assumeV isis for forisS aisnot thereS VERTEX-COVERan anis usis usminimum that a notedge edge Suppose−tois to− an provea proveVconnecting INDEPENDENT-SET.connecting edge vertexS isV isis connecting its its not S ofcover.AAis atheandand not VERTEX-COVER. Then,ABB minimum.and. Since SinceB.A,A, Since vertex− B B Therefore,A,VV cover.− B SSV,,∈ Then, thereS−, ∈ there are− two is another vertices vertexA, B−− / coverV VS S where Proof. Weminimality. know that SupposeProof.V S LetisV a us vertexS assumeis not cover minimumthat byminimality.V lemmaS vertexis 1. not Suppose The cover. a VERTEX-COVER. only Then,V thingminimality.S there thatis not− is− remainsProof. anotherminimum Therefore, Suppose forLet vertex us vertex usV there to assumeand cover proveS cover. areis thereminimality.minimality. notV twothatand is itsThen, is minimum vertices thereSV an where edge thereS Suppose isSupposeisA, an−− vertexconnecting not Bis edge− another / aVVV VERTEX-COVER. cover.connecting−∈ SVSVSA vertexis−isand Then,S notS not > have BSS isS is . another.whereA, anotherA,S By By. B B As lemma lemma /AS vertexV vertex.and As 2, 2,∈SABS−S cover cover−andare−isis an an connectedBVV independent independentareSS connected wherewhere set. set.− Therefore, Therefore,− SS∈isis not not− a a − − Proof. Theminimality. proof is actually Suppose⊆ similarTherefore,Therefore,V toS theVis thereV there previous− notSS areminimality.are minimum<< twolemma. twoVV verticesTherefore, verticesSS vertex,, Let Suppose, which which which usA,A, cover. assumeBthere implies impliesB impliesV VV are Then,−∈ that−S that that thatS twoisS<−Vand notand∈ thereS verticesVSS there minimumthere> −is>S is− notTherefore,S, anotherS isA,.. whichis a. By By an anB ByINDEPENDENT-SET. vertex lemmaedge lemma edge lemma impliesV vertex there connecting connecting cover.S 2, 2, 2,arethat coverandSS twoisis Then,thereisS an anV− anA verticesA> independent independentandis independentandS thereS an .whereBB− edge ByA,... is Since Since SinceBlemma another connecting set. set. set.VA,A, Therefore, Therefore,2, B B Therefore, vertexSSandVVisA∈ an coverandthereSSS independent−,,,SB∈isis isV. not not Sincean not−−− aS aedge a A,where set. connectingB Therefore,V S,A andS isB not. Since a A,− B V S, minimality.− SupposeVERTEX-COVER.Proof.V− WeSminimality.minimality.is know notgraph minimum thatTherefore, Suppose SupposeGV(V,E− S vertex)isVV there a vertexcover.SS areisis not not cover two Then,wewe− minimum minimum have have vertices bywe therethere lemmaA,A, have BB A, isis vertex vertex/ /BA, another another 1.SS B..− The AsV Ascover. cover. / SAA vertex− only.Sandand Asand Then, Then, thingA BB cover cover thereandareare there there∈ that B connected connectedV isare an− is|andremains is| S edgeanotherconnected another−− therewhere− by by| connecting| for an anis vertex vertex|| usV an edge,by edge,−− to edge anS cover provecover−|| weA weedge,< connectingand note noteV∈V is weB its that that.S− noteSS Since ,∈ where which whichwhereSAS thatisandis−A, not− not B impliesS implies|B| is a. a|| SinceVERTEX-COVER.V VERTEX-COVER.not | that| that aS∈||A, VERTEX-COVER., S B /∈>∈V S −.S ThisBy This, we lemma is is have This a a 2,A, isS aB isS an. As independentA and B are set. connected Therefore, S is not a minimality.V SupposeS < VVandS thereS,is which not is an minimumimplies edge connecting that vertexSV > cover.SASand<. By Then,VB lemma. SinceS there, which 2,A,WeS is BV anotherimpliesis will/ anVS first independent that, is set.|Theorem which|A,S following an|Proof.V.− B Therefore,edge−by By impliesS|| an lemmaS|TheV connecting.V two1.where edge,|by As|∈|If proof thatS− lemmas. anAS 2,S−−andis we anand a weare aSS independentthat MAX-INDEPENDENT-SET note,Bconnected,.| similar∈ which∈ which. ByS Since− that lemma−is−maximummaximum impliesto| implies notA,S the set.||| B| anis2,| previous|−/ thatnot|S Therefore, that INDEPENDENT-SET. independentV independent||is|| an|| anSS|S lemma. INDEPENDENT-SET., independent> we>∈ ofSSS have graphis set.. set.. Let− not By ByA, Thisus This lemmaG a lemma B set.(assumeV,E is Thisis| S Therefore,a a) 2,. 2,|, contradiction. contradiction. thenAsthatS isS This| a∈Aisis|VV contradiction. anand an isS−S independent independentS aisBisis contradiction.∈ notare not ThereforeTherefore a MIN-VERTEX-COVER aconnected− a INDEPENDENT-SET.∈∈ Therefore set. set.VV−− Therefore, Therefore, ThereforeSS isisV the the−S minimumS minimumSVisisis a not notS ∈is a a vertex vertex a− cover. cover. ∈ − Proof. Let− usTherefore, assume that thereV V −S are| S<− twoisV not−− vertices| S awe|we VERTEX-COVER., which− have haveA,| BA, impliesmaximumA,maximum BV B / /S thatSV.∈∈..and independent As AsTherefore, As independentSAA there∈weand> set. connected ThereforeV Since note note|SA, This.S|B set. BythatA, that /− isV−−B lemmaV Therefore,bySS aS.| contradiction.is anS AsisisVS notis notis notedge, 2,Ais the theSSand the a a a,S VERTEX-COVER. minimumVERTEX-COVER. minimumVERTEX-COVER.is we minimumisB an notnoteare Therefore− independent a connected that vertex vertex vertex| S|∈Vis cover. cover. cover.| not set.This by This This−S| an ais Therefore, is is VERTEX-COVER.is the edge, a a a minimum weS noteis vertexnot∈ that a ThisS cover.is is not a a VERTEX-COVER. This is a | − | | −− | V S < V Sminimality.|,| which|− | | implies|VV | SupposeSS− that <<| weVVVS have>SSS,,S∈is whichA, which. not ByB− / minimum lemma implies impliesS.| Ascontradiction.contradiction. 2,| thatA thatS vertexand| contradiction.isS|SB an−> cover.>∈are independentS|S Therefore| Therefore connected. . −−By By Then, Thereforelemma lemma|| VV thereset.|| by 2,− 2, 2,an−SS Therefore, V isSSisis edge,|| another an anisisS anan INDEPENDENT-SET. INDEPENDENT-SET.is we independentby independent anS note vertexisan INDEPENDENT-SET. not edge,that∈ cover a Smaximumset. set.− set.we|is| V Therefore, not| note| Therefore, Therefore,S| a|  thatindependent VERTEX-COVER.||where SSS isisisis not ∈ not not set. a an a amaximum This INDEPENDENT-SET. This is− ais in contradiction. a- Therefore This−− is a−V contradiction.S−is the minimum Therefore vertexV cover.S is a V S maximum< V S independent, whichby an implies edge, set. that we This noteS is a> that contradiction.SmaximumS. Byis not lemma an independent Therefore 2, INDEPENDENT-SET.S is| anV− set. independent−maximumS| Thisis| the is−by aminimum independent contradiction. This set.| anedge, Therefore, is vertexaof∈ contradiction. we set.the∈ Thereforenote− cover.∈S graph This| ismaximummaximum that− not is|G a(| aV|V,ES contradiction.Thereforeis|| independent independentS) not.| −is the an|V minimumINDEPENDENT-SET.∈ ThereforeS set. set.isA, This Thisa B vertexV is isV a a cover. contradiction.S contradiction.S|is|∈ the This| minimum−| is a Therefore∈ Therefore contradiction.− vertex∈− −V cover.V SS is Thereforeis the theA minimum minimumVB −S vertex vertexis aA, cover. cover. B V S | − | | Lemmaand− there| 2. isIf an||weS edge−− haveVProof. connecting||isA, amaximum|| B| VERTEX-COVERLet− /−|−S us.||A As| assumeindependentandA andB∈.contradiction.that Sincecontradiction.contradiction.B ofare set. graphVA, connected BThisS|Therefore,|G /is|VERTEX-COVER.(|V isV,ETherefore notTherefore Therefore amaximum|| bycontradiction.S) a||,VERTEX-COVER., VERTEX-COVER. thenan therewe edge,Vcontradiction.V haveV independent areSS weA,− two−Sisisis Therefore Bisnote an an an vertices an INDEPENDENT-SET.− INDEPENDENT-SET. INDEPENDENT-SET.S that INDEPENDENT-SETTherefore. set. Therefore, AsVS ThisAisandS not isVis athereB thea contradiction.areS VERTEX-COVER.contradiction. minimumis are connectedand an two− INDEPENDENT-SET.of there the vertices vertex Therefore is Therefore an cover. This edgeA, BV is connecting /V aVS SisSis the an minimum INDEPENDENT-SET.and . vertexSince cover. −, − | − | | − | maximum independent| | | V| set.S maximum< ThismaximumV is aS contradiction., independent independent whichcontradiction.Lemma− implies 1. set. set. ThereforeIf that ThereforeS This ThisSV is isVis> a aV contradiction. ancontradiction.SSdependent. INDEPENDENT-SETisS By theis lemma an minimum INDEPENDENT-SET. set. Therefore Therefore 2, ThisS− vertexis is anaVV ofcontradiction. independent cover. graphSS−isis the theGVERTEX-COVER.( minimum minimumV,E From set.ThereforeFrom∈), Therefore,− then the− the vertex vertex above aboveV cover. cover.S theorem, theorem, isis notathe VERTEX-COVER minimum a we we conclude conclude vertex−− that that cover. of athe a MIN-VERTEX-COVER MIN-VERTEX-COVER− ∈ can− can be be easily easily constructed constructed if if we we have have a a maximum independentVERTEX-COVER. set. This is a contradiction. Therefore⊆V S is the∈ minimumVERTEX-COVER. vertex⊆ cover.− −we∈FromFrom have− theA, the Babove above / S−−. theorem,− Astheorem,A−∈and we weBFrom concludeare conclude− connected the abovethat − that a abytheorem, MIN-VERTEX-COVER MIN-VERTEX-COVER− an edge, we we conclude note that∈ that− can− canS− ais be MIN-VERTEX-COVER be not easily easily a VERTEX-COVER. constructed constructed if if we can we Thishave have beeasily is a a a constructed if we have a graphby an| G edge,−(V,E| we)contradiction.| note−and− that| thereS Thereforeis is not an edge anV INDEPENDENT-SET. connectingS| isTheoremTheorem| an−| INDEPENDENT-SET.TheoremA| and 1. 1. BIfIf.SS 1. ThisSinceIfVV∈S isisA,is a a a BV contradiction.MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETV /isV− aS MAX-INDEPENDENT-SETS, we have ThereforeA, B V ofS ofFrom. graph graph AsS is of theA aG graphGand( above(V,EV,EBG))are,(, theorem,V,E then then connected),VV then weSSV concludeisis a aS MIN-VERTEX-COVER MIN-VERTEX-COVERis a that MIN-VERTEX-COVER a MIN-VERTEX-COVER can be easily constructed if we have a From the above theorem, we concludemaximum thatFrom a MIN-VERTEX-COVERtheindependent above theorem,graph set.From ThisG the(From weV,E is above conclude can a) the− contradiction.Theorem beTheorem theorem,above easily that theorem,Proof.MAX-INDEPENDENT-SET. constructed a1. 1. we MIN-VERTEX-COVER ThereforeLemma concludeSSWe weV knowLemmaVFrom conclude⊆⊆ ifFrom 2.V wethatTheoremIf that havetheS⊆ theS a2.is thatMIN-VERTEX-COVER above above∈IfV atheS 1.is acan minimum− MIN-VERTEX-COVERa theorem,If theorem,isV VERTEX-COVERbeS ais vertexeasilyMAX-INDEPENDENT-SET.MAX-INDEPENDENT-SET. aV vertexVERTEX-COVER weis we constructed acover conclude conclude MAX-INDEPENDENT-SET cover. canTheorem by∈ of be lemma− that that graphcan if easilyGG we(a of( abe1.V,EV,E 1. MIN-VERTEX-COVERhave MIN-VERTEX-COVERG graphconstructed easily( The)V,E)S a G only) constructedV,(V,E thenVV of thing if) graphS weVS,−− then that have ifSG weV(is− remainsV,Ecan acan an haveS be) INDEPENDENT-SETbe,is then aeasily easily anfor INDEPENDENT-SETV us constructed constructed toS proveis a MIN-VERTEX-COVER is ifif its ofG we we( theV,E have have of) a thea V S From the above theorem, weFromFrom conclude the theTheorem above above that atheorem, theorem, MIN-VERTEX-COVER 1. If S weTheorem weVof concludeof concludeSis the the aMAX-INDEPENDENT-SET. MAX-INDEPENDENT-SETMAX-INDEPENDENT-SET. graph graphcontradiction. 1. thatIf thatIfIf canGG a a((V,EV,E MIN-VERTEX-COVERFrom MIN-VERTEX-COVER beisGisis) easily).( a. Therefore a aV,E− the MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET constructed⊆above) −V theorem,⊆ ofMAX-INDEPENDENT-SET. graphS ifisLemma can can we an weG haveINDEPENDENT-SET.( be beV,E conclude easily easily 2. a), of of ofMAX-INDEPENDENT-SET. thenIf graph constructedgraph constructedgraphS thatV V aS(is MIN-VERTEX-COVERis aIf aifif VERTEX-COVER), MIN-VERTEX-COVER, we, we then then then have haveVis a aS MAX-INDEPENDENT-SETisis−is a a a MIN-VERTEX-COVER of MIN-VERTEX-COVER MIN-VERTEX-COVER can graph− be easilyG(V,E constructed), then of graphV if weS is have an INDEPENDENT-SET a, then is a MIN-VERTEX-COVER of the FromMAX-INDEPENDENT-SET. the above theorem,Lemma we 2. concludeIf S V thatVERTEX-COVER.is a a VERTEX-COVERMAX-INDEPENDENT-SET. MIN-VERTEX-COVERby an of graphedge, canMAX-INDEPENDENT-SET. weG be(V,E note easilyLemma), that then constructedV 2.isminimality.If notofSS theis if an anwe graphV INDEPENDENT-SET.⊆MAX-INDEPENDENT-SET.⊆MAX-INDEPENDENT-SET. INDEPENDENT-SET haveis Suppose a VERTEX-COVERa G(V,EV. ) S −is not Thisof of⊆ the minimum graph is a contradiction.G(V,E vertex), then cover. ThereforeV Then,S⊆is there an INDEPENDENT-SET−− is anotheris a vertex cover of− theV S where − Proof. The proofTheorem is actually 1.MAX-INDEPENDENT-SET. similarIf S toV theis a previous MAX-INDEPENDENT-SETofof⊆ the the lemma. graph graph1GGgraph Let(((V,EV,EMAX-INDEPENDENT-SET. usG)graph) assume)..(.V,Eof of) the that graph graphV G(SV,EGis(V,E not), then) a. INDEPENDENT-SET.V S ofis athe MIN-VERTEX-COVER⊆ graph− G(V,E). − − MAX-INDEPENDENT-SET.⊆ FromMAX-INDEPENDENT-SET.MAX-INDEPENDENT-SET. the aboveVERTEX-COVER. theorem,ofProof. the⊆ graphLet we usconcludeG( assumeV,E). that that− aV MIN-VERTEX-COVER We⊆S sayis that not problem a VERTEX-COVER. X is −reducible− can be to easilyproblemgraph Therefore, constructed YG−(V,E) there if we are have two− verticesa A, B / V S − MAX-INDEPENDENT-SET.graph G(V,E) G V,EA, B graphV SG(V,EVTheorem) −S < V 1. IfSSVV, whichVSS is a impliesA MAX-INDEPENDENT-SET thatB InInS the the >A, beginning beginningS B. ByV lemma of of ofS this this graph 2, section, section,SG (isV,E an we we) independent, assume assume then∈ V − we weS know set.knowis a Therefore, MIN-VERTEX-COVER that that MIN-VERTEX-COVER MIN-VERTEX-COVERS is not a is is a a NP-hard NP-hard problem. problem. It It is is Therefore,Lemma 2. thereIf ofS aretheV two graphis a verticesand VERTEX-COVER( there). is an edge ofProof.Proof. connectingand graph| thereProof.WeWeG−InIn(InV,E theis theknow knowA the| anWeand) beginning beginning, beginningProof.|edge thenthat knowthatB−. connectingV Since| thatThe⊆ of of ofS thisproof thisVA, thisisis B a ansection, asection,S section,is vertex vertex/ INDEPENDENT-SET actuallyandisVIn a the vertexwe we coverS cover we., beginningassumeSincesimilar assumewe| assume by coverby| have lemma lemmato| we weA, wethe| by of know know Bknow lemma this previous 1. 1. ofS thatThethesection, thatThe. that As, 1. lemma. onlyMIN-VERTEX-COVER MIN-VERTEX-COVERonlyA MIN-VERTEX-COVERThe weand thing thing only assume LetB are that thatthingus assume connectedwe remains remains that knowV − that remains isS is that for foris a aV a NP-hard NP-hard us us MIN-VERTEX-COVER NP-hardS for to tois prove proveus not problem. problem. to problem. a isINDEPENDENT-SET.prove is its its ItIt is It is is its is is a NP-hard problem. It is In the beginning of this section, we assumeMAX-INDEPENDENT-SET.In the we beginning know⊆ that of MIN-VERTEX-COVER this section,In the∈ we beginningProof.−Proof. assumeWe isWe ofmaximum weaofknow thisNP-hard know know theProof. section, graphthat that that independent problem.TheInInVVG MIN-VERTEX-COVER wethe theProof. proof(V,ES assumeS beginning beginning−−is Itisis is).set. aWe is a aactually vertex vertex vertex− we knowThis of knowofsimilarthis cover thisiscover cover that agoodgood that section, contradiction.section, isbyV byto by toMIN-VERTEX-COVERa to lemmathe lemma lemma NP-hard knowS know we wepreviousisProof. assume a assume as1. as1. 1.In vertex∈Therefore problem.many manyThe The Thethe lemma.We− we we beginning only cover onlyNP-hard only NP-hardknow know know ItV Let thing thing thing byis isthat thatus thatproblemaS lemma problem of thatassume NP-hard thatis thatV this MIN-VERTEX-COVER MIN-VERTEX-COVER the remains remains remains 1.section,Sas minimum as thatis The problem.possible. possible. a vertex for onlyfor forwe vertex us usassume us Thisis It thingThis cover to to notto is proveiscover. prove proveis a that isnecessarywe isnecessaryby INDEPENDENT-SET. a a know lemmais NP-hard is remainsis NP-hard its its its that so so 1. that thatfor problem. problem. MIN-VERTEX-COVER The us if ifwe only weto encounter proveencounter It It thing is is is that its a a new new remains is problem problem a NP-hard forX, us X, we towe problem. prove is It its is we haveG(A,V,E B) / S. AsLemmaA andProof.In 2.B theareIfWe beginningS connected knowV is that aofminimality. VERTEX-COVERbyminimality. thisV angood section,minimality.goodS edge,is to a to Supposewe Supposeknow vertexwe know noteIn assume Supposeasof the coveras thatV manygraphV beginningmany weS bySS NP-hardV knowGis NP-hardisis lemma( notV,E not notS of that∈ ais) minimum thisminimum problem, VERTEX-COVER. 1.problemnot then MIN-VERTEX-COVER−Proof. Thesection, minimumV as only vertexas vertexThe possible.S we possible. thingis proofassume vertex ancover. cover. This thatINDEPENDENT-SET This is This∈ cover. actually we Then, Then, is remains is is is knowa necessary a necessary NP-hardThen, there there similar that for is usso isthere MIN-VERTEX-COVER toso anotherproblem. anotherthat to the that of prove is ifprevious the another if we vertexwe vertex It is encounterencounter is− its lemma. vertex cover cover− aVLetcoveraV is new new a us NP-hardS problemSV assumeproblem wherewhereS problem.X, thatwhere X, we weV S Itis is not a INDEPENDENT-SET. Proof. TheIn proof the isbeginning actuallygraph similarof this to section,∈ theInInprevious the the we beginning beginning assumeby lemma. an edge,we of of Let know this this we usProof. section, section, thatassume note MIN-VERTEX-COVERThe that we we that− proof assume assumeSVisTherefore, is notS actually we weis anTherefore, not know know INDEPENDENT-SET. athere− similar− INDEPENDENT-SET. that that is− area there MIN-VERTEX-COVERto NP-hardMIN-VERTEX-COVER two the aregood previousvertices two problem. to vertices knowA, lemma. This B− It as is isA,V many Let a isgood is B contradiction. a a usS NP-hard NP-hard NP-hardV assumetoand know thereS and problem.that problem.problem as is manythere Therefore−V an edge asS NP-hardItis Itis possible. isan− is not connectingV edge a problem INDEPENDENT-SET.S connectingThisis aA is asand necessary possible.AB.and− Since so ThisB that.A, Since is B if necessary weA,V encounter B−S so,V that aS new, if we problem encounter X, we a new problem X, we In thegood beginning to know of as this many section, NP-hard we assume problem we asgood know possible. to that knowProof. This MIN-VERTEX-COVER asWe manyis necessary know NP-hardgood that soV thattoproblem⊆ know ifS isminimality.minimality. we ais as NP-hard aencounter manypossible. vertex NP-hard problem.Suppose cover Suppose a− This newgoodgood by is problem problem necessaryV It lemmaV to istominimality. knowS knowS− as X,is 1.isis possible.so notwe asnot notas The that− many many minimum minimum minimum Supposeonly if This weNP-hard NP-hard thing encountercancan is vertex vertexV vertex necessary use that use problem− problemS any any cover. remainscover. cover.ais newminimality. of notof so as as the∈ the that problem Then,possible. minimumThen,possible. Then, for NP-hard NP-hard− if us we there there there Suppose X,to encounterThis This vertexproblemswe prove problems is is is is is another− another another necessary necessaryV is cover. a its that thatnewS vertex vertex vertexis Then,we weproblem− so so not know, thatknow, that cover minimumcover cover there if ifX, reduce reducewe we weVV is encounter encounter another vertex itS itS− to towherewhere problem problem cover. avertex a− new new X,problemX,problem coverThen, and andV thus∈ therethus X, X, weweS− prove prove iswhere another that that X X vertex is is also also coverNP-hard. NP-hard.V S where contradiction. ThereforegraphgoodVminimality.G(SV,E tois know) an INDEPENDENT-SET. Suppose as− many NP-hardVV cancanSScanV is< useproblem< use usenotSVVgood any any any minimum> problem− ofso therewe weSSS we∈ the that.. know, know,> Bythereknow, By isNP-hard as−S if lemma anotherlemma possible.we. reduce reduce are Byreduce encounter twolemma problems 2, 2, itvertex itS itThisSvertices to to toisisproblem 2,problem a problemis an ancover thatnewS necessary independent independentA,is problemwe B−anV X, X, X, know, independentand and andV soS thusX, thusthatwhere thusreduceS set. set. weand prove proveif prove Therefore,we Therefore,it set. there encounter to that that that−− Therefore,problem is X X Xan isS isS is alsoedge alsois ais also X,new not notS NP-hard. NP-hard.and connecting NP-hard.is aproblem a ∈ notthus a− prove X,A− weand thatB X. is Since also NP-hard.A, B V S,− Therefore,good there to know are two as many verticesIn NP-hard theA,goodgood Bbeginning problem to toV know knowS of asVERTEX-COVER.and− as thisas possible. many many there section,V NP-hard NP-hard is This anTherefore, weS edge is assume necessaryproblem problem|| connecting−− there we| asProof. as| so| knowFrom possible.−we possible. arethat||A have| twoWethat− the−and ifwe we|A, know|verticesThisabove| This MIN-VERTEX-COVERB have encounter− B. Since is is/ that| theorem,A, necessary necessarySA,. BA, AsV B a / B newASVS. weand so so AsVis problem thatconclude thatS aAB|| vertexandSandare| ifis| if, we wea X, connectedthere||B| NP-hard that encounter coverweencounter||are iscan a| connected an byMIN-VERTEX-COVER| useproblem. by edge lemma a a ananynew new connecting edge, by of problem problemV 1. It thean is The weS edge, NP-hard noteX, onlyX,A we weand that thing can∈− problemsnoteBS be.− thatthat Sinceis easily not that remainsSA, ais constructed VERTEX-COVER.we B not know, for aV VERTEX-COVER. us reduceS toif, we prove haveit to This is problem a its is This a X, is and a thus prove that∈ X− is also NP-hard. good to knowcan use as anymany of NP-hard the NP-hard problem problems as possible.Proof. thatcan weThe This use know, proof anyisminimality. necessary reduce is∈ of actually the− it NP-hard so to Suppose similar that problemcan ifproblems to we use theX, encounter any and previous thatis ofVV thus not the we aSS provelemma. NP-hardminimumnew know, << problemV thatV reduce Let problems XS vertexScan uscan, is,, X, whichitassume which whichalso use use weto cover. that problemVNP-hard. any any implies implies implies that we ofS of Then, theV know,the< X,∈ that that that∈ NP-hard andNP-hardVS∈ thereis reduceS−S thus notS−>,> is aproblems which problems prove it1 anotherS INDEPENDENT-SET.1S to... By problemBy Bythat implies lemma that lemma lemmathat vertexV X is we thatX,we alsoS 2, 2,cover 2,know, and know,S reducereduce an an an proveSS independent independent independent., Byit whichitwhere that to to lemma problem problem X implies is set. set. set. 2,also X,S X, Therefore, that Therefore, Therefore, NP-hard. andis and anS thus thus independent>∈S proveS proveSisisis−. not not notBy that that a lemma a aset. X X is is Therefore, also also 2, S NP-hard. NP-hard. is anS independentis not a set. Therefore, S is not a canV useS any < ofV theS NP-hard, whichmaximummaximum problems impliesmaximum1 independent independentcan that that independent use weS any know,> set. set.∈ ofS theThis This. reduce set. By NP-hard− is is lemma This a a it contradiction. contradiction. to iswe problems problem2, a contradiction. haveSWeWe is say say anA, X, that that that ThereforeB Therefore independentand we/ problem problem thusS know,Therefore. As proveV XV XA isreduce is set.and reducible reducibleSS thatVisis Therefore,B itthe the XareS to to isto minimumis minimum problem problemalsoconnected problem theS NP-hard. minimumis Y YX, vertex notvertex andby a an vertexthus cover. cover. edge, prove cover. we that note X that is alsoS is NP-hard. not a VERTEX-COVER. This is a we have A, B / S. As A and B arecan connected use any byof the anedge, NP-hard− wewe problems note||| have−− thatA,| that||SMAX-INDEPENDENT-SET. Bminimality.is|1 /|| weWe1 notS−−. know,say As a|| that| VERTEX-COVER.contradiction.A reduceand Supposeproblem | B− itare X toV is| connected problem reducible Therefore−|SV This−|is||1 notX,| to|S|| is by problemV and a| minimum|| an||| thusS edge, Yis provean| vertexwe INDEPENDENT-SET.− notethat| cover.| X that| is| alsoS−− Then,| is| NP-hard.| not there a VERTEX-COVER. is another vertex| | This cover| | is aV S where can use any ofTheorem the NP-hardgood 1.to knowIf problemscanVS use asSV many any thatis< a of|V MAX-INDEPENDENT-SET NP-hard we the− know,S NP-hard,| which problem| reduce− problems impliesmaximummaximum| itas to possible. that problem that independent independentS of wecontradiction. ThisWe graph X,> know, say andS is. thatGnecessary reducethus By(| set.V,E set. problemmaximum| lemma prove This) ThisTherefore, it| thenso to| X isthat that2,is problemis aV independentaS reducible contradiction. contradiction.X ifis weSis anWe alsois X, encounterto aindependent say andis MIN-VERTEX-COVER NP-hard.problem an thatset. thus INDEPENDENT-SET. Therefore Therefore problem This aV Y prove newmaximum set.S is∈1 problemXa thatisV Therefore,contradiction.V reducible X independentSS is X,−−isis also we the thetoS NP-hard.problem− minimumis minimum Therefore not set.Y a This vertex vertexV is aS cover. cover. contradiction.is the minimum Therefore vertex cover.V S is the minimum vertex cover. can use any1 of the NP-hard problems∈ that weTherefore, know, reduce1 there it are to problem twoProof. verticesmaximumLemmaThe X, and proofA,1We 2. thus B independent is sayIf actually proveVS thatmaximumSV problem thatand similaris set. a X there VERTEX-COVERX isThis independent∈ tois also reducible the is is NP-hard. an a previous contradiction. edge11 to set. problem connecting lemma. This of graph Y is Therefore Let− aA contradiction.G us(and−V,E assumeBV),.− then Since thatS is ThereforeV theA, B minimumSWeisisV not ansay a INDEPENDENT-SETthatS INDEPENDENT-SET. vertex,Vis problem theS cover. minimum X is reducible vertex of to the problem cover. Y − We say that problem X is reducible to problemV S YWe say| that−⊆ problem| | X1We− is reducible say| that∈ problem to problem− X is Y reducible| | to| problem1| WeWeV sayY sayS that that problem problem− X X is is reduciblecontradiction. reducible to to problem problem− Therefore∈ Y Y −− is an INDEPENDENT-SET.− − contradiction.1 Thereforeof thecan graph useis anyG anmaximum(V,E INDEPENDENT-SET.11 of the). NP-hard independent problems set.contradiction. that This⊆ we is a know,From contradiction.V Therefore reduce theS above < itWe to ThereforeV say theorem, problem thatS is, problem which anV X, we INDEPENDENT-SET. and concludeS implies Xis thusis thereducible prove that minimum that− toS that a problem MIN-VERTEX-COVER>− X vertexS is. Y also By cover. NP-hard. lemma− 2, S canis an be independent easily constructed set. Therefore, if we haveS ais not a 1 We say thatwe problem have− XA, is B reducible / SWeWe. As toTherefore, say say problemA that thatandgraph problem problem YB thereareG( XV,E X connected are is is reducible reducible) two vertices by to to problem anproblemFrom edge,A,| theBFrom− Y Y we aboveV| thenoteTheorem|S above theorem,− that−andS| thereS theorem, 1.is weVIf not isS conclude an a we VERTEX-COVER.V edge concludeis a connectingthat MAX-INDEPENDENT-SET| a that MIN-VERTEX-COVER| | aA|MIN-VERTEX-COVER Thisand B is. a Since A, ofG canB graphV,E beV canG easily(V,ES be, constructedeasily)V, thenS constructedV S if weis a have MIN-VERTEX-COVERif we a have a We say that problem X is reducible to problem Y ∈ FromFrom the themaximumInTheorem above above the∈ beginning theorem, theorem,− independent 1. IfFrom ofwe we this conclude conclude set. the− section,is Thisabove a MAX-INDEPENDENT-SET that that is we theorem, a a contradiction.a assume MIN-VERTEX-COVER MIN-VERTEX-COVER we we conclude knowFrom Therefore thatthe that of above MIN-VERTEX-COVER graphV a can can MIN-VERTEX-COVER theorem,S be be(is∈ easily easily the)−, we minimum then constructed constructed conclude is vertex a NP-hard canthatis if if a we we cover.MIN-VERTEX-COVERbe a have haveMIN-VERTEX-COVER easily problem. a a constructed It is if we can have be a easily constructed if we have a contradiction.1We say Therefore that problemwe haveV X isA,FromS reducibleis B an / theS INDEPENDENT-SET.. to above As problemA and theorem,MAX-INDEPENDENT-SET.MAX-INDEPENDENT-SET. Y B areMAX-INDEPENDENT-SET. we connected conclude by that an a edge,⊆ MIN-VERTEX-COVER we⊆ noteTheorem that S is 1. not canIf aS be VERTEX-COVER. easilyV is a constructed MAX-INDEPENDENT-SET This if we is havea a− of− graph G(V,E), then V S is a MIN-VERTEX-COVER Theorem 1. If S V is a MAX-INDEPENDENT-SETV S of∈ graphTheoremG(V,E), 1. thenIf SofV theVS graphofisis a thea MAX-INDEPENDENT-SET MIN-VERTEX-COVERG graph(V,EG).(V,E). of graph G⊆(V,E), then−V S is a MIN-VERTEX-COVER − ⊆ Proof. We know thatFrom theProof.− aboveis aThe vertextheorem, proof coverMAX-INDEPENDENT-SET.MAX-INDEPENDENT-SET. iswe actually concludeby lemmagood similar that to 1.⊆− know to The a theMIN-VERTEX-COVER as only previousMAX-INDEPENDENT-SET. many thing NP-hard lemma. that remains problem Let uscan assume for asbe uspossible. easily to thatMAX-INDEPENDENT-SET.G prove constructedVV,E This isS isis its necessary not if a we INDEPENDENT-SET. have so− that a if we encounter a new problem X, we of the graph G(V,E). contradiction.−MAX-INDEPENDENT-SET. Thereforeof theV graphS isG an(V,E INDEPENDENT-SET.). of the graph ( ). minimality. SupposeMAX-INDEPENDENT-SET.V S is not minimum vertex− cover.From Then, the thereabove is theorem, another we vertex conclude cover thatV aS MIN-VERTEX-COVER−where can be easily constructed if we have a Theorem 1. If S V is aTherefore, MAX-INDEPENDENT-SET there are twoInIn verticescan the the of useProof.In beginning beginning graph theA, any B beginningProof.GWe of(V,E theV of of know this this NP-hardWe),S then of that section,and section, know thisV thereV problems section, that weS weS isis assumeV assumeis an athat awe MIN-VERTEX-COVER edge vertexS assumeis we we we connecting a know, know know vertexcover we reducethat that know by coverA lemma MIN-VERTEX-COVER MIN-VERTEX-COVERand that it by toB lemma MIN-VERTEX-COVER 1. problem. Since The 1. only X,A, The Band thing only thusV is is that a a thing prove NP-hardS NP-hard, is remains a that that NP-hard problem. problem. remains X for is also us problem. to for It It NP-hard. isprove is us Itto is prove its is its ⊆ − MAX-INDEPENDENT-SET.∈ − − − − ∈ − ofV theS graph < VG(V,ES ,)Theorem which. implies 1. If thatS SV is> aInInSIn MAX-INDEPENDENT-SET the. the the By beginning beginning beginning lemma1 2, of of ofS this this thisis an section, section, section,In independent the of graph beginning we we we− assume assume assumeG set.(V,EProof. of we weTherefore, we this), know then know knowWe section, knowV that that thatSInS weis MIN-VERTEX-COVERthatMIN-VERTEX-COVER MIN-VERTEX-COVER theis not assume a beginning MIN-VERTEX-COVERV a S weis know ofa vertex this that section, is is coveris MIN-VERTEX-COVER a a a NP-hard NP-hard NP-hard bywe lemma assume problem. problem. problem. 1. we The know It It It is only is is a that NP-hard thing MIN-VERTEX-COVER that problem. remains It foris us is to a prove NP-hard is its problem. It is Proof. We know that| V− S| is a| vertex− | coverwe byIn lemmahave theA, beginning 1. B⊆| TheProof. / |S. only As of|goodgoodWe| thisA thingand know to togood section, know knowWe thatBminimality. that to sayare asas remainsknow we that connectedVminimality. many many assume problem asS Suppose NP-hard NP-hardformanyis awe usby X vertex isNP-hardSuppose know to an reducibleV problem problem prove edge, cover thatS problemVis towe asas MIN-VERTEX-COVER byitsnotproblem notepossible. possible.S lemma minimumis as that not Ypossible.This 1.This minimumS−is The vertex is is not This necessary necessary only a vertexcover.is VERTEX-COVER. is thingnecessary− a NP-hard so so cover. Then, that that that so ifremains if thereThen, problem. that we we encounter encounter if This is there we for another Itencounter is us is ais toa a another new new vertex prove aproblem problem new is vertexcover its problem X, X,V cover we we S X,V wewhereS where maximum− independentIn theof set.the beginning graph This isG of a(V,E contradiction. this∈). section,goodgood to to we know Thereforeknow assume as as many many weV know NP-hard− NP-hardSgoodis that the to problemproblem minimum MIN-VERTEX-COVER know− as as as many vertex possible. possible.minimality.− NP-hard cover. This Thisgood is problemSupposeis is a necessary necessary NP-hard to know asV possible. so so problem. asS that that manyis notif if This we weNP-hard It minimumencounter is encounteris necessary problem vertex a a new sonew as that cover. problem problem possible. if we Then, X,encounter X, This we we there is− necessary a is new another− problem so that vertex X, if we cover encounterV S a newwhere problem X, we minimality. Suppose V S is not minimum vertexgoodcontradiction. to cover. know Then, asminimality. Therefore many therecancan NP-hard use useV is Supposecan anotherany anySV problemuseis of of an any the theSV vertex INDEPENDENT-SET.V ofNP-hard< NP-hardasS the possible.VSis cover NP-hard not Then, ifS we reduce it it. encounterto> toBy there problem problemS lemma it. to is By problemanother a lemma X,2, X, newS and and problemisX, vertex 2,thus thus an andS independent prove proveis coverthusX, an wethat independentthat proveV X X set.thatS is is also alsowhere Therefore, X set. is NP-hard. NP-hard. also Therefore, NP-hard.S is notS ais not a Proof.− We know that V S is a vertex cover by lemmaJonathanJonathan− In 1. the The Irvin Irvin beginning−− only GUNAWAN GUNAWAN thing of this that− section, remainsJonathanJonathan we for assume us Irvin Irvinto prove we GUNAWAN GUNAWAN know is its that− MIN-VERTEX-COVER is− a NP-hard problem. It is − good to know− as many NP-hardcancancan problem use use use any any any as of of of| possible. the the the− NP-hard NP-hard NP-hard|| This−|can problems problemsis problems−| use necessary| any− that ofthat thatJonathan| sothe we we we that NP-hard know,V know, know, if Irvin weS reduce reduce reduce encounterproblems GUNAWAN<| Jonathancan|V it it it| use| to to toS that| a problem|, problem problemany new which Irvin we| of problem| know, theGUNAWAN impliesX, X, X, andNP-hard and and reduce X, thus that thus thus we itproblems prove prove proveS to > problem that that thatS that. X X X By isX, is iswe lemmaalso also alsoand know, NP-hard. NP-hard.thus NP-hard. 2, reduce proveS is anit that to independent problem X is also X, NP-hard. set. and thusTherefore, prove thatS isX not is aalso NP-hard. Jonathan IrvinV GUNAWANS < V S , whichJonathan implies that IrvinS GUNAWAN > canS . useByJonathan lemma any of the 2,V IrvinS NP-hard S GUNAWANis an<11 independentV problems1maximumS ,Jonathan whichJonathan thatmaximum set. independent we implies Therefore, know,Irvin Irvin independent that GUNAWAN GUNAWAN reduce set.SSis itThis> not to set.|S problem ais.− This aBy contradiction.| lemma is X, a| andcontradiction.− 2, thusS|  Thereforeis prove an independent Therefore thatV X isS alsoVis set.| the NP-hard.|S Therefore, minimumis| the| minimum vertexS is not cover. vertex a cover. | − | | − | minimality.From the Suppose above| theorem,Proof.|V Jonathan| S|Weis we not know conclude Irvin minimum that GUNAWAN| S thatV− vertexV aS| MIN-VERTEX-COVERisWeWe| a cover.good say say vertex−We that that| toJonathan say Then, problem problem coverknow that there problemas by X X Irvin manyis is lemma reducible reducible iscan GUNAWANX another NP-hard is be 1.reducible| toeasily to The problem| problem vertex problem only to|constructed| problemG Y Y cover thingV,E as possible. YV that if weS remainsV have ThiswhereS ais for necessary us to− prove so that is− itsif we encounter a new problem X, we Jonathan Irvin GUNAWAN JonathanJonathancan use any Irvin Irvin ofTheoremGUNAWAN theGUNAWAN NP-hard 1. If problems−111 is that a MAX-INDEPENDENT-SET we know, reduce1 it to problem of graph X,maximum and( thus) independent prove, then1 that X set. isis also a This MIN-VERTEX-COVER NP-hard. is a contradiction. Therefore V S is the minimum vertex cover. Jonathan Irvin GUNAWANmaximum independent set. This is a contradiction.− 1 Therefore maximumV ⊆SWeWeissay the say independent that that minimum problem problem set. vertex X X is is This reducible reducible cover.We is say a to to contradiction. that problem problem problem Y Y X is Therefore reducible− toVWe problem say−S thatisY the problem minimum X is reducible vertex cover. to problem Y − MAX-INDEPENDENT-SET.V S < V S ,minimality. whichof implies theWe saySupposegraph that thatG problemS(VV,E−> )S. X. is By reducible notcan lemma minimum use toany 2,problemS of vertexFromis the Y an NP-hard theindependent cover. above Then,problems theorem, set. there thatTherefore, we is we another conclude know,S is− vertexreducethat not a a cover it MIN-VERTEX-COVER to problemV S X,where and thus can prove be that easily X isconstructed also NP-hard. if we have a | −Jonathan| | − Irvin1We| GUNAWAN say that problem X is| reducible| −| to| problem Y From the above theorem, we conclude that a MIN-VERTEX-COVER− can be easily constructed if we have a maximum independentV set.S This< V is a contradiction.S , which implies Therefore that SV >SSis. the By lemmaminimum 2, vertexS is anFrom cover. independent the above set. theorem, Therefore, we concludeS is not that a a MIN-VERTEX-COVER can be easily constructed if we have a From the above theorem, we conclude| that− a| MIN-VERTEX-COVER| − | From the can aboveMAX-INDEPENDENT-SET.1 beWe easily| theorem,say|MAX-INDEPENDENT-SET. that− constructed| problem| we conclude X is if reducible we that have to a a problemMIN-VERTEX-COVER Y can be easily constructed if we have a In the beginning ofmaximum thisProof. section, independentWe we know assume set. that we ThisV know isS a thatis contradiction. a vertex MIN-VERTEX-COVER cover Therefore by lemmaV 1. is aSMAX-INDEPENDENT-SET. The NP-hardis the only minimum thing problem. that vertex It remains is cover. for us to prove is its MAX-INDEPENDENT-SET. MAX-INDEPENDENT-SET.− − goodFrom to know the above as many theorem, NP-hardminimality. we problem conclude Suppose as possible.that aV MIN-VERTEX-COVER ThisS is is not necessary minimum so that vertex can if bewe cover. easily encounter Then,constructed a new there problem if is we another have X, we a vertex cover V S where From the above theorem, we−Jonathan concludeIn Irvin the that beginning GUNAWANIn a the MIN-VERTEX-COVER beginning of this ofsection, this section, we can assume be we easily assume we know constructed we that know MIN-VERTEX-COVER thatif we MIN-VERTEX-COVER have− a is a NP-hard is a NP-hard problem. problem. It is It is canMAX-INDEPENDENT-SET. use any of the NP-hardV problemsS < thatV weS know,, which reduce implies it to that problemS > X,S and. By thus lemma prove 2, thatInS theis X anis beginning also independent NP-hard. of this set. section, Therefore, we assumeS is not we a know that MIN-VERTEX-COVER is a NP-hard problem. It is In the beginning of this section, we assume we| know− | that| MIN-VERTEX-COVER− In| the beginninggood of togood thisis know a| NP-hardsection, to| as know| many| we problem. as NP-hard assume many NP-hard It we problem is know problem as that possible. MIN-VERTEX-COVER as possible. This is Thisnecessary is necessary so is athat NP-hard so if we that encounter problem. if we encounter a It new is problem a new problem X, we X, we MAX-INDEPENDENT-SET.maximum independent set. This is a contradiction. ThereforegoodV toS knowis the as minimum many NP-hard vertex cover. problem as possible. This is necessary so that if we encounter a new problem X, we good to know as many NP-hard1We say thatproblem problem as possible. X is reducible This to is problem necessarygood Y to so know that as ifcan we many encounter use NP-hardcan any use of a theany problemnew NP-hard of problem the as NP-hard possible. problems X, we− problems This that is we necessary that know, we reduce know, so that reduceit if to we problem itencounter to problem X, and a new X, thus and problem prove thus that X, prove we X thatis also X NP-hard. is also NP-hard. In the beginning of this section, we assumeJonathan weJonathan knowJonathan that Irvin Irvin MIN-VERTEX-COVER GUNAWAN GUNAWAN Irvin GUNAWAN is acan NP-hard use any problem. of the NP-hard It is problems that we know, reduce it to problem X, and thus prove that X is also NP-hard. can use any of the NP-hard problems that we know, reduce it tocan problemJonathanJonathan use any X, ofIrvin Irvinand the thus GUNAWAN GUNAWAN NP-hard prove problemsJonathan that X is that alsoIrvin weNP-hard. GUNAWAN know, reduce itJonathan to problem Irvin X, GUNAWAN and thus prove that X is also NP-hard. good to know as many NP-hardInJonathan theFrom beginning problem Irvin the asaboveGUNAWAN of possible.Jonathan this theorem, section, This Irvin we is GUNAWANnecessary1 concludeassumeWe say1 thatWe we so that say problemknow that that a ifMIN-VERTEX-COVER that weproblem X is encounter MIN-VERTEX-COVER reducible X is reducible to a problem new to problem problem canY be is X, Y easily a we NP-hard constructed problem. ifwe It is have a Jonathan Irvin GUNAWAN 1We say that problem X is reducible to problem Y 1We say that problem X is reducible to problemgood Y toMAX-INDEPENDENT-SET. know as many NP-hard1We say that problem problem as X possible. is reducible This to problem is necessary Y so that if we encounter a new problem X, we can use any of the NP-hard problems that we know, reduceJonathan it to problem Irvin GUNAWAN X, and thus prove that X is also NP-hard. can use any of the NP-hard problems that we know, reduce it to problem X, and thus prove that X is also NP-hard. 1We say that problem X is reducible to problem Y In the beginning of this section, we assume we know that MIN-VERTEX-COVER is a NP-hard problem. It is 1We say that problem X is reducible to problem Y good to know as many NP-hard problem as possible. This is necessary so that if we encounter a new problem X, we Jonathan Irvin GUNAWANcan use any of the NP-hard problems that we know, reduce it to problem X, and thus prove that X is also NP-hard. 1We say that problem X is reducible to problem Y JonathanJonathan Irvin GUNAWAN Irvin GUNAWAN Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWAN

Jonathan Irvin GUNAWAN 90 J.I. Gunawan

From the above theorem, we conclude that a MIN-VERTEX-COVER can be easily constructed if we have a MAX-INDEPENDENT-SET. In the beginning of this section, we assume we know that MIN-VERTEX-COVER is a NP-hard problem. It is good to know as many NP-hard problem as possible. This is necessary so that if we encounter a new problem X , we can use any of the NP-hard problems that we know, reduce it to problem X , and thus prove that X is also NP- hard.

3. How to Proceed

Suppose we already know that a problem is unsolvable (i.e. any known will not solve this problem in time). In competition, it is impossible to complain that “This 33 How How to to proceed proceedis unsolvable, can you eliminate this problem?” to the judges, since the judges believe they have a solution. Such a request is absurd when there are already several contestants SupposeSuppose we we already already know know that that a a problem problem is is unsolvable unsolvable (i.e. (i.e.who any any knownhave known solved algorithm algorithm that problem. will will not not solve solveAlso, this thisin a problem problemmajor competition in in (e.g. ACM International time).time). In In competition, competition, it it is is impossible impossible to to complain complain that that "This "ThisCollegiate is is unsolvable, unsolvable, Programming can can you you Contest eliminate eliminate World this this Finals, problem?" problem?" IOI), it is unlikely that the judges have toto the the judges, judges, since since the the judges judges believe believe they they have have a a solution. solution.incorrect Such Such a a solution. request request is is absurd absurd when when there there are are already already severalseveral contestants contestants who who have have solved solved that that problem. problem. Also, Also, in in a a major major competition competition (e.g. (e.g. ACM ACM International International Collegiate Collegiate ProgrammingProgramming Contest Contest World World Finals, Finals, IOI), IOI), it it is is unlikely unlikely that that the the3.1. judges judges Approximation have have incorrect incorrect solution. solution.3 How to proceed Suppose we already know that a problem is unsolvable (i.e. any known algorithm will not solve this problem in 3.13.1 Approximation Approximation time).In Inreal competition, life, when we it iscannot impossible find the to complainoptimal solution, that "This we iscan unsolvable, try to find can theyou solution eliminate this problem?" InIn real real life, life, when when we we cannot cannot find find the the optimal optimal solution, solution, we weto can can thethat try tryjudges, is to to close find find since theto the the the solution solution optimal judges that that believesolution. is is close close they More to to havethe the specifically, optimal optimal a solution. we Such try to a find request a solution is absurd thatwhen is there are already solution.solution. More More specifically, specifically, we we try try to to find find a a solution solution that thatseveral is is not not contestants larger larger than than who αα (where have(where(where solved α>α> that11)) timestimes times problem. the the optimal optimal optimalAlso, in solution a major for competition a minimisation (e.g. ACM prob- International Collegiate solutionsolution for for a a minimisation minimisation problem. problem. The The most most common commonProgramming approximation approximationlem. The Contestmost algorithmalgorithm common World approximation IFinals, I found found IOI), in in textbooks textbooks it algorithm is unlikely is is the theI that found the in judges textbooks have is incorrect the 2-approx solution.- 2-approximation2-approximation MIN-VERTEX-COVER MIN-VERTEX-COVER problem, problem, which which means meansimation that that the the MIN-VERTEX-COVER algorithm algorithm will will not not choose choose problem, more more than than which twice twice means that the algorithm will not thethe number number of of vertices vertices than than the the optimal optimal solution. solution. However, However, approximationchoose approximation more than problems problems twice the rarely rarely number occur occur of3.1 in invertices competitive competitive Approximation than the optimal solution. However, ap- programmingprogramming (especially (especially IOI). IOI). One One of of the the reason reason is is because becauseproximation to to create create this this problems kind kind of of rarely problem, problem, occur the the in judges judgescompetitive have have toprogramming to (especially IOI). One knowknow the the optimal optimal solution solution in in order order to to verify verify that that the the contestant’s contestant’sIn realof life, thesolution when solutionreason we is isis cannot because indeed indeed findα αto-approximation.-approximation. thecreate optimal this kind solution, However, However,of problem, we can the try tojudges find have the solution to know that the is close to the optimal generatinggenerating the the optimal optimal solution solution is is impossible impossible (or (or takes takes a asolution. long longoptimal time). time). More Sincesolution Since specifically, this this in approach approachorder we to try verify is is to not not find that really really athe solution suitablecontestant’s suitable that for for issolution not larger is indeed than α-approxima(where α>- 1) times the optimal competitivecompetitive programming, programming, I I will will not not discuss discuss this this approach approachsolution in in detail.tion. detail. for However, a minimisation generating problem. the optimal The most solution common is impossible approximation (or takes algorithm a long time). I found in textbooks is the 2-approximationSince this approach MIN-VERTEX-COVER is not really suitable problem, for whichcompetitive means programming, that the algorithm I will will not not dis choose- more than twice the numbercuss this of approach vertices thanin detail. the optimal solution. However, approximation problems rarely occur in competitive 3.23.2 Pruning Pruning programming (especially IOI). One of the reason is because to create this kind of problem, the judges have to ThisThis approach approach is is useful useful in in some some competitive competitive programming programmingknow problems. problems. the optimal In In ACM ACM solution International International in order Collegiate Collegiate to verify Programming Programming that the contestant’s solution is indeed α-approximation. However, 3.2. Pruning ContestContest (ICPC) (ICPC) World World Finals Finals 2010, 2010, problem problem I I (Robots (Robotsgenerating on on Ice) Ice) required required the optimal the the contestant contestant solution is to to impossible count count the the (or number number takes aof of long time). Since this approach is not really suitable for HamiltonianHamiltonian Paths Paths with with constraints constraints ( (ACMACM ICPC ICPC World Worldcompetitive Finals Finals 2010 2010 programming, problem problem statement statement I willn.d.), notn.d.), discuss which which this is is known known approach to to in detail. bebe a a NP-hard NP-hard problem. problem. While While finding finding all all possible possible paths paths is is impossible, impossible,This approach the the solutionis solution useful for forin thissome this problem problemcompetitive is is to to programming prune prune problems. In ACM Inter- thethe exponential exponential algorithm algorithm we we use use to to find find all all possible possible paths paths ( (ACMnationalACM ICPC ICPC Collegiate World World Finals FinalsProgramming 2010 2010 Solutions Solutions Contestn.d.).n.d.).3.2 (ICPC) If If Pruning atWorld at Finals 2010, problem I (Ro- somesome point point we we know know that that it it is is impossible impossible to to visit visit the the rest rest of of the thebots unvisited unvisited on Ice) points, points,required then then the we wecontestant can can prune prune to the thecount path path the and and number of Hamiltonian Paths with backtrackbacktrack immediately. immediately. However, However, it it is is not not very very suitable suitableThis for for IOI. IOI. approachconstraints Usually, Usually, is useful(ACM IOI IOI problems problems inICPC some World require requirecompetitive Finals deep deep programming2010 analysis analysis problem from from problems. statement, In n.d.), ACM which International is known Collegiate Programming thethe contestant. contestant. It It is is rare rare that that we we can can get get Accepted Accepted by by only onlyContest "hacking" "hacking"to be (ICPC) a NP-hard a a complete complete World problem. Finals search search 2010, While algorithm. algorithm. problem finding Therefore, Therefore, I (Robotsall possible we we on Ice)paths requiredis impossible, the contestant the solution to count the number of willwill not not discuss discuss this this technique technique in in detail. detail. Hamiltonian Paths with constraints (ACM ICPC World Finals 2010 problem statement n.d.), which is known to be a NP-hard problem. While finding all possible paths is impossible, the solution for this problem is to prune the exponential algorithm we use to find all possible paths (ACM ICPC World Finals 2010 Solutions n.d.). If at 3.33.3 Finding Finding Small Small Constraints Constraints some point we know that it is impossible to visit the rest of the unvisited points, then we can prune the path and SupposeSuppose there there is is an an NP-hard NP-hard problem problem with with large large NN thatthatbacktrack is is impossible impossible immediately. to to solve solve However, exponentially exponentially it is not (e.g. (e.g. veryN> suitableN>5050). for). IOI. Usually, IOI problems require deep analysis from SometimesSometimes we we should should also also look look for for other other small small constraints constraintsthe that that contestant. may may help. help. It Foris For rare example, example, that we a a can SUBSET-SUM SUBSET-SUM get Accepted problem problem by only "hacking" a complete search algorithm. Therefore, we isis considered considered an an NP-hard NP-hard problem, problem, and and will will not not be be solvable solvablewill with withnot discussNN == 100 100 this.. When When technique we we are are in given detail.given the the constraint constraint that that allall the the elements elements inside inside the the array array are are small small (e.g. (e.g. [0[0,,100]100]),), this this problem problem can can be be solved solved using usingOO((NXNX22))DynamicDynamic Programming,Programming, where whereXX isis the the upper upper bound bound of of the the elements elements inside inside the the array. array. Even Even though though3.3 the the running running Finding time time of of Small the the Constraints algorithmalgorithm is is exponential exponential to to the the size size of of the the input, input, the the algorithm algorithm is is still still fast fast enough enough for for the the given given constraint. constraint. Another Another wayway to to apply apply this this technique technique is is when when the the value value of ofNN isis notSuppose not too too large large there (e.g. (e.g. is anN50). algorithmalgorithm for forNN == 36 36isis unlikely unlikely to to run run in in one one second, second, weSometimes we can, can, for forwe instance, instance, should use usealso a a lookOO(2(2N/ forN/22) other)MeetMeet small In In The The constraints Middle Middle that may help. For example, a SUBSET-SUM problem algorithmalgorithm for for solving solving a a problem problem like like SUBSET-SUM. SUBSET-SUM. While WhileisO consideredO(2(2N/N/22))isis anstill still NP-hard exponential exponential problem, to toNN, and, it it is is will much much not faster faster be solvable than than with N = 100. When we are given the constraint that 2 OO(2(2NN)),, and and the the range range of ofNN thatthat it it can can solve solve is is twice twice the theall range range the elements of ofNN usingusing inside a aOO the(2(2NN) array)solution.solution. are small (e.g. [0, 100]), this problem can be solved using O(NX ) Dynamic Programming, where X is the upper bound of the elements inside the array. Even though the running time of the algorithm is exponential to the size of the input, the algorithm is still fast enough for the given constraint. Another 3.43.4 Finding Finding Special Special Cases Cases way to apply this technique is when the value of N is not too large (e.g. N<40). For example, while O(2N ) ThisThis is is the the most most suitable suitable approach approach in in IOI, IOI, and and thus thus is isalgorithm the the main main forfocus focusN of= of 36 this thisis paper. paper.unlikely To To to solve runsolve in IOI IOI one 2008 2008 second, Island Island we can, for instance, use a O(2N/2) Meet In The Middle andand IOI IOI 2014 2014 Friend, Friend, we we need need to to use use this this approach. approach.algorithm We We must must for find find solving a a special special a problem constraint constraint like SUBSET-SUM. in in the the problem problem While such suchO(2N/2) is still exponential to N, it is much faster than thatthat this this constraint constraint allows allows the the problem problem to to be be solvable solvable in inO(2 polynomial polynomialN ), and the time. time. range We We of can canN checkthat check it whether whethercan solve an an is additional additionaltwice the range of N using a O(2N ) solution.

3.4 Finding Special Cases JonathanJonathan Irvin Irvin GUNAWAN GUNAWAN This is the most suitable approach in IOI, and thus is the main focus of this paper. To solve IOI 2008 Island and IOI 2014 Friend, we need to use this approach. We must find a special constraint in the problem such that this constraint allows the problem to be solvable in polynomial time. We can check whether an additional

Jonathan Irvin GUNAWAN 3 How to proceed 3 How to proceed 3 How to proceed3 How to proceed3 How to proceed 3 How to proceed Suppose we already know that a3 problem How is unsolvable to proceed (i.e. any3 known How algorithm to will proceed not solve this problem in Suppose we already know that a problem3 How is unsolvable to proceed (i.e.Suppose any3 known we How already algorithm to knowSuppose willproceed thattime). not a we solve problem In already competition, this is problem know unsolvableSuppose that it in is a impossible(i.e. problem we any already known is to unsolvable complainknow algorithm that (i.e. that a will problem any "This not knownsolve is is unsolvable, unsolvable algorithm this problem (i.e. can will inyou notany eliminatesolve known this algorithm thisproblem problem?" will in not solve this problem in Suppose we already know that a problem is unsolvable (i.e. any known algorithm will not solve this problem in Supposetime). we already In competition, know that it a is problem impossible is unsolvable to complain (i.e. that any "Thistime). known is In unsolvable, algorithm3 competition, How will canSuppose nottime). it to you isto solve impossible eliminate proceed thewe In this competition,already judges, problem this to know since complain problem?" in it that the istime). impossible judges thata problem In "This believe competition, to is is unsolvable complain unsolvable, they have it is that (i.e. aimpossible can solution. "This any you known eliminate is to unsolvable, Such complain algorithm a this request problem?"can that will isyou "This not absurd eliminate solve is unsolvable,when this this thereproblem problem?" can are in already you eliminate this problem?" Suppose we already know that a problem is unsolvable (i.e. any known algorithm willtime). not solve In competition, this problem it in is impossible to complain that "This is unsolvable, can you eliminate this problem?" time).Supposeto In the competition, we judges, already since know it is the that impossible judges a problem believe to complain is they unsolvable have that a (i.e. "This solution. anyto is unsolvable, theknown Such judges,algorithm a request can since you willis thetime). absurdto eliminate notjudges theseveral In solve judges, when competition, believe this contestantsthis there problem?" since problem they are the it have who already is in judgesto impossible a have thesolution. believe solved judges, to Such that they complain since problem. ahave therequest that a judges solution. Also, is"This absurd believe in ais Such major unsolvable, when they a competition request havethere can a are issolution. you absurd already (e.g. eliminate ACM whenSuch International a therethis request problem?" are alreadyis Collegiate absurd when there are already time).Suppose In competition, we already it know is impossible that a problem to complain is unsolvable that "This (i.e. is any unsolvable, known algorithm can youto eliminate will the not judges, solve this since problem?"this problem the judges in believe they have a solution. Such a request is absurd when there are already totime). theseveral judges, In competition, contestants since the who judges it3 is have impossible Howbelieve solved they tothat complain have problem. proceed a solution. that Also, "This in Such aseveral majoris unsolvable, a request contestants competition is can absurd who (e.g. youtoseveral have the eliminatewhen ACMProgramming judges, solved contestants there International this that since are problem?" problem. already Contest the who Collegiate judges haveseveral Also,World solved believe in Finals, contestants a that major they problem.IOI), competition have who it is a Also,haveunlikely solution. (e.g. solved in a that major ACM Such that the competitionInternational a problem. judges request have Also, is (e.g. absurdCollegiate incorrect in ACM a major when solution. International competition there are Collegiatealready (e.g. ACM International Collegiate time). In competition, it is impossible to complain that "This is unsolvable, can you eliminate this problem?" severalto theProgramming contestants judges, since who Contest the have3 judges World solvedto How the believe Finals, that judges, problem. to they IOI), since proceedhave it Also,is the unlikelya solution. judges in a major that believeProgramming Such the competition judges they a request have have Contest (e.g. ais incorrect solution. absurd ACMseveral WorldProgramming International when solution. contestantsSuch Finals, there a requestIOI), Contest Collegiateare who it already is is have World unlikely absurdProgramming solvedseveral Finals, thatwhen that contestants the IOI), there problem. judges Contest it are is unlikely havewho already Also, World have incorrect in thatFinals, a solved major the solution. IOI), judges thatcompetition it problem. ishave unlikely incorrect (e.g. Also, that ACM in solution. the a International major judges competition have Collegiate incorrect (e.g. solution. ACM International Collegiate Suppose weProgramming alreadyseveral know contestants Contestthat a who problem World have Finals,several is solved unsolvableto IOI), contestants that the judges,it problem. (i.e. is unlikely anywho since Also, known have that the in solved athejudges algorithm major judges that believe competition problem. havewill theynot incorrect solve Also, have(e.g. this inProgrammingsolution. ACMa solution.a problem major International competition Such in Contest a Collegiate request World (e.g. ACMis Finals,Programming absurd International IOI),3 when it Howis Contestthere unlikely Collegiate are Worldto alreadythat proceed theFinals, judges IOI), have it is incorrect unlikely thatsolution. the judges have incorrect solution. time).Suppose In we competition, already know it is that impossible a problem toProgramming is complain unsolvableseveral that contestants (i.e. Contest "This any is World known who unsolvable, have Finals, algorithm solved IOI),can that youwill it isnot eliminateproblem. unlikely solvethat Also,this this problemthe problem?" in a judges major in have competition incorrect (e.g. solution. ACM International3.1 Collegiate Approximation Programming Contest World Finals, IOI), it is unlikely that the judges have incorrect solution. 3.1 Approximation3.1 Approximation3.1 Approximation totime). the judges, In competition, since the it judges is impossible believe to they complain haveProgramming a thatsolution. "This3.1 Contest Such is unsolvable, Approximation a World request Finals, can is absurd you IOI), eliminate whenit is unlikely there this arethat problem?" already the judges have incorrect solution. 3.1 Approximation SupposeIn we real already life, when know we that cannot a problem find the3.1 is optimal unsolvable Approximation solution, (i.e. weany can known try to algorithm3.1 find the Approximation will solution not solve that isthis close problem to the in optimal severalto the judges,contestants sinceIn who realthe have judges life, solved when believe wethat cannot they problem. have find Also,a the solution. optimal in3.1 a major SuchApproximation solution, competition a request we canIn (e.g. isreal try absurd life, to ACM3.1 find when when International theApproximation we solution theretime). cannotIn are real Collegiate thatsolution. In find already life, competition, is the close when optimal More to we the specifically, cannot it solution, optimal is impossibleIn find real we we the life, can try optimal to when try to complain findto we find solution, a cannot solution the that3 solution we find "This How that can the is thattry is optimal unsolvable, not to to is find larger close solution,proceed the to than can solution the you weα optimal(where can eliminate that try isα> to close findthis1) to times theproblem?" the solution the optimal optimal that is close to the optimal In real life, when we cannot find the optimal solution, we can try to find the solution that is close to the optimal Programmingseveral contestantsIn Contest realsolution. who life, World havewhen More solved Finals, we cannot specifically, that IOI), problem. find it is the we unlikely optimal try Also, to that in find solution, a the major a solution judges competition we can have that try incorrectsolution. is to (e.g. not find larger ACM thesolution. More3.1 solution than International specifically,α Approximationto(whereIn thatsolution. the real isCollegiatesolution judges,we life,α> close try when More1 to) to since timesfor the find we specifically, a optimal the minimisationcannot thea solution3 judges optimal findsolution. How we believe that the try problem. optimal is to Moreto notthey find larger proceed specifically, haveaThe solution, solution most than a solution. weα thatcommon we can(where try is try Such not to approximationα> to find larger afind31 request a) the solutiontimes than How solution isα the algorithm absurd(where that optimal to that is whenα> not proceed is I closefound larger1 there) times to in than are the textbooks the already optimalα optimal(where isα> the 1) times the optimal In real life, when we cannot find the optimal solution, we can try to find the solution thatsolution. is close More to the specifically, optimal we try to find a solutionα thatα> is not1 larger than α (where α>1) times the optimal Programmingsolution.In Contest realsolution life, More World when for specifically, Finals, a we minimisation cannot IOI), weit find try is unlikelyproblem. the to find optimalthat a Thesolution solution, the most judges that common we haveis can not tryincorrectsolution approximationlarger to find than forsolution. the aα solution minimisation(where algorithmseveralsolution.α> thatsolution I2-approximation1 iscontestants found problem.) close times More for inSuppose to a the specifically, textbooks minimisation theThe who optimal optimal most MIN-VERTEX-COVER have we alreadyis we common solvedsolution the problem. try toknowthat for approximationfind problem. Theathat a minimisation solution mostproblem,a problem Also, common algorithm that in which isproblem. a is unsolvablemajor not approximation means I larger found competition The that (i.e. than in most the textbooks any algorithm algorithm (e.g.common(where known ACM is Ialgorithmwill approximation the found International not) times inchoose will textbooks the not Collegiate morealgorithm optimal solve than is thethis Itwice found problem in textbooks in is the solution.In real More life, specifically, when we cannot we try find to thefind optimal a solutionα solution, that isα> we not can larger try to than findα the(where solutionsolutionα> that1) times for is close a minimisationthe to optimal the optimal problem. The most common approximation algorithm I found in textbooks is the solutionsolution.2-approximation for More a minimisation specifically, MIN-VERTEX-COVER problem. we3.1 try toApproximation The find most a problem, solution common whichthat approximation is means not2-approximation larger thatSuppose thanthe algorithm algorithm we MIN-VERTEX-COVER(where alreadyProgramming Isolution found will2-approximation know notthe1 in for) choose number textbookstimes that a Contesttime). minimisation a themore problem problem,ofMIN-VERTEX-COVER optimal verticesis In World than the competition, is whichtwice problem.2-approximation Finals, unsolvablethanSuppose means the IOI), it The optimal we is(i.e. that it problem, impossiblealready mostis MIN-VERTEX-COVER anytheunlikely solution. common algorithm known whichknow thatto However, complainalgorithmthat means approximationthe will a judges not problemthat approximation that willchoose problem, the have not "This isalgorithm algorithm moreincorrect unsolvable solve which is thanunsolvable, thisproblems will means solution.I twiceproblem found (i.e. not that choose rarelyany canin in thetextbooks known you occur more algorithm eliminate algorithm inthan iscompetitive the twicewill this notwill problem?" choose not solve more this than problem twice in solutionsolution. for a minimisationMore specifically, problem. we try The to find most a commonsolution that approximation is not larger algorithm than α (where I2-approximation foundα> in textbooks1) times MIN-VERTEX-COVER the is the optimal problem, which means that the algorithm will not choose more than twice 2-approximationsolutionthe number for a minimisation MIN-VERTEX-COVER of vertices than3.1 problem. the Approximation optimal problem, The most solution. which common means However, approximation thatthe approximation the numbertime). algorithm algorithm of In vertices competition, will problems not2-approximation I thanthe found choose rarelyprogramming number the it in ismore optimal textbooksoccur impossibleto of MIN-VERTEX-COVER than thevertices in solution. (especially competitive judges, twice is to the than complainthe However,sincetime). the IOI). number optimal the Onethat In judgesapproximation problem, ofcompetition, of "This solution. vertices the believe iswhich reason unsolvable, than However, theyproblemsit means is is the because impossible have optimal that approximation can rarely a thesolution. toyou solution. occurcreateto algorithm eliminate complain in Such this problems However, competitive will kindthis a that notrequest problem?" of rarely "This chooseapproximation problem, is occur is absurd more unsolvable, the in than competitive when judges problems twice can there have yourarely are to eliminate already occur in this competitive problem?" In real life, when we cannot find the optimal2-approximation solution,solution we for can MIN-VERTEX-COVER aminimisation try to find the problem. solution problem, that The is most which close common meansthe to the number that optimal approximation the of vertices algorithm than algorithm will the notthe optimal choose Inumber found moresolution. in of textbooks vertices than However, twice than is the the approximation optimal solution. problems However, rarely approximation occur in competitive problems rarely occur in competitive the2-approximation numberprogramming of vertices MIN-VERTEX-COVER (especially than the IOI). optimal One solution. problem, of the reason whichHowever, is means because approximation thatprogramming to theto create algorithm the problems judges,this (especially kind will since rarely notofprogramming IOI).problem, choosetheknow occur judgesOne the inmore theseveral of competitive optimal(especially believe the judges than contestantsreason twice solutionthey have IOI).programming is haveto becauseinOne who the a order solution. judges, haveof to the3.1 to (especially create solved verify reason since Such Approximation thatthis that the is a IOI). kind problem.because request judgesthe Oneof contestant’s problem, believe tois Also, of absurd create the in they reasonthe a solution thiswhen major havejudges kind is there competition because ais of havesolution. indeed areproblem, to alreadytoα-approximation. (e.g.create Such the ACM a judgesthis request International kind have ofHowever, is absurdproblem, to Collegiate when the therejudges are have already to solution.In real life, More when specifically, we cannot we find try the to optimal findthe a solution solution, number2-approximation that we of vertices can is not try MIN-VERTEX-COVER larger tothan find the than the optimalα solution(where solution. thatα> problem, is1 close) However, times which to the themeans approximation optimal that the problems algorithm rarelyprogramming will not occur choose in (especially competitive more than IOI). twice One of the reason is because to create this kind of problem, the judges have to programmingthe numberknow the of (especially optimal vertices solution than IOI). the One in optimal order of the to solution. reason verify is that However, because the contestant’s to approximationknow createseveral the this solution optimal kind contestantsproblems ofis solution indeed problem,programming rarelyknow whoα ingenerating-approximation. occurthe orderhave optimaljudges solved (especiallyinProgrammingto competitive verifythe have that solution optimal that However, toproblem. IOI).know theContest insolutionseveral One order contestant’s theAlso, of World tocontestantsis optimal the inimpossible verify a reason Finals, major solution solutionthat who is competitionIOI), (or the because is have takes in contestant’s itindeed order is solved unlikelya to long (e.g.α tocreate-approximation. that verify time). ACM solutionthat problem.this that the International Since kind is judges the indeed Also, thisof However,contestant’s problem, have approach inα Collegiate a-approximation. incorrect major the issolution competition notjudges solution. really is have However, indeed suitable (e.g. to α ACM-approximation. for International However, Collegiate solution.solution for More a minimisation specifically, we problem. try to find Theprogramming a most solutionthe common number that (especially is approximation of not vertices larger IOI). than than One algorithm theα of(where optimal the I reason foundα> solution.1 is) in times because textbooks However, the to optimal createis approximation the this kind problems of problem,know rarely the the optimal occur judges in solution have competitive to in order to verify that the contestant’sα solution is indeed α-approximation. However, knowprogramminggenerating the optimal (especially the solution optimal IOI).in solution order One to ofis verify impossible the reason that the (or is contestant’s because takes a long togenerating create solution time).Programming this Since the is kind indeed optimal this of ContestIn approachαknow problem,-approximation. realsolutiongenerating thecompetitive life, World is the optimalis when not impossible the judgesFinals, really we optimal However, solutionprogramming, cannot haveIOI), suitable (or solution toit in takesfindgenerating is order forProgramming unlikely the I a is will long to optimalimpossible verifynot that the time). discuss optimalthe solution, thatContest (orSince judges the this takes solution Worldthis wecontestant’s approach have acan approach long Finals, isincorrect try impossible time). in tosolution detail. IOI), isfind notsolution. Since the it (or really is is solution this unlikelytakes indeed suitable approach a that long that-approximation. for is time).the is close not judges Since toreally the havethis However,suitable optimal incorrect approach for solution. is not really suitable for 2-approximationsolution for a minimisation MIN-VERTEX-COVER problem. The problem, mostprogramming which common means approximation (especially that the algorithm IOI). algorithm One will of I not the found choose reason in textbooks more is because than is twice to the create this kindα of problem, the judges have to generatingknowcompetitive the the optimal optimal programming, solution solution inknow order is I willimpossible the to not optimal verify discuss (or that solution takes this the approach a contestant’s longin order time). incompetitive to detail. verifysolution Since that this programming, is approachindeed the contestant’ssolution.generatingαcompetitive-approximation. is I not will More really notthesolution programming, optimalspecifically,discuss suitable However,is indeed this solution for approachwecompetitive Igenerating will try-approximation. isimpossible to not in find discuss detail. programming, the a solution (or optimal this However, takes approach that solution a I3.1 longwill is not in not time). is detail. Approximation larger impossible discuss Since than this this (orα approach(where approachtakes aα> in long is detail.1 not time).) times really Since the suitable optimal this approachfor is not really suitable for α the2-approximation number ofcompetitivegenerating vertices MIN-VERTEX-COVER than programming, the the optimal optimal solution I problem, will solution.generating not isknow impossible discusswhich However, the means this optimal (or approximationapproach that takes solution the a inlong algorithm detail. isin time).problems impossible order will Sinceto not rarelyverify (or this choose takes occurthat approach more athesolutioncompetitive in long competitivecontestant’s than is time). not for twice really a programming, Since minimisation solution suitable this approach is for3.1 I indeed problem. willcompetitive not is Approximation not-approximation. discuss The really programming, most this suitable approach common However, for I in approximation will detail. not discuss3.1 algorithm this approach Approximation I found in detail. in textbooks is the programmingthe number of (especially vertices than IOI). the One optimal of the solution.competitive reasongenerating is However, because programming, the approximation to optimal create I willsolution this not problemskind discuss is of impossible problem, rarely this approach occur (or the takes judges in in competitive a detail. long have time). toIn real Since life, this when approach we cannot is not find really the suitable optimal3.2 for solution, Pruning we can try to find the solution that is close to the optimal competitive programming, I will not discuss this approach in detail. 2-approximation MIN-VERTEX-COVER3.2 PruningUnderstanding problem, whichUnsolvable3.2 means Pruning Problem that the algorithm3.2 will Pruning not choose91 more than twice knowprogramming the optimal (especially solution IOI). in order One to of verify the reason thatcompetitive the is because contestant’s programming, to create3.2 solution this Pruning I willis kind indeed not ofIn discussproblem, realα-approximation. life, this the when approach judges we cannot However, have in detail. to findsolution. the optimal More solution, specifically,In real life, we whenwe can try try we to to cannot find find a the solutionfind solution the optimalthat that is isnot solution, close larger to we thethan can optimalα try(where to findα> the1) solution times the that optimal is close to the optimal 3.2 Pruning the numberThis approach of vertices is thanuseful the in some optimal competitive solution.3.2 programming However, Pruning approximation problems. In problems ACM3.2 International Pruning rarely occur Collegiate in competitive Programming generatingknow the optimal the optimalThis solution approach solution in order is is impossible useful to verify in some that (or takes competitivethe contestant’s a long3.2 programmingtime). solution Pruning Since this problems. isThis indeed approach approachsolution.α In-approximation. ACM3.2 is is not More useful International really Pruningprogramming specifically, inThis suitable some However,Contest approachfor Collegiate competitive this for we (especiallysolution (ICPC) problem try is useful toProgramming programming find World for is IOI). in ato a someThis minimisation solutionprune Finals Onesolution. approachcompetitive oftheproblems. 2010, that the exponential More reason problem.problemis usefulnot programming In specifically, ACM larger is algorithm inI because The(Robots some International than most we problems. competitiveto αwe tryon(where createcommon use Ice) to Collegiate findto In required thisα>find programming ACM aapproximation solutionkind 1all) ProgrammingInternational thetimespossible of contestantproblem, that theproblems. algorithmpaths is optimal Collegiate not the to larger In judges count ACM I found Programming than thehave Internationalα in number to(where textbooks of Collegiateα> is1) the times Programming the optimal This approach is useful in some competitive programming problems. In ACM International Collegiate Programming competitivegenerating the programming,This optimal approachContest solution (ICPC)Iis will useful is not impossible World in discuss some Finals competitive this (or 2010,approach takes aproblem programming long in detail. time). I (Robots Since problems. on thisContest Ice) approach In requiredsolution ACM (ICPC) International is thefornot World3.2 a contestantreally minimisationknowThisContest Finals PruningCollegiate suitable approach theHamiltonian(ACM to2010, optimal (ICPC) countfor problem. Programming2-approximation is problemICPC useful solution the World Paths World numberin The I someFinals(Robotswith in mostFinalsContest ordersolution MIN-VERTEX-COVERofconstraints competitive 2010, common on to2010 (ICPC) verifyIce) problem for Solutions. required( aprogramming approximationACM that Worldminimisation I the(Robots ICPC then.d.). Finals contestant’s problem, Worldcontestant problems.If on 2010,algorithm problem. at Ice) Finalssome which problem requiredsolution to In point 2010 TheI meansACM count found I mostproblemwe is the (RobotsInternational thethat indeed inknow contestant common textbooksnumber the statement α onthat algorithm-approximation. Ice) Collegiateit of approximation tois required count then.d.), will Programming not thewhich the However, choose number algorithm contestant is known more of I tothanto found count twice inthe textbooks number is of the This approach is useful in some competitive programming problems. In ACM InternationalContest Collegiate (ICPC) Programming World Finals 2010, problem I (Robots on Ice) required the contestant to count the number of competitive programming,ContestThisHamiltonian approach (ICPC) I willis World useful Paths not Finals discuss in with some 2010, constraints this competitive approach problem (ACM programming I in (Robots detail. ICPC World on problems. Ice) Finals requiredHamiltonian 2010 In2-approximation ACM the problem contestantPaths International statement withgeneratingContest MIN-VERTEX-COVERHamiltonian to constraints Collegiate countben.d.),impossible (ICPC) a the NP-hard thethe whichoptimal (PathsProgrammingACM numberWorld number to problem. is with ICPCvisit solution knownFinals problem, of of constraintsthe WorldHamiltonian vertices 2010,2-approximation toWhile isrest impossiblewhich Finals of problem finding than (theACM means 2010Paths unvisited the (or all IICPC thatproblem(RobotsoptimalMIN-VERTEX-COVER withtakespossible Worldthe points, constraints a solution. algorithmstatement onlong paths Finals Ice) then time). is required 2010 However,( willweimpossible,ACMn.d.), Since can not problem,problem ICPCwhichthe chooseprune this approximation contestant the World approachstatementis whichthe more knownsolution path Finals means thanisto toandn.d.), problems fornot 2010count twice that this really which problem the problem rarely suitable algorithmnumber is known statement occur is for to of will into prune competitive notn.d.), choose which more is known than twice to ContestThis (ICPC) approach World is useful Finals in 2010, some competitive problem I (Robots programming on Ice) problems. required In the ACM contestant InternationalHamiltonian to count Collegiate the Paths number Programming with of constraints (ACM ICPC World Finals 2010 problem statement n.d.), which is known to HamiltonianContestbe a (ICPC) NP-hard Paths World with problem. constraints Finals While 2010,3.2 ( findingACM problem Pruning ICPC all I possible (Robots World Finals paths on Ice) 2010 isbe impossible,required a problem NP-hardthe number the statement the contestantproblem. solution ofcompetitive verticesHamiltonianben.d.), While tofor athe NP-hardcount thanbacktrack this which findingexponential programming, problemPaths the theprogramming is problem. optimal knownall numberimmediately. with possible is algorithm to constraintsto solution. I ofWhile prune willbe (especially pathsthe aHowever,not we finding NP-hard number However, discussis use (ACM impossible, IOI). to allit ofproblem. findICPCthisis possible approximationOne verticesnot approachall Worldvery theof possible Whilepathsthe thansolutionsuitable Finals reason in theis pathsfinding detail.problems impossible, 2010for optimal is (IOI. thisACM because all problem rarely possibleUsually, problem solution. ICPC the to occur statement solution createWorld pathsIOI is However, toin problems competitiveprune Finalsthisis forn.d.), impossible, thiskind approximation 2010 which problem of Solutions problem, the is known is solution to problemsn.d.). the prune to judges for If rarely atthis have problem occur to in is competitive to prune HamiltonianContest Paths (ICPC) with World constraints Finals 2010, (ACM problem ICPC World I (Robots Finals on 2010 Ice) problem required statement the contestantben.d.), a NP-hard to which count problem.is theknown number to While of finding all possible paths is impossible, the solution for this problem is to prune beHamiltonian a NP-hardthe exponential problem.Paths with algorithm While constraints finding we3.2 use ( allACM to Pruning possible find ICPC all possible pathsWorld is Finals paths impossible,the 2010 (ACM exponential problemprogramming the ICPC solution Worldstatement algorithm (especially forbe Finalsthe this an.d.),NP-hard wesome exponential 2010 problemrequire use IOI).which pointSolutions toknow problem. Onefinddeep is is we toalgorithm knowntheall of knowanalysisprunen.d.). thepossible optimal While to that reasonthe If we fromprogramming at finding it pathsuseexponential solution is isthe impossibleto because ( allcontestant. findACM in possible allorder algorithm(especially ICPC to possible to create to visitIt paths World is verify therare we pathsthis IOI). is Finals userest that impossible,that kind One ( toACM ofwe the 2010 offind the ofcan contestant’s problem, ICPC the unvisited allSolutions theget possible reason WorldAccepted solution the points,n.d.). issolution Finals pathsjudges because for by Ifthen this 2010(only atACM have is weindeedto problem Solutions tocreateICPC canα prune-approximation. Worldis thisn.d.). to the kindprune Finals path If of at problem,2010 and However, Solutions the judgesn.d.). have If at to This approachbe is useful a NP-hard in some problem. competitive Whilebe programming findingaHamiltonian NP-hard all possible problem. problems. Paths paths Whilewith In ACM is constraints findingimpossible, International all ( possibleACM the Collegiate solution ICPC paths Worldthe for Programmingis exponentialimpossible, this Finals“hacking” problem 2010 the algorithm isproblem a solutiontocomplete prune statement we for usethesearch this toexponential problemn.d.), findalgorithm. all which possible is algorithm toTherefore, is prune known paths we weto ( useACM will to ICPCnot find discuss all World possible this Finals technique paths 2010 (ACM Solutions ICPCn.d.). World If Finals at 2010 Solutions n.d.). If at the exponentialsome point algorithm we know wethat use it is to impossible find all possible to visit paths the rest (ACM ofsome the ICPC unvisited pointknow World we the points,know Finals optimal that 2010 thensome solution itbacktrack weSolutions is point impossible can in prunewegenerating ordern.d.). immediately. know to theto visitIf verifythat path at the the itsome andthatoptimal isHowever,know rest impossible pointthe of the solution contestant’sthe weit optimal isunvisited toknow not3.2 visitis impossible very solution that the solution points, Pruning suitable it rest is in impossible ofthen(or is order thefor indeed takes we IOI. unvisited to can averifyα to Usually, long-approximation. prune visit points,that time). the the IOI the rest path problems thenSince contestant’s of and weHowever, the this can unvisitedrequire approach prune solution deep points,the is analysisnot path is indeed then really and from we suitableα-approximation. can prune for the path However, and ThisContest approach (ICPC) is Worlduseful in Finals some 2010, competitive problemthe programming I exponential (Robotsbe a NP-hard on problems. algorithm Ice) problem. required In we ACM While use the International to contestant finding find all all possible to Collegiate possible count paths thepaths Programming number(ACM isin impossible, detail. ICPC of World the Finals solutionsome 2010 for Solutionspoint this problemwe known.d.). is that If to at pruneit is impossible to visit the rest of the unvisited points, then we can prune the path and somethe exponentialbacktrack point we know immediately. algorithm that it is we However, impossible use to find it to is all visit not possible very the rest suitable paths of the ( forACM unvisitedbacktrack IOI. ICPC Usually,generating points, Worldimmediately. IOI then theFinals problems optimalsome webacktrack 2010 However, can pointthe requireSolutionssolution prune contestant. we immediately.it deepcompetitivethe isknow is notn.d.). path impossible analysis that very It and Ifis it suitableHowever, atprogramming,rare isfrombacktrack (or impossiblegenerating that takes for weit IOI. is immediately. acan not Itolong the willUsually, get visit very optimal time). not Accepted the suitable discuss IOI However,rest Since solution problems of by forthis this the only IOI. itis approach unvisitedapproach isrequireimpossible "hacking" Usually, not very deepin points, is IOI detail. a not(or suitable complete analysis problems takes really then for a wesuitable from search long IOI. require can time).Usually, prune algorithm. for deepSince the IOI analysis path problemsTherefore, this and approachfrom require we is not deep really analysis suitable from for HamiltonianContest (ICPC) Paths World with Finals constraints 2010, (problemACMsome ICPC I (Robotsthe point World exponential we onFinals know Ice) 2010 that algorithm required it problem is impossible the we contestantstatement use to to find visitn.d.), to all the count possible which rest the of ispaths numberthe known unvisited (ACM toof ICPC points, World then Finals webacktrack can 2010 prune immediately.Solutions the pathn.d.). and However, If at it is not very suitable for IOI. Usually, IOI problems require deep analysis from backtracksomethe point contestant. immediately. we know It that isHowever, rare it is that impossible it we is not can veryto get visit Accepted suitable the rest for by of IOI. only thethe Usually, "hacking" unvisited contestant.competitive IOI points, a problems complete It programming,thenis rareThisbacktrack require search wethe that approach canwill contestant. algorithm.deep we prune not immediately. I can will isanalysis discuss theuseful get not It Therefore, path Accepted is discuss this fromin rare However, someand technique thatthe this by wecompetitive we contestant. onlyapproach it can is in "hacking" not detail. get veryprogrammingin programming, Accepted It detail. is suitable a rare complete by that for onlyproblems. I we willIOI. search "hacking" can not Usually, get algorithm.In discuss ACM Accepted a IOI complete this International problems Therefore, approach by only search require "hacking"Collegiate we in algorithm. detail. deep a Programming analysis complete Therefore, from search we algorithm. Therefore, we beHamiltonian a NP-hardthe Pathsbacktrack problem. contestant. with immediately.While constraints It is finding rare ( thatACM However, allbacktrack possiblewe ICPC cansome it World get is paths notimmediately. point Accepted Finals very is we impossible, suitable know 2010 by However, only thatproblem for "hacking"the it IOI. is solution itwill statement impossible Usually, is not a complete fordiscuss very IOIn.d.), this to suitable problems visit this problem search which the techniqueContestthe forwill rest requirealgorithm. is iscontestant.IOI. known tonot of (ICPC) Usually,prunein the deepdiscuss detail. to unvisited Therefore, analysis ItWorld IOI this is rare problems technique points, Finals from we thatwill2010, we thenthe require notin can contestant. detail.we problem discuss get deep can Accepted prune analysis this I It(Robots techniqueis the rare by from path only onthat and Ice)in "hacking" we detail. required can get a complete Accepted the contestant search by only toalgorithm. "hacking" count the Therefore, a number complete weof search algorithm. Therefore, we will not discuss this technique in detail. 3.3. Finding Small Constraints 3.2 Pruning thebe a exponential NP-hardwillthe problem. algorithmnot contestant. discuss While we this It use finding is technique to rare find thatall allthe possible in we possible detail. contestant.backtrack can paths get paths Accepted is immediately. It impossible, ( isACM rare by ICPC that only However, the weWorld "hacking" can solution Finalsget it aisAccepted for complete not 2010 this very Solutions problem bysuitable search onlyHamiltonianwill "hacking" isn.d.). notalgorithm. for to discuss IOI.prune If Pathsat Usually, a Therefore, thiscomplete with technique IOI constraints search problemswe will in3.2 algorithm. detail. not require (ACM discussPruning ICPC deepTherefore, this analysisWorld technique we Finals from in 2010 detail. problem statement3.2 Pruningn.d.), which is known to thesome exponential point we know algorithm that it we is useimpossible to find to allwill visit possible notthe the discuss contestant. rest paths of this the(ACM technique It unvisited is ICPC rare that in World points, detail. we Finals can then get we 2010 Accepted can Solutions prune by the onlyn.d.). path "hacking" If and atThis a approach complete is search useful algorithm.in3.3 some competitive Finding Therefore, programming Small we Constraints problems. In ACM International Collegiate Programming will not discuss this technique in detail. be a NP-hard3.3 problem. Finding While findingSmall3.3 all Constraints possible Finding paths Small is impossible,3.3 Constraints Finding the solution Small for this Constraints problem is to prune backtracksome point immediately. we know that However, it is impossible it is not to very visitwill suitable the3.3 not rest discuss for of Finding IOI. the this unvisited Usually, technique Small IOI points, problems in Constraints detail. thenThis we require approach can prune deep is usefulanalysis the path in from some andContest competitive (ICPC) programmingThis World approach Finals problems. 2010, is useful problem In in ACM some I International (Robots competitive on CollegiateIce) programming required Programming the problems. contestant In ACM to count International the number Collegiate of Programming 3.3 Finding Small Constraints the exponentialSupposeSupposethere algorithm there is is an an we NP-hardNP-hard use3.3 to find problem Finding all possible with large large Small paths N ( ACMthatthat Constraints3.3 is is ICPC impossible impossible Finding World to Finals to solveSmall solve 2010 expo exponentially Solutions Constraints- n.d.). (e.g. IfN> at 50). thebacktrack contestant. immediately. ItSuppose is rare However, that there we can is it anis get not NP-hard Accepted very3.3 suitable problem by Findingonly for with "hacking" IOI. large Usually, SmallN a completethat IOI3.3 ConstraintsSuppose problems is impossible search FindingContest there require algorithm. (ICPC) to is deep Smallan solvesome NP-hard Therefore,World analysisSuppose exponentially point ConstraintsSometimes Finalsnentially problem from we there weHamiltonian know 2010, (e.g. we(e.g.is with anthat should problem N> NP-hard large it isPaths alsoSuppose50 impossibleN IContest ). (Robots). lookthat problem withSometimes forthere is constraints(ICPC) toonimpossible other with visit Ice)is we an small Worldlarge therequired should NP-hard (ACM torest constraintsN Finals solve that ofalso the ICPC theproblem 2010, exponentiallylook contestantis unvisited World impossiblethat for problem with may other Finals points, to largehelp. (e.g. to countsmall I 2010 (Robots solveNFor then N>constraints theproblemthat example, exponentially we numberon50 is can). Ice) impossible statement prune a required ofSUBSET-SUM (e.g. the ton.d.), path the solveN> contestant andwhichproblem exponentially50). is known to count to (e.g. theN> number50). of Suppose there is anN NP-hard problem with large N that is impossibleN> to solve50 exponentially (e.g. N>50). willthe contestant.not discussSupposethis ItSometimes is technique rare there that is we we inan detail.should can NP-hard get also Accepted problem look for by with other only large "hacking"smallN constraintsthat a complete is impossible thatSometimes3.3 search mayHamiltonian to help. Finding algorithm.we solve should For exponentially Paths example,backtrackSuppose also Therefore, SmallSometimes with lookis athat considered thereconstraintsSUBSET-SUM immediately. forConstraints (e.g. wemay otherwebe is shouldhelp.N> a an ansmallNP-hard (NP-hardACM NP-hardFor50 However, also problem constraints). example, ICPCSometimes lookproblem.Hamiltonian problem problem, it for World isa thatother SUBSET-SUM not While withwe Finalsand may very small should Paths willlarge finding help. suitable 2010 constraints not withalso For problem allbeproblemthat look forconstraints example,solvablepossible IOI. is for that statement impossibleis otherUsually, considered with maypaths a ( SUBSET-SUMACM smallN help. is IOIn.d.),= to impossible,ICPC constraints100an problemsFor solve whichNP-hard. example, World When exponentially problem is require the thatFinals we knownprob a solution are SUBSET-SUM may- deep 2010 given to help.(e.g. analysisfor problem the Forthis constraint example, problem from statement). that ais SUBSET-SUM ton.d.), prune which is problem known to Suppose there is an NP-hardN problem with large N that is impossible toN> solve exponentiallySometimes (e.g. we shouldN> also50). look for other small constraints that may help. For example, a SUBSET-SUM problem will not discussSometimesSuppose thisis technique considered there we should is in an an detail.also NP-hard NP-hard look problem, for problem other and small with will constraintslarge not bethat solvable that is may impossibleis with considered help.Nbe= a For to100 NP-hard an example, solve. When NP-hard exponentially problem.theSometimes we ais contestant. SUBSET-SUM problem, considered arealllem, given Whilethe we (e.g.and andelementsthe shouldIt an finding willis will constraintexponential NP-hard problem rare not notalso inside all that 50be be look possible). problem,solvableis that solvable we the algorithmbeconsidered for can arraya other paths NP-hard getandwith with are Acceptedsmall we will anisN small impossible, use NP-hard problem.=not constraints 100 to be(e.g. by . find. solvableWhen When only problem, While[0 allthe,that "hacking"100] we possible we solution with findingare), aremay and this Ngiven given will help.paths a= for allproblem complete 100 notthe thethis possible For (.ACM beconstraint constraint When problem example, cansolvable search ICPC paths webe isthat solvedare thataWorld algorithm.with is to SUBSET-SUM givenimpossible,all pruneN using Finals= the 100 Therefore,O constraint 2010.( theNX When problem Solutions solution2) we weDynamic that are forn.d.). given this theIf problem at constraint is to that prune SometimesSuppose we there should is also an NP-hardlook for other problem small with constraints large N thatthat may is impossible help. For2 example, to solveisa exponentially considered SUBSET-SUM an (e.g. NP-hard problemN> problem,50). N and= 100 will not be2 solvable with N = 1002. When we are given the constraint2 that isSometimes consideredall the weelements an NP-hardshould3.3 inside also problem, Finding look the for array and other willare Small small smallnot be constraints (e.g.Constraints solvable[0, 100] with that),Nall may this= the 100 problemhelp.the elements. exponential When For can example, weinside be arewillis solved algorithmall consideredthe given anot SUBSET-SUMtheProgramming, array discuss usingthe the elements weelements are constraint anOsome use this( small NP-hardNX to inside technique point problem whereinside find) (e.g. thatDynamic problem, the we all Xthe[0all knowpossible inarray,is the100]array thedetail. the exponentialand that), areelements upperare this paths willsmall itsmall problemis bound not (impossibleinsideACM (e.g.(e.g.algorithm be of solvable canICPC[0 the the, 100] tobe array elements Worldwe visit with),solved usethis this are the Finals toproblem insideproblemsmall using rest find 2010 of (e.g.theO all. can( the When canNX possible array. Solutions be[0 unvisited be, )solved100] weDynamic Evensolved arepaths),n.d.). points,usingthis though given using (ACM problem If the atthen theO ICPC( constraintNX running we can Worldcan) beDynamic timeprune that solved Finals of the the using 2010 pathO Solutions and(NX ) Dynamicn.d.). If at is consideredSometimes an NP-hardwe should problem, also look andN for will other not small be solvable constraints with thatN = may 1002 . help. When For we example, areall given the a elements theSUBSET-SUM constraint inside[0, 100] that theproblem array are small (e.g. [0, 100]), thisO problem(NX2) can be solved using O(NX2) Dynamic allis the consideredProgramming, elements an inside NP-hard3.3 where theX problem, arrayFindingis the are upper and small Small will bound (e.g. not beConstraints[0 of, solvable the100] elements), this with problemProgramming, inside=some 100 the can. array.point When be where solved we Even we knowXall areusing thoughProgramming,is the given the thatalgorithm elementsO upper the( the itNX is running constraintbacktrack impossible bound is) whereinside Dynamic exponential time ofX the thatimmediately. the tois of arrayProgramming,Programming, visitthe elements the tosome upper the theare point size restsmall insideHowever, bound of of wewhere where(e.g. the the knowof input,unvisitedit array.the X is that elementsis notis the Even thethe it), very points,algorithm isupper this though impossible insidesuitable problem bound boundthenis the still forwe of torunningarray. of can canIOI.the fast visitthe be elements prune EvenUsually,enough elements the timesolved rest though the offor IOIinside usingof theinside path the the problems the andgiven theunvisited running array. constraint. requireDynamic time points, Even deep of though Another thenthe analysis we the can running from prune time the path of the and N 2 2 Suppose thereProgramming,all is the an elementsNP-hard where probleminsideX is the the with arrayall upper thelargeis are bound consideredelementsN smallthat of (e.g. the inside is an impossible elements[0 NP-hard, the100] array), inside problem, this to are solvealgorithm problem the small and array.backtrackexponentially (e.g. willis can Evenexponential not be[0 immediately., thoughsolved be100] (e.g. solvableProgramming,),algorithm to thisusing theN> the runningproblem withthe However, sizeO50 (array. isNX). ofthe exponential where= timethe can )Even contestant. 100itDynamic input, isX ofbe. notWhenthough theis solvedto the veryalgorithm the ItweupperProgramming,algorithmbacktrack the using suitable is size are rarerunning bound of givenO is that( the isforNX exponential immediately. still thetime ofinput, IOI.we where) the fast constraint canDynamic of Usually,the elements enoughtheX get to algorithm is However,algorithm the Accepted the IOI that for size inside upper problems the of is itis by the stillgivenis boundexponential only not array.input, fast require constraint. "hacking"very of enough Even the the suitabledeep to algorithm elements though forthe Another aanalysis completethesize for the given inside isIOI.of fromstill running Usually, searchconstraint. the fast array. enough time algorithm. IOI Evenof Another problems for the thoughthe Therefore, givenN require the constraint. running we deep analysis time Another of from the algorithm is exponential to the size of the input, the algorithm is still fast enough for theway given to applyconstraint. this technique Another3.3 is when Finding the value2 Small of N is Constraints not too large (e.g. N<40). For example, while O(2 ) SometimesSuppose there we should is an NP-hard also look problem for other with smallProgramming, large constraintsall theN that elements where that is impossible mayX insideis help. the the upper to For array solve example, bound are exponentially small of a the SUBSET-SUM (e.g. elements[0 (e.g., 100] insideN>), problem this the50 problem). array. Even can though be solvedNalgorithm the using running is exponentialO(NX time of) Dynamic the to the size of the input, the algorithmN is still fast enough forN the given constraint. AnotherN algorithmProgramming,way is to exponential apply where thisX techniquetois the the size upper is of when the bound input, the of value the algorithmelements of N is insidenot is stillway too the fast to largethe array.apply enough contestant. (e.g. Eventhis forN< technique though thealgorithm It40way given is). rare the For to is constraint.the runningthatapply whenis example, input, exponentialwill we thethis time can notthe Another valueN whiletechnique getalgorithm discuss= of to36 the AcceptedofO the(2wayN this sizethe isis )is towhen nottechnique contestant. ofstill by apply the too only thefast input, this largevalue "hacking"enough in Ittechnique detail. the (e.g. is of rare algorithmNforN< a is that completethe is not 40 whengiven weis too). stillcan For searchthe largeconstraint. fastget example, value (e.g. Accepted enoughalgorithm. of AnotherN The useO(2 Middle50 a).40O) (2). For) example,Meet In The while Middle(2 ) 2 algorithm for solving a problem like SUBSET-SUM.N While (2 ) is still exponential to , it is much faster thanN/ allis considered the elements an NP-hard inside the problem, array are and small will not (e.g.algorithm be[0 solvable, 100]), is with thisexponential problemN = 100 to can. the When be size solved we of are the using given input,NO the the(NX constraint algorithmN/)2 Dynamic that is still fastN< enough40N for the givenN/2 constraint.O(2 Another) N/2 N/2N/2 2 algorithmwayalgorithm to apply for N this for= solving36 techniqueis unlikely a problemway is when to to run likeapply the in SUBSET-SUM. onevalue this second, technique of N is weWhile notis can, when tooO foralgorithm(2 large the instance,N/2) value(e.g.is for still useN50). N N/N2 N wayalgorithm to apply is exponential thisO(2N technique), and to the the is rangesize when of of the theN valueinput,Othat(2 algorithm ofit the), canN and algorithmis solve the not for range is too solving twiceis largestill of theN afast (e.g. problemthat range enoughN< it canof like forN40 solveSuppose SUBSET-SUM.).using the For givenis a twice example,O there(2 constraint.N the)Programming, is Whilesolution. range while an NP-hardO Another ofO(2(2N using) whereSometimes), problemis and still a X theO exponential(2is with rangewethe) solution. should upperlargeSuppose of to N boundalsoN thatthat, there itlook3.4 is of isit much thefor is impossible can an other elements Finding faster solve NP-hard small than tois inside twicesolveconstraints problem Special the exponentially the array. with range that Cases Even large may of though(e.g.N help. thatusingN> For the is aexample, runningimpossible 50). time a SUBSET-SUM to of solve the exponentially problem (e.g. N>50). N 3.4 Finding Special CasesN/2 N 3.4 FindingN Special3.4 FindingCases Special3.4 Cases Finding Special Cases wayalgorithm to apply for thisN = technique 36 is unlikely is when to run the in value one second,O of(2N )is, weand not can, toothe forrange large instance, (e.g. of N N

Jonathan Irvin GUNAWAN Fig. 4. Comparison of O(2N) and O(2N/2) SUBSET-SUM algorithm running time for various Jonathan Irvin GUNAWAN input sizes. This experimentJonathan is run Irvin 100 times GUNAWAN for each value of N on a MacBook Pro (Retina, 13-inch, Early 2015). 3 How to proceed

Suppose we already know that a problem is unsolvable (i.e. any known algorithm will not solve this problem in time). In competition, it is impossible to complain that "This is unsolvable, can you eliminate this problem?" to the judges, since the judges believe they have a solution. Such a request is absurd when there are3 already How to proceed several contestants who have solved that problem. Also, in a major competition (e.g. ACM International Collegiate Programming Contest World Finals, IOI), it is unlikely that theSuppose judges have we already incorrect know solution. that a problem is unsolvable (i.e. any known algorithm will not solve this problem in time). In competition, it is impossible to complain that "This is unsolvable, can you eliminate this problem?" 3.1 Approximationto the judges, since the judges believe they have a solution. Such a request is absurd when there are already several contestants who have solved that problem. Also, in a major competition (e.g. ACM International Collegiate In real life, when we cannot find the optimal solution, we can tryProgramming to find the solutionContest Worldthat is Finals, close to IOI), theit optimal is unlikely that the judges have incorrect solution. solution. More specifically, we try to find a solution that is not larger than α (where α>1) times the optimal solution for a minimisation problem. The most common approximation algorithm I found in textbooks3.1 is the Approximation 2-approximation MIN-VERTEX-COVER problem, which means that the algorithm will not choose more than twice In real life, when we cannot find the optimal solution, we can try to find the solution that is close to the optimal the number of vertices than the optimal22 solution. Identifying Identifying However, approximation Intractability Intractability problems2 rarely Identifying of of occur a a Problemin Problem competitive Intractability through through Reduction Reduction of a Problem through Reduction programming (especially IOI). One of the reason is92 because tosolution. create this More kind specifically, of problem,J.I. we Gunawan the try judgesto find have a solution to that is not larger than α (where α>1) times the optimal 2 Identifying Intractabilitysolution for a minimisation of a problem. Problem The most through common approximation Reduction algorithm I found in textbooks is the know the optimal solution in order toWeWe verify would would that like like the to to knowcontestant’s know that that the the solution problem problem is that indeedthatWe we weα arewould are-approximation. attempting attempting like to know is is However, unlikely unlikely that the to to problem have have an an that immediate immediate we are solution. solution.attempting The The is unlikely to have an immediate solution. The 3.4. Finding2-approximation Special Cases MIN-VERTEX-COVER problem, which means that the algorithm will not choose more than twice generating the optimal solutionWe is would impossiblemostmost like common common to (or know takes way way that a is islong the to to applytime). applyproblem a a Since well-known well-known that this we approach aremost technique technique attempting common is not called called isreally wayunlikely reduction. reduction. suitable is to to apply have for Suppose Suppose aan well-known immediate we we know know technique solution. that that problem problem The called X X reduction. is is Suppose we know that problem X is the number of vertices than the optimal solution. However, approximation problems rarely occur in competitive competitive programming, I willmost not commonimpossibleimpossible discuss this way to to approach solve,is solve,22 to apply and and Identifying Identifying in we wedetail. a alsowell-known also know know that that technique Intractability weIntractability weimpossible can can solvecalled solve problem problem to reduction. solve, X X and by by Suppose of of using we using also a a problem problem Problem knowweProblem know that Y Y as as that we a a black-box black-box can problem through through solve11. problemX. If If is we we can canReductionReduction X by using problem Y as a black-box1. If we can programming (especially IOI). One of the reason is because to create this kind of problem, the judges have to impossiblesolvesolve to problem problem solve, and Y, Y,This then wethen is also wethe we knowcanmost can solve solve thatsuitable problem problem we canapproach solve X Xsolve as as problemwell.in well. problemIOI, Therefore, Therefore, and X Y, bythus then using is problem problem wethe problem canmain Y Y solve is isfocus Y also also as problem aof impossible impossible black-box this Xpaper. as1 to. well.to IfTo solve. solve. we Therefore, can problem Y is also impossible to solve. Figure 4: Comparison of O(2N ) and O(2knowN/2) SUBSET-SUM the optimal solution algorithm in order running to verify time for that various the contestant’s input sizes. solution This is indeed α-approximation. However, solve problem Y,3.2 thensolveWeWe we Pruning wouldcan would IOI solve 2008 like like problem Island to to know know and X that that asIOI well. the the2014 problemNproblem Therefore, NFriend, that thatwe problemN/ needN/ we we2 2 are areto Yuse attempting attempting is this also approach. impossible is is unlikely unlikely We to must solve.to to have have find an an immediate immediate solution. solution. The The OO OO N N/ experiment is run 100 times for eachFigureFigure valueFigure 4:generating 4: ofComparison ComparisonN 4:on ComparisonFigure the a MacBook optimalof of 4: Comparison(2(2 of solution) ProO)andand(2 (Retina,N )(2 isofand(2 impossibleO(2O 13-inch,)(2)SUBSET-SUMSUBSET-SUM)N/and2) (or EarlySUBSET-SUMO(2 takes 2015)2) algorithm a algorithmSUBSET-SUM long algorithm time). running running Since algorithmrunning time time this for approachfor time runningvarious various for various isinput time input not forsizes. really input sizes. various This suitable sizes. This input This for sizes. This N N/2 WeWe are are using usingamostmost NP-hard NP-hardspecial common common constraint problems problems way way for forin is is illustration.the toillustration. to applyproblem apply a aWe well-knownRecall well-knownRecallsuch are Nthat that thatusing this NP-hard NP-hard technique techniqueNP-hard constraintN/ problems problems2 problems called called allows have reduction.have reduction. for the illustration.yet yet problem to to be beSuppose Suppose solved solved to Recall be in inwe we polynomialthat polynomial know know NP-hard that that problem problemproblems X X have is is yet to be solved in polynomial Figure 4: Comparison of O(2This) and approachO(2 isN) usefulSUBSET-SUM in someN/2 competitive algorithm programming running timeexperimentexperiment problems. for variouscompetitiveFigure Inis input is run4: ACM run Comparison 100 sizes. programming,100 International times times This for of for eachO Collegiateeach I(2 will value) value notand of discussProgrammingO ofN(2Nonon this) aSUBSET-SUM a MacBookMacBook approach Pro in Pro detail. (Retina,algorithm (Retina, 13-inch, 13-inch,running Early time Early 2015) for 2015) various11 input sizes. This Figure 4: Comparison of O(2 ) and O(2 )WeSUBSET-SUMtimeFiguretime are using for for 4: more more NP-hardComparison algorithm than thansolvableimpossibleimpossible problems 4 4 decades. decades. of runninginO toexperimentpolynomial to(2 for solve,N solve, MIN-VERTEX-COVER) MIN-VERTEX-COVERillustration. timeand and andexperiment forO istime.(2 we variouswe runN/ alsoRecall also2We 100)timeSUBSET-SUM knowinput knowiscan times that run for check thatsizes. that ismoreNP-hard 100 is for a a wegrapheach wetimesgraphwhetherThis than canalgorithm can problems value problemfor 4problem solve solve decades.an each of additional problem problemrunningN have that value thaton MIN-VERTEX-COVER yet involvesa involves of Xtime XMacBook toconstraintN by by beon forusing usingsolved finding finding a various MacBook Pro problemcauses problem in a a (Retina, polynomial minimuminput minimum a Y is Y Pro assizes.a as 13-inch, graph (Retina,a a subset subset black-box black-box This problem Early 13-inch,.. 2015) Ifthat If we we Early involves can can 2015) finding a minimum subset experiment is run 100 timesContest for each (ICPC) value of WorldN on Finals a MacBook 2010,N Proproblem (Retina, I (Robots 13-inch, on Early Ice)experiment required 2015) the is runcontestant 100 times to countfor each the value number of N ofon a MacBook Pro (Retina, 13-inch, Early 2015) experiment is run 100 times for eachconstraint valuetime of causes forofFigureexperimentofon more nodesnodes a a problem MacBook 4: than such such Comparison is 4 to runthat thatdecades.problemsolveProsolve be 100 solvable for for (Retina, problem problemof timesevery everyto MIN-VERTEX-COVERO be(2 in solvable foredge,13-inch,N edge, polynomialY, Y,) eachand then then at at Oin valueEarlyleast weleast we(2 polynomial timeN/ can can one of2015)2one) solveof using solveNSUBSET-SUM of isof nodeson aits itstime problemthe problem graph a endpoint endpoint MacBook such reduction using problem X thatX the algorithm as asis is Pro proofreduction well.infor well.in that the the every(Retina, ofTherefore, Therefore, subset.runninginvolves subset. the edge,proof original 13-inch, MAX-INDEPENDENT-SETtimeMAX-INDEPENDENT-SET findingof at problem problem the least problem for Earlyoriginal a various one minimum Y Y 2015) is (with-is of prob also also its input- endpoint impossiblesubset impossible sizes. This is is to atoin a solve.the solve. subset. MAX-INDEPENDENT-SET is a Hamiltonian Paths withFigure constraints 4: Comparison (ACM of ICPCO(2N World)lemand Figure(without FinalsO(2N/ 4: 2010 2the) ComparisonSUBSET-SUM additional problemstatementof constraint),O(2 algorithmN ) andn.d.), andO running check(2 whichN/2 )whether time isSUBSET-SUM known for the various to proof algorithminputstill holds sizes. runninggiven This the time for various input sizes. This out theof additional nodesgraphexperimentgraph such constraint), problem problem that is for run of of and every finding finding100constraint checkconstraintedge, times a a whetherconstraint maximum maximumat for causes causes least each theconstraint acausesone value subseta proofsubsetproblem problem of ofa itsstill of problemofgraphN causes toendpoint nodes holdstonodeson be be problema solvable a givensolvableto suchMacBook such problem beis in solvablethethat that inof the in polynomialadditional tofinding forpolynomialPro for subset. be in every every (Retina, solvable polynomial a maximum3.2constraint MAX-INDEPENDENT-SET edge, timeedge, time in13-inch, using atpolynomial atPruningusing time most most tosubset the usingtheEarly one reductionone reductionproblem. of time the 2015) of of nodes itsreduction itsusing proofendpoint endpoint proof such the is of a proofofthatreduction the theis is fororiginalin inof original the every proof original problem problem edge, of the problem at (with- original (with- most (with- one problem of its (with- endpoint is in be a NP-hard problem.experiment While finding is run 100 all possible times for pathsadditional eachexperiment is value impossible, constraint of N is runon theto a 100 the MacBook solution timesproblem. for for Pro each this (Retina, value problem 13-inch, of N ison to Early prune a MacBook 2015) Pro (Retina, 13-inch, Early 2015) constraint causesconstraint a problem causes to be a solvable problem in to polynomial be solvable time ingraph polynomial usingthe problemthe the subset. subset. reduction time of usingfinding Suppose Suppose proof theWe aWeout weofreductionout maximumwe are theare already alreadythe usingoutusingconstraint originaladditional additional theproofsubset knowNP-hard knowNP-hard additional problem ofout causes constraint), that that constraint),ofthe the problems problemsnodes originalMIN-VERTEX-COVER MIN-VERTEX-COVER(with- aadditional constraint), problemthe such and subset. forproblem forand thatillustration. checkillustration. toconstraint), check and be Suppose for (with- whethersolvable check whether every Recall Recall andis wewhetheris edge, thein a a the already checkNP-hardpolynomial NP-hard thatproof that proof at the NP-hardwhethermost NP-hard still know proofstill problem. problem. holdstime one holds that still the problems problems ofusing given holdsMIN-VERTEX-COVERgivenproof Therefore,its Therefore, theendpoint the giventhestillhave have reduction additional additional holds yet theyetwe we is to canto additional cangiven in beproof be constraint show showconstraint solved solved the of is additional constraintthe a in in NP-hard topolynomial originalpolynomial to the the problem.constraint to problem. problem.problem the problem. (with-to Therefore, the problem. we can show the exponential algorithm we use toconstraint find all possible causes apathsWe problem will (ACM Thisgive to be ICPC approachwe solvable one World example is in usefulFinals polynomial of in 2010 a somespecial time Solutions competitive usingcase inn.d.). the a reductionNP-hard programming If at problem. proof problems. of theSuppose original In ACMwe problem International (with- Collegiate Programming out the additionalout constraint), the additional and constraint), check whether and the check proofWe whetherthe will still subset. giveholdsthat thethat we proofgiven MAX-INDEPENDENT-SET MAX-INDEPENDENT-SETSuppose one stillthe example additional holds wetimetime already given of for for a constraint more specialmore the knowout additional than than the that case is isto additional 4 4also also MIN-VERTEX-COVER the decades.in decades. constraint a aproblem. a NP-hard NP-hard NP-hard constraint),that MIN-VERTEX-COVER MIN-VERTEX-COVER to MAX-INDEPENDENT-SET problem.problem problemthe problem. and isby by checkSuppose a reducing reducing NP-hard whether is weis a a problem. have graphMIN-VERTEX-COVER graphMIN-VERTEX-COVER theproofa is problem problem function also Therefore, still a NP-hard holds that that with we involves involvesgiven the canproblem problem problem the show finding finding additional by into into reducing a a a aminimum minimum constraint a MIN-VERTEX-COVER subset subset to the problem. problem into a some point we know that it is impossibleconstraintout the to additionalvisit causes thehave rest a constraint), problem a of function theContest unvisitedto and bewith solvable check (ICPC)the points, following whether in World polynomial then theformula we Finals proof can time 2010, prune still using holds problem the the path given reduction I and the(Robots additional proof on of Ice) theconstraint required original to problem the the contestant problem. (with- to count the number of constraintfollowingthat causes formulaO(2 MAX-INDEPENDENT-SETMAX-INDEPENDENT-SETNMAX-INDEPENDENT-SET a) problemO(2 toN/ be2of)of solvable nodes nodesconstraintWeWe such such in is will polynomial problem.will problem. causesalsoWe that that give give a will for for NP-hard a we we problem giveevery everytime oneWe one we usingwillexample edge, problemedge, exampleMAX-INDEPENDENT-SET to one give be the at atexample solvable weofleastreduction by least of a onereducing a special one specialone ofin example polynomial a ofproof of special case aits its case MIN-VERTEX-COVER ofendpoint endpoint of in the in case a a time problem.a special originalNP-hard NP-hard in isusing is a in in NP-hardcase problem the the theproblem. problem. insubset. subset.reduction a (with-problem. problem NP-hard Suppose MAX-INDEPENDENT-SETSuppose MAX-INDEPENDENT-SET proof into Supposeproblem. ofwe awe the have have original we Suppose a ahave function function problem a we function with have is withis (with- a a the a the with function the with the backtrackFigure immediately. 4: Comparison However, of it isout notand the very additional suitableSUBSET-SUM constraint), for IOI.Hamiltonian Usually, and algorithm check IOI Paths whetherproblems running with the require time constraints proof for deep still various holds analysis(ACM input given ICPC from sizes. the World additional This Finals constraint 2010 problem to the statement problem. n.d.), which is known to We will give we one example of a special case in a NP-hardMAX-INDEPENDENT-SET problem. Supposegraphgraphoutfollowing wefollowing problemproblem. problem the have additional aformulaWe formula of functionof finding finding will constraint), give with a a maximum maximumwe the one and example check subset subset whether of of anodes nodes special the such such proof case that that still in for afor holds NP-hard every every given edge, edge, problem. the at additionalat most most Suppose one one constraint of of we its its endpointhave endpoint to the a function problem. is is in in with the We will give weexperiment one example isout ofrun athe 100 special additional times case for constraint), in eachWe a NP-hard will value give and of problem. weN checkon one a whether example MacBook Supposefollowingbe a NP-hard the of Prowe formulafollowing proofa special have (Retina, problem. still a formula caseholds function 13-inch, Whilein given a with NP-hardEarly thefinding the additional 2015) problem. all possible constraint Suppose paths to is we the impossible, have problem. a function the solution with the for this problem is to prune following formula the contestant. It is rare that we can get Accepted bythethe only subset. subset. "hacking"following Suppose Suppose1,n a completewe formula we already already search know know algorithm. that that=1 MIN-VERTEX-COVER MIN-VERTEX-COVERn =2 Therefore, we is is a a NP-hard NP-hard problem. problem. Therefore, Therefore, we we can can show show following formula N WeWe will willN/ first2 first prove prove the the following following two two lemmas. lemmas. We will first prove the following two lemmas. will notFigure discuss 4: Comparison this technique of O in(2 detail.) followingandWeO(2 will formula give) SUBSET-SUM wef( onen)= examplethe algorithm exponential of a special running algorithm case time in wefor a NP-hard varioususe∨ to1,n1 find,n input problem. all sizes. possible Suppose This paths we (=1ACM have=1 aICPCnn function=2=2 World with Finals the 2010 Solutions n.d.). If at We will giveWe wewill one first example provethatthat the of following MAX-INDEPENDENT-SET aMAX-INDEPENDENT-SETWe special willf two( casen give lemmas.1) in we + a one NP-hardf(n example2), is problem.is alsoalso n> of a a a2 special NP-hard NP-hard Suppose case problem problem we1,n in have a NP-hard by by a1 reducing reducingfunction,n problem. a awith MIN-VERTEX-COVER MIN-VERTEX-COVER theSuppose=1 n =2 we=1 haven a=2 problem functionproblem into into with a a the experiment is run 100 times forfollowing each value formula of N on a MacBooksome point Pro (Retina, we know 13-inch, thatf itf(n Early(isn)=)= impossible 2015) to visit the rest of the unvisited∨∨ points, then we can prune the path and constraint1,n causes a problem toLemmaLemma be=1 solvable 1. 1.n If=2 inIf SS polynomialMAX-INDEPENDENT-SETMAX-INDEPENDENT-SETVV isis an an time INDEPENDENT-SET INDEPENDENT-SET using− the reduction problem.− problem.Lemma proof of of graph graph 1. ofIf thef(SGGnf original()=(f(V,EV,En(nV )is)1),f1,1) problem(,n then an thenn + +)=f INDEPENDENT-SETf(VnV(n (with-2)SS2),isis, n>a a n> VERTEX-COVER VERTEX-COVER22 =1 of∨ graphn =2G of of(∨V,E the the ), then V S is a VERTEX-COVER of the f(n)= following1 formula,n∨ ⊆⊆following=1 n =2 formula ,nf(n⊆)=f(n n1) +−f−(fn(n 1)2) +,f( n>n 22)∨, n>2 − out the additionalf(Wen)= constraint), considerLemmaN thegraphgraph and 1. sequence checkIfGGN/S((V,EV,E2 whetherFV))=is anf the(n INDEPENDENT-SET) proof∨n∞=1backtrack, still and holds we immediately. define given1 F ofthegraph(N graph additional) However,toG beG(V,E(V,E the constraint)it first), is then notN−−=1terms toV very theS suitable of problem.=2isF− a−. VERTEX-COVERWe for want IOI. toUsually, know IOI of the problems require deep analysis from Figure 4: Comparisonf(n 1) + off(On(2 2)3.3),and n>O Finding(22 ⊆) SUBSET-SUM Small{ } Constraints algorithmf(n)= running time for various input sizes.f(n−∨− This1) + f(−n− 2), n>− 2 − whetherf− we(n can1) create + f(n a partition2), n>WeWe ofWe 2 considerF consider( considerNthe) into contestant. the the the two sequence sequence sequence disjoint1 It,n isF multisets rareF== thatff(n(nA) we)n∞and=1n∞ can=1 , B, and and get andsuch we Acceptedwe=1 wethat define define define−n the=2F by F sum(N( onlyN) ) ofto −to "hacking"to all be be be elements the the the first first afirst completeN Ntermsterms search of ofFF.. algorithm.We We want want to toTherefore, know know we graph−G(V,E) − We considerWe the considerf sequence(n 1) the{ +{F sequencef=(n}}f(2)nF),n∞= n>=1,f and(2n) wen∞=1 define, and weF (N define) to beF ( theN) to first beN theterms first ofNFterms. We of wantF . to We know want to know experimentconstraint iscauses run 100 a problem times for to be each solvable value in of polynomialN on aWeWe MacBook willtime will1 first,n firstV usingV Pro prove provefSS the(n (Retina,)= reduction the the following following 13-inch,− proof two two=1 ofEarly the lemmas. lemmas.{n− 2015) original=21,n} problem{ ∨V} (with-S =1 n =2A,A, B B / / VV SS A, B / V S We consider the sequence FSuppose= f(n) theren∞We=1, will is and an give we NP-hard22in define weA Identifyingis oneIdentifying equalF problem example(N) toProof.Proof.to the bewith of sum theLet aLet large special first ofus us Intractability Intractability all assume assumeNNf elements case(thattermsnwhether)=whether in thatthat is of ofa impossible inwillWe NP-hardF weB we.. notconsiderWe We can can discusswant wantisis create problem. create to not not of oftheto solve to a athisknow sequenceknowa VERTEX-COVER.apartition VERTEX-COVER. a partitionProof. Supposeexponentially technique Problem Problemwhetherf(LetF ofn of)= we=F∨ inwe usF( haveN(f detail. N assume(e.g.can()n)into) Therefore,through Therefore,intothrough acreaten∞ function=1N> twothat two, anda disjoint 50partition disjoint therewe). therewith defineReduction multisets Reduction the are multisetsis areof not twoF two(N a verticesA verticesVERTEX-COVER.)A ∨tointoandand be twoBB thesuch such first that thatN theterms Therefore, the sum sum of ofF of. all there allWe elements elements want are two to know vertices We consider the{ sequenceout the} additionalF = f( constraint),n) n∞=1, and and we check define whetherF (N) to the be proof the stillfirstwhetherF − holds−Nfterms wen givenwhether can of thef createF(n. we additional We can1) a want partition + createf( constraint ton {F knowa of2) partitionN,F}(N n>to) theinto of2 problem.F two(N−) disjointintoN two multisets disjointF A multisetsand B∈∈ suchA −and− thatB such the sum that of the all sum elements of all elements ∈ − whether we can create a partitionSometimes of F ( weN) shouldinto{ two also disjoint} lookProof. for multisets otherandWeandLet considerthere smallthere usA assumeand is constraintsis anB anthedisjointsuch edge edgethat sequencein thatin connectingV connecting thatA multisetsAis theisSfwhether mayequal( equalnis= sum not help.A1) toA( ofto weand a+and the)all the VERTEX-COVER.Forf cann∞ ( sumB=1 elementsBn sum example,. ., createsuch Since and Since of2)and of−, all wethat all aA, n>A, there elements apartition elementsdefine Bthe SUBSET-SUMB2 / / issum Therefore,VV− an in( off in edgeS(BS n)FallB,,to( we weNelements connecting1) be) problemthere have haveinto + thef(A, areA, two firstnin B B twoA disjoint2) and,isSSterms vertices .equal. n> As AsB multisets.A ofA2 SincetoandA,and the. B WeBA,sumBA /are Bareand wantV / connected connectedVBS tosuch knowS, wethat have theA, sum B of allS. elements As A and B are connected whether we can createfollowing a partition formula of F (N) into two disjoint multisetsLemmaLemmaA and− 1. 1.inIfIfBASS−suchis{ equalVV thatin}isisA to an an theis− the INDEPENDENT-SET equal INDEPENDENT-SET sum sumof to of all the all∈ elements∈ sum elements−− of all− of in of elements graphB graph GG in−((V,EV,EB∈∈ )),, then then VV SS∈isis a∈ a− VERTEX-COVER VERTEX-COVER− of of the the∈ Wewhether consider we can the create sequence a partitionF = ⊆⊆f of(n)F ∞(N),into and two we define disjointF ( multisetsN) to beA theand firstB Nsuchterms that of theF .− sum− We of want all elements to know in A is equal to the sum ofis all consideredconstraint elements in ancausesB NP-hard aWeWe problem problem,would wouldand to like like be there andby solvable toby to willknowan knowan is an edge, notedge, in that edgethat polynomial be we wethe solvable the connectingof note noteall problem problem elements timeG thatG thatwith((V,EV,EA usinginthatS thatNSand) A)inisis= weiswethe not not100B equal are .. are reduction. an Since an Whenn attempting attempting=1 toINDEPENDENT-SET. INDEPENDENT-SET. theA, weby proof B sum are an/ isV isof ofgiven edge, unlikely unlikely the allS, elementsoriginalthe weto constraint to havenote Thishave Thishave problem inA, that isBan isan B athat a immediateS immediate (with- contradiction. contradiction.Sis. not As A an solution. solution.and INDEPENDENT-SET.B Therefore Thereforeare The The connectedVV SS isis This a a is a contradiction. Therefore V S is a in A is equal to the sum of all elementsWe considerThis in B looks the likesequence a classicF = PARTITIONgraphgraphf(Wen) n∞ consider=1, problem. and the{ wesequence define PARTITION} F (NF )=∈to problemf be(−n the) n∞=1 firstis3.3, NP-hard andN terms Finding we define by of∈ reductionFF. Small( WeN) wantto from be Constraints to SUBSET- the know first N terms−− of F . We want to know − We will give we one examplewhetherin ofA ais special equal we can to casecreate the in sum a a NP-hard partition of all elements problem. of F (N in) SupposeBinto two{ wedisjoint have} multisets a function2 A withand B thesuch that the sum of all elements allout the the elements additional inside constraint),mostmost the commonarray commonby andan areVERTEX-COVER.VERTEX-COVER. edge, checkway smallway is is we whether (e.g. to to note apply apply[01,n, the{ that100] a aThis proof well-known well-known),S} thisThislooksisNThis still not problem looks holdslike looks an technique technique a INDEPENDENT-SET.like givenclassic like can a=1 a theclassic be classic calledPARTITION called additionalsolvednVERTEX-COVER. PARTITION=2 PARTITION reduction. reduction. using constraint problem.O This(NX Supposeproblem. Suppose problem. is toPARTITION) a theDynamic contradiction. we wePARTITION problem. PARTITION know know problem that thatA problemTherefore problem problem problem is NP-hardB is isX XV NP-hard NP-hard is isbyS is by a by reduction reduction from from SUBSET- SUBSET- whetherSUM. Therefore,we can create for a a partition large value ofwhetherF of(N), weinto it isThis can two unlikely createlooks disjointThis to like a partitionbe multisets looksa able classic like to ofA PARTITION find aFand classic(N an)Binto algorithmsuch PARTITION two problem. that disjoint that the PARTITIONproblem. sum finds multisets of all1and1 PARTITION elementsA problemandinB an−such is problem NP-hard that the is by NP-hard sum reduction of all by elements reductionfrom SUBSET- from SUBSET- following formulaXimpossibleimpossibleVERTEX-COVER. to to solve, solve,in Af( andis andn)= equal we we also also toreductionProof.Proof. the know know sumLetLet that that from ofSuppose us us all we we assumeThisSUBSET-SUM. assume elements can can looks solvethere solve that that in problemlike problemisB∨VV ana Therefore, classic NP-hardSS X Xisis by by not not PARTITION using using aNforproblem aN VERTEX-COVER. VERTEX-COVER. a problem problem large with problem.value Y Ylarge as as of a a black-box black-box PARTITIONN Therefore, Therefore, , thatit is isunlikely.. impossible If If there thereproblem we we canto can are arebeis to two two NP-hard solve vertices vertices exponentially byA,A, reduction B BAA / / VV (e.g.B fromBSS N> SUBSET-50). This looks like aThis classic looksProgramming, PARTITION like a classic problem. where PARTITIONinefficientA PARTITIONisis the equal problem. upper way. to problemHowever, boundthe PARTITION sum of is of the this NP-hard allf elements( sequenceelementsn probleminSUM.1) bySUM.A + insidereductionis isin isf Therefore,equalSUM.( NP-hardB definednTherefore, the2) to Therefore, array.from, the in bySUM. n> for a for reductionsumSUBSET- Even very a2 a largeTherefore, of largefor special though−− all a value from elementslargevalue way, the for ofSUBSET- value of running a in in, large the, it ofB it isN issense timevalue unlikely, unlikely it is of that of unlikely the toN toF, be it beis isable todefined able unlikely be to to able find using find to to an be an find the algorithm able algorithm an to algorithm find that that an finds findsalgorithm that finds∈∈andand that−A− andinin finds an anB inA and an B in an solvesolve problem problem Y,Lemma Y,Lemma then thenThis we we 2. looks 2. can canIfIf SS likeand solveand solve aVV there thereclassic problem problemisis a a is is VERTEX-COVER VERTEX-COVER PARTITIONan an X X edge edge as as well. well. connecting connecting Therefore, Therefore, problem. ofLemma of graphA graphA and PARTITIONand problem problem 2.GGBB((.V,E.IfV,E Since SinceS Y Y) is), is, problem then alsoV thenA, alsoA,is B B impossible impossibleV aV / / VERTEX-COVERV isVS NP-hardS isSisS, an, an to we to we INDEPENDENT-SET solve. INDEPENDENT-SET solve. have byhave reductionA,A, of B B graphS fromS.. AsG As( SUBSET-V,EAA of ofandand) the, the thenBB areareV connected connectedS is an INDEPENDENT-SET of the SUM. Therefore, for a largealgorithm valueWe of isN will exponential, it give is unlikely weaforementioned one to theto example be size able of of the to recurrence. a find specialinput, an the algorithmcase Therefore,able algorithm⊆⊆− in toefficient aefficient find NP-hard that we is SometimesSUM.an still finds way.should − way.algorithm problem.fast Therefore,A However, However, inspectand enough we thatB should Suppose theinfinds thisfor for this an recurrence the a alsosequence sequence large we givenand look have value constraint. forformula isin isa definedan other functionof defined⊆ efficientN more, small itAnother in in is with aclosely. − aunlikely− constraints veryway. very the specialHowever, special to be that way, ableway,this may insequence to in the help. findthe sense sense an For algorithm example,that thatFFisis thata definedSUBSET-SUM defined− finds using usingA and the the problemB in an SUM. Therefore, for a large value of N, itLemma is unlikelygraphgraph 2. If toGGS((V,E beV,E1,n ableV)) is to a findVERTEX-COVER anefficient algorithm way.=1efficientN that of However, graphn finds=2 way.graphGA( However, thisV,EandG(V,E sequence)B, thenin) this anV issequence definedS ∈is∈ an is− in− INDEPENDENT-SET defined a very specialin a very way,∈ special∈ A in of the the way,B sense in the that senseF is that definedF is using defined the using the followingWe consider formula the sequence F =SUM.fThis(n Therefore,) looksn∞=1,N andlikeisbyby defined for anaan we classic a edge, defineedge, large inFis PARTITIONawe considered we valueFvery(N note note )special ofto that that beN< an, problem. ittheway, NP-hardSS isis firstis unlikelyin not nottheN PARTITION problem, an ansenseterms to INDEPENDENT-SET. INDEPENDENT-SET. bethat of able and F problem.is will to We defined findO not want is an beN NP-hard tousing algorithm solvable know This This the by is with isaforementioned that reductiona a contradiction.N contradiction. finds= 100 from.and When SUBSET- Therefore Therefore wein an are givenVFV theSS is constraintis a a that efficient way. However,efficient way. thisway sequence However, to apply is this definedthis sequence technique inThis a veryis is definedlooks when special likef inthe({ way,na a)= classicvalue very in} ⊆ specialthe of PARTITION senseis way, notaforementionedaforementioned thatThis tooin problem. theaforementionedefficient lookslargeis sense defined (e.g.like PARTITION recurrence.way.aforementioned that recurrence. a using classic∨ However,F recurrence.is40 the definedPARTITION). Therefore, problem Therefore, For this recurrence. example, Therefore, using sequence is we NP-hardwe problem. the should should while Therefore, we is− defined byshould inspect PARTITION inspect(2 reduction we) inspect in the the should a recurrencevery fromrecurrence problem the inspectspecial SUBSET- recurrence formulais formula way,the NP-hard recurrence formulain more morethe by senseclosely. reduction moreclosely. formula that closely. from more−is− definedSUBSET- closely. using the whether we canLemma creategraph a 3. partitionAnyGSUM.efficient(V,E consecutive of Therefore,)F way.(fN(n) into However,subsequencerecurrence.VERTEX-COVER.VERTEX-COVER.1) for two + af disjoint( largen this Therefore, of2) sequencevalueF, multisetswith n> of we lengthN2 is ,shouldA defined itand is multiples unlikely inspectB insuchN/ a2 of verythe to that three berecurrence special the able can sum to be way, findformula of partitioned allin an the elements algorithmmore sense into closely. that two that multisetsF findsis definedA and usingB in the an 2 aforementioned recurrence.algorithm Therefore, for weN should= 36 inspectis unlikelyWeWe are arethe usingusing to recurrence runProof.Proof. NP-hard NP-hard in oneTheThe formulaproblems second, problems proof proof more is is we actually foractually for closely. can, illustration. illustration.allaforementioned forsimilar similar the instance, elements to toRecall Recall the the use previous previousthat that recurrence. inside aProof. NP-hardO NP-hard(2 lemma. lemma.theThe array) Therefore, problems problemsMeet proofLet Let are us usIn is smallassume have Theassumehave actually we should yetMiddle yet(e.g. that that to tosimilar be[0 be inspectVV, solved solved100] toSSis the),is thein notin notthis previous polynomial polynomialrecurrence a a problem INDEPENDENT-SET. INDEPENDENT-SET. lemma. formula can Letbe solved moreus assume closely. using thatO(VNXS)isDynamic not a INDEPENDENT-SET. aforementioned recurrence. Therefore,SUM. we Therefore, should inspect for a large the recurrence value− SUM. ofLemmaLemmaN formula, Therefore, it− is 3. 3. unlikelyAny moreAny consecutive for consecutiveclosely. to a be large able value subsequence subsequence to find of N an, it algorithmof of isFF unlikelywithwith thatlength length to finds be multiples multiples ableA and to findof ofB three threein an an algorithm can can be be partitioned partitioned that finds into intoA and two two multisetsB multisetsin an in A is equal totimetimeof the equal for for sum more more sum. of all than thanaforementionedefficient elements 4 4 decades. decades.1 way.,n in B However, MIN-VERTEX-COVERrecurrence. MIN-VERTEX-COVERO thisN/LemmaProgramming,2 Therefore, sequence=1 3.LemmaAny weis is isn where defined a ashould=2 consecutive graph graph 3. XAny ininspect problemis problemN a theconsecutive very subsequence upper the that specialthat recurrence bound involves involves subsequence way, of ofF infindingformulafinding thewith the elements of length− sense− a aF more minimum minimumwith multiplesthat inside closely. lengthF subset subset theis of multiples defined array. three Evencan using of bethree though the partitioned can the be runningpartitioned into− two time multisets into of twothe multisets algorithmWe consider for solving the a sequence problemProof.F like= SUBSET-SUM.Therefore,Therefore,Thef(n) proofn∞=1, thereis there and actually WhileLemma we are areefficient define two two similar (2 3. vertices vertices FAny way.( to)N is the consecutive) stillto However,A,A, previous beB B exponential theVV firstlemma. thissubsequenceTherefore,SSN sequenceandand toterms Let there there, usit ofthere of is isassume is is muchF defined an an . arewith We edge edgethat faster two want length in connecting connectingV verticesa than tovery S multiples knowis special notA,AA B aand and INDEPENDENT-SET.of way, V threeBB.. inS Since Since can theand besenseA,A, there B B that isVV anF edgeSSis,, defined connecting usingA theand B. Since A, B V S, Lemma 3. Any consecutive subsequence of F withefficient length way. multiples However,f{(n)= of} three this can sequenceLemmaLemma beof partitionedof equal is equal 2. 2. definedLemmaIfIf sum. sum.SS into inVV 3.two aisis very∈∨Any∈ multisets a a VERTEX-COVER VERTEX-COVER− specialconsecutive− way, subsequence in the of of sense graph graph of thatGFG−((V,EwithV,EF is)) length,, defined then then∈ multiplesVV using−SS is theis of an an three INDEPENDENT-SET INDEPENDENT-SET can∈∈ be−− partitionedinto of of the the two multisets ∈ − Lemma 3. AnyO(2N consecutive), and thesubsequence rangeofof of nodes nodesN that of such suchF itwith can thataforementioned that length solve for for every everyf is multiplesn twice edge, edge, recurrence. the of atf at range threen least leastofalgorithm of canTherefore, one equalone,N be⊆ n>⊆ ofusing of sum.partitioned its itsof is exponentialendpoint equalwea endpointO should(2 sum.N into) issolution. is inspect toin twoin the the multisets sizesubset. the subset. recurrenceof the MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET input, formula the algorithm more closely.− is− still is fastis a a enough for the given constraint. Another whether we canaforementioned createProof. a partitionTherefore,Pick anywewe recurrence.Lemma of haveconsecutive have thereF (NA,A, 3.)( are Binto B Therefore,Any two/ /partitionedgraph1) subsequencegraph twoSS consecutive. +. verticesaforementioned As As disjointG(GA weA((V,EV,Eand andinto shouldA,2) multisets subsequence) of) B BtwoFareare inspect V recurrence.multisetswith connected connected2AS lengthand theofand ofFB recurrencewe thereequal Therefore,with bymultiplessuch by have an an lengthissum. that edge, edge, anA, formula B ofedgewethe multiples we /we three, should sumS connectingnote note. more As of which ofinspectthatAthat all closely. threeand elementsSS weAisB theis canandwill not notare recurrence beB adenoteconnected a.partitioned VERTEX-COVER. VERTEX-COVER. Since by formulaA,F by B into an= V more edge,two ThisS multisetsThis closely., we isnote is a a that S is not a VERTEX-COVER. This is a of equal sum. This looksgraphgraph like a problemclassic problem PARTITION of of finding finding a a problem. maximum− maximum∈∈ PARTITION subset subset−of equal of of∈ nodes nodes problemsum.− such such is that that NP-hard for for every every by reduction edge,∈ edge, at at most mostfrom one SUBSET-oneN of of its its endpoint endpoint is is in in∈ −N< O N of equal sum. in A is equal to the sumwe of all have elementsA, B / inSB. As A andProof.Proof.BVVarewayPickPickS connectedS to any any apply consecutive consecutive this by an technique edge, subsequence subsequence we is note when that of the ofFFS valuewithiswithV not lengthof lengthS a VERTEX-COVER.is multiples not multiples too large of of three, three, (e.g. This which which is a 40 we we). will willFor denote example,denote by by whileFF == (2 ) f(a),fF(a + 1)fcontradiction.Lemmaofcontradiction.,fn equal(a + sum.2)3., ...fAny Therefore Therefore(b consecutive) for someFProof.N subsequenceak>(( senseGaGV cover.S+3+1+3(S(V,E3V,E.{.−S By thatBy))),0 Then,,−< lemmak lemma then then)F,V0is. V thereV defined 2, 2,Sk S−,SSS which isis≤isisis− anotherusing an aan a≤ VERTEX-COVER implies VERTEX-COVER− independent independentb theb a vertexa(32 that2+1+3} coverS set. set.3 > Therefore,) Therefore, ofV of0S the the.S By where lemmaSS−isis not not− 2, S a a is an independent set. Therefore, S is not a LemmaProof.{ 3.PickAny any consecutive consecutive≤ subsequence≤ subsequence3 { of} F ofwithofofF− the theA lengthwithA≤ graphand graphand length≤ThisB multiplesBwill(will( is multiples3 have the have)) of.. most}∪{ the three the{ sameof same suitable can three, sum, be sum, partitioned which approach as as≤ for for we every≤ every inwill into≤ IOI,0 denote03 two andkk3 multisets}∪{ thusby−}−F−− is =b thea main2 b focus−a≤2 of≤ this paper.3 } To solve IOI 2008 Island || ⊆⊆−− || || −− || { A and B willA and| have| ≤||B the|will≤|| −|b| same havea3| sum,the2| } same− as− for−| sum, every as0 for everyk3 3 0− −| k| |− |− aforementioned recurrence.graphgraphGbG(V(aV,E Therefore,V,E2 S))maximummaximum < weV should independentS independent, which inspectB implies set. set. thef a This recurrenceThis that is isS a ak contradiction. contradiction.>, formulaS .k Bymaximum more lemma Therefore Therefore closely. 2, independentS. isVV anS independentS≤ set.≤isis the the≤ This≤ minimum minimum is set. ab contradiction.3 Therefore,a vertex vertex2 cover. cover.3 S Thereforeis not a V S is the minimum vertex cover. A and B will have the same sum,of as equalf for(a) every,fsum.(a +0 1),fk (a +−| 2)−,− ...f(|b) |forb− somea |2 a>)=SS} f.0.(a By By+2+3.. lemma As lemma As −kand3and) 2,− 2, SS  isareisare an an connected connected independent independent set. set. Therefore, Therefore, SS isis not not a a { } || −−JonathanJonathan|| || Irvin−− Irvin≤|| GUNAWAN GUNAWAN≤ ∈∈ −− || || || ||∈∈≤ ≤ byby an an edge, edge,MAX-INDEPENDENT-SET. we we note note that that SS maximumismaximumis not notb an ana INDEPENDENT-SET.independentJonathan INDEPENDENT-SET.independent2 f(Jonathan Irvina +3 set. set. GUNAWANk This)+ This Irvinf is( isa This This a aGUNAWAN+1+3 contradiction. contradiction. is is a ak contradiction.)= contradiction.f(a Therefore Therefore+2+3 Therefore Thereforek)VV SS isisVV the the minimumS minimumS isis a a vertex vertex cover. cover. Proof. Pick any consecutiveB f subsequencea k , of bF kwitha 2 length multiples. of three, whichb wea will2 denote by F  = −− Jonathan Irvin GUNAWAN = ( +2+3InIn the the) beginning beginning0 f( ofa of−+3 this this−kJonathanJonathan)+ section, section,f(a +1+3 we weIrvin Irvin assume assume GUNAWAN GUNAWANk)= we wefIn( knowa know the+2+3f(a beginning that+3 thatkk MIN-VERTEX-COVER))+ MIN-VERTEX-COVERf of(a this+1+3 section,k)=−− wef( assume isa is+2+3 a a NP-hard NP-hard wek) know problem. problem. that MIN-VERTEX-COVER It It is is is a NP-hard problem. It is Jonathan Irvin GUNAWAN VERTEX-COVER.VERTEX-COVER.A = f({a +3Jonathank), 0 k Irvin≤− GUNAWAN≤− 3 f(}a +1+3k), 0 k − − f(a),f(a + 1),f(a + 2){, ...f(b) for some≤ ≤a> SS.. By By lemma lemma 2, 2,SS isis an an independent independent set. set. Therefore, Therefore,SS isis not not a a || −− || || −− || JonathanJonathan Irvin| Irvin| || GUNAWAN GUNAWAN|| || maximummaximum independent independent set. set. This This is is a a contradiction. contradiction. Therefore ThereforeVV SS isis the the minimum minimum vertex vertex cover. cover. −− FromFrom the the above above theorem, theorem, we we conclude conclude that that a a MIN-VERTEX-COVER MIN-VERTEX-COVER can can be be easily easily constructed constructed if if we we have have a a MAX-INDEPENDENT-SET.MAX-INDEPENDENT-SET.

InIn the the beginning beginning of of this this section, section, we we assume assume we we know know that that MIN-VERTEX-COVER MIN-VERTEX-COVER is is a a NP-hard NP-hard problem. problem. It It is is goodgood to to know know as as many many NP-hard NP-hard problem problem as as possible. possible. This This is is necessary necessary so so that that if if we we encounter encounter a a new new problem problem X, X, we we cancan use use any any of of the the NP-hard NP-hard problems problems that that we we know, know, reduce reduce it it to to problem problem X, X, and and thus thus prove prove that that X X is is also also NP-hard. NP-hard.

11WeWe say say that that problem problem X X is is reducible reducible to to problem problem Y Y

JonathanJonathan Irvin Irvin GUNAWAN GUNAWAN 3 How to proceed

Suppose we already know that a problem is unsolvable (i.e. any known algorithm will not solve this problem in time). In competition, it is impossible3 How to complain to that proceed "This is unsolvable, can you eliminate this problem?" Supposeto the we judges,already sinceknow the that judges a problem believe is unsolvable they have (i.e.a solution. any known Such algorithm a request will is absurd not solve when this there problem are inalready time).several In competition, contestants it who is impossible have solved to that complain problem. that Also, "This in a is major unsolvable, competition can you (e.g. eliminate ACM International this problem?" Collegiate to theProgramming judges, since Contest the judges World believe Finals, they IOI), have it is a unlikely solution. that Such the ajudges request have is incorrectabsurd when solution. there are already several contestants who have solved that problem. Also, in a major competition (e.g. ACM International Collegiate Programming Contest World Finals, IOI), it is unlikely3.1 Approximation that the judges have incorrect solution. In real life, when we cannot find the optimal solution, we can try to find the solution that is close to the optimal solution. More specifically, we try to3.1 find a Approximation solution that is not larger than α (where α>1) times the optimal In realsolution life, when for we a minimisation cannot find the problem. optimal The solution, most we common can try approximation to find the solution algorithm that Iis found close to in the textbooks optimal is the solution.2-approximation More specifically, MIN-VERTEX-COVER we try to find a solution problem, that which is notmeans larger that than the algorithmα (where willα> not1) timeschoose the more optimal than twice solutionthe for number a minimisation of vertices problem. than the optimal The most solution. common However, approximation approximation algorithm problems I found rarely in textbooks occur in competitive is the 2-approximationprogramming MIN-VERTEX-COVER (especially IOI). One problem, of the reason which means is because that to the create algorithm this willkind not of chooseproblem, more the than judges twice have to α the numberknow the of vertices optimal than solution the in optimal order tosolution. verify that However, the contestant’s approximation solution problems is indeed rarely occur-approximation. in competitive However, programminggenerating (especially the optimal IOI). solution One of is the impossible reason is (or because takes a to long create time). this Since kind this of problem, approach the is not judges really have suitable to for knowcompetitive the optimal programming, solution in order I will to not verify discuss that this the contestant’sapproach in detail. solution is indeed α-approximation. However, generating the optimal solution is impossible (or takes a long time). Since this approach is not really suitable for competitive programming, I will not discuss this approach3.2 in Pruning detail. N N/2 This approach is usefulFigure in some 4: Comparisoncompetitive programmingof O(2 ) and problems.O(2 ) SUBSET-SUM In ACM International algorithm Collegiate running Programming time for various input sizes. This Contest (ICPC) Worldexperiment Finals 2010, is run problem 1003.2 times I (Robots Pruning for each on value Ice) required of N on the a MacBook contestant Pro to (Retina, count the 13-inch, number Early of 2015) N N/N N/2 This approachHamiltonianFigure is 4: useful Paths ComparisonFigure in with some 4: constraints of competitive ComparisonO(2 ) and (ACM programming ofOO(2(2 ICPC2))and WorldSUBSET-SUM problems.O(2 Finals) InSUBSET-SUM 2010 ACM algorithm problem International running statement algorithm timeCollegiaten.d.), running for various Programmingwhich time input is for known various sizes. to This input sizes. This N N/2 ContestFigurebe (ICPC)aexperiment 4: NP-hard Comparison World problem. isexperiment run Finals ofconstraint 100O While(2 2010, times is) and run problemfinding causes for 100O each(2 a alltimes problemI value (Robots possible) SUBSET-SUM for of eachtoN on paths beon valueIce) solvable a is MacBook required algorithm impossible,of inN polynomialon the Pro a running MacBook contestantthe (Retina, solution time time Pro13-inch,using forto for (Retina, count various the this Early reduction theproblem 13-inch,input 2015) number sizes. proof is Early to of ofThis prune the2015) original problem (with- experimentthe exponential is run 100 algorithm times for we each use to value find of allN possibleon a MacBook paths (ACM Pro (Retina, ICPC World 13-inch, Finals Early 2010 2015) Solutions n.d.). If at Hamiltonian PathsFigure with 4: constraintsout Comparison the additional (ACM of O ICPC(2 constraint),N ) Worldand O(2 FinalsandN/ check2) 2010SUBSET-SUM whether problem the statement proofalgorithm stilln.d.), holds running which given time the is for known additional various to input constraint sizes. to This the problem. some point we know that it is impossible to visit the rest of the unvisited points, then we can prune the path and be a NP-hardconstraint problem.experiment causesconstraint While a problem is finding run causes 100 to beall a times problem solvable possible for toeach in paths be polynomial valuesolvable is impossible, of inN time polynomialon using a MacBookthe the solution time reduction usingPro for (Retina, the proof this reduction problem of 13-inch, the original proof is Earlyto of prune problem the 2015) original (with- problem (with- backtrack immediately. However,We will give it is we not one very example suitable of for a IOI.special Usually, case in IOI a problems NP-hard requireproblem. deep Suppose analysis we from have a function with the theconstraint exponentialout the causes algorithmadditional aout problem the weconstraint), additional use to be to solvable find and constraint), all check in possible polynomial whether and paths check the time (ACM proof whether using ICPCstill the the holds reduction World proof given Finals still proofthe holds additional2010 of given the Solutions original the constraint additionaln.d.). problem to If theconstraint (with-at problem. to the problem. the contestant. It is rare that we can get Accepted by only "hacking" a complete search algorithm. Therefore, we someout point the additional we know thatconstraint), itfollowing is impossible2 and formula check Identifying2 to whether visit Identifying the the rest proof of Intractability the still unvisited holds Intractability given points, the additional then of we can constrainta prune Problem of thea to Problem thepath problem. and through through Reduction Reduction will not discussconstraint this technique causes a in problem detail. to be solvable in polynomial time using the reduction proof of the original problem (with- backtrack immediately.We will give However,We we one will example giveit is notwe one ofvery a example special suitable case of for a IOI. in special a Usually, NP-hard case IOI in problem. a problems NP-hard Suppose require problem. we deep have Suppose analysis a function we from have with a function the with the out the additionalWe constraint), wouldWe like would to and know checklike thatto whether know the problemthat the1 theproof,n thatproblem still we holds are that given attempting we arethe=1 additionalattempting is unlikelyn =2 constraint is to unlikely have to an to the immediate have problem. an immediate solution. solution. The The the contestant.Wefollowing will give It is formula we rarefollowing one that example we formula can of get a Accepted special case by onlyin a NP-hardf"hacking"(n)= problem. a complete Suppose search we algorithm. have a function∨ Therefore, with we the most commonmost common way is to way apply is to a well-known applyUnderstanding a well-known technique Unsolvable technique called Problem reduction. called reduction. Suppose Suppose we know93 we that know problem that problemX is X is willfollowing not discuss formula this technique in detail.3.3by the Finding construction Small of the Constraints function.f(n 1) + f(n 2), n>2 We will giveimpossible we oneimpossible example to solve, of toand a solve, special we also and case know we inalso that a− knowNP-hard we can that solveproblem. we− can problem solve Suppose X problem by we using have X problem by a using function Y problem as awith black-box Y the as a black-box1. If we can1. If we can O(2N ) O(2N/2) byby the the construction construction1,n of of the1 the,n function. function.by the=1 constructionn =2=1 of then function.=2 Figure 4: ComparisonSuppose of thereandfollowing is anWe NP-hard formulaSUBSET-SUM consider problem thefTheorem sequencen algorithmwith large 2.F Iff running =(Nn)= fthatis( ndivisible) time isn∞=1 impossible for, andby various three, we define to then input∨ solve F sizes.(N exponentially) tocan This∨ be be the partitioned first (e.g.NN>terms into two50 of). multisetsF . We want to know by the constructionsolve problem ofsolve theTheorem( )= function.1 Y,,n problemby then the 2. construction we Y,If N can{ thenbyis solve divisiblethe we} canconstruction of problem the=1 solve by function. three, X problemn as=2 of then well. the XF function. Therefore, as(N well.) can Therefore, be problem partitioned Y problem is also into Y impossible two is also multisets impossible to solve. of equal to solve. sum. experiment is run 100Sometimes times for each we should valuewhether of alsoN lookon3.3 we a for MacBook can Finding otherof create equalN small Pro asum.f partition Smallconstraints(Retina,(n N/1)2 +of 13-inch, ConstraintsfF thatf(n((Nn ) may2) Earlyinto1), help.+ twon> 2015)f(n disjointFor2 2) example,, multisets n>2 a SUBSET-SUMA and B such problem that the sum of all elements Figure 4: Comparisonf(n of)=TheorembyTheoremO(2 the) constructionand 2. 2.OIfIf−(2NN isis of) divisible divisibleSUBSET-SUM the− function.− byTheorem by three, three,∨ algorithm− then then 2. IfFFN((N runningNis)) can divisiblecan betime be partitioned partitioned by for three, various then into into inputF two two(N sizes. multisets multisets) can This be partitionedof of equal equal sum. sum. into two multisets of equal sum. f(byn the1) construction+ f(n 2), of n> the2 function. is consideredTheorem an NP-hardin 2.A problem,isIfby equalN theis construction divisible andtoProof.byby the will the the sumTheorem by notIf construction construction three,N ofof beis all the solvable divisible elements2. then function.1Theorem,nIf of ofNFN with( thethe byNis in) divisible three, function. function.NBcan 2.=by beIf 100 thentheN bypartitioned.is construction When three,F divisible(N=1) we thenis into a are by prefixnF of three,two given(=2N the) multisets ofcan function. the thenF bewith constraintF partitioned( ofN length) equalcan that multiplesbe sum. into partitioned two of multisets three. into twoBy of lemmaequal multisets sum. 3, F of(N equal) sum. by the constructionSupposeWe there of the consider is function.experiment an NP-hard theWe sequence consider is runproblem the100FWe= sequence timesare withfProof. using(nWe) forlargen∞ F areIfNP-hard=1 each−f =,N( usingn and )= valuethatisf( divisiblen we problemsNP-hard) is of definen∞−=1 impossible, andonby problems forF three, a(illustration.N we MacBook) todefineto then for solvebe illustration. theF Pro Recall( exponentiallyN first) (Retina, tois thatN a∨ be Recallprefixterms theNP-hard 13-inch, (e.g.first that ofof FN problemsNP-hard .N> Earlywith Weterms wantlength 2015)50 problemsof have). F to multiples. yet know We to have want be of yetsolved to to know be in polynomialsolved in polynomial by the construction of the function.by the constructionall the of the elements function. inside the array are{TheoremProof.Proof.can small be} IfIf (e.g. partitionedNN 2.{isis[0If divisible divisible,N100]}is into), divisible this by by two three, three, problem multisets byProof. three, then then canIf ofFF thenN(( equal beNNis))F solved divisibleisis( sum..N a a) prefix prefixcan using by be of of three,O partitionedFF(NXwithwith then2) length lengthDynamicF into(N multiples) multiples twois a multisets prefix of of ofthree. three. ofF equalwith By By lemmalength lemma sum. multiples 3, 3, FF((NN)) of three. By lemma 3, F (N) constraint causesSometimes a problembyWe the considerwhether construction to we be should the solvable we sequence canwhether also of increate the look polynomial function.F we for atime= partitioncan otherf for( createn time) more smalltimen∞three. of=1 using a,F forthanconstraintspartition and (TheoremByN the more) lemma we4into reduction decades. define than of two 2.that3,Ff 4(( disjointIfNFn decades.proof MIN-VERTEX-COVER may(N)Ninto1))is help.to ofcan divisible+ multisets twothe bef MIN-VERTEX-COVERbe(n Forthe disjoint originalpartitioned by example, first2)A, three,and multisetsproblemN n>Bterms into is then a2such a SUBSET-SUM graph(with-twoA ofF that( andFNmultisets is. problem) a WetheBcan graphsuch wantsum be of problem that problempartitioned thatequal of to all involves know the sum. elements that sum into finding involves of two all elements a multisets finding minimum a of minimum subset equal sum. subset Proof. If N isTheorem divisible{ }cancan byTheoremTheorem 2. three,be beIfProof.N partitioned partitionedis then 2. 2. divisibleIfIfIfNFNN(isN intoProof. intoisis) divisibleby divisible divisibleis− two two three, aIf prefix multisets multisetsN bycan then byTheorem byis three, of divisiblethree, three,be−FF partitionedof( ofNwith thenequal thenequal) then 2.can by lengthFIfF three,F sum.. sum..(beN(N(NN into) partitionedis)) multiplesis divisiblecan thencan twoa prefix be beF multisets( partitioned partitionedN byof into of) three. three,isF two awith of prefix multisetsthenequalBy into into length lemma ofF two two sum..(FNmultiples of multisetswith multisets) 3,can equalF length( beN sum.) ofpartitioned of of three.equal multiplesequal sum. sum. By into oflemma three. two multisets3, ByF ( lemmaN) of equal 3, F ( sum.N) Theorem 2. If Programming,N is divisible by where three,X thenisThis theF looks upper(N)Fcan like boundN be a classic partitioned of the PARTITION elements into two inside problem. multisets theA array. PARTITION ofB equal Even sum.though problem the running is NP-hard time by of reduction the from SUBSET- out theTheorem additional 2.is constraint), consideredIfwhetherN isin divisibleA we anandis can equalNP-hard check bycreatein three, to whetherA the problem, ais partition then sum equalof theF of nodesand to( proofN all of the) will elementscanofProof.such still( sum not nodes be) holds thatinto of be partitionedIf in all suchsolvableN twogiven forB elementsis every disjointthat divisible theN with into foradditional edge, in multisetsN everytwo byB= at three, multisets 100 leastedge, constraint.,F thenWhen oneand atN of least ofFequal we to( itsNsuch the oneare) endpointis sum.problem.that givenof a prefix its the the endpoint is sum of in constraintF the ofwith subset.isall in elements length that the MAX-INDEPENDENT-SET subset. multiples MAX-INDEPENDENT-SET of three. By lemma is a 3, F ( isN a) Theorem 2. If N is divisible by three, then F (N) can be partitionedconstraintWecanN consider be partitionedSUM. intocauses the two Therefore, a sequence problem multisets intoTheorem twoF to for of multisets= becanFa equal solvable largeNf be( 3.n) sum. partitionedIfIf valuen∞ of =1 in equal,can polynomial and of1 beN sum..(mod we into, partitioned it define is two time3) unlikely , multisetsF using((N into)) to cannot thetocannot two be of be reduction ableequal multisets the be bepartitionedfirst to sum..partitioned find proofN ofterms an equal of algorithm into the into of sum.. original twoF two. Wemultisets that multisets problem want finds toof (with-A of knowequal and sum.B in an allTheorem theinalgorithmA elementsis equal 2. isIf toinside exponential theis thesum divisibleby array of to the allgraph theProof. by are elementsconstruction three, size small problemIf ofgraphcanN thenProof.Proof. the(e.g. inis beB input, ofdivisibleproblemProof. partitioned{([0IfIf findingthe,NN)100] the function.can}isIfis byof),N algorithmdivisible divisibleNaby befinding three,this maximum intois≡ the partitioned divisible problem two construction then by by a is maximum multisetsthree, three,still subsetFTheorem byProof. can( into,F,F fastN three, then then)N beofN twois enoughof of subsetIfnodes a solved theF thenFby equal3.Nmultisets prefix((NN the function.isIf for)) ofF such divisibleN sum..usingisis( constructionof nodestheN a aF) ofthat prefix prefix1 givenisOwith equal (mod a(such byNX for prefix of ofconstraint. lengththree, everysum.2 thatF 3)Fof) ,F ofDynamicwithwith the thenfor multiplesedge,(byFN function. lengthwith lengtheverythe) AnotherFcannot at( constructionN length mostedge,) ofmultiples multiplesis bethree. a one atmultiplespartitioned prefix most of By of of its of three. three.the lemma one endpointF of function. intowith three.of By By 3,its two lengthlemma lemmaF endpoint is By(N multisets in) lemma multiples 3, 3, F isF(( in3,ofNN))F equal of(N three.) sum. By lemma 3, F (N) N byF theN constructionTheoremTheorem ofF the 3. 3. function.FIfIf(NN) 11 (mod (mod 3) 3),F((N)) cannotcannotA be be partitioned partitionedB F N into into two two multisets multisetsN of of equal equal sum. sum. Proof.Proof. IfIf N isis divisible divisibleway toapply by by three, three,outwhether this the then then technique additional weefficientF can((N)) create is constraint),isis way. when a a prefix prefix a However,equal partition the of of andvalue sum.F checkwithwith this of of N sequence length length whetheris≡≡into not multiples multiples toothe twois defined proof large disjoint of ofstill (e.g. three. three.in multisets holdsaN< very By By given special lemma40 lemma).and≡ the For way,3, 3,additional example,Fsuch(( inN) the) that constraint whilesense the sumO that(2 to ofF the) allis problem. elements defined using the Proof. If Nbyis the divisible construction by three,We of the then will function.by giveF ( theNProgramming, we) constructionis one a prefix exampleThis of ofwhereF theof lookswithTheorem a function.X special lengthlikeisThis the a 3. caseclassic uppermultiples lookstheIfcanN in subset.belikePARTITION bound a NP-hard partitioned1 of atheProof. (modcancan classic three. ofSuppose subset. thebe beTheoremcan 3) problem.Suppose partitionedPARTITION partitionedByproblem. elements,F into be weSuppose( lemmaN partitioned two already) 3.cannotF Suppose insidePARTITIONTheorem multisets(If 3,into into weN problem.NF know)= already( betwo thetwo intoN weF1) partitioned array.thatof( multisets multisets 3.(modN twohavecan equalPARTITION knowproblem)If MIN-VERTEX-COVER multisetsN Even beaf 3)(1) functionsum.. that,F partitioned of of into1. thoughis( equal equalN Note (modMIN-VERTEX-COVER NP-hard twoof) problemcannot withequal sum.. sum..that multisetsthe 3) into,F the runningby sum..F be is( twoN( reduction NP-hardN partitioned) is of)cannot multisets acontains timeequal NP-hardbyfrom of isbe sum. into thereduction aofN partitioned NP-hardproblem. SUBSET- equal two1 elements. multisets sum.. from problem. Therefore, into SUBSET- two of Since Therefore, equal multisets weN can sum.1( show of wemod equal can3) show sum., we can be partitionedProof. intoIf N twoismultisetsin divisibleA is equal by of three, equal to the sum.. then sumF ofN(N all) is elements a prefix in ofBF with lengthF N− multiplesTheorem of three. 2.N/2 ByN lemmaTheorem 3, F (N−) 2. If N isF divisible(N) by≡ three, then F (N) can be partitioned into two multisets of equal sum. can be partitionedalgorithm into two for multisetsN = 36Theoremaforementioned ofTheoremis equal unlikely sum.. 2.≡ 2. toIfIfTheoremProof. runProof.N recurrence.is inis divisible one divisibleSupposeSuppose 3. second, Therefore,If by byNFTheoremF three, three,(( weNN1)=)= can, (mod then we≡ thenFF 2. shouldfor((FNN 3)Proof.If() instance,),FN(N)( inspectff)isNcan(1)(1)canSuppose≡) divisiblecannot. be. use Notebe Note the partitioned partitioned a byFrecurrenceO thatbe that(2( three,N partitionedF)=FIf() into(NN thenintoMeetF formula))(isN twocontainscontains twoF divisible) into In( multisetsN Themultisetsf more) two(1)canNN. Middleby multisets Noteclosely. be three, of11 of partitionedelements.elements. equal that equal then of sum.F equal sum.(N Since Since into) sum.containscan twoNN be multisets1(1(N partitionedmodmod1 ofelements.3)3) equal,, we intowe sum. two Since multisetsN 1( ofmod equal3) sum., we can be partitioned into twofollowing multisets formulaby ofthe equalalgorithm construction sum..ThisSUM. is looksexponential of Therefore, the like function.SUM. a classicto forthe Therefore, a size PARTITIONthat large of MAX-INDEPENDENT-SET the value forthatProof. input,Proof.have a of problem. large MAX-INDEPENDENT-SETNN theSuppose, it value1 algorithm is PARTITION unlikely0( ofmodN is, toit still3) is is. beproblem also Byfastunlikely able lemma aenough NP-hardis to is toalso find NP-hard 3, be for . a.F an ableNote NP-hardproblem the(N algorithm)given tobythat can find reduction by problem be constraint. reducingan that partitioned algorithm contains findsfrom by reducinga Another MIN-VERTEX-COVERSUBSET-A into thatand two aB finds MIN-VERTEX-COVER in multisetselements.elements. anA and of B Since equalin problem an sum. into problem Therefore, a into, thewe a Theorem 2. If N is divisibleTheorem by three,can 2. then beIf partitionedNFis(N divisible) canWe into be bywill partitioned two three, give multisets we then one intoF of( exampleN twoTheoremTheorem equal) can multisetsTheorem− sum.. be of 3. partitioned3.a≡ special ofIfIf 3.NN equal≡If caseN11 intosum. (mod (modN/ in1 two2 a (mod 3)Theorem 3)NP-hard multisets−,F−,F(( 3)NN,F)) problem.cannotcannot( 3. ofN) equalIfcannotN be be Suppose sum. partitioned partitioned1 be (mod partitioned we 3)− into,F intohave(N two two into a) functioncannot−− multisets multisets two multisets be with partitioned of of equal equal the of equal sum. sum. into≡≡ sum. two− multisets of equal sum.≡ algorithm forProof. solvingSuppose a problemTheoremF like(N SUBSET-SUM.)=havehaveSince 3.FNNIf( Proof.NN)11 1fSuppose0((1)0( (mod While.modmod NoteProof. 3)O3)F3) ,F,(2 that.. we((N BySuppose ByN )= have)F lemma lemmahavecannotis(FN still (N)NFcontains 3, 3,exponential)( beNF1F)=f partitioned(((1)NN0()F).Ncanmod(can NoteN to)1 be beN3)elements. intothat,f partitioned partitioned.. it(1) By By twoisF. lemma much Notelemma(N multisets Since) contains intointo thatfaster 3, 3,NNF two twoF of( thanN( equalNmultisets multisets1() )can modcontainscan1 sum. beelements. be3) of partitionedof , equal equalweN Since1 sum. sum.elements. intoN Therefore, Therefore, two1( multisets Sincemod the theN3) of, we1( equalmod sum.3), Therefore, we the Theoremway 3. SUM.If toN applyefficient Therefore,1 (mod this way. technique 3) for,Fefficient However,( aN largeProof.) iscannot way. whenMAX-INDEPENDENT-SET value thisIf However,N be the sequence ofis partitionedMAX-INDEPENDENT-SETN valuesum divisible, itthis of isof is allunlikelyN defined bysequence− into elementsis three, not two to in too multisetsproblem.then beis≡a≡ in very defined large ableFF≡(N( specialNN to (e.g.problem. of)) in findisis equala even. aN< way, very an prefix sum. algorithm− However,40 in specialProof. of). theF For sensewithIf way,− example,that theN≡ lengththatisin sum finds divisibleF theF ofN while senseAmultiplesis alland defined by elementsOProof. that(2B three,in of)F using anthree.If≡ inthenisNF definedF the−is(FN By divisible()=N lemma) usingFis( aN by prefix the3,)+ three,Ff(N(1) of) thenF, which≡withF (N length is) oddis a multiples prefix of ofF with three.N length By lemma multiples 3, F of(N three.) By lemma 3, F (N) TheoremTheorem 3. If 2.N If≡NN1is (mod divisiblefollowing 3)This,F by(NProof. looksformulaLemma three,) cannot likeIf thenN 3. a be classicFisAny partitioned( divisibleProof.N) consecutivecan PARTITION−Suppose−be by≡ intopartitioned three,≡≡ subsequence twoFProof. problem. then( multisetsN)= intoFIf(NF of PARTITIONtwo() ofNisFis) equal divisiblemultisetswith a prefixf(1) length− sum.. byproblem of Noteof≡F three, multiplesequalNwith that is thensum. length NP-hard−F of(N three() multiplescontains) by canis reduction a be prefix ofN partitioned three. of1 fromelements. Bywith SUBSET- into lemma length two Since 3, multisets− multiplesFN(N)1( ofmod three.3), weBy lemma≡ 3, ( ) Theorem 3. If N 1 (mod 3),F(N) cannot beO(2 partitioned), and thehave into rangeN two multisets1 of Nby0(that themod of construction it equal can3)sumsumpartitioned. By solve ofsum. ofhave lemma all all isofN elements elements twice intothe 3,1 function.F two thehave(0( inN in rangemultisets)FFmodNcan((NN of) be3)1) sumisis .N partitionedof Byeven. even.−0( usingequal of lemmamod all However, However, a elements sum.3)O into3,(2. ByFN/ Therefore,) two2( thelemma thesolution.N in) multisets sum sumFcan( 3,N be of of the)F allispartitionedall  ( of sumN even. elements elements equal) can of However, sum.beall− into in in partitioned elementsFF Therefore, two((NN the)=)= multisets sum inF intoF  the(( ofNN two)+ ofall)+ equal elements multisetsff≡(1)(1),, sum. which which in of Therefore,F equal is is(N odd odd)= sum.F the( Therefore,N)+f(1) the, which is odd Proof. If≡N is divisible by three,Proof.algorithm thenIfTheoremefficientNFis(≡Naforementioned divisible for) way.is 3.N aIf= prefix However, byN 36 three,aforementionedis of1 unlikelyrecurrence.−1F (mod,ncan thisthenwith≡ be sequence 3) toF length partitioned,F(N run Therefore,( recurrence.)Nis in) multiplesbecause aisProof.cannotProof. one prefix defined into second,Proof. weSuppose Therefore,SupposebeF of oftwo should=1 in( partitionedF three.NSupposemultisets weawith) verynis inspect can,FF=2 even By welength((N specialN forlemmaF should)= into)=of while the( instance, equalN multiplesFF two)= way,recurrence((f 3,NinspectNProof.(1) sum..)multisets)F in(isN useff ofthe odd.(1))(1) theSupposethree. a formulacan. sense.fO recurrenceof Note Note Therefore,(1)(2 be equal. By that partitionedF Note thatmore that) lemma( sum.MeetNF formulaF)=F that thereclosely.is((NN In definedF 3,F) into)( TheisFNcontainscontains( moreN no()N two) Middlecan) wayusingcontainsf closely.(1) multisets beN toN. the partitionedNote partition1N1 elements.elements. of that1 equalFelements.F( intoN( sum..N) Since Since. two) contains Since multisetsNN N1(1(N modmod of1(1 equalelements.mod3)3),, we wesum..3), we Since N 1(mod 3), we f(SUM.n)=≡ Therefore,canof equal beProof. partitioned sum.for aSuppose largehave intoN valueF two1(N of multisets−)=0(N∨ ,canmod≡F it( isN be of3)) unlikely partitioned. equal− Byf(1) lemma≡. sum..to Note be into 3, able that−F two to(NF multisets find)(Ncan) ancontains be algorithm partitionedof equalN sum.. that1 intoelements. finds twoA multisetsand Since− B Nin of an equal1(mod sum.3) Therefore,, we≡ the Proof. Suppose F (N)=F (sumN) off all(1) elements. Note that in becauseFbecauseF((NN)sum) −iscontainsisFF even.even. of((≡NNby all)) is However,theisHowever, elementsN even evensum constructionN/12 while whileof−elements. the inthe allF ff elements sumbecause(1)(1)(N of− −)isof Sinceofis theis odd. odd.all all even.F in function.elements elementsN(FN Therefore, Therefore,)( However,Nis1() even ismodin in even. F there therewhile( the3)N,)= However, we sum is isf(1) no noF− of−( wayis wayN all odd.)+ the to elementsto f sum partition partition− Therefore,−(1) , ofwhich in allFF elements( ( thereis NN odd)≡))=.. isF no in(NF way)+(≡≡N to)=f(1) partition−F, which(N)+F isf(N(1) odd)., which is≡ odd can be partitioned intoProof. twoProof.can multisetsSuppose bealgorithmIf partitionedaforementionedN ofFis equal( divisibleN for)= solvingintosum..F by( twoN recurrence. three,)a multisets− problemff(1)( thenn. Note Therefore,like of1)F ( equal +SUBSET-SUM.NWe thatf) (is willn sum..F a wehavehave prefixfirst(2)WeN should,NN)have provewillcontains n> of While1N1F firstinspect2 thewith0(0(1 proveON following(2modmod lengththe−0(1 the recurrencemod3)3))elements.is.. followingmultiples two ByBy still3) lemma.have lemmalemmas. exponential By formulaSinceN two lemmaof 3, 3, three. lemmas.N1FF more( 3,(≡ toNN0( By1(F)N) canmod closely.can(,mod lemmaN it)be isbecan3)3) much partitioned. partitioned, 3, By be weF partitionedfasterlemma(N) into thaninto 3, F two two into(N multisets multisets) twocan multisets be ofpartitioned of equal equal of equal sum. sum. into sum. Therefore, Therefore, two Therefore, multisets the the of the equal sum. Therefore, the Proof. Suppose F (N)=F (N) f(1). Note that F (N) containsefficient−N way.1Theorem However,haveelements.N sum 2.1 this SinceIf of0( sequenceN allNmodis elements divisible1(−3) is.mod Bydefined1≡,n by− in lemma3) three,F,( weinN 3,) a thenis veryF even.(FN special()Ncan However,) can be way,≡=1 be partitioned partitionedin then the=2 sum sense into of into all thattwo elements two multisetsF multisetsis defined in F of( equalN of using)= equal sum.F the( sum.N Therefore,)+f(1), which the is odd have− N 1 Proof.0(N modLemmaSuppose3). By 3.because lemmaFAny(LemmaN)= consecutive 3,Proof.FTheorem−F(−N 3.((N)NPickAny)is) can even subsequence3.f consecutive any(1)− beIf−Theoremodd while.N≡ consecutivepartitioned Note becausebecausef1(1)−− that of subsequence(mod≡ 4.Fis≡ ≡F intoodd.IfwithF subsequence 3)(NTheorem(N,FN twobecause)length Therefore, )(containsisN2is of multisetseven) (modevenFcannot multiples 3.withF ofwhile while(N 3)IfthereNF length.ofN) be Fwithis1 equalf of( ispartitioned(1)N evenelements.1−three no) multiples lengthTheoremN (modisiscan sum. way≡ while odd.odd. can be to3) Therefore,multiples SinceintoTherefore,f Therefore,bepartitioned,F of partition(1) 3. partitionedthree( twoNisIfN) odd.Ncannot multisetsof can the Fthere there1( intothree,(N Therefore,1bemod into) (mod be.is partitionedtwoTheorem is ofno which partitionedtwo no3) multisets equalway 3), way wemultisets,F there we to( tosum. 3. intoN partition will partitionis) ofintoIfcannot notwoN equal denote two way multisets 1F sum.be multisets to (mod( byN partitioned partition)F.  3)=,F of( equalFN into()Ncannot) sum.. two multisets be partitioned of equal into sum. two multisets of equal sum. havecanN − be1O≡ partitioned(20()mod, and3) theinto. By range two lemma multisets of NTheorem 3,thatF  of(N it equal) can− 3.canIf solve sum.. beN3.4sumsum partitioned is1 of ofsum twicef Finding(mod all all(n of)= elements elements the intoall 3) range,F elements two≡( SpecialN in in) of multisetsFFcannotN( in(NNusingF))sumisis( Casesbe ofN− even. even. a) partitionedequal ofOis(2 all even. However, However, sum. elements) solution. However, into Therefore,∨ the the twoin sumF sum the multisets(≡N the of of sum) is all all even. of elements elements of all equal elementsHowever, insum. in FF(( inNN the)=)=F sum(NFF)=(( ofNNF all)+)+( elementsNff(1))+(1),,f which which(1) in, whichF is is(N odd odd)= is oddF (N)+f(1), which is odd haveN 1 0(mod 3). By lemma 3, F−(N≡) can be partitionedaforementioned into two multisetssum recurrence. of all ofTheorembecauseTheorem elements equal≡ Therefore,≡ F sum. 4. 4.( inNTheoremIfIfF) Therefore, weisNN(N even should) 2is2 while2.(mod even.(mod the inspectIf Nf 3)However,Theorem 3)(1)is.. theFF divisibleis(≡(NN odd. recurrence)) thecancan 4. Therefore, by sumIf be be three,N partitioned partitioned formulaof all2 then there (mod elements moreF≡ isinto( into 3)N no.) closely.F twoin twocan way(NF multisetsbe( multisets) toNcan)= partitioned partition beF  partitionedof of(N equal equalF)+( into≡Nf)(1) sum. sum.. two into, which multisets two is multisets odd of equal of sum. equal sum. − Theorem≡ 3. If NWe consider1sum (modTheorem of the3) all,F sequenceelements(haveNLemma 3.) cannotNIfof inFN equal 3.1F= be(Any1Nf0( partitioned(sum. (mod)nismod) consecutiveofn∞ even.=1 3) equal3),,F and.f However, intoBy(aN sum.) we subsequenceLemma,f) lemma twocannot( definea +multisets the 3,1) 1.Lemma beF,f sumF(IfN( ofpartitioned(aNS) of+F . of)to2) allcan1.with equal beV, ...felementsIf beis the lengthS( intosum. an partitionedb) firstf INDEPENDENT-SET(V twoforn multiples inNis someF multisets1) anterms(N + into INDEPENDENT-SET)=a want off sum.be(1) graphpartition ofpartitioned2, to whichequal know ofG( graphFV,E sum. is oddinto), Therefore,G then two(V,E multisetsV), then theS isV a VERTEX-COVERS is a VERTEX-COVER of the of the sum of all elements in− F ≡({N) is} even. However,Proof. theIf N sumbecausebecauseis divisible ofbecause allFF elements((N byNF)) three,isis(N≡≡ even even) in−is thenF whileeven while(NF)= while(ffbecauseN(1)(1)F)−is(isfisN(1) a odd. odd.)+ prefixFis(fN odd. Therefore,(1) Therefore,) of,is whichF Therefore,≡ evenwith therewhile thereis length odd there isf is(1) no no multiples is way way noodd. to to way partitionof Therefore,partition to three. partitionFF By( there(NN lemma))F.. ( isN no). 3, wayF (N to) partition F (N). sum of all elements in F (N)≡is even. However, the sum≡ of allTheorem elements{Proof. 4. in IfFbecause(NSupposeN)=2FFProof. (mod(F(NN())+TheoremNis 3)⊆Assign)=. evenfF(1)F(N,( whileNf which) 4.⊆(1))can}TheoremIfftof be(1)N is(1)A odd partitionedis.and2 Note odd. 4.(modf(2)If that Therefore,N 3)to into.FBFProof.2( two.(NN (mod Since) there)contains multisetscanSuppose 3)f is be(1). noF partitioned(N = ofN wayFf) equal(2)(can1N toelements.,)= partition webe sum.Proof. intoFpartitioned are(−N two now) SinceFSuppose( multisetsNf trying(1))− into.N.F Note to two1( of(N partition equalmod)= multisetsthatFF3) sum.(N,(FN we) of()Ncontains equalf)=(1).F sum. Note(NN) that1 elements.F (N) contains Since NN 1(1 elements.mod 3), we Since N 1(mod 3), we whetherbecause weTheorem canF create(Nsumof) 3.Thisis equal aIfof even partitionN allis sum. thewhile elements1 most (modoffF(1)( suitableNin 3)is)F,FProof. odd.into((NN) twoapproach) Therefore,graphisSupposecannot even. disjointG(graph beV,E However,inF there multisets partitioned IOI,()NG)= is and(V,E no theFA thus( way)N sum intoand)Proof. to is ofBtwofthe partition(1) allsuch multisetsSuppose. main elements Note thatF focus( thattheN ofF in). sum(equal ofFNF()=( thisNN of sum.)=)F all paper.contains(NF elements)(N To)+fN(1) solvef.(1) Note1 ,elements. IOI which that 2008 isF odd SinceIsland(N) containsN 1(Nmod 13)elements., we Since N 1(mod 3), we F N WeLemmaf consider 3. theAny sequence consecutive≡ TheoremF = subsequencef( 4.n) If∞ffN(1)(1) of,− andF2NAwith(modA we≡ define lengthF 3)Proof.ff(2).(2)NF multiples(NAssign≡)BBcanto be ofbef(1) the three partitionedff−(1)to first(1)F canA = =NNandf bef−terms(2)(2) into partitionedf(2) two oftoF multisetsB. We. intoF Since− want two off multisets(1)to equal≡ know = sum.f−(2), weFF are((N−N)=)= nowFF trying((NN)) − to≡ partitionF NF (N)=F≡(−N) ≡ F N f because ( ) is evenProof.F≡ whileNPick(1)F anyProof.Nis consecutiveodd.Pickfcan Therefore, any beF partitioned subsequence consecutiveNProof.Proof.Theoremf there(1)F isAssignAssignf intoN(2) no subsequence4. of. wayProof. twoIfFnF f=1(1)(with to−multisetsN)to partitionIftowillN lengthA of haveisandandF of divisible multipleswith equalbfN( (2). a) length.to2to sum.. byelements.2B of three,.can.three,multiples Since Since beN then partitioned Sincef which(1) of(N = three, we−)f(2)is 2(into will a,, whichmod prefixwe wetwo denote are are 3)multisets weofbN, now now we by willawith obtainF trying trying  denote2of= length≡equalN to to bypartition partition multiples2F  0(= modF of(N three.3))=. ByF By( lemmaNN) lemma 3, ( ) because Proof.( ) isSuppose even whileinF A(N(1)is)= equalisF odd.Proof.(N to) Therefore, theSupposef(1) sumand. Noteof IOIthereF all(2014 that elementsN is)= noF Friend, way((N in)) toBcontainshave we partitionN(1)N needf .1N Note3.41 to0(( use10( thatmodelements.) Finding.mod this{3)( approach.3).) SinceBycontains} Special lemmahaveN≡ WeN 3,1( mustFF1 Cases(mod1N(elements.N) find0()3)canmod, a we specialbe3) Sincehave partitioned.F ByN constraintN lemma11( intoby 3,0(mod thein twoFmod the(3) constructionN multisets,)3) problemwecan.have By be lemma of partitioned such ofequal1 the 3, sum.0( function.F mod( intoN Therefore,) twocan3). Bybemultisets partitioned lemma the of 3, equal into( sum.) two−−can multisets Therefore, be partitioned of the equal into sum. two Therefore, multisets− of the equal sum. Therefore, the − because ( ) Proof.is evenhaveAssign while− f(1)(1)is−to odd.ATheoremTheoremandA Therefore,−=Theoremf(2).f By( 4. 4.ato+3 lemmaIf thereIfB 4.NNk.) Since,If isf0≡ 3,N22 no− (mod (modkf way(1)2A (mod to3)Theorem 3)=can−..− partitionfFF(2) be− 3)f((NN., partitioned)) weFcan 4.can(N are(BIff) be be(canNa− now)≡. partitioned+1+3 partitioned into be≡2 trying partitioned (modf twok≡), tomultisets0 into into 3) partitionf. kF two two into(N of multisets multisets) two−can equalF−( multisets−N be≡)= sum. partitioned of ofF equal equal Therefore,( ofN− ) equal sum. sum.≡ into sum. the two multisetsF N ofF equalN sum. Proof. fPicka ,f anywhetherofa equal consecutivef,f( wea sum.),fa can(aTheorem create+−subsequence,− ...f1)≡,f≡b a(aff partitionsum.(1)+(1) 4. 2)If of,Proof. ...fNffF(2)(2) of(withba graphS ofS is edges> planar.S can We be willSTherefore, upprovide to aS quadratic solving several this order problem with respect is reducedS to the to checkingS number whether of N 1 (mod 3). We can solve this in O(1). examples. 4.1 Planarf(anda +3kwill)+ graphs havef(a +1+3 the4.1 samek Planar)= sum,f (a as,+2+3 which for graphs every impliesk,4.1.1) which that impliesNumber3 that of4. edges By Some lemma4.1.1. By 2, lemma example Number is4.1.1 an 2, independent of is Number edges an of independent special set. of Therefore, edges set. cases Therefore,is not a is not a ≡ examples. | − | | |− −| | | − |2 ≤ ≤ | | | | | | | Planar graph is a graph that can be drawn on a flat surface without having two edges crossing each other (West examples. PlanarPlanarWemaximum graph graph will4.1 look is ismaximumInIn avertices independent Planara graphat simple simple graph some that(i.e. generalthatindependent general common graphs canO set. can(PlanarV be graph, graph,This be) examples). drawn drawn set. Thisis graph the thea Thison contradiction. is on numberIn numberofis anot ais simplespecialflat flatgrapha the contradiction.surface ofsurface of casePlanar generalcases that edges4.1.1 edges Therefore for without can thatwithout graph planarcan can graph, Number be may Therefore beWe beV drawnhaving is having graph. uptheaoccur up will graphS to to numberonofis twoprovide twoVinaInthe a a edgesthat quadratic quadraticcompetitiveedges flataedges minimumS planar moreof canissurface crossing theedges crossing be graph,examples order order minimum vertexdrawn withoutprogramming can each witheach withwe be cover.on of mayotherhaving vertex up respectothera respectspecial flat to show problems.(West cover. a(Westsurfacetwo cases toquadratic to that edges the the in withoutE number number the crossing order3 followingV having of of with6 each twosection. respect other edges (West to crossing the number each ofother (West 22 4.1.14.1.14.1.12 Number Number− Number of of− edges edges of edges4.1.1 Number of edges ≤ − Planar graph is a graph thatPlanar can be graph drawn is aon graph a flatIn that surface simple canetet without be al. general al. drawn 2001). 2001). having graph, on There There averticesverticesPlanarholds flat two the are are surfaceIn edgesfor numbergraph many (i.e. (i.e. simple manyfV(a crossingWe O withoutOgraphis+33 graph( ( ofV generalaVet willby kgraph)+ edgesIn) al.) problems).using). look eachproblems simplehaving 2001).f This This ( graph,thata can atthe other+1+3 is is somecan generaltwo which Therebevertices Euler’s not notwhich the (West4.1.1be up edgesk thecommon the )=are numberdrawnare to aregraph, formula. (i.e. case case easy afcrossingmanyet easyNumber( quadratica al.onO forexamples+2+3 for to ofthe( 2001).tographaV Therefore, solveplanar planaredgesflat eachsolve number)). ofk problems order ifsurface) ThisThere ofother canifgraph. graph. the edges thespecial of the is with begraph are (West graph edgesnotwithout whichIn numberupIn many casesrespect athe aiset tois planar planar canplanar. al. are aplanar. casehaving graph that of quadratic2001). beeasy to edges graph, graph,for may Weup the problemstwo We to planar There to will numberissolveoccur will weedges weorder aO provide( quadratic providemayVgraph.are may ifwhich in ) the with. of manycompetitive Naturally, show show several graph are Inseveral respect ordergraph a easythat that planar is planar.anytoE withE problemsprogramming to solve graph,algorithmthe3 respect3VV We number if which the willwe66 to graph mayproblems. provide are ofthe show easy is number planar.several to that solve ofE We if will the3V provide graph6 is several planar. We will provide several 4.1.12 NumberIn simple of general edges graph,2 the number of edges can be up to a quadratic order with respect to the number≤≤ −− of ≤ − et al. 2001). ThereJonathan are many IrvinPlanaret graph al. GUNAWAN4.1.1 2001). graph problems Number isThere a graph which are of many thatvertices are edges easy can graph (i.e. tobeexamples. solveproblems drawn4.1.1O(V ifFrom on the)). Numberwhich aholds graphholdsThis thecrossing flatFrom aboveare surface is forvertices foris not easyof planar.eachV theV theorem, theedges≥ withoutto above other (i.e.33 solvecase Webyexamples.byvertices Ousing using(West theorem,will we for( havingifV the concludeprovide planar) the theet). (i.e.graph al. two This Euler’s Euler’sweholds, graph. several2001).O edgesconclude isthat is(V planar.for not formula.2 formula.) a). InTherecrossingVexamples. theMIN-VERTEX-COVER Thisa that We planar3 caseare Therefore, Therefore,by is will aeach many notusingMIN-VERTEX-COVER for graph, provide otherplanar the graph the the thecase we (Westseveral Euler’s graph. numberproblems numbermay for canexamples. planar show formula. In be of of awhich edgeseasilythat edgesplanar graph. can Therefore, Eare be isconstructed is graph, InOeasyO easily3(( aVV planar)).. we theconstructed Naturally, Naturally,6 may if number graph, we show have any any ofwe if that awe edges algorithm algorithmmay haveE show is O a3V(V that).6 Naturally,E 3V any6 algorithm examples.In simpleverticesthatInIn general4.1.1 simple simple hasIn (i.e. simple graph,O general( generalNumber≥≥EO)(inV general the2 its) graph, graph,). number runningof This graph, edges the the is of time notIn number number4.1 the edges simple the can number casePlanar can be of of general≥ edgeschanged edges forbe of upplanar edges can graph,cangraphs to into bea be graph. can quadraticO the up up( beV to to number) In. up aComputing a a quadraticto quadratic order planar a of quadratic with edges graph, shortest order order respect can≤ we order with with be path may to− up withrespect respect the inshow to a respect number a general that quadratic to to the theE to graphof number number the3 orderV using number≤ 6 of of with− of respect≤ to− the number of examples. In simpleetexamples. al. 2001). general There graph, are the manyholds number graph for V of problems edgesMAX-INDEPENDENT-SET.3 by can using whichMAX-INDEPENDENT-SET.thatto be thesolve are up hasholds Euler’s easy to ifOO (the a(E forE to quadratic) ) formula.graph solveVin itsholds22 is3 if running byplanar. the orderTherefore,2 for using graphV with timeWethat the is3will the canrespecthas planar.by Euler’s provide usingnumberO be(E changed Weformula. to) the inseveral the willof its Euler’s2 edges number provide runninginto Therefore, examples.OO isformula.((OV severalV of time())V.) Computingthe. can Therefore, Naturally, number be changed shortest of anythe edges4 numberalgorithm into2 path isSomeOO(V of( inV). edgesa). Computing general Naturally, example is O graph(V ) shortestany. Naturally, using algorithm of path special any in a algorithm general cases graph using In simple general graph, theJonathan number Irvin of edges GUNAWAN canthatthatBellman-Ford beverticesvertices up has hasvertices to2 (i.e. (i.e. a( quadratic) algorithmO (i.e.Oinin((VV its itsO)) running). running).(V order This Thistakes)).isThiswith timeis timeOvertices not not(VEiscan respect can the the) not(Halim be be (i.e. case case the changed changed toO for casefor &the(V Halimplanar planar numberfor) into into). planar This 2013), graph. graph.( of is) graph... not but ComputingIn ComputingIn thea ita planar planaronly In case a takesplanar shortestgraph,for shortestgraph, planarO graph,(V we we path path) graph.may mayin we ina in showplanar showmay a aIn general general ashow that that graph. planar graph graphEE that≤ Counting graph,3E3 usingV usingV− 3 we66V may6 show that E 3V 6 In simple general graph, the number of edges can2 be up to a quadratic≥ ordervertices with (i.e.holds respectO for(V V to)). the This3 by number≥ isusing not the the of Euler’s case≥ for formula. planar graph. Therefore, In4.1 a the planar number Planar graph, of we edges graphs may is showO(V ) that. Naturally,E 3V any6 algorithm 2 verticesexamples. (i.e. InO( simpleV 2 )). This general isthat not graph, has theO case the(EPlanar) number forin its planar graph running of graph. edgesis athat time graph can In has can a that beO planar be( upE can changed) toin graph, be itsa drawnquadratic runningO into weOO(Bellman-FordEVEVE) mayOon( timeV a order) show flat. Computing can surface with that algorithm be changedrespectE without shortest3 takesV to into having theO6 path(OVE( numberVtwo in).(Halim a Computing edges general of O & crossing(V HalimOO graph) V shortestV22 2013), using each path other but in it (West a only general takes≤≤ graphO≤(−−V using) −in a planar graph.≤ Counting− 2 vertices (i.e. O(V )). This is not the case for planarBellman-FordBellman-Fordthe graph. numberholds InVV≥ for ofa algorithm algorithm planar connected3V3 that3 graph,by takeshas takes usingcomponents4.1.1 weO(( theVE mayin Euler’sNumber)) its show(Halim(Halim using runningV thatformula. DFS & &3 of Halim HalimE time inedges a Therefore,3 can 2013),general 2013),V be4.1.16 changed but but graph the it it Number only onlynumber takes into takes takesO of( ofVO edges+((. edgesVE4.1.1 ComputingOO)()(,V isVinin but))O a a( planar planarNumberV it) only. shortest≤ Naturally, graph. graph. takes− of pathO Counting Countingedges( anyV4.1.1 in) algorithmin aO ageneral(V Number) graph of using edges vertices (i.e. O(V )). This is not the case for planar graph. In2 a planar graph,holds we forthat mayVholdsholds has show3 for forbyO( usingthatE) inE thebyby its usingEuler’s using3runningV 4.1.1 the the6 formula. time Euler’s Euler’sholds canNumber for Therefore, formula. formula. be changed of Therefore,by Therefore, edgesthe using into≤ numberWeO thewill(−V the the2) Euler’slook of. number number Computing edges at formula. some is of ofO edges edges(common shortestV ) Therefore,. Naturally,is is path examples..the in2 Naturally, Naturally, any a number general of algorithm special any anyof graph edgescases algorithm algorithm using that is may.occur Naturally, in competitive any algorithm programming problems. holds for V vertices3 by using (i.e. theO(Bellman-FordV Euler’s)). This formula.et is algorithm notal.In Therefore,4.1.1 2001). the thethethe case4.1.1. beginningtakes There NumberIn number number for theBellman-Ford theONumber( planarareVE number beginning of of of manyPlanar≥≥) of this connected(Halim connectedof graph. edges ofEdges≥≤ section, graphBellman-Ford algorithm graph of edges & this In− Halimproblems components components a is we is section, planar aO takesthe assume graph( 2013),V algorithm number) which. graph,O we Naturally, that( using weVEusing but assume are know can)of weit takes≥(Halim DFS DFS easyonly connected may be anywe thatO in intakesdrawnto( know≤ show &VE algorithma a solve MIN-VERTEX-COVER general Halimgeneral)O components on that(Halim(− ifV a the 2013),) graphflat MIN-VERTEX-COVERgraphEin graph & a surface Halim3 planar but takes takesVusing is it planar.6 2013),without onlyO graph.O DFS((V isV takes a++ in We but NP-hard CountingEE havinga)) generalwill,O it, butis but( onlyV aprovide two it NP-hard) problem.it takesin graph only only edges aseveral planar takes takesO takes( problem. ItcrossingV 2 isO graph.O)O(in(VV(V a))each It planarin+in Counting isE a a ) other, graph.but (Westit only Counting takes O(V ) in a holds for V 3 by using4.1.1 the Number Euler’s formula. of edges Therefore,theplanarthatthat≥ number the has hasthat graph. numberOO has(( ofEE)Therefore,) connectedOinin( ofE its its) edgesin running running its componentsif is running theO time timethat( problemV ). can timehas can Naturally, using beO be requires can(E changed changed DFS) bein any changed itsus in algorithmato intorunning into general computeOO into((VV time) graph)O..( Computingthe Computing≤V can). takesnumber Computing be− changed( shortest shortest of+ connected shortest into2), path path butO(V inpathit componentsin) only a. a Computing general general in takes a general graph graph in( a shortestplanar) graph using usingin a using path in a general graph using holds for V 3 by using the Euler’s formula.≥≥ Therefore, the number ofIn edges simplethat is has generalO(VBellman-FordOIn)(. Esimple Naturally, graph,) in its general the running algorithm any numberIn graph, algorithm simple timetakes the of can general edgesnumberO be(VE changed can graph, of) (Halim edges beIn up into the simple can & to numberO Halim abe(V general quadraticup). 2013),Computingto of a edges graph,quadratic orderbut canIn it shortestthe withonly simpleorder be number takes respect up with path general toO respect of a( inV to quadratic edges a graph,) the generalin a number can planar the order graph be number up graph. of with using to a respect Countingof quadratic edges to can the order be number up with to respect ofa quadratic to the order number with of respect to the number of ≥ that has O(Eholds) in its for runningV 3the timeby numberusing canIn thebe simple ofexamples. changedgood Euler’s connected4.1.1 general to formula. know intogoodplanarplanarNumber components graph,O as to(the graph.V graph. many Therefore,know). number the Computing ofet NP-hard as Therefore,Therefore, number using al. edgesmany of 2001). the connected DFS problemNP-hard number shortestof if ifThere edges in the the aplanar generalas ofproblem problemcomponents path are can possible.connected edges manygraph.in be graph a requiresas requiresis up general graphO possible. This tousingTherefore,( components takesV a) is. usproblems us quadratic graph Naturally,DFSnecessaryO to to This(V compute compute inif using+ isusing the awhichE necessary ordergeneralso) any, problem thatbut DFS the the are algorithm with it ifnumbergraph number easyinso only we requires a respect that generalencounter to takes2 solveof of if weconnectedus connected toO graph if to(encounter theV a the22 compute) new+in number takes graphE a2) componentsproblem components, but aO is thenew( ofV planar.itnumber only+X, problemE we in) in takes, We buta a of planar planarX, willO itconnected we( only provideV )2 in takes a several componentsO(V ) in a in a planar that has O(E) in its running≥ time can be changed intograph,Bellman-FordBellman-FordO2 (Bellman-FordV even). Computing though algorithm algorithm algorithm the shortest constrainttakes takes takesOOBellman-Ford path((VEVE2 statesO in))(VE(Halim(Halim a general that) (Halim algorithm & &V Halim Halimgraph &100 Halim takes 2013), 2013),using, 0002 ,EO 2013), but( butVE it it100) but only only(Halim, 000 it takes takes only2 , & the takesHalimOO(( standardVV2O)) 2013),(ininV a a) DFSplanar planarin but asolution planarit graph. graph. only graph. takes stillCounting CountingO runs Counting(V ) in a planar graph. Counting that has OIn(E simple) in its general running graph, time can theIn be number simple changed general of into edgesO graph,(V can). beComputing the up number tovertices a shortest quadraticBellman-Ford of (i.e. edges pathOtheto order( canV 2the number in algorithm) be ).number a with general This up of respect to isof connectedtakes a notgraphvertices quadraticO tothe( usingVE the case(i.e. components) number order(Halim forO2(V planar with) & of ). using HalimThis respectvertices graph. DFSis 2013),not Into (i.e. in the a the a butplanar case generalO number(V it for only) graph,). graphplanar This takes ofvertices we takes isgraph.O may not(V (i.e.O2 2 the)In( showVin aO+ case aplanar( planarE thatV ), for)). butE planar graph. This it3 onlyV is graph. Counting not takes6 the InO case(2 aV planar) in for a planar graph,E graph. we3V may In6 showa planar that graph,E 3 weV may6 show that E 3V 6 Bellman-Fordthat algorithm has O takes(E) inplanarO its(VE running graph.vertices) (Halimcan time Therefore, (i.e. & use HalimcanO anycan(graph, beVif 2013), of changed) use the). theplanar evenThis any problem NP-hard but of intothoughis graph.examples. it the not onlyvertices requiresO problemsNP-hardplanar( theV Therefore, thetakes). caseconstraint Computing (i.e. usgraph.O problems that( for toVgraph,2 if compute planar) we Therefore,thein states know, ashortest that). evenproblem planar graph. This the we that reducethough ifnumber graph.pathknow,is requirestheV InV not a it≤ probleminthe planarreduce the100to100 Counting a of constraintproblemus general,, case connected000000 to graph, it requires,E,E compute forto graph X, problem planar≤ states we and100100 components us mayusing, the, thusto000000 graph. that X, compute number show2 andprove,V the In thusin that standardthat a100 ofa the planar planar prove connectedE, X000 number is3,E that graph,alsoDFSV 4.1 ofXNP-hard. components solution6100 is connectedwe also, 000 may Planar NP-hard. still, show the incomponents runsa standard that planar graphs DFS in a solutionplanar still runs 2 Bellman-Ford algorithm2 takes O(VE) (Halim & Halim2 graph,graph,underthethe 2013), number numberthe evenone even but number second though though of itof only connected connected of (inthe takesthe connected competitive constraint constraintO components components(V the components) in statesnumber states programming, a planar using using that that of using graph. DFS DFS connected inDFS inwe100 Counting a a assume general general in000 components a general that graph graph100 1 graph takes usingtakesmillion000 takesOO DFS,,( the(operations theVV +O in+ standard standard(EE aV)) general,+, but but≤E can≤) DFS DFS, it it but graphbe only only−− solution solution doneit takes takes only takes in takesOO still still1O((V second(VV) runs) runsO+inin(VE a a)),in but a ≤ it only− takes O(V ) in a≤ − ≤ − Bellman-Fordvertices algorithm (i.e. O takes(V O)).(VE This)Invertices(Halim is simple not the& (i.e. general Halim caseO(V for2013), graph,) planar). This but the graph. it is number only notholds takesInthe athe of casefor planarO edges numberV(V for) graph,planargraph,3planar caninby of a be planarusing connected graph. wewe graph. up maymay the tograph. Therefore, aIn showEuler’sshow componentsholds quadratic a Counting planar thatthat for formula. ifEV graph, the order using problem3 Therefore,Vby with we DFS using6 may respectholds requiresholds in the show a the2 generalfor forEuler’s tonumber usthat ≤≤V the to2 graphE formula. compute number3 of byby edges3 takes usingVusingTherefore, ofthe≤≤6 isOholds thethe(O numberV( Euler’s V+ for)E. the) Naturally,V, of but formula. number connected≤32 itby only using any Therefore,of takes algorithmedgescomponents the2≤O Euler’s is(V theO) (inV number informula.) a. a Naturally, planar of Therefore, edges any is algorithmO the(V ) number. Naturally, of edges any algorithm is O(V ). Naturally, any algorithm the number ofBellman-Ford connected components algorithmgraph, evenholds takes using though forO DFS(1VEV thein) 3(Halim aby constraint general1 usinggraph, & Halim graph the states even Euler’s 2013), takes though thatgraph, formula.O butV(V eventhe it+100 onlyEunder constraint Therefore, though4.1.1),000 takesbut one,E it theO Number only statessecond( theV constraint100 takes) number,in that000 (in a ofO planar competitiveV,( edgesVstates theof) edgesin100 standardgraph. a that, 000 is programming, CountingVO,E( DFSV )100.100 solution Naturally,, 000, 000,E we still, the anyassume100 runs standard algorithm, 000 that, the DFS 1 million standard solution operations DFS still runssolution can be still done runs in 1 second the number of connected2 components using DFSWe in say≥ aunderunder(Halim that generalWe problemplanar one onesay & graph that Halimsecond second X graph. problem is takes reducible 2013)). (in (in Therefore, XO competitive competitive( isV to reducible+ problem≤≥E) if, buttheto Yprogramming,− programming, problemproblem it only Y takes requires we weO≥( assumeV assume us)≤in to a compute that that− 1 1 million million the number2 operations operations≥ of connected can can be be done donecomponents in in 1 1 second second in a planar the numberholds of connected for V 3 componentsby using theverticesholds using Euler’s for DFS (i.e.V formula. inO a3(V generalby) Therefore,). using This graph the is Euler’s notthe takesthat numbertheO formula. has(planar caseV +O of for≥E(E graph. edges) Therefore,,)graph, planarTherefore,planar butplanarin its is itTherefore,Ograph.even running only graph. graph.(V thethe) takesthough. Naturally,InnumbernumberTherefore, timeTherefore, ifthat aO the planar( the canV has problemof) constraintinany beedges O ifgraph,≤ if a( changed theE the algorithm) planarrequiresis isin problem problem weO itsstates( intomayV graph.running) us .that ≤ requiresNaturally, requiresthat Naturally,O show to(V hasTherefore, compute timeV). that ComputingO us us (any can100E any to toPlanarE)the ,≤ computealgorithmin computebe000if algorithm3 itsthenumber changedV,E graph shortest running problem6the thethatthat100 is of into≤ numberanumber path,≤ timehasconnected has graph000 requiresO O(in canV,( theEof that)of a.) be general usconnected Computingconnectedincomponentsin standard can changedto≤ itscompute berunning graph drawn DFS components components into shortest in using timethe solutionO a on( planar numberV a can path) flat. inComputing in bestill surfacein a aof changed planar planara runs connected general without shortest into graph componentsO having(V path using). Computing intwo a inedges general a planar crossing shortest graph usingeach pathother in a general (West graph using planar graph.the Therefore,≥ number ifof the connectedunder problem onethat components secondrequires has O( (inE us) competitiveusingto(Halimin(Halim itscomputeDFS runningunder & & Halim Halim in the programming, one a time general number 2013)). second2013)).under can graph be of (in one changed connectedwe competitive takes second(Halim assumeO into( &(incomponentsV that HalimO+ programming, competitive(EV 1)),. million 2013)). but Computing in it a onlyoperations programming,4.1.1 planar≤ we takes shortestassume− NumberO can(V that path) we bein assumedone 1 a inof million22 a edges general in that2 1 operations second graph1 million using can operations be done2 can in 1 be second done in 1 second ≥ planar graph. Therefore, if the problem requires us to(Halimgraph,graph, computegraph, & even even Halim the thougheven though number 2013)). though the the of constraint constraint theconnected constraintgraph, states states components even states that that thoughVV that≤ in the100 aV100 planar constraint,,000000100,E,E, 000≤2 states,E1001002 ,,000000100 that,,,000V the the, standard standard100 the, standard000,E DFS DFS solutionDFS solution100, 000 solution still still, the runs runs still standard runs DFS2 solution still runs 2 planar graph.that Therefore, has O(E) ifin the its problem runningholdsthat timerequires has for canVO us( beE) to3 changedinby compute its using running into the theO Euler’s time number(VBellman-Ford). can ComputingIn formula.graph, of be simple connected changed even Therefore, algorithmgeneralunderrunning shortest though into components one graph,timeO path takesthe( second theV can) number. in constrainttheO ComputingBellman-Ford abe( inVE (in general numberchanged a) planarcompetitiveof2(Halim edges states graph shortest ofinto algorithm edges&is that usingO Halim programming,(V pathV can) . Bellman-Ford 2013), takesComputing Naturally, in be100 a upO, general but000( toVE we,Eit anyshortest aet) assumeonly algorithm graphquadratic(Halim al. algorithm100 takes 2001). path using, that000 &takesO Halimin orderBellman-Ford There( 1,Va2 the milliongeneralO) with 2013),in( standard areVE a planarmany respectoperations)graph(Halim but algorithm DFS graphitus graph.only to- & solution thecan Halim problems takes Counting number be 2013),O donestill((VEV which2 runs of) in) butin(Halim 1 are a it second planar onlyeasy & takes toHalim graph. solveO 2013),( CountingV if the) in but graph a planar it only is planar. graph. takes O We Counting(V will) in provide a planar several graph. Counting graph, even thoughplanar≥ graph.the constraint Therefore,(Halim statesBellman-Ford & if Halim the that problem 2013)).V algorithm100 requires, 000(Halim,E takes us to &O100 compute( HalimVE,(Halim000) (Halim2 2013))., the & Halimnumberstandard & Halim 2013)). of DFS 2013), connected≤ solution but it≤≤ components only still≤≤ runstakes O in(≤≤V a planar) ≤in a planar≤ graph. Counting≤ graph, even thoughO E the constraint states that2 V ≤ 100underunderO, 000Vunder one2 one,EO2 V≤ second second oneIn100 simple second, 000 (in (in generalcompetitive, competitive the(in competitive standardunder graph,2 programming, programming,4.1.2 one DFS the programming, second number solution Maximum (in we we of stillexamples. competitive assumeedges assume we runs Clique assume can that that be programming, problem 1 that1 up million million to 1 million a operations quadraticoperations we operations assume order can canE that be becan withV done done 1 be respectmillion done in in 1 1 second secondoperations in to 1 the second number can be of done in 1 second graph, evenBellman-Ford though the algorithmconstraint takes statesthatBellman-FordO that( hasVEgraph,)V((Halim) algorithm100in even its, &000 Halimrunning though,E takes 2013),100 the timeOthe(,VE constraintthe000 butcan number)vertices number,(Halimunder it be the only changed standardstates of≤ one(i.e. oftakes & connected(Halim connectedHalim second that intoO( DFS(V &2013),V)) (in).Halim components( solutionin components≤ This)100 competitive a. but Computing planar 2013)).the, is000 it still not numberonly,E graph. using runsusing the takes programming, shortest100 case DFS of Counting DFSO, connected000( for inV in2 path a,) planar a general thein generalthewe ain componentsstandard planar agraph. number assume general graph graph graph. In DFS oftakes that graphtakes a usingconnected planar Countingsolution 1OOmillion( using DFSV(V graph,++the componentsstillE inE operations) a, number) runs,but generalwe but mayit it only of only graphusingcan show connected takes takes be DFS takes that doneOO( inV(O componentsV) a in(V)in general 1in3+ a second aE),6 graph but using it takes only DFS takesO in(V a general+O(EV)), butin graph a it only takes takesO(VO+(VE))in, but a it only takes O(V ) in a under one second≤ (in competitive≤ programming, we assume that 1 million operations2 can4.1.24.1.2 be done Maximum Maximum in 1 second Clique Clique problem problem4.1.2 Maximum Clique≤ problem− under onethe second number (incompetitive of connectedunder programming, componentsBellman-Fordthe one number second using ofwe algorithm (in connected assume DFS competitive in takes that a components generalO 1 programming,( millionVE graph)holds(Halim(Halim using operations takes for DFS &we &VO Halim(Halim(Halim Halim( assume inV can3+ aby(Halim general2013),E be 2013)). & &) using that,≤ done Halim Halimbutvertices &but graph1 the it Halimin million only2013)).it 2013)). Euler’s1 only takes (i.e.second takes 2013)). operations takes≤O formula.O(O(VV(O(HalimV+)()).VEin2 canThisTherefore,), ain & butplanar be a Halimis planar it donenot only graph.the the2013)). ingraph. takes number case1 second Therefore,O Counting for(V of planar) edgesin aplanar if graph.the is O problem graph.(V In). a Naturally, Therefore, planar requires graph, anyus if to the algorithm we compute problem may show the requires number that E us of to3 connected computeV 6 the components number of in connected a planar components in a planar (Halim & Halimunder 2013)). one second (in competitiveplanarplanar graph. graph. programming, Therefore, Therefore,The Maximum if if we the the4.1.2 assume problemCliqueplanar problem Maximum problem that graph. requires requires 1 million Therefore, requires us Clique us to to operations compute uscompute if toproblem the find problemthe can the the number numberbe maximum requiresdone of of in connected connectedset us1 second toof computevertices components components in the a graph, number in in a asuch planar ofplanar connected that every components pair of ≤ in a− planar (Halim & Halim 2013)). ≥ 4.1.2 Maximum4.1.2 Clique Maximum problem Clique problem 2 2 (Halim & Halimplanar 2013)). graph. Therefore, iftheplanar the number problem graph. of requires Therefore,connected us to components if compute the problemgraph, thethat using evenrequires number has DFS thoughOTheThe(E usinof) aconnectedMaximum toMaximum in thegeneralcompute its constraint runningholds graph Cliquecomponents Cliquegraph, thefor time takes number states problemV problem even canO3 that in( beV ofthoughbyThe a requires requires+ changedconnectedV planarusingE Maximum),4.1.2 the100 but the us usgraph, into constraint, itto000 Euler’stocomponents only Maximum findO findClique,E( evenV takes the the)formula.. states100 problemthough Computing maximum maximumO in, 000 Clique( aV that2 Therefore,) planar2 the requires,in theV seta setconstraintshortestgraph, problem standard of of100 us thevertices vertices, even to path000 number statesfind DFS,E though in in in the a a asolution that of100general graph, graph, maximum theedges,V000 constraint stillsuch such graph2 is100, theOset runs4.1.1 that, that(000V using standardof). states,Eevery everyvertices Naturally, Number pair100 pairthat DFS in, of000 of aV any solution ofgraph,, algorithm100 edges the, such stillstandard000,E runs that DFSevery100, solution000 pair, of the still standard runs DFS solution still runs (Halim & Halim 2013)).graph, even thoughvertices the inconstraint the set is states directly≥ that connectedV 100, by000 an,E edge.100 By, 000 reduction, the standard from vertex DFS cover, solution themaximum still≤ runs clique≤ problem ≤ ≤ 2 that hasO VEO(E)2in its≤ running≤ 4.1.24.1.2 time4.1.2 Maximum Maximum can≤≤ Maximum be changed Clique Clique Clique into≤ problem problemO4.1.2OV(V problem2). MaximumComputing≤ shortestClique path problem in a general graph using graph, even though the constraintplanargraph, graph. even states though Therefore, that V theThe constraint100 if the, Maximum000 problemunder,Eunder statesBellman-Ford one100 Cliquerequiresone that second, 000 second problemVverticesverticeson us, the (inalgorithm togeneral (in100The standardcomputecompetitive inrequires competitivein, 000 Maximumthe the graph,E takes set set theDFS usunder is is isThe100 programming,to number directly directlyprogramming,( NP-hard.Clique solution find, one Maximum000) the(Halim second4.1.2 problemofconnected, connected stillverticesthe maximum connected However, standardClique runswe & (in weMaximum requires Halimassume in competitiveby assumebyunder the problemset itcomponents an an DFS 2013),is setof edge.us edge. that easyone thatvertices Clique isto solution requires directly butsecond find1 Bytoprogramming, By 1 million insolvemillion itreduction reduction thein problemonlya still usa connected(in planar maximum graph,this operations to runs takes operationscompetitive find problemunderfrom from we such the by( setassume vertex vertex one canan maximumthat) canof inin programming, edge. second verticesbe planar cover, cover,everya be that planar done done By set 1pair (ingraph.the the in reduction millionin graph. of ina competitive maximumof maximum 1 graph,vertices 1 we second Consider second operations Countingassume from such in clique clique programming,a vertex the that that graph, can problem problem every 1 cover, bemillion such donepair the that we operations of inmaximum assume every 1 second pair that can clique of 1 be million problem done inoperations 1 second can be done in 1 second ≤ 4.1.24.1.2≤ Maximum MaximumThe≤ Maximum Clique Clique problem problem Clique≤ problem2 requires us to find theIn maximum simple general set of vertices graph, inthe a number graph, such of edges that2 every can be pair up of to a quadratic order with respect to the number of under one second (in competitive4.1.2graph,under evenone Maximum programming, second though (in Clique the competitive we constraintvertices assume problem in(Halim thatstates theprogramming,the set 1 &number that million is Halim directlyVonon of operations 2013)). wegeneral general100 connected connectedvertices assume, 000 graph graph,EBellman-Ford can in that components by(Halim the beis is100vertices an 1 NP-hard. setNP-hard. done million, edge.000 &is directlyalgorithm Halimin using, By theoperations1 theon However, However, second reduction standardgeneral2013)). DFSset connected takes is in directly(Halim canit aitgraph fromO DFS generalis is( bybeVE easy easy connected& vertex solutionis andone) Halim NP-hard.(Halim tograph toedge. solve insolve cover, still 2013)).1 takes By &by second this this Halim runsHowever,thereduction anO problemedge. problem(Halim maximum(V 2013),+ ByE2 fromit &) in inis, reductionbut Halimbut clique easyplanar planar vertex it it only to only 2013)). problem graph.cover, graph. fromsolve takes takes vertex thethis ConsiderO ConsiderO(V maximum( problemV cover,) inin the the a a planarthe in cliqueproblem problem planar maximum graph. problem graph. Counting clique Consider problem the problem (HalimJonathanThe & Halim Maximum4.1.2Jonathanverticesof IrvinTheThe 2013)).≤ colouring MaximumGUNAWAN MaximumThe CliqueMaximum in Irvin the Maximum problema set GUNAWAN graph≤ Clique Clique is Clique directly Clique suchrequires problem problem thatproblem connectedproblem usThe requires requiresno to Maximumtwo find requires by adjacent us usthe an to to maximum edge. us findClique find to vertices the the findByvertices problem maximum maximumreduction set the have of maximum (i.e. vertices requires the fromset setO same( ofV of in usvertexset vertices vertices) a). tocolour. ofgraph, This find vertices cover, in in the is suchNote a a not the graph, graph,maximum in that that thea maximum graph, suchevery casesuch if there set thatsuchfor that pair clique of planaris everyvertices everythat of a problemclique every graph.pair pair in of of ofa pair graph, In of a planar such thatgraph, every we pairmay of show that E 3V 6 (Halim & Halim 2013)).Theunder Maximum(Halim one & Halim secondClique 2013)). problem (in competitiveon requires general programming,us graphplanar to find is graph. NP-hard. the maximum we Therefore, assumeon However, general setthe that if of numberthe graph it verticeson 1 isproblem million general easy is of NP-hard. in connected to operations requiresaof graph solvegraph, colouring However,isthis us componentssuch NP-hard. can to problem a thatcompute be graph it done every is However, in using such easy theplanar in pair 1 thatDFSto number second of solveit graph.no in is aeasy two of this general Considerconnected adjacent to problem solve graph the thiscomponentsvertices in takes problem planar problemO have( graph.V in+ in theE a planar) planar Considersame, but graph. it colour. only the takesConsider problem NoteO that(V the) ifin problem there a is a clique of ≤ − The Maximum Clique problem requires us to find theofofsizeverticesvertices maximum colouring colouringkverticesin in in a graph,the theset a a in graph graph setof set the vertices the is is set suchdirectly suchdirectly set is ofthat indirectly that thea connected connectedvertices graph, no no vertices connectedtwo two such in adjacent adjacent by by inside the anthat an byset edge. edge. the every anvertices verticesis directly edge.clique Byholds By pair reduction reduction have have By must forof connected reductionV the the be from from same same3 colouredby by fromvertex vertex using colour. colour. anedge. with vertex cover,the cover, Note Notek Euler’s By cover,colours. the the reduction that that maximum maximum formula. the if if Therefore, there there maximum from Therefore, clique cliqueis is vertex a a the clique clique clique problem problem entire cover, the of of problem number the maximum of edges clique is O( problemV ). Naturally, any algorithm The Maximum Clique problem requiresvertices(Halim us in to the & findThe Halim set the Maximum is directly maximum2013)). Cliqueconnectedof set colouring of problem vertices by a anvertices graph requires edge. in a suchgraph, inon By us the general reduction tothat suchset find no is that thegraph directly twoplanar from maximum every adjacent is vertex connectedgraph. NP-hard. pair cover,set verticesof Therefore, of by However, vertices the an haveV maximum edge. if thein it100 aBy is sameproblem graph,, easy000 reduction clique,E colour. to suchrequires problem solve100 from that Note, this000 us vertexevery that2 problemto≥ compute pair cover, if there of in the planar the is maximum a number clique graph. of of clique Consider connected problem the components problem in a planar vertices in the set is directly connected bygraph, an edge. even Bysizesize though reductionkkofoninin colouring a a generalthe graph, graph, from constraint graph the the vertexaof graph colouring set set4.1.2 isstates cover, of of NP-hard. such the thesize Maximum that athe vertices verticesthat graphk maximumin However, no a such inside insidetwo graph, Clique adjacentthat clique the theit the is no clique clique problem easyset problem4.1.2 two vertices of to must mustadjacent the solve Maximum verticeshave be be, this the coloured coloured vertices the standardproblem inside same Clique with withhave4.1.2 the colour. inDFSkk clique the planarproblemcolours.colours. Maximumsolution same Note must graph. colour.Therefore, Therefore, that bestill colouredClique Consider if runs thereNote4.1.2 the the thatis problemwith theentire entire a Maximumclique if problemk therecolours. of is a CliqueTherefore, clique of problem the entire vertices in the set is directly connected by an edge. By reduction from vertexon cover, general theofonon graphcolouring maximum general general is NP-hard. grapha graph clique graph is is problem such4.1.2NP-hard. NP-hard. However, that Maximumon no However, itHowever, general is two easy≤ adjacent Clique itto graphit is is solve easy easy vertices is problem this NP-hard. to tothat≤ solve solveproblem have has this thisO However, the( inE problem problem) same planarin its it colour. running graph.inis in easyplanar planar NoteConsiderto time graph. graph. solve that2 can thisifthe be Consider Consider there changed problem problem is the thea intoclique in problem problem planarO( ofV ). graph. Computing Consider shortest the problem path in a general graph using on general graphvertices4.1.2 is NP-hard. in Maximum the setsize However, isk directly Cliquein a graph, itunder4.1.2 connected problemis easy the one Maximum tosetsecond by solve of an thesize edge. this(in vertices Cliquek competitivein problemgraph, By a reduction graph, insidesize problem even ink theplanar theprogramming, thoughin from aset clique graph, graph. of vertex the the must constraintthe vertices cover, Consider we be set assume coloured of the inside the states the maximum that vertices problem withthe that 1 cliquek millionV insidecliquecolours. must100 operations theproblem, Therefore,000 be clique coloured,E must can100 the be with be, 000 entire done colouredk,colours. the in 1 standard with second Therefore,k colours. DFS solution the Therefore, entire still runs the entire 2 on general graph is NP-hard. However,on general it is graph easy is to NP-hard. solve this However, problem in itof isplanar colouringeasy graph. tosizeJonathanofof solve colouringa colouringk graphofin Consider this acolouring Irvin graph, problemsuch a a GUNAWANgraph thegraphthat the a problem graph in set such suchno planar of two suchthat that the adjacentof graph. vertices no nothat colouring two two no ConsiderThe verticesadjacent insideadjacent two a Maximum graphadjacent the havethe vertices vertices clique such problemBellman-Ford the verticesClique mustthat same have have≤ problem no be havethecolour. theThe two algorithmcoloured same same the Maximum adjacent requires Note same colour. colour. with≤ takes that colour. us vertices Cliquek Note NoteO to ifcolours.( thereVE find Noteproblem that that have) the(Halim is Therefore, if ifthat a maximumthe there thereclique requires sameif& there Halimis is of thea a colour. setus clique clique is entire2013), to of a findclique vertices ofNote of but the of that it maximumin only a if graph, there takes set such isO( of aV clique verticesthat) in every a of planar in apair graph, graph. of such Counting that every pair of of colouring aon graph general such graph that is no NP-hard. twoTheThe adjacent Maximum4.1.2(Halim Maximum However, &vertices Maximum HalimClique Clique it is have 2013)). problem easy problem Clique the tounder same requiressolveThe requires problem one colour.Maximum this secondus us problem to to Note find find (in Clique the thatin competitive the planar maximum problem maximum if there graph. requiresprogramming, is set set a ofcliqueConsider of vertices us vertices ofto findthe we in in a problem assumethe a graph, graph, maximum thatsuch such 1 that set that million of every every vertices operations pair pair ofin of a graph, can be such done that in 1 every second pair of of colouring a graph such that no two adjacent verticesJonathanJonathansizesize k haveksizeinin Irvin Irvina ak the graph, graph,in sameGUNAWANGUNAWAN a graph, the the colour. set set the of of set Note the theJonathansize of vertices vertices that thek in vertices ifIrvin a thereinside graph,inside GUNAWAN inside is the the the a clique cliquethe set the number of clique ofmust must the vertices must be beof connected coloured coloured be inside coloured with with componentsthek cliquewithk colours.colours.k mustcolours. using Therefore, Therefore, be DFS coloured Therefore, in the thea general with entire entire thek entirecolours. graph takes Therefore,O(V + E the), entire but it only takes O(V ) in a of colouringThe a graphMaximum such Clique that no problemsize twokThein adjacent requires a Maximum graph,of colouringvertices us the toClique set find have ofa problemthe graph the the maximum vertices same such requiresverticesvertices thatcolour. inside setsize usin no of in thetok the verticesNote twothein find set clique a set adjacent thatgraph, isthe is in directly must directly maximum aif graph,there the vertices be(Halim connected set connected colouredis suchvertices of set a haveclique the & of that Halim verticesby withthe in by everyof an the ansamek 2013)). edge. setedge.colours.in insidepair colour.a is Bygraph, of directly By the reductionvertices Therefore, reduction Noteclique such connected thatin that must from the from the if every beset vertexthere entire by vertex coloured is an pair directly is cover, edge. cover, a ofvertices clique with Bytheconnected the reductionk ofmaximum in maximumcolours. the by set from an clique Therefore,is clique directlyedge. vertex problem problem By connected cover,the reduction entire the by maximum from an edge.vertex clique By cover, reduction problem the maximum from vertex clique cover, problem the maximum clique problem size k in a graph, the set of theJonathan vertices Irvin inside GUNAWAN the clique mustJonathan be coloured IrvinJonathan GUNAWAN with Irvink colours. GUNAWAN Therefore, the entire size k in avertices graph, the in the set set of theis directly verticesThevertices connected inside Maximum in the the by clique setClique an edge.is must directly problem By be reduction connected coloured requireson general from with us by to an vertexk graph find edge.colours. the cover, is By maximum NP-hard. Therefore, reduction the maximum seton However, from the generalof entire vertices vertex clique it graph is cover, problem in easy a is graph, totheNP-hard. solveon maximum such general this However, that problem cliquegraphplanar every itproblem is pair in graph. is NP-hard. planar easy ofon Therefore, to general graph. solve However, graphthis Consider if the problemit is is problem NP-hard. easy the in problem to requiresplanar solve However, graph.this us to problem it compute Consider is easy in toplanarthe the solve number problem graph. this of problem Consider connected in the planar components problem graph. in Consider a planar the problem size k in a graph, the seton of general the vertices graphJonathan insideis NP-hard. the Irvin clique GUNAWAN However, must be it4.1.2 is coloured easy Maximum to with solvek thiscolours. Clique problem Therefore, problem in planar the graph. entire Consider the problem 2 on general graph is NP-hard.verticeson general However, in the graph itset is is is easy directly NP-hard. to solve connected However, thisof colouring problem by it an is edge. aeasy in graphJonathanJonathan planar BytoJonathan solvesuch reduction graph. Irvin Irvin that this GUNAWANIrvin GUNAWANof Consider problemfromno colouring two GUNAWAN vertex adjacent thein planara cover, problemJonathan graph vertices graph.the suchof maximum Irvin colouring havethat Consider GUNAWAN no the clique twograph, samea the graph adjacent problem problem colour. even suchof though vertices Notethat colouring no that the have two constraint if a theadjacentthere graph same is such states a vertices colour. clique that that ofno haveNoteV two the that100 adjacent same, if000 there,E colour. vertices is a100 cliqueNote have, 000 that of the, the ifsame standard there colour. is a DFS clique Note solution of that if still there runs is a clique of Jonathan Irvin GUNAWAN of colouringJonathan a graph Irvin such GUNAWAN that no two adjacent vertices have the4.1.2 same colour. Maximum Note Clique that if there problem is a clique of ≤ ≤ of colouring a graph suchJonathanon thatof generalcolouring no Irvin two GUNAWAN graph adjacent a graph is NP-hard. suchvertices that have However, nosize two theThek in adjacentsame it Maximum a is graph, easy colour. vertices to the Clique solveNote set have problemof thisthat the thesize problem if vertices there same requiresk in is aincolour. inside graph,a planar us clique to the Notefind the graph. of clique set the thatsize of maximumConsider mustk if thein there avertices be graph, colouredunderis the set a problemcliqueof inside the one vertices with set secondof thesize ofk cliquein thecolours.k a (inin verticesgraph, a must competitive graph, Therefore, such be inside the coloured that set the programming, the every of clique with entire the pair verticesk mustcolours. of we be inside assume coloured Therefore, the that with clique 1 thek million mustcolours. entire be operations coloured Therefore, can with the bek entire donecolours. in 1 Therefore, second the entire Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWANsize k in a graph, the set of the vertices inside the clique must be coloured with k colours. Therefore, the entire size k in a graph, the set ofofsize the colouringk verticesin a graph, a inside graph the the such set clique of that the must no vertices two bevertices adjacent coloured inside in the vertices withset cliquek iscolours. havedirectly mustThe the be Maximum Therefore, connected same coloured colour. Clique bythe with an entire Notek edge.problemcolours. that By requires if reduction Therefore, there isus(Halim afrom to the clique find vertexentire&the Halim of maximum cover, 2013)). the set maximum of vertices clique in aproblem graph, such that every pair of size k in a graph, the set of the verticeson general inside the graph clique is NP-hard. mustvertices be coloured However, in the set with it is is directlyk easycolours. to connected solve Therefore, this by problem an the edge. entire in By planar reduction graph. from Consider vertex thecover, problem the maximum clique problem Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWANJonathan Irvin GUNAWANJonathan Irvin GUNAWAN Jonathanof colouring Irvin GUNAWAN a graph suchon generalthat no graph two adjacent is NP-hard. vertices However, have the it issame easy colour. to solve Note this that problem if there in planar is4.1.2 a clique graph. Maximum of Consider Clique the problem problem Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWAN size k in a graph, the setof of colouring the vertices a graph inside such the that clique no must two adjacent be coloured vertices with havek colours. the same Therefore, colour. the Note entire that if there is a clique of Jonathan Irvin GUNAWAN The Maximum Clique problem requires us to find the maximum set of vertices in a graph, such that every pair of size k in a graph, the set of the vertices inside the clique must be coloured with k colours. Therefore, the entire vertices in the set is directly connected by an edge. By reduction from vertex cover, the maximum clique problem Jonathan Irvin GUNAWAN on general graph is NP-hard. However, it is easy to solve this problem in planar graph. Consider the problem Jonathan Irvin GUNAWAN of colouring a graph such that no two adjacent vertices have the same colour. Note that if there is a clique of size k in a graph, the set of the vertices inside the clique must be coloured with k colours. Therefore, the entire

Jonathan Irvin GUNAWAN by the construction of the function. by the construction of the function. by the constructionby the constructionof the function. of the function. by the constructionTheorem 2. of theIf N function.is divisible by three, thenbyF ( theN) constructioncan be partitioned of the function.into two multisets of equal sum. Theorem 2. If N is divisible by three, then F (NTheorem) can be partitioned 2.TheoremIf N is divisible into 2. twoIf N by multisetsis three, divisible then of by equalF three,(N sum.) can then beF partitioned(N) can be into partitioned two multisets into two of equal multisets sum. of equal sum. TheoremProof. 2. If NIf Nis divisibleis divisible by three,by three, then thenF (NF)(NcanTheorem) is be a partitioned prefix 2. ofIfFN intowithis divisible two length multisets by multiples three, of equal then of three.F sum.(N) Bycan lemma be partitioned 3, F (N) into two multisets of equal sum. Proof. If N is divisibleby by the three, construction then byF ( oftheN) the constructionis a function.Proof. prefixIf ofcanN ofF beis theProof.with divisible partitioned function. lengthIf N by multiplesis three, into divisible two then of multisets by three.F three,(N) Byis of then a lemmaequal prefixF (N sum..3, of) isFF( aNwith prefix) length of F multipleswith length of three.multiples By of lemma three. 3, ByF ( lemmaN) 3, F (N) can be partitioned into two multisets of equal sum..Proof.can beIf partitionedN iscan divisible be into partitioned by two three, multisets into then two ofF ( equalN multisets) is sum.. a prefix ofProof. equal of FIf sum..withN is length divisible multiples by three, of then three.F ( ByN) lemmais a prefix 3, F of(NF) with length multiples of three. By lemma 3, F (N) Theorem 2. If NTheoremis divisible 2. byIf three,NTheoremis divisible then F 3.( byNIf) three,canN be then1 partitioned(modF (N 3)),Fcan into(N be) twocannot partitioned multisets be partitioned into of equal two multisets into sum. two of multisets equal sum. of equal sum. can be partitioned into two multisets≡ of equal sum.. can be partitioned into two multisets of equal sum.. Theorem 3. If N 1 (mod 3),F(N) cannot beTheorem partitioned 3.Theorem intoIf N two1 multisets 3.(modIf N 3),F of1 equal(N (mod) cannot sum. 3),F be(N partitioned) cannot be into partitioned twoby multisets the into construction two of equal multisets sum. of the of equal function. sum. ≡ Proof. If N is divisibleProof. byIf N three,is divisible then F ( byN) three,is≡ a prefix then F of(N≡F )withis alength prefix of multiplesF with oflength three. multiples By lemma of three. 3, F (N By) lemma 3, F (N) TheoremProof. 3. If NSuppose1 (modF (N 3))=,F(FN()Ncannot) f(1) be. partitioned NoteTheorem that F into 3.(NIf two) Ncontains multisets1 (modN of 3)1 equal,Felements.(N sum.) cannot Since beN partitioned1(mod into3), wetwo multisets of equal sum. can be partitioned into two multisets of equal≡ sum.. − ≡ − N ≡ F N Proof. Suppose F (N)=F (N) f(1)can. Note be partitioned thatProof.F (NSupposehave into) containsNProof. twoF1 multisets(NSuppose0()=mod1Felements. of(NF equal3))(.N By)=f sum..(1) SincelemmaF.( NoteNN) 3, thatFf1((1)(NFmod.) Note(canN)3) becontains that, we partitionedF (NNTheorem) contains1 intoelements. two 2.N multisetsIf Since1 elements.is divisible ofN equal1( Since bymod sum. three,N3) Therefore,, then we1(mod( the3)) ,can we be partitioned into two multisets of equal sum. − − ≡ − − −≡ − − ≡ ≡ haveN 1 0(mod 3). By lemma 3, F (N) canProof.have beN partitionedSupposesum1 have of0(F allmodN into( elementsN)= two13).F multisetsBy0((N in lemmamod)F (fN3)(1) of) 3,.is equal. ByF Note even.( lemmaN sum.) that However,can 3, Therefore,F beProof.F( partitionedN(N) the)containsSupposecan sum the be ofinto partitionedNF all two( elementsN1)= multisetselements.F into(N in) twoF of Since(Nf equal multisets(1))=.NF sum.Note(N1( of)+ Therefore,that equalmodf(1)F3) sum.(,N, which we) thecontains Therefore, is oddN the1 elements. Since N 1(mod 3), we − ≡ Theorem 3. If NTheorem1 (mod 3. 3)If,FN−(N)1≡cannot (mod 3)− be,F partitioned≡(N) cannot− into be two partitioned multisets into of equal two multisets sum. Proof.− of equalIf sum.N is− divisible by≡ three, then F (N) is a prefix− of F with length multiples≡ of three. By lemma 3, F (N) F (N) ≡ haveN 1 sum0(mod of all3)F. elements ByNF lemma(N)= in F 3,F(F(NN())+Nis) even.fcan(1) be However,have partitionedN 1 the into sum0(mod two of all multisets3)F elements. ByN lemma ofF in equalNF 3,(NF sum.)=(fN)F Therefore,can(N be)+ partitionedf(1) the, which into is odd two multisets of equal sum. Therefore, the sum of all elements in  is even. However,sum the sum of− allbecause≡ of≡ elements all elementsF (N in ) is in( even) is while even.f However,(1) is odd. the, Therefore, which sum of is− all odd there≡ elements is no wayin to( partition)= ( F)+(N).(1), which is odd F N canF beN partitionedN F N intof two multisets of equal sum.. F N F N f because F (N) is evenProof. whileSupposef(1) is odd.FProof.(N Therefore,)=SupposesumFbecause(N of) thereF allfF((1) elementsN is(N)=.because no) Noteis wayF ( evenN in that to)F  while partition((NFf(1)))(Nisisf.)(1) even Noteeven.containsFis(N while odd. that However,). NFf Therefore,(1)(N1is the)elements.contains odd. sum there Therefore, ofN Sinceisall no elements1 wayNelements. there to1( in ispartitionmod no Since(( way3))=)F,is toN we(N even. partition().1()+ However,modF(1)(3)N,, which) we. the sum is odd of all elements in ( )= ( )+ (1), which is odd − − − − ≡ ≡ because FTheorem(N) is even 4. If whileN f2(1) (modis odd. 3). Therefore,F (N) canbecause there be partitioned isF no( wayN) intois to even partition two while multisetsFf((1)N). ofis odd. equal Therefore, sum. there is no way to partition F (N). haveN 1 0(havemodN3). By1 lemma0(mod 3, 3)F .(N By) lemmacan be≡ 3, partitionedF (N) can into be two partitioned multisets into of equal two multisets sum.Theorem Therefore, of equal 3. the sum.If N Therefore,1 (mod the 3),F(N) cannot be partitioned into two multisets of equal sum. Theorem 4. If N 2 (mod− 3).≡F (N) can be− partitionedTheorem≡ 4. intoTheoremIf twoN multisets2 4.(modIf N of 3). equalF2( (modN sum.) can 3) be. F partitioned(N) can be into partitioned two multisets into two of equal multisets sum.≡ of equal sum. sum of all elements in F (N) is even. However, the sum of≡ all elements in F (N)=F (N)+f(1), which is odd ≡ sum of all elementsProof. in F (AssignN)≡is even.f(1) to However,A and f the(2) sumto B of. all Since elementsf(1) = infF(2)(N,)= we areF (N now)+ tryingf(1), whichto partition is oddF (N)=F (N) Theorem 4. If N 2 (mod 3). F (N) can be partitionedTheorem into 4. twoIf multisetsN Proof.2 (mod ofSuppose equal 3). F sum.F(N(N) can)= beF ( partitionedN) f(1). into Note two that multisetsF (N) ofcontains equal sum.N 1 elements. Since N 1(mod 3), we because F (N) is even while f(1) is odd. Therefore,≡ there is no way to partition F (N). ≡ − Proof. Assign f(1) to A and f(2) to becauseB. SinceFProof.f((1)N) =isAssign evenf(1)(2),Proof. while weff(1)(2) aref.toAssign(1)F nowA(isNandtrying odd.)fwill(1)f(2) Therefore,to have totoA partitionNandB. Sincef there2(2)elements.F (tof isN(1) no)=B. = way SinceFf((2)N to),Nf partition we(1) are2( = fmod now(2)F (N, trying3) we)., we are to obtain now partition tryingN 2F to( partitionN0()=mod−F (FN3).)(N By)= lemmaF (N) − ≡ − − −≡ haveN 1 0(mod−3).≡ By lemma 3, F−(N) can be− partitioned into two multisets of equal sum. Therefore, the f(1) f(2). F (N) will have N 2 elements.Proof. Sincef(1) NAssignf3,(2)2(F. f(modFf(1)N(1)()Ncan3))tofwill,(2)A webe.and have partitionedobtainF (fNN(2))Nwillto2 intoelements.B2 have. Since two0(N mod multisets Sincef2(1)elements.3)Proof.. =N Byf of(2) lemma equal2(Assign, Since wemod sum, areNf3)(1) now, which we2(to tryingobtainmodA impliesand− 3) toN≡f,(2) we partition our2 obtainto theorem.B0(.FmodN Since(N)=23)f.(1) ByF0(( =N lemmamod)f(2)3),. we By are lemma now trying to partition F (N)=F (N) − Theorem 4.− If NTheorem2 (mod 4. 3)If.−NF≡(N2) can (mod be− 3) partitioned. F (N) can into− be− two partitioned≡ multisets− into of equal two≡ multisets sum. of≡sum equal of sum. all elements− ≡ in F (N−) is≡ even. However,− the sum of all elements in F (N)=F (N)+−f(1), which is odd 3, F (N) can be partitioned into two multisets≡ f of3,(1) equalF (Nf(2) sum,)≡can. F3, which be(FN partitioned()Nwill implies) can have be our intoN partitioned theorem. two2 elements. multisets into Sincetwo of equal multisetsfN(1) sum,2(f(2) ofmod which equal. F3)(, impliesN sum, we) will obtain which our haveN theorem. impliesN 2 2 elements. our0(mod theorem.3) Since. ByN lemma2(mod 3), we obtain N 2 0(mod 3). By lemma − − ≡− because F (N−−) is≡ even while f(1) is odd.≡ Therefore, there is no way− to≡ partition F (N). 3, F (N) canTherefore, be partitioned solving into this two problem multisets is reduced of equal3, toF sum,( checkingN) whichcan be whether implies partitioned ourN theorem.1 into (mod two 3) multisets. We can of solve equal this sum, in whichO(1). implies our theorem. Proof. Assign f(1)Proof.to AAssignand f(2)f(1)totoBA. Sinceand ff(2)(1)to =Bf.(2) Since, wef are(1) now = f trying(2), we to are partition now tryingF (N to)= partitionF≡(N) F (N)=F (N) Therefore, solving this problem is reduced to checkingTherefore,We whether will solving provideTherefore,N this1 more (mod problem solving examples 3). this is We reduced problem of can special solve to is checking cases thisreduced in inO whetherthe to(1) checking. followingN whether section.1 (modN 3).− We1 (mod can solve 3). We this− can in O solve(1). this in O(1). f(1) f(2). F (Nf(1)) willf have(2). NF (N2)elements.will have N Since≡ 2Nelements.2(mod Since3),N we obtain2(modN 3)2, we0( obtainmod≡TheoremN3). By2 lemma0( 4.≡modIf N 3).2 By (mod lemma 3). F (N) can be partitioned into two multisets of equal sum. We will provide more examples− of special cases− inWe theTherefore, will following− provideWe solving section. more will providethis examples− problem more≡ of isspecial examples reduced cases of to≡ special in checking the following casesTherefore,− whether in≡ the section.N solving following1 (mod−this section.≡ problem 3). We is can≡ reduced solve thisto checking in O(1). whether N 1 (mod 3). We can solve this in O(1). 3, F (N) can be3, partitionedF (N) can into be two partitioned multisets into of equal two multisets sum, which of equal implies sum, our which theorem. implies our≡ theorem. ≡ We will provide more examples of special cases in theWe following will provide section. moreProof. examplesAssign off special(1) to casesA and inf the(2) followingto B. Since section.f(1) = f(2), we are now trying to partition F (N)=F (N) − Therefore, solvingTherefore, this problem solving is reduced this problem to checking is reduced whether4 to checkingN Some1 (mod whether example 3).N We can1 (mod solve off 3) specialthis(1). We infO can(2)(1). solve.F cases(N this) will in haveO(1)N. 2 elements. Since N 2(mod 3), we obtain N 2 0(mod 3). By lemma 4 Some example of special4 cases Some4 example≡ Some example of≡ special of− special cases cases − ≡ − ≡ We will provide moreWe will examples provide of more special examples cases in of the special following cases section. in the following section. 3, F (N) can be partitioned into two multisets of equal sum, which implies our theorem. We will look at some4 common Some examples example of special of cases special that may occur cases4 in competitive Some example programming of problems. special cases We will look at some common examples of specialWe cases will look thatWe atmay some will occur look common in at competitive some examples common programming of special examples cases problems. of special that may cases occur that inTherefore, may competitive occur solving in programming competitive this problem programming problems. is reduced problems. to checking whether N 1 (mod 3). We can solve this in O(1). by the construction of the function. ≡ We4 will Some look at some example4 common Some examples of example special of special of cases4.1We special willthat Planar look may at occur cases some graphsWe in common willcompetitive provide examples more programming examples of special problems. of cases special that cases may in occur the followingin competitive section. programming problems. 4.1 Planar graphs Theorem4.1 2. If PlanarN is4.1 divisible graphs Planar by three, then graphsF (N) can be partitioned into two multisets of equal sum. Planar graph is a graph that can be drawn on a flat surface without having two edges crossing each other (West We will look at someWe will common look at examples some common of special examples cases that of special mayby occur cases4.1 the construction in that Planarcompetitive may occur of graphs programmingthe in function. competitive problems. programming problems.4.1 Planar graphs Planar graph is a graph that can be drawn on aPlanar flat surface graphet al. withoutPlanar is 2001). a graph graph having There that is aretwo a can graph many edges beProof. drawn that graph crossingIf canN on problems beis a each flatdivisible drawn other surface which on by (West aare withoutthree, flat easy surface then to having solveF without(N two if) theis edges ahaving graph prefix crossing is two of planar.F edgeswith each4 We crossing length other willSome provide(West multiples each example other several of (West three. By of lemma special 3, F (N) cases et al. 2001). There are many graph problems whichPlanaret al. are 2001). graph easyexamples. to iset There solve a al. graph 2001). are if the manythat graphThere can graph is arebecan planar. drawnproblems many be partitioned Wegraph on which a will flat problems provide arePlanarsurface into easy two severalwhich graph without to multisets solve are is a havingeasy if graph the of to equalgraph two solve that edges sum.. is can if planar. the be crossing graph drawn We is willeach on planar. aprovide other flat We surface (West several will provide without several having two edges crossing each other (West 4.1 Planar4.1 graphsTheorem Planar 2. graphsIf N is divisible by three, then F (N) can be partitioned into two multisets of equal sum. examples. etexamples. al. 2001). Thereexamples. are many graph problems which areet easy al. 2001). to solve There if theWe are graph will many look is graph planar. at some problems We common will which provide examples are several easy of to special solve if cases the graph that mayis planar. occur We in competitive will provide severalprogramming problems. Theorem 3. IfNN 1 (mod 3),F(N) cannotF N be partitioned intoF two multisets of equal sum. F N Planar graph is aPlanar graph graphthatexamples. can is a be graph drawn that on can a flat be surface drawn withouton aProof. flat having surfaceIf two4.1.1 withoutisexamples.≡ divisible edges Number having crossing by three, two eachof edges then edges other crossing( (West) is each a prefix other of (Westwith length multiples of three. By lemma 3, ( ) can be partitioned into two multisets of equal sum.. et al. 2001). Thereet are al.4.1.1 2001). many Number graph There problems are of many edges which graph are problems easy toProof. which solveSuppose ifare4.1.1 the easy graph toNumberF  solve( isN4.1.1 planar.)= ifF theof( NumberN We edgesgraph) willf(1) is provide planar. of. Note edges several We that willF  provide(N) contains severalN 1 elements.4.1 Planar Since N graphs1(mod 3), we In simple general graph, the number of edges can be up− to a quadratic order with respect to− the number of ≡ examples. examples. haveN 4.1.11 0( Numbermod 3). of By edges lemma 3, F (N) can be partitioned4.1.1 into Number two multisets of edges of equal sum. Therefore, the In simple general2 graph,Theorem the number 3. ofIf N edges1 can (mod be 3) up,F to(N a) quadraticcannot be order partitioned with respect into two to multisets the number of equal of sum. In simple general graph, the number of edges canIn simple be upvertices general to a quadratic (i.e. graph,O(V the order)). number This with is respect ofnot− edges the≡ to case can the for be number planar up≡ to of agraph. quadratic InPlanar a planar order graph with graph, is a respect graph we may that to show the can number thatbe drawnE of 3 onV a flat6 surface without having two edges crossing each other (West 2 2 sum of all elements in F (N) is even. However, the sum of all elements in F≤(N)=−F (N)+f(1), which is odd vertices (i.e. O(V )). This is not the case forIn planarvertices simple94 graph.holds (i.e. generalverticesO In for( aV graph,V2 planar)). (i.e.3 Thisby the graph,O using( is numberV not) we). the the This may ofEuler’s case edgesJ.I. showis not forGunawan formula. that can planarthe beIncaseE graph.simpleTherefore, up for3V to planar a generalIn6 quadratic a the planar graph. number graph,et al. graph, order In 2001). thea of planar with edges we number There may respect graph, is O show are of(V edgesmany towe). that Naturally, the may graph canE number show be3 problemsV any up that of to algorithm6 E a which quadratic3V are6 easy order to withsolve respect if the graph to the is planar. number We of will provide several 4.1.12 ≥ Number4.1.1 ofbecause edgesProof. NumberF (SupposeN) is of even edges≤F ( whileN)=− fF(1)(Nis)2 odd.f(1) Therefore,. Note that thereF ( isN no) contains way≤ to partitionN − 1 elements.F≤(N). − Since N 1(mod 3), we holds for V 3 by using the Euler’s formula. Therefore,verticesholds for (i.e.that theV Oholds numberhas(3VbyO) for(). usingE of) ThisVin edges the its is3 runningbynot Euler’s is usingO the(V formula.) timecase. the Naturally, Euler’s forcan planarTherefore, be formula. changed anyvertices graph. algorithm the intoTherefore, (i.e. In number aOO planar(V(V). ofexamples. the−) Computing). edgesgraph, number This is isweO not of( shortest mayV edges) the. showNaturally, case pathis O that for(V in) anyplanarE a. Naturally,general algorithm3V graph. graph−6 any In using algorithm a planar graph, we≡ may show that E 3V 6 ≥ ≥ ≥ haveN 1 0(mod 3). By lemma 3, F (N) can be partitioned≤ into− two multisets of equal sum. Therefore, the ≤ − O(E) holds forOVO(V E)that3 by has usingO( theE) in Euler’s its running formula. time− Therefore, can≡holds be changedO the forV numberV into3 byO of( usingVedges). Computing the is O Euler’s(V ). Naturally, shortest formula.2 path anyTherefore, in algorithm a general the number graph using of edges is O(V ). Naturally, any algorithm that has in its runningIn simple time general canIn be graph, simple changed thethat general into numbering has Bellman-FordBellman-Ford graph,(≥ of.) edges Computingin the its number can runningalgorithm algorithm be shortest of up time edgestakes takes toTheorem can path a quadraticO can be( inVE changed be a 4.) general up(Halim(HalimIf order toN into a graph &and with quadratic2 Halim (mod(Halim, using respect). 2013), Computing 3)≥ order2013),. F to( butN the with )but itcan shortestnumber onlyit respect beonly takes partitioned pathtakesof toO the( inV a) number into generalin a two planar of graph multisets graph. using of Counting equal sum. 2 2 sum of all elements≡ in F (N) is even. However, the sum of2 all elements in F (N)=F (N)+f(1), which is odd Bellman-Ford algorithmvertices takes O (i.e.(VEO)(V(Halimvertices)). This & (i.e.that HalimBellman-Ford isO not has( 2013),V theO2the)( ).Ein case number)Bellman-Ford butThisa algorithmin planar for itits is only runningplanar ofnot graph. connected takes the algorithm graph. time caseCountingO(VEV cancomponentsfor In)) takesin planar a (Halimbethe planara changed planarnumberO( graph.VE & using graph, Halim graph.) intoof(Halimthat In DFSconnected we 2013),O a Counting has(planar mayinV &) a.O Halim but general Computing show( componentsE graph,) itin 2013), only that graphits we takes runningE shortest but may using takesO it3 showV( only V timeDFSO path2()6V takesthatin canin+ in a E planarE a beO) general,(V changedbut3V graph.) itin onlygraph a6 intoplanar Counting takes usingO( graph.VO)4.1.1(.V Computing) Countingin a Number shortest of edges path in a general graph using because F f(N) is evenA whilef f(1) Bis odd.≤ Therefore,2−f f there≤ is− no way to partition F (N). F N 2 F N the number of connectedholds components for V 3 by using using DFS theBellman-FordVthe in Euler’s a number3 generalplanar formula. of algorithmthegraph connectedgraph. number takesTherefore, takes Therefore, takes ofO components( connectedVO the(+VEE ifProof. number)) the , (Halimbut using components problem itAssign it ofonly only DFS& edges Halim takesrequires takes in(1) usingBellman-Ford isa 2013), generaltoO(usV DFS) and to. butin Naturally, graph in compute a it aplanar algorithm(2) onlygeneral takesto O takesgraph. theany(OV. graph takes( number) algorithm SinceVO Therefore,(+V takesOE)()(1)VE of,in butOconnected a =)( planarV(Halim it+(2) onlyE, graph.) we takes&, components but Halim are itO Counting now( onlyV 2013),) tryingin takes in a abut planarO to it(V partition only) in takes a O((V)=) in a( planar) graph. Counting ≥ holds for by using the Euler’s formula. Therefore, the number of edges is . Naturally, any algorithm − the≥ number of connected componentsf(1) usingf(2) DFS. F in(N athe general) will number have graph ofN connected takes2Inelements.O simple(V components+ E general Since)2, butN itgraph, using only2(mod DFStakes the number in3)O,( aV we general) obtainin of a edges graphN can takes2 be0(O up(modV to+ 3) aE). quadratic, By but lemma it only order takes withO( respectV ) in a to the number of planar graph. Therefore,that if has theO problem(E) inthat its requires running has Oplanar us(E time toif) inthe compute graph. can itsgraph, problem running beplanar Therefore, changedthe even requires number time graph. though into can if us Therefore, theoftheO beto connected( problemVcompute changed constraint). ComputingTheorem if−requiresthe the componentsinto states problemnumberO( shortestV us4. that). toIf ofrequires Computing inN compute Vconnected patha planar2100us in(mod, the ato000 shortest components general− compute number 3),E. F path( graph100N of the) ,incan connectedin000 numberusinga a planar be general, the partitioned of standard components≡ graph connectedinto using DFS twoincomponents solution a multisets planar still in of runs− a equal planar≡ sum. by the construction of the function. ≡≤ ≤ 2 2 VplanarO100graph,(VE graph., 000) even,Egraph, Therefore, though100 even, 000the if thoughconstraint2 the problem the3, statesF constraint( requiresN that) can V us statesbe toO partitionedplanar( computeV that,2) graph.V,E theinto100 Therefore, number two, 000,vertices multisets2,E2 of , the if connected (i.e.100 the standard of, problem000O equal(V , components) the sum,). requires This standard which is us not in implies toDFS a the planar compute solution case our theorem. for the still planar number runs graph. of connected In a planar components graph, we in may a planar show that E 3V 6 graph, even though theBellman-Ford constraint statesalgorithmbyBellman-Ford thethat takes constructiongraph, algorithm evenunder of(Halim though the takes one function. & secondO the Halim(VE constraint) (in, 2013),(Halim the competitive standard but states& Halim it onlythat DFS programming, 2013), takes solution but100 it still000 only wein runs a assume takes planar100O graph. that(V000) 1in, Counting themillion a planar standard operations graph. DFS Counting solution can be done still runs in 1 second ≤ − ≤ ≤ Proof. Assign≤ f(1) to A≤≤and f(2)holds2to for≤B.V Since3 fby(1) using = f the(2), Euler’s we are formula. now trying Therefore, to partition2 the numberF (N)= ofF edges(N) is O(V ). Naturally, any algorithm under one second (inthe competitive number of programming, connectedthe number componentsgraph,under we ofDFS connectedassume even one (Halimsolution usingsecond thoughunder that components &Theorem DFSstill 1Halim (in theone million runs in competitive constraint second a 2013)). under2. general operationsusingIf (inNone statesDFS graphis programming,competitive second divisible incan thattakes a generalbe(inV by O donecompetitive programming,( three,V we100 graphgraph,+ in assumeE, then0001), second takes but even,Eprogramming,F that( it weNO though only100)( assumeV 1can, million+ takes000E be the )we,, partitionedthatO but constraintthe operationsassume(V 1it standard) million onlyin≥ athat into statestakes can operationsDFS two beO that( solution multisetsV done)Vin can in a still100 1 of be second, equalruns000 done,E sum. in 1100 second, 000 , the standard DFS solution− still runs Therefore,f(1) f(2)≤ solvingF (N this) problem≤ N is reduced2 O toE checkingN whether2(modN≤ 3)1 (mod 3)≤. WeN can2 O solve0(V mod this in3)O(1). (Halim & Halim 2013)).planar graph. Therefore,Theorem ifunder(Halim the 2. 1If problem million oneN &issecond Halim divisible (Halimoperations requires 2013)). (in by & competitiveus three,Halimcan to computebe then 2013)).done programming,F in( theN 1 )second numbercan be (Halim partitionedof we. connectedunder assume and oneHalimwill into that components second have two2013)). 1 million multisetsthat (in competitivein haselements.operations a of planar( equal) Sincein programming,can sum. its be running done time in we 1≡ secondcan assume, we be obtain changed that 1 million into ( operations). Computing. can By be lemma shortest done in path 1 second in a general graph using planar graph. Therefore, if the problem requiresWe will us to provide− compute more the examples number of of special connected− cases components in the following in≡ a planar section. − ≡ 2 Proof. If N is divisible3, byF  three,(N)2can then beF partitioned(N) is a prefix intoBellman-Ford two of F multisetswith length algorithm of equal multiples takes sum, ofO which( three.VE) implies(Halim By lemma our & Halimtheorem. 3, F 2013),(N) but it only takes O(V ) in a planar graph. Counting graph, even thoughgraph, the constrainteven(Halim though & states Halim the constraint that 2013)).V 100 states, 000 that,E V 100100, 0004.1.2, 000, the,E(Halim Maximum standard100 &, 000 Halim DFS2 Clique, the solution2013)). standard problem still DFS runs solution still runs Proof. If N is4.1.2. divisible Maximum bycan three, beClique≤partitioned then ProblemF (N) intois≤ a≤ two prefix multisets of F with of≤ equal length sum.. multiplesthe of number three. of By connected lemma 3, componentsF (N) using DFS in a general graph takes O(V + E), but it only takes O(V ) in a under one second4.1.2under (in competitive oneMaximum second programming, Clique(in competitive problem we programming, assume that4.1.2 1 we millionTherefore, assume Maximum operations4.1.2 that solving 1 Clique Maximum million this can problem be problem operations done Clique is in reduced 1 can secondproblem be to done checking in 1 second whether N 1 (mod 3). We can solve this in O(1). can be partitionedThe MaximumThe into Maximum two multisetsClique Clique problem of equalproblem requires sum.. requires us to find us to the find maximum the maximum set ofplanar vertices set of graph. verticesin a graph, Therefore, in a graph, if the such problem that≡ every requires pair usof to compute the number of connected components in a planar (Halim & Halim 2013)).(Halim & Halim 2013)). Theorem 3. If N 4.1.21We (mod will Maximum 3) provide,F(N) morecannot Clique examples4 be problemSome partitioned of special example into cases two in multisets the4.1.2 of following ofMaximum special equal section. sum. Clique cases problem The Maximum Clique problem requires us to findThe thesuch Maximum maximum verticesthat Theevery Clique set in Maximum pair the of vertices problem setof vertices is Clique directly in requires a in≡ graph, problem the connected usset such to is requires finddirectly that by the an every us edge.maximumconnected to pairfind By ofthe reductionby set maximuman of edge.graph, vertices from By set even invertexreduction of a though graph,vertices cover, suchthe in the a constraint that graph,maximum every such states pair clique that of that problemeveryV pair100 of, 000,E 100, 0002, the standard DFS solution still runs Theorem 3. If N 1 (mod 3),F(N) cannot be partitioned into two multisets of equal sum. ≤ ≤ vertices in the set is directly connected by an edge.Thevertices Byfrom Maximum reduction inon≡vertex the generalvertices Clique setcover, from is graph directly in problemthe vertex the maximum is set connectedNP-hard. cover, requires is directly theclique us However,by maximum toconnected problem an find edge. the it clique onThe isBy by maximum general easy anreduction Maximumproblem edge. to graph solve set By fromofClique is reductionthis verticesNP-hard.under vertex problem problem one cover, in from However, a second in graph, requires vertex the planar maximum (in such cover, us graph. competitive to that thefind clique Considerevery maximum the problem pairprogramming,maximum the of clique problem set problem of we vertices assume in that a graph, 1 million such operations that every paircan beof done in 1 second 4.1.2Proof. MaximumSuppose CliqueFWe(N will)= problem lookF (N at) somef(1) common. Note that examplesF (N) ofcontains specialN cases1 thatelements. may occur Since inN competitive1(mod programming3), we problems. vertices in theon set general is directly graph4.1.2 connected is NP-hard. Maximum by an However, edge. Clique− Byvertices itreduction problem is easy in the tofrom set solve vertex is directly this cover, problem connected the in maximum− planar by an graph. edge.clique By Considerproblem reduction≡ the from problem vertex cover, the maximum clique problem on general graph is NP-hard. However,Proof. it isSuppose easyon to generalit solveisF ofeasy(N colouring thisgraph)= to have problemsolveF is(NN NP-hard.a )this graph inf1 problem(1) planar such.0( However, Notemod graph.thatin that planar3) no. itF By Consider two is (graph.N lemma easy) adjacentcontains toConsider the 3, solveF problem vertices(NN this )thecan1 problemproblem haveelements. be(Halim partitioned the inof sameplanarSince colouring & Halim colour. intoN graph. two 2013)).a1( Note multisets Considermod that3),if weof the there equal problem is sum. a clique Therefore, of the − − 4 Some example≡ of special cases of colouring a graphThe such Maximum that no two Clique adjacent problemonof vertices general colouringgraph requiressize havesuch graph uskof a thein graphthat to colouring is a find same graph,NP-hard.no such thetwo− colour. a themaximum that≡adjacent graph However, set no Note of such twovertices theset that adjacentthat itof vertices is ifvertices have noeasy there two verticesinsidethe to isinon adjacent solve asame a general theclique graph, have thiscolour. clique vertices of thegraphsuch problem mustNote same that is have be NP-hard. inthat colour. every colouredplanar the if pairthere same Note graph. However, of withis colour. thata k Considercolours. if it Notethere is easy thatthe is Therefore, a to problem clique if solve there of the this is a entire problem clique of in planar graph. Consider the problem ThehaveN Maximum1 0( Cliquemod problem3).sum By lemma ofrequires all elements 3, usF ( toN find) incanF the( beN maximum) partitionedis even. set However, into of twovertices themultisets sumin agraph, of of4.1 all equal elements such Planarsum. that Therefore,in everyF (N graphs pair)= theF of(N)+f(1), which is odd k −of≡ colouringclique of asizesize graph k inin such a graph, graph, that the no thek set two set ofadjacent of the the vertices vertices vertices insideof inside colouring have the theclique the clique a samegraph must must colour.be such coloured be that colouredNoteno with that two with if adjacent therek colours. is vertices a clique Therefore, have of the the same entire colour. Note that if there is a clique of size in a graph, thevertices set of the in the vertices setverticessum is inside directly of all in thesize elementsthe connected cliquek setin is a must in directly graph, byF  bean(becauseN theedge.coloured)connectedis set even.F By of( withN reduction theHowever, by) is an vertices evencolours. edge.We from the while inside By will sum vertexTherefore, reductionf look(1) the of cover,allisat clique odd. elements some the from the must Therefore, entire common vertex maximum in beF coloured cover,(N examplesthere)= clique theF is with( no problemmaximumN of)+ wayk specialcolours.f to(1) partition clique, cases which Therefore, problemthat isF odd( mayN). the occur4.1.2 entire in competitive Maximum programming Clique problem problems. on general graph is NP-hard.size k However, incolours. a graph, Therefore, it is the easy set tothe of solve theentire vertices this Planargraph problem insiderequires graph inthe is at planar a cliqueleast graphsize k graph. must thatincolours. a be graph,can Consider coloured By be the drawn thefour set with on problemofcolourk theacolours. flat verticesthe surface- Therefore, inside without the the having clique entire must two edges be coloured crossing with eachk othercolours. (West Therefore, the entire becauseon generalF ( graphN) isisJonathan even NP-hard. while Irvinf(1) However, GUNAWANis odd. it Therefore, is easy to there solve is this no problem way to partition in planarF ( graph.N). Consider the problem orem, any planarTheorem graph can 4. IfbeN coloured2 (mod with 3)at. mostF (N four) can colours. begraph partitioned (Gonthier, requiresThe Maximum into at2005). least two Sincek multisets Cliquecolours. problem of By equal the requires four sum. colour us to theorem, find the any maximum planar graph set of can vertices be coloured in a graph, with such at most that four every pair of Jonathan Irvin GUNAWANof colouring a graphof colouring such thatJonathan a nograph two Irvin such adjacentJonathan GUNAWAN that novertices Irvin two GUNAWAN adjacent haveet≡ the al. vertices 2001).same colour. There have the are Note samemany that colour.graph if there problems Note is a that clique which4.1 if ofthere are Planar easy is a to clique solve graphs of if the graph is planar. We will provide several graph requiresgraph at least requiresk colours. at least Byk colours. theTheorem four By colour the 4. theorem, fourat Nmost colour any2four (modtheorem, planarcolours 3) graph anyFare(N planarrequired can) be graph colouredto colour can be witha planar coloured at most graph, with four therecolours. at most does (Gonthierfourvertices not exist in 2005).a the clique set Since is directly at most connected four colours by an are edge. required By reduction to colour from a planar vertex graph, cover, there the maximum does not clique exist problem size k in a graph,size thek setin ofJonathan a graph, theIf vertices the Irvin set inside GUNAWAN of the the. vertices cliquecan mustinsideexamples. be be the partitioned coloured clique must with intoJonathan be twok colours. coloured multisets Irvin Therefore, with GUNAWAN of equalk colours. the sum. entire Therefore, the entire graph requires at leastcolours.k colours. (Gonthiercolours. By the 2005). (Gonthier four colour Since 2005). theorem,at most Since four any at coloursplanar most fourgraph are requiredcolours≡ can be areProof. colouredto requiredcolourAssign with a toplanar atf colour(1) most graph,to a fourA planarand theref graph,(2) doesto not thereB. exist Since doesf not(1) exist = f(2), we are now trying to partition F (N)=F (N) with more than four vertices. Hence,Planar we can graphsolve the is a problem grapha that cliqueby checking can withon be general drawn morewhether than on graph there a fourflat is NP-hard.surface vertices. without Hence,However, having we it can is two easy solve edges to the solve crossing− problem this each problem by otherchecking in (West planar whether graph. there Consider is a clique the problem colours. (Gonthier 2005).a clique Since witha at clique more most than with four four more colours vertices. than are four required Hence,Proof. vertices. to weAssign colour can Hence,isf solvea(1) a clique planar weto the canA with problem graph,andf solve(1) fourf(2) therethe fvertices. by(2)to problem checking. doesBF.( SinceIfN not )there bywill whether existf checking (1)is have no = therecliqueNf(2) whether2, iswith weelements. a areclique four there nowwith vertices, Since is trying afour cliqueN ofwe vertices. to colouring check2( partitionmod Ifwhether there3) aF graph, we(N is)= obtain no such cliqueF (N that) with2 no two four0(mod adjacent vertices,3). By vertices we lemma check have whether the same there colour. is a clique Note with that three if there vertices. is a clique of − et al. 2001).− There are many graph≡ problems4.1.1 which Number are easy of edges to−− solve≡ if the graph is planar. We will provide several a clique with more than four vertices. Hence,Jonathan we can Irvin solve GUNAWANJonathanf(1) the problemf(2) Irvin. F by GUNAWAN(N checking) will have3, whetherFN(N)2can thereelements. be is partitioned a clique Since N into2( twomod multisets3), we of obtain equalN sum,2 which0(mod implies3). our By theorem. lemma k with four vertices.with four If there vertices. is no If clique there is with no cliquefour− vertices, withthere four we is vertices,a check clique whether with we− checkthree there vertices. whether is a clique Findingexamples. there with is whether≡ a cliquethree there vertices. with is three Findinga clique vertices. with whethersize −k invertices≡ there a graph, is can a theclique set with of thek vertices vertices can inside be the solved clique naively must in beO coloured(V ). Therefore, with k colours. the whole Therefore, solution the entire with four vertices. IfFinding there is whether noFinding clique there withwhether is four a clique there vertices, with is a wecliquek3,vertices checkF ( withN) whether cancank vertices be be solved there partitioned can isnaively naively bea clique solved into in in two withO naively(V multisetsk three) . Therefore, Therefore, inIn vertices.O simple( ofV equalk) .the the general Therefore, whole sum, whole which graph,solution solution the implies whole the takes number our solutionO(V theorem.4 of) time,time, edges which which can beis is polynomial. up to a quadratic The solution order with can be respect improved to the to numberO(V 2). Insteadof of having four nested 4 4 k Therefore,2 solving this2 problem is2 reduced to checking whether N 1 (mod 3). We can solve this in O(1). Finding whether theretakes is aO clique(V takes) time, withO whichk(Vvertices) time, is polynomial. can which be solved is polynomial. The naively solution in Thepolynomial. canO( solutionV be). improved Therefore, The can solution be to improved theO(V can whole). be Instead tovertices improved solutionO(V of) (i.e.. havingto Instead O(V four of) ).. Instead having nested Thisloops isof four not having to nested the find four case four nested for vertices planar loops≡ independently, graph. In a planar we can graph, have we two may nested show loops that overE the3V edges6 instead and test whether 4 Therefore, solving2 thisWe problem will provide is reduced more to examples checking of whether specialN cases1 in (mod the followingJonathan 3). We can section.4.1.1 Irvin solve GUNAWAN Number this in O(1) of. edges ≤ − takes O(V ) time, whichloops to is polynomial.findloops four to vertices find The four solution independently, vertices can independently, be we improved can have to weto twoO find can(V nested ) havefour. Instead loops twovertices nested of over independently, having the loops edges fourholds over nested instead thewe for can edgesV andhave3 instead test bytwo using whether nested and the≡the testloops Euler’s four whether over vertices formula. the edges (which Therefore, instead are the the endpoint number of of the edges two is edges)O(V ) form. Naturally, a clique. any This algorithm solution takes O(E2), which is the We will provide more examples of special cases in the following≥ section. loops to find four verticesthe four independently, verticesthe four (which vertices we are can the (which have endpoint two are the nested of endpoint the loops two edges) of overand the test the form two whether edges edges) a clique. instead the form Thisfour a and clique.vertices solution testthat whetherThis (which takesIn has solution simple OareO((E Ethe2)) takesgeneral, inendpoint which itsO running( graph,E is of2 the) ,thesame which time thetwo as number canedges) isO the(V be2 form) changed ofin edges planara clique. into can graph. O be(V up). Computing to a quadratic shortest order path with in respect a general to graph the number using of the four vertices (whichsame are as theO(Vsame endpoint2) in as planarO of(V the2 graph.) in two planar edges) graph. form a clique. This solution takes O(E2) , which which is vertices the the same (i.e. as O(V 2) ).in ThisplanarO(VE is graph. not) the case for planar graph. In a planarO graph,(V 2) we may show that E 3V 6 Bellman-Ford4 algorithm Some takes example(Halim of &special Halim 2013), cases but it only takes in a planar graph. Counting≤ − same as O(V 2) in planar graph. holds for V 3 by using the Euler’s formula. Therefore, the numberO of(V edges+ E is) O(V ). Naturally,O any(V ) algorithm 4 Some examplethe number of of connected≥ special components cases using DFS in a general graph takes4.1.3 Problem, but example it only takes in a 4.1.3 Problem4.1.34.1.3. Problem example ProblemWe Example will example look at someplanar commonthat graph. has examplesO Therefore,(E) in its of if runningspecial the problem cases timethat can requires be may changed usoccur to compute in into competitiveO(V the). Computingnumber programming of connected shortest problems. path components in a general in a graph planar using 4.1.3 ProblemWe example will look atWe some will commonuse a past examplescompetitive of specialgraph,programmingBellman-Ford caseseven though thatproblem mayalgorithm the to occur constraintillustrateWe takes in willcompetitive Othe states use(VE importance a) that past(Halim programmingV competitive of & 100the Halim , 000 problems. 2013), programming,E but100 it, 000 only problem2, takes the standardO to(V illustrate2) in DFS a planarthe solution importance graph. still Counting runs of the properties in a planar We will useWe a past will competitive use a past competitive programming programming problemproperties to problemillustrate in a to theplanar illustrate importance graph. the The importance of ‘Traffic’ the properties ofproblem the in properties afrom planar Centralgraph. in a planarEuropean The ‘Traffic’ Olympiad problem≤ in from Central≤ European Olympiad in Informatics (CEOI) 2011 illustrates this concept underthe one number second of (in connected competitive4.1 components Planar programming, using graphs DFS we assumein a general that graph 1 million takes operationsO(V + E) can, but be it done only takesin 1 secondO(V ) in a We will use a past competitivegraph. Thegraph. ‘Traffic’ programming The problem ‘Traffic’ problem from problem Central to illustrate from European Central the importanceOlympiadInformatics European in Olympiad of Informatics(CEOI) the properties 2011 in (CEOI)Informatics illustrates in a2011 planar this (CEOI) illustrates concept 2011 thiswell. illustrates concept In this thisproblem, concept there is a directed V , (Halimplanar & Halim graph. 2013)). Therefore,well. if the In problemthis problem, requires there us is to a compute directed the graph number with upof connected to = 300 components000 vertices in givena planar in a 2D plane. There are graph. The ‘Traffic’ problem from Central European Olympiad in Informatics (CEOI) 2011V illustrates, this4.1 concept Planar graphs well. In thiswell. problem, In this there problem, is a directed there is graph a directed with upgraphgraph to V withwith= 300 upupPlanar ,to 000 vertices= graph 300 is000 given a graphverticesvertices ingraph, a that 2D given caneven plane. in be thougha a drawnThere2D 2D plane. plane. the areontwo constraintTherea Thereflat vertical surfaceare are two stateslines vertical without denoted that linesV having as ‘left’100 two, 000 and edges,E ‘right’. crossing100 All, 000 vertices each2, the other are standard contained (West DFS within solution the ‘left’still runs and ‘right’ lines, with some well. In this problem,two there vertical is atwo lines directed vertical denoted graph lines aswith ‘left’ denoted up and to as ‘right’.V ‘left’Planar= 300 All and graph, vertices000 ‘right’.verticesdenoted isa are All graph containedvertices givenas that‘left’et in are al. canand within a contained2001). 2D be‘right’. plane. drawnthe There ‘left’All within There on vertices are and a theflat many are ‘right’ ‘left’ surfaceare graph lines,contained and without problems ‘right’ with within some lines, having whichvertices the with two ‘left’ are some possibly edges easy and to‘right’ crossing lying solve lines, on if each the these≤ graph other two is (West lines. planar.≤ The We problem will provide requires several the contestant to print the number of visitable2 under one second (in competitive4.1.2 programming, Maximum we Clique assume problemthat 1 million operations can be done in 1 second two vertical lines denoted as ‘left’ and ‘right’. All vertices are contained withinwith the some ‘left’ vertices and ‘right’ possibly lines, lying with on some these two lines. The problem2 requires2 the contestant vertices possiblyvertices lying possibly on these lying two on lines. theseet The al. two 2001). problem lines. There The requires problem are many theexamples. requires contestant graph problems the to contestant print which the(Halim toare number print easy & Halim the to of solve visitable number 2013)). if thevertices of graph visitable lying is planar. on the We ‘right’ will provide line from several every vertex lying on the ‘left’ line (which we shall call ‘left’ vertices and 2 2 vertices possibly lyingvertices on these lyingvertices two on lines. the lying ‘right’ The on problem line the from ‘right’ requires every lineexamples. vertexfrom the contestant every lyingto vertexprint on theto the lyingprint‘left’ number onthe line the numberof (which visitable ‘left’ of line we visitableThe vertices shall (which Maximum call lying we ‘left’ shall on Clique vertices the call ‘right’ problem ‘left’ and ‘right’line vertices requires from vertices andevery us forto vertex find simplicity). thelying maximum An instance set of for vertices this problem in a graph, can such be seen that on every figure pair 5. of on the ‘left’ line (which we shall call ‘left’ vertices and ‘right’ vertices for simplicity). An vertices lying on the‘right’ ‘right’ vertices line‘right’ from for simplicity).vertices every vertex for simplicity). An lying instance on the An for ‘left’ instance this line problem for(which this can weproblem be shall seen cancall on figure be‘left’ seen vertices 5. onvertices figure and in 5. the set is directly4.1.1 connected Number by anof edge. edges By reduction from vertex cover, the maximum clique problem instance for this problem can be seen on Fig. 5. 4.1.2 Maximum Clique problem ‘right’ vertices for simplicity). An instance for this problem can be seen on figure 5. 4.1.1on general Number graph of is edges NP-hard. However, it is easy to solve this problem in planar graph. Consider the problem The bruteIn force simple solution general for ofthis graph, colouring problemThe the Maximum numberis a to graph run Clique ofDFS such edges from problemthat can every no be tworequires ‘left’ up adjacent tovertex us a toquadratic which vertices find the orderhave maximum the with same set respect of colour. vertices to the Note in number a that graph, if of there such isthat a clique every pairof of In simple generalgives graph, us a runningvertices the number time (i.e. of ofO( edgesV 2)).. It can Thisis very be is updifficult not to the a casequadraticto find for aplanar solution order graph. with (if any) respect In faster a planar to than the graph, number we may of show that E 3V 6 size verticesk in a graph, in the the set set is directly of the vertices connected inside by an the edge. clique By must reduction be coloured from vertex with k cover,colours.≤ the− Therefore,maximum clique the entire problem vertices (i.e. O(V 2) ).for This thisholds isproblem. not for theV However, case3 by for using planarthere the is graph. Euler’san important In formula. a planar constraint Therefore, graph, on we the the may problem. number show The that of edgesE is3VO(V 6). Naturally, any algorithm ≥ on general graph is NP-hard. However, it is easy to solve≤ this− problem in planar graph. Consider the problem holds for V graph3 by usinggiven theinthat this Euler’s has problemO( formula.E) isin always its Therefore, runningof a colouring planar time the graph. can a number graph beWe changed first suchof edges relabel that into is no OtheO( two(V V‘right’)).. adjacent Naturally, Computing vertices vertices any shortest algorithm have path the in same a general colour. graph Note using that if there is a clique of ≥ Jonathan Irvin GUNAWAN 2 that has O(Ein) in ascending its running Bellman-Fordorder time according can be algorithm changedto the sizey-coordinate. takes intok inOO a((VEV graph,) .The) Computing(Halim theplanar set & properties Halim of shortest the 2013), vertices pathensures but in inside itathat generalonly thefor takes clique graphO( mustV using) in be a coloured planar graph. with k Countingcolours. Therefore, the entire Bellman-Ford algorithm takestheO number(VE) (Halim of connected & Halim components 2013), but using it only DFS takes in aO general(V 2) in graph a planar takes graph.O(V Counting+ E), but it only takes O(V ) in a the number of connected componentsplanar graph. using Therefore, DFS in if a the general problem graph requires takes O us(V to+ computeE), butthe it only number takes ofO( connectedV ) in a components in a planar 2 vertex v is visitable from vertex u if there Jonathanis a path from Irvin u to v GUNAWAN planar graph. Therefore, ifgraph, the problem even though requires the us constraint to compute states the thatnumberV of100 connected, 000,E components100, 0002, in the a planarstandard DFS solution still runs ≤ ≤ graph, even though the constraintunder one states second that (inV competitive100, 000,E programming,100, 0002, we the assume standard that DFS 1 million solution operations still runs can be done in 1 second ≤ ≤ under one second (in competitive(Halim & programming, Halim 2013)). we assume that 1 million operations can be done in 1 second (Halim & Halim 2013)). 4.1.2 Maximum Clique problem 4.1.2 Maximum Clique problem The Maximum Clique problem requires us to find the maximum set of vertices in a graph, such that every pair of The Maximum Clique problemvertices requires in the us set to is find directly the maximum connected set by of an vertices edge. By in reductiona graph, such from that vertex every cover, pair the of maximum clique problem vertices in the set is directlyon connected general graph by an is edge. NP-hard. By reduction However, from it is vertex easy to cover, solve the this maximum problem clique in planar problem graph. Consider the problem on general graph is NP-hard.of colouring However, a graph it is easy such to that solve no this two problem adjacent in vertices planar graph.have the Consider same colour. the problem Note that if there is a clique of of colouring a graph suchsize thatk noin atwo graph, adjacent the set vertices of the have vertices the insidesame colour. the clique Note must that be if coloured there is witha cliquek colours. of Therefore, the entire size k in a graph, the set of the vertices inside the clique must be coloured with k colours. Therefore, the entire Jonathan Irvin GUNAWAN Jonathan Irvin GUNAWAN

Figure 5: An instance of problem ‘Traffic‘. In this example, the expected output is {4, 4, 0, 2}, since the top ‘left’ Figure 5: AnFigure instance 5: An of problem instance ‘Traffic‘. of problem In this‘Traffic‘. example, In this the example, expected the output expected is {4, output 4, 0, 2}, is {4, since 4, 0, the 2}, top since ‘left’vertex the top can ‘left’ visit 4 ‘right’ vertices, the second top ‘left’ vertex can visit 4 ‘right’ vertices, the third top ‘left’ vertex Figure 5: An instancevertex of problem can visitvertex ‘Traffic‘. 4 ‘right’ can visit In vertices, this 4 ‘right’ example, the vertices, second the expected top the ‘left’second output vertex top is ‘left’ can {4, visit vertex4, 0, 4 2}, ‘right’ can since visit vertices, the 4 ‘right’ top the ‘left’ vertices, third top the ‘left’ third vertex topcannot ‘left’ vertex visit any ‘right’ vertex, and the bottom ‘left’ vertex can visit 2 ‘right’ vertices vertex can visit 4 ‘right’cannot vertices, visitcannot any the ‘right’ second visit vertex, any top ‘right’ ‘left’ and vertex vertex,the bottom can and visit the ‘left’ 4 bottom ‘right’vertex ‘left’ vertices,can visit vertex the 2 ‘right’ can third visit vertices top 2 ‘left’ ‘right’ vertex vertices cannot visit any ‘right’ vertex, and the bottom ‘left’ vertex can visit 2 ‘right’ vertices The bruteforce solution for this problem is to run DFS from every ‘left’ vertex which gives us a running time The bruteforceThe solution bruteforce for solution this problem for this is to problem run DFS is to from run every DFS ‘left’ from vertex every ‘left’ which vertex gives which us a running gives us time a running time 2vertex v is visitable from vertex u if there is a path from u to v The bruteforce solution for this problem is to run DFS from every ‘left’ vertex which gives us a running time 2vertex v is visitable2vertex fromv is visitable vertex u fromif there vertex is au pathif there from isu ato pathv from u to v 2vertex v is visitable from vertex u if there is a path from u to v Jonathan Irvin GUNAWAN Jonathan IrvinJonathan GUNAWAN Irvin GUNAWAN Jonathan Irvin GUNAWAN Understanding Unsolvable Problem 95

Fig. 5. An instance of problem ‘Traffic’. In this example, the expected output is {4, 4, 0, 2}, since the top ‘left’ vertex can visit 4 ‘right’ vertices, the second top ‘left’ vertexof O( canV 2 )visit. It 4 is very difficult to find a solution (if any) faster than O(V 2) for this problem. However, there is an ‘right’ vertices, the third top ‘left’ vertex cannot visit any ‘right’ vertex, and the bottom ‘left’ vertex can visit 2 ‘right’ vertices. important constraint on the problem. The graph given in this problem is always a planar graph. We first relabel the ‘right’ vertices in ascending order according to the y-coordinate. The planar properties ensures that for every ‘left’ vertex, the sequence of ‘right’ visitable vertices from that ‘left’ vertex is a contiguous sequence, assuming that ofofOO((VV22)).. It It is is very very difficult difficult to to find find a a solution solution (if (if any) any)of faster fasterO(V 2 than) than. ItO isOof(( veryVVO22)()V difficultforfor2) this. this It is problem. to problem. very find difficult aevery solutionHowever, However, ‘left’ to find(if vertex, there there any) a solution is is fasterthe an an sequence than (if any)O (ofV faster 2‘right’) for than this visitableO problem.(V 2 )verticesfor However, this from problem. therethat However,‘left’ is an vertex there is is an we have removed all ‘right’ vertices which are not visitable from any ‘left’ vertex. With this property, there is a importantimportant constraint constraint on on the the problem. problem. The The graph graph given givenimportant in in this this problem problem constraintimportant is is always always on the constraint a a problem. planar planar graph. ona graph. Thecontiguous the graph Weproblem. We first first givensequence, relabel relabel The in graphthis assuming problem given that in is this alwayswe problemhave a planarremoved is always graph. all a‘right’ We planar first vertices graph. relabel which We first are relabel not visitable from any ‘left’ vertex. With this property, there is a O(V log V ) solutionsolution (CEOI 2011 Solutions n.d.). thethe ‘right’ ‘right’ vertices vertices in in ascending ascending order order according according to to the thetheyy-coordinate.-coordinate. ‘right’ verticesthe The The ‘right’in planar planar ascending vertices properties properties order in ascending ensures according ensures that that order to for thefor according every everyy-coordinate. to the They-coordinate. planar properties The planar ensures properties that for ensures every that for every (CEOI 2011 Solutions, n.d.). ‘left’‘left’ vertex, vertex, the the sequence sequence of of ‘right’ ‘right’ visitable visitable vertices vertices from from‘left’ that that vertex, ‘left’ ‘left’ the vertex vertex‘left’ sequence is vertex, is a a contiguous contiguous of the ‘right’ sequence visitable sequence, sequence, of ‘right’ vertices assuming assuming visitable from that that that vertices ‘left’ from vertex that is a ‘left’ contiguous vertex is sequence, a contiguous assuming sequence, that assuming that wewe have have removed removed all all ‘right’ ‘right’ vertices vertices which which are are not not visitable visitablewe have from from removed any anywe ‘left’ ‘left’ all have ‘right’ vertex. vertex. removed vertices With With all this this ‘right’ which property, property, verticesare not there there visitable which is is a area from not any visitable ‘left’ from vertex. any With ‘left’ this vertex. property, With there this property, is a there is a 4.2 Bipartite Graph OO((VV loglogVV))solutionsolution ( (CEOICEOI 2011 2011 Solutions Solutionsn.d.).n.d.). O(V log V ) solutionO(V log (CEOIV ) solution 2011 Solutions (4.2.CEOI Bipartite 2011n.d.). Solutions Graph n.d.). Bipartite graph is a graph in which the vertices can be partitioned into two disjoint sets U and V such that all edges connect a vertex from U and a vertex from V . Some problems have a bipartite graph as an input although 4.24.2 Bipartite Bipartite Graph Graph 4.2 Bipartite4.2 Graph Bipartite Graph the problem statement does not explicitly state that the given input graph must be bipartite. The problem that we Bipartite graph is a graph in which the vertices can be partitioned into two disjoint sets used as an introduction for this paper, IOI 2014 Friend is a very good example. The construction of the graph BipartiteBipartite graph graph is is a a graph graph in in which which the the vertices vertices can can be beBipartite partitioned partitioned graph into intoBipartite is a two two graph disjoint disjoint graph in which is sets sets a graph theUU andand vertices in VV which suchsuchsuch can the that thatthat be vertices partitioned allall edges can connect intobe partitioned two a vertex disjoint into from sets two U disjointandand Va vertexsuch sets U that fromand all V .such Some that all in subtask 5 of this problem implicitly ensures that the final graph will always be bipartite. There are several edgesedges connect connect a a vertex vertex from fromUU andand a a vertex vertex from fromVV.. Someedges Some connectproblems problems aedges have have vertex aconnect a bipartitefrom bipartiteU aand vertex graph graph aproblems vertex fromas as an anU inputfrom input haveandV although aalthougha. vertex Somebipartite from problems graphV . Someas have an aproblemsinput bipartite although have graph athe bipartite as problem an input graph statement although as an does input not although graph problems that are NP-hard for general graph but solvable in polynomial time if the graph is bipartite. Since thethe problem problem statement statement does does not not explicitly explicitly state state that that the thethe given given problem input input statement graph graphthe problem must must does be be statement not bipartite. bipartite. explicitlyexplicitly does The The state problemnot problem state that explicitly thatthe that giventhe statewe we given input that input the graph given graph must input must be bipartite.graph be bipartite. must The be The problem bipartite. problem that The that we problem we used that we bipartite graph and bipartite matching was recently included in IOI 2015 syllabus (Forisek 2015), we can expect usedused as as an an introduction introduction for for this this paper, paper, IOI IOI 2014 2014 Friend Friendused is is asa a very very an introduction good goodused example. example. as an for introduction thisThe The paper, construction constructionas an forIOI introduction this 2014 of of paper, the Friendthe graph graphfor IOI is this 2014a very paper, Friend good IOI isexample.2014 a very Friend good The is a constructionexample. very good The example. of construction the graph The construc of the- graph that this type of problem may be conceived in the near future of IOI. We will take a look at several examples. inin subtask subtask 5 5 of of this this problem problem implicitly implicitly ensures ensures that that thein the subtask final final graph graph 5 ofin will willthis subtask always always problem 5 be be of implicitly bipartite. thisbipartite. problemtion ensures of There There the implicitly graph arethat are several several the in ensures subtask final graph that 5 of the willthis final alwaysproblem graph be implicitly willbipartite. always ensures There be bipartite. arethat several the Therefinal aregraph several graphgraph problems problems that that are are NP-hard NP-hard for for general general graph graph but butgraph solvable solvable problems in in polynomial polynomialgraph that are problems time NP-hardtime if if that the the for graph aregraphwill general NP-hard always is is bipartite. bipartite. graph be for butbipartite. general Since Since solvable graph There in butpolynomialare solvableseveral timegraph in polynomial if problems the graph time that is bipartite. ifare the NP-hard graph Since isfor bipartite. general Since 4.2.1 Vertex Cover and Independent Set (and maximum matching) bipartitebipartite graph graph and and bipartite bipartite matching matching was was recently recently included includedbipartite in in graph IOI IOI 2015bipartite 2015 and bipartitesyllabus syllabus graph (Forisek (Forisekmatching and bipartitegraph 2015), 2015), was but recently matching we we solvable can can expectincluded expect wasin polynomial recently in IOI included 2015 time syllabusif the in IOIgraph (Forisek 2015 is bipartite. syllabus 2015), Since (Forisek we can bipartite expect2015), graph we can and expect bipartite matching was recently included in IOI 2015 syllabus (Forišek, 2015), we can thatthat this this type type of of problem problem may may be be conceived conceived in in the the near nearthat future future this of typeof IOI. IOI. ofthat We We problem this will will taketype take may aof a be look look problem conceived at at several several may in be examples. theexamples. conceived near future in the of IOI. near We future will of take IOI. a Welook will at several take a look examples.As we at severaldiscussed examples. in an earlier section, both of the MIN-VERTEX-COVER and MAX-INDEPENDENT-SET problems expect that this type of problem may be conceived in the near future of IOI. We will are NP-hard. However, both of these problems are solvable in polynomial time on bipartite graph. By Konig’s take a look at several examples. 4.2.14.2.1 Vertex Vertex Cover Cover and and Independent Independent Set Set (and (and4.2.1 maximum maximum Vertex4.2.1 matching) matching) Cover Vertex and Independent Cover and Independent Set (and maximum Set (and matching) maximum matching)theorem, the size of the minimum vertex cover in bipartite graph is equal to the size of the maximum bipartite matching (Bondy & Murty 1976), and the size of the maximum independent set in bipartite graph is equal to the AsAs we we discussed discussed in in an an earlier earlier section, section, both both of of the the MIN-VERTEX-COVER MIN-VERTEX-COVERAs we discussedAs in andwe andan discussed earlier MAX-INDEPENDENT-SET MAX-INDEPENDENT-SET section, in an4.2.1. bothearlier of Vertex section, the MIN-VERTEX-COVER Cover problems problems both and of the Independent MIN-VERTEX-COVER and Set MAX-INDEPENDENT-SET (and Maximum and MAX-INDEPENDENT-SET Matching) problems problems number of the vertices minus the size of the maximum bipartite matching. Therefore, both problems are equivalent areare NP-hard. NP-hard. However, However, both both of of these these problems problems are are solvable solvableare NP-hard. in in polynomial polynomial However,are NP-hard. time time both on on However, of bipartite bipartite theseAs problems bothwe graph. graph. discussed of theseBy By are Konig’s Konig’s solvable in problems an earlier in are polynomial section, solvable both time in polynomialof on the bipartite MIN-VERTEX-COVER time graph. on bipartite By Konig’s graph. and MAX- By Konig’s to finding the size of the maximum bipartite matching, which can be solved in O(V 3) time. Finding the size of the theorem,theorem, the the size size of of the the minimum minimum vertex vertex cover cover in in bipartite bipartitetheorem, graph graph the is issizetheorem, equal equal of the to to the minimumthe size size of of vertex the theINDEPENDENTSET maximumminimum maximum cover in vertex bipartite bipartite cover problems graph in bipartite is areequal NP-hard. graphto the is size However, equal of the to the maximum both size of of these bipartite the problemsmaximum are bipartite maximum matching in bipartite graph using Hopcroft-Karp algorithm or Maximum-Flow algorithm is much simpler matchingmatching (Bondy (Bondy & & Murty Murty 1976), 1976), and and the the size size of of the thematching maximum maximum (Bondy independent independentmatching & Murty set set (Bondy in 1976),in bipartite bipartite & and Murtysolvable graph thegraph 1976), size is isin ofequal equalpolynomial and the to tomaximumthe the the size time of independent theon maximumbipartite set graph. independent in bipartite By Konig’s setgraph in theorem, bipartite is equal tothe graph the size is of equal the to the to solve, as compared to using Edmonds Blossom algorithm on general graph. This is actually the solution of the numbernumber of of the the vertices vertices minus minus the the size size of of the the maximum maximumnumber bipartite bipartite of matching. matching. the verticesnumber Therefore, Therefore, minus of the the vertices both both size problems problemsminimum of minus the maximum the are arevertex size equivalent equivalent of cover bipartite the maximumin bipartite matching. bipartite graph Therefore, is matching. equal both to the Therefore, problems size of the are both maximum equivalent problems bipartite are equivalent 5th subtask of IOI 2014 Friend. toto finding finding the the size size of of the the maximum maximum bipartite bipartite matching, matching,to which which finding can can the be be size solved solvedto finding of the in inOO maximum the((VV33 size))time.time. of bipartite thematching Finding Finding maximum matching, the the(Bondy size size bipartite of of whichand the the Murty, matching, can be 1976), solved which and in can Othe( beV size3 solved) time. of the in Finding Omaximum(V 3) thetime. sizeindependent Finding of the the set size in of the maximummaximum matching matching in in bipartite bipartite graph graph using using Hopcroft-Karp Hopcroft-Karpmaximum algorithm algorithm matchingmaximum or or Maximum-Flow Maximum-Flow in bipartite matching graph algorithm algorithm in bipartiteusing isHopcroft-Karp is much muchgraph simpler simpler using algorithmHopcroft-Karp or Maximum-Flow algorithm or Maximum-Flow algorithm is much algorithm simpler is much simpler toto solve, solve, as as compared compared to to using using Edmonds Edmonds Blossom Blossom algorithm algorithmto solve, on on as general general comparedto graph. solve, graph. to as This using This compared is is Edmonds actually actually to using the Blossom the solution solution Edmonds algorithm of of theBlossom the on general algorithm graph. on generalThis is actually graph. This the solution is actually of the solution of the 55thth subtasksubtask of of IOI IOI 2014 2014 Friend. Friend. 5th subtask of IOI5th 2014subtask Friend. of IOI 2014 Friend. 4.3 Directed Acyclic Graph A directed acyclic graph is a directed graph that does not contain any cycle. Similar to planar and bipartite graphs, there are several graph problems that are much easier to solve if the graph is a directed acyclic graph. 4.34.3 Directed Directed Acyclic Acyclic Graph Graph 4.3 Directed4.3 Acyclic Directed Graph Acyclic Graph 4.3.1 Minimum Path Cover AA directed directed acyclic acyclic graph graph is is a a directed directed graph graph that that does does notA not directed contain contain acyclic any anyA cycle. cycle. directed graph Similar Similar is acyclic a directed to to planar planargraph graph andis and a thatdirectedbipartite bipartite does graph graphs, graphs, not contain that does any not cycle. contain Similar any to cycle. planar Similar and bipartite to planar graphs, and bipartite graphs, therethere are are several several graph graph problems problems that that are are much much easier easierthere to to solve solve are if severalif the thethere graph graph graph are is is problems a aseveral directed directed graph that acyclic acyclic are problems much graph. graph. easierthat are to much solve if easier the graph to solve is a if directed the graph acyclic is a directed graph.MIN-PATH-COVER acyclic graph. is a problem that requries us to find the minimum number of vertex-disjoint paths needed to cover all of the vertices in a graph. By a simple reduction from Hamiltonian Path, this problem is NP-hard. 4.3.14.3.1 Minimum Minimum Path Path Cover Cover 4.3.1 Minimum4.3.1 Path Minimum Cover Path Cover A graph has a Hamiltonian Path if and only if we only need one path to cover all of the vertices. However, this problem can be solved in polynomial time for a directed acyclic graph. For a graph G =(V,E), we create a new MIN-PATH-COVERMIN-PATH-COVER is is a a problem problem that that requries requries us us to toMIN-PATH-COVER find find the the minimum minimumMIN-PATH-COVER number number is a problem of of vertex-disjoint vertex-disjoint that is a requries problem paths paths us that to needed needed find requries the minimum us to find number the minimum of vertex-disjoint number of vertex-disjointpaths needed paths needed graph G =(V V ,E), where V = V = V and E = (u, v) V V :(u, v) E . Then it can be toto cover cover all all of of the the vertices vertices in in a a graph. graph. By By a a simple simple reduction reductionto cover all from from of Hamiltoniantothe Hamiltonian cover vertices all of in Path, Path, thea graph. vertices this this problem problem By in a a simple graph. is is NP-hard. NP-hard. reduction By a simple from reduction Hamiltonian from Path, Hamiltonian this problem Path, is this NP-hard. problemout is NP-hard.∪ in out in { ∈ out × in ∈ } shown by Konig’s Theorem that G has a matching of size m if and only if there exist V m vertex-disjoint AA graph graph has has a a Hamiltonian Hamiltonian Path Path if if and and only only if if we we only onlyA need graph need one one has path path aA Hamiltonian tograph to cover cover has all all aPath of ofHamiltonian the the if and vertices. vertices. only Path ifHowever, However, we if onlyand onlythis needthis if one we path only needto cover one all path of theto cover vertices. all of However, the vertices. this However, this | |− paths that cover all of the vertices in G. problemproblem can can be be solved solved in in polynomial polynomial time time for for a a directed directedproblem acyclic acyclic can graph. graph. beproblem solved For For a a in graphcan graph polynomial beGG solved=(=(V,EV,E time in) polynomial),, for we we a create create directed time a a new new acyclic for a directed graph. For acyclic a graph graph.G =( ForV,E a graph), weG create=(V,E a new), we create a new graphgraphGG =(=(VVout VVin,E,E)),, where whereVVout ==VVin ==VV andandgraphEEG== =(((u,u,V v v)graph) VVVoutG,E=(VV)in,V whereout:(:(u,u, vV v)V)in,EEE=).,.V whereThen Then= V it itVout canand can= beE beV in= =(u,V vand) EV = (Vu, v):(u,V vout) EVin. Then:(u, v it) canE be. Then it can be out ∪∪ in out in {{ out∈∈∪ outin ×× in ∪ out∈∈ }} in { ∈ out ×{ in ∈ ∈× } ∈ } shownshown by by Konig’s Konig’s Theorem Theorem that that GG hashas a a matching matching ofshown of size size bymm if Konig’sif and andshown only only Theorem if by if there there Konig’s that exist existG TheoremVVhas amm matching thatvertex-disjointvertex-disjointG has of asize matchingm if and of only size ifm thereif and exist onlyV if therem vertex-disjoint exist V m vertex-disjoint 4.4 Miscellaneous || |−|− | |− | |− pathspaths that that cover cover all all of of the the vertices vertices in inGG.. paths that coverpaths all of that the cover vertices all inofG the. vertices in G. 4.4.1 Special case of CNF-SAT problem

4.44.4 Miscellaneous Miscellaneous 4.4 Miscellaneous4.4 Miscellaneous We will use Code Jam 2008 Round 1A ‘Milkshake’ problem for this example. This problem requires the contestant to find a solution with the minimum number of true variables that satisfy a CNF-SAT problem with up 4.4.14.4.1 Special Special case case of of CNF-SAT CNF-SAT problem problem 4.4.1 Special4.4.1 case Special of CNF-SAT case of problem CNF-SAT problem

WeWe will will use use Google Google Code Code Jam Jam 2008 2008 Round Round 1A 1A ‘Milkshake’ ‘Milkshake’We will problem problem use GoogleWe for for this willthis Code example.use example. Jam Google 2008 This This Code Round problem problem Jam 1A 2008 requires requires‘Milkshake’ Round the the 1A problem ‘Milkshake’ for this problem example. for This this example.problem requiresJonathan This problem the Irvin requires GUNAWAN the contestantcontestant to to find find a a solution solution with with the the minimum minimum number numbercontestant of of true true variables variables to findcontestant a that that solution satisfy satisfy to withfind a a CNF-SAT CNF-SAT a the solution minimum problem problem with number the with with minimum of up up true number variables of that true satisfy variables a CNF-SAT that satisfy problem a CNF-SAT with up problem with up

JonathanJonathan Irvin Irvin GUNAWAN GUNAWAN Jonathan IrvinJonathan GUNAWAN Irvin GUNAWAN of O(V 2). It is very difficult to find a solution (if any) faster than O(V 2) for this problem. However, there is an important constraint on the problem. The graph given in this problem is always a planar graph. We first relabel the ‘right’ vertices in ascending order according toof theOy((V-coordinate.22)).. It It is is very very The difficult difficult planar to to properties find find a a solution solution ensures (if (if that any) any) for faster faster every than than O((V 22)) forfor this this problem. problem. However, However, there there is is an an 2 2 of O(V 2). It is very difficultof toO( findV 2). a It solution is very (if difficultof any)O( fasterV to2) find. It‘left’ than ais solution very vertex,O(V difficult2) the(ifforof any) sequence this toO(V find fasterproblem.2). a of It solution than ‘right’is However,veryO( visitableV difficult(if2) any)for there this vertices fasterto is find problem. an thanimportantimportant a from solutionO that( However,V 2 constraint) constraint ‘left’(iffor any) this vertex there faster problem. on on is is the thean a than contiguous problem. problem. However,O(V 2) sequence,The Thefor there this graph graph is problem. an assuming given given in in However, that this this problem problem there is is is always always an a a planar planar graph. graph. We We first first relabel relabel important constraint on theimportant problem. constraint The graph on givenimportantimportant the problem.in this constraint constraintwe problem have The graph removed ison on always the theimportant given problem. problem. all a in ‘right’planar this constraint The The problemvertices graph. graph graph We onwhich is given given always the firstare problem. in in relabel a this thisnot planarthethe problemvisitable problem The ‘right’ ‘right’ graph. graph is isfrom vertices vertices always always We given any first ain a in ‘left’ in planarrelabel planar ascending ascending this vertex. problem graph. graph. order order With We We isaccording alwaysaccording this first first property, relabel relabel a planar to to the the there graph.y-coordinate.-coordinate. is a We first The The relabel planar planar properties properties ensures ensures that that for for every every the ‘right’ vertices in ascendingthe ‘right’ order vertices according in to ascendingthe the ‘right’y-coordinate. order verticesO(V accordinglog inTheV ascending) planarsolution tothe the ‘right’ propertiesy order (-coordinate.CEOI vertices according 2011 ensuresSolutions in The ascending to that planar the foryn.d.).-coordinate. everyproperties order‘left’‘left’ according vertex, vertex, ensures The planar theto the that the sequence sequence properties fory-coordinate. every of of ‘right’ ‘right’ ensures The visitable visitable that planar for vertices vertices properties every from from ensures that that ‘left’ ‘left’ that vertex vertex for every is is a a contiguous contiguous sequence, sequence, assuming assuming that that ‘left’ vertex, the sequence of‘left’ ‘right’ vertex, visitable the sequence vertices‘left’‘left’ from of vertex, vertex,‘right’ that ‘left’ visitable the the sequence sequence vertex vertices is ofa of‘left’ contiguous ‘right’ ‘right’from vertex, that visitable visitable ‘left’the sequence, sequence vertices vertices vertex assuming is from from of a contiguous‘right’ that that that visitable ‘left’ ‘left’we have sequence, vertex vertex vertices removed is is a aassuming contiguous contiguous from all that‘right’ that ‘left’ sequence, sequence, vertices vertex which assuming assuming is a contiguous are that that not visitable sequence, from assuming any ‘left’ that vertex. With this property, there is a we have removed all ‘right’we vertices have removed which are all not ‘right’we visitable have vertices removed from which any all ‘left’are ‘right’ not vertex.we visitablevertices have With removed which from this any are property, all ‘left’not ‘right’ visitable4.2 vertex. there vertices is Bipartite fromWith aO which((V any thisloglog are ‘left’ property,V )) not Graphsolutionsolution vertex. visitable there ( (With CEOI is from a this 2011 any property, Solutions ‘left’ vertex. theren.d.). is With a this property, there is a O(V log V ) solution (CEOIO 2011(V log SolutionsV ) solutionn.d.). (CEOIO(V 2011log V Solutions) solutionn.d.). (CEOIO 2011(V log SolutionsV ) solutionn.d.). (CEOI 2011 Solutions n.d.). Bipartite graph is a graph in which the vertices can be partitioned into two disjoint sets U and V such that all edges connect a vertex from U and a vertex from V . Some problems have a bipartite graph4.2 as an input Bipartite although Graph 4.2 Bipartite Graph4.2 Bipartite Graph4.2 Bipartite Graph4.2 Bipartite Graph the problem statement does not explicitly state thatBipartite the given graph input is graph a graph must in be which bipartite. the vertices The problem can be that partitioned we into two disjoint sets U and V suchsuch that that all all Bipartite graph is a graphBipartite in which thegraph vertices is a graph canBipartite be in partitioned which graphused the is as vertices into a an graph two introduction canBipartite indisjoint which be partitioned sets graph forthe thisU vertices isand paper, ainto graphV can twosuch IOI be in disjoint that2014 which partitioned all Friendedgesedges sets the verticesU into connectis connectand a verytwo V can asuch a disjoint good vertex vertex be that partitioned example. setsfrom from all UUandand The intoV a construction two vertexsuch disjoint that from all ofsetsV .. the Some SomeU graphand problems problemsV such havethat have all a a bipartite bipartite graph graph as as an an input input although although edges connect a vertex fromedgesU and connect a vertex a vertex from Vedges from. SomeU connectand problemsin a subtask avertex vertex have from 5 from a ofedges bipartiteV thisU. Someand problemconnect grapha problems vertex a implicitly as vertex from an have input fromV ensuresa. Somebipartite althoughU and problemsthatthe athe graph vertex the problem problem asfinal have from an graphstatement astatement inputV bipartite. Some althoughwill doesdoes always graph problems not not as be explicitly explicitly an have bipartite. input a bipartite state state although There that that graph are the the several given given as an input input input graph graph although must must be be bipartite. bipartite. The The problem problem that that we we the problem statement doesthe not problem explicitly statement state that doesthe the problem not given explicitly inputgraph statement graph problems state does must thatthe that not the be problem explicitlybipartite. aregiven NP-hard input statement state The graph for problem that general does must the not that given be graph explicitly bipartite. we inputused but solvable graphas state The an that mustproblemintroduction in polynomialthe be given thatbipartite. forwe input time this The graph if paper,theproblem must graph IOI that be 2014 is bipartite. bipartite. we Friend Theis Since a problemvery good that example. we The construction of the graph used as an introduction forused this as paper, an introduction IOI 2014 Friendused for thisas is an a paper, very introductionbipartite good IOI graph2014 example. forused Friend and this asbipartite The paper, is an a construction introductionvery IOI matching good 2014 example. Friend of wasfor the this recently isgraph Theapaper, veryinin construction included subtask subtask goodIOI 2014 example.in 5 5 of ofIOIFriend of this this 2015the The problemis problem graph asyllabus construction very implicitly implicitlygood (Forisek example. of ensures ensures 2015),the graph The we that that construction can the the expect final final graph graph of the will will graph always always be be bipartite. bipartite. There There are are several several in subtask 5 of this problemin subtask implicitly 5 ensures of this problem thatinin subtask subtask the implicitly final 5 5that graph of of this this ensures willtypeproblem problem always that ofin problem subtask implicitly implicitly the be finalbipartite. may 5 graphof ensures ensures be this There conceived will problem that that always are the the inseveral implicitly final final be the bipartite.graph near graph graph ensures future problems will will There always alwaysof that IOI. that are the beWe be severalare final bipartite. bipartite. will NP-hard graph take a There There forwill look general always at are are several several several graph be bipartite. examples. but solvable There in arepolynomial several time if the graph is bipartite. Since graph problems that are NP-hardgraph problems for general that graph aregraph but NP-hard solvable problems for ingeneral that polynomial are graph NP-hardgraph time but solvable problemsif for the general graph in that polynomial graph is are bipartite. NP-hard but time solvable Since iffor thebipartite general in graph polynomial graph graph is bipartite. but andtime solvable bipartite if Since the graph in matching polynomial is bipartite. was time recently Since if the included graph is inbipartite. IOI 2015 Since syllabus (Forisek 2015), we can expect bipartite graph and bipartitebipartite matching graph was and recently bipartitebipartite included matching graph in IOI and was 2015 bipartite recently syllabusbipartite4.2.1 matchingincluded (Forisek Vertex graph in was 2015),IOI and recently Cover 2015 bipartite we syllabus can included and matching expect Independent (Forisek inthatthat IOI was this this 2015),2015 recently type type syllabus Set we of of canincluded problem problem(and (Forisek expect maximum mayin may IOI 2015), be be 2015 conceived conceived matching) we syllabus can expectin in (Forisekthe the near near 2015), future future ofwe of IOI. IOI. can We We expect will will take take a a look look at at several several examples. examples. that this type of problem maythat be this conceived type of problem in the near may future be conceived of IOI. We in the will near take future a look of at IOI. several We willexamples. take a look at several examples. that this type of problem maythat be this conceived type of problem in thethat near may this future be type conceivedAs of of we IOI. problem discussed We in thewill may nearin take an be future a earlier conceived look of at section, IOI. several in Wethe both examples. willnear of take future the aMIN-VERTEX-COVER look of IOI. at several We will examples. take a and look MAX-INDEPENDENT-SET at several examples. problems 4.2.1 Vertex Cover and Independent Set (and maximum matching) are NP-hard. However, both of these problems are solvableJ.I. in Gunawan polynomial time on bipartite graph. By Konig’s 4.2.1 Vertex Cover and4.2.1 Independent Vertex Cover Set4.2.1 (and and Vertex Independent maximum Cover96 matching) Set and4.2.1 (and Independent Vertex maximum Cover matching) Set and(and Independent maximum matching) Set (and maximum matching) theorem, the size of the minimum vertex cover inAs bipartite we discussed graph inis equalan earlier to the section, size of both the of maximum the MIN-VERTEX-COVER bipartite and MAX-INDEPENDENT-SET problems As we discussed in an earlierAs section, we discussed both of in the an MIN-VERTEX-COVER earlierAs we section, discussedmatching both in anof the(Bondyand earlier MIN-VERTEX-COVER MAX-INDEPENDENT-SETAs section, we& Murty discussedbipartite both 1976), of ingraph the an and earlierMIN-VERTEX-COVER andis the equal MAX-INDEPENDENT-SET problems size section, to of the theare both number maximum NP-hard. of the and of MIN-VERTEX-COVERthe independentMAX-INDEPENDENT-SET However, vertices problems both minus set inof the bipartitethese size and problems of MAX-INDEPENDENT-SET graph problems the maximum is are equal solvable to the in polynomial problems time on bipartite graph. By Konig’s are NP-hard. However, bothare of NP-hard. these problems However, areare both solvable NP-hard. of these innumber polynomialHowever, problems of the both are time verticesare solvable ofNP-hard. on thesebipartite minus bipartite in problems However,the polynomial matching. graph. size areof both Bythe solvable timeTherefore, Konig’s maximum of on these inbipartitetheorem,theorem, polynomialboth problems bipartite problems graph. the the matching. are sizetime size By solvableare of of on Konig’s theequivalent the bipartite Therefore, minimum minimum in polynomial graph.to bothfinding vertex vertex problems By time cover cover Konig’sthe on size in inare bipartite bipartite bipartiteof equivalent the graph. graph graph By is is equal equalKonig’s to to the the size size of of the the maximum maximum bipartite bipartite 3 theorem, the size of the minimumtheorem, vertex the size cover of the intheorem, bipartite minimum the graphto vertex size finding is of equalcover the the minimum toin sizetheorem, bipartite the of size themaximum vertex the maximum of graph the size cover maximum is ofbipartite equal bipartite the in bipartite minimum to matching, bipartite the matching, size graph vertexmatching ofwhich which the is cover equal maximumcan (Bondy can in tobe be bipartite thesolved solved & bipartite size Murty in in graphof O 1976),the(V is maximum) equaltime. andtime. the to Finding bipartite the size size of thethe the of sizesize themaximumof maximum the independent bipartite set in bipartite graph is equal to the matching (Bondy & Murtymatching 1976), and (Bondy the size & of Murty thematching maximum 1976), (Bondy andmaximum independent the & size Murty matching ofmatching theset 1976), inmaximum in bipartiteof bipartiteand (Bondythe the maximum independent graph size graph & Murtyof is usingthe equalmatching 1976),maximumset Hopcroft-Karp to in the bipartitein andnumber bipartite independent the graphsize ofalgorithm graph the of is the verticesset equalusing maximum orin bipartiteMaximum-Flow toHopcroft-Karp minus the independent the graph size is algorithm ofalgorithm equal the set maximum toin is bipartite theor much Maxi bipartite simpler- graph is matching. equal to Therefore,the both problems are equivalent mum-Flow algorithm is much simpler to solve, as compared to using Edmonds Blos- 3 number of the vertices minusnumber the size of of the the vertices maximum minusnumber bipartite the of size theto matching.of solve,vertices the maximumas minus comparedTherefore,number the bipartite size to bothof using theof problemsmatching. the vertices Edmonds maximum minusare Therefore, Blossomequivalent bipartite the sizeboth algorithmtoto matching. of finding finding the problems maximum on the the Therefore, general aresize size equivalent ofbipartite of graph. the the both maximum maximum matching. problems This is bipartite bipartiteactually are Therefore, equivalent thematching, matching, solution both problems which which of the can can are be be equivalent solved solved in in O((V 3)) time.time. Finding Finding the the size size of of the the th som algorithm on general graph. This is actually 3the solution of the 5th subtask3 of IOI to finding the size of the maximumto finding bipartite the size matching, of theto maximum finding which the can5 bipartite size besubtask solved of matching,the of inmaximum IOItoO finding(V 2014 which3) time. bipartite Friend. the can size Finding be matching, of solved the the maximum in sizeO which( ofV 3 the) can bipartitetime.maximum be Finding solved matching, matching in theO( sizeV which in) oftime. bipartite the can Finding be graph solved the using in sizeO( Hopcroft-KarpV of) thetime. Finding algorithm the size or of Maximum-Flow the algorithm is much simpler 2014 Friend. maximum matching in bipartitemaximum graph matching using Hopcroft-Karp in bipartitemaximum graphalgorithm matching using or in Hopcroft-Karp Maximum-Flow bipartitemaximum graph algorithm matching algorithm using Hopcroft-Karp or in is Maximum-Flow bipartite much simpler graph algorithmtoto usingalgorithm solve, solve, or Hopcroft-Karp as asMaximum-Flow compared comparedis much simpler to to algorithm usingalgorithm using Edmonds Edmonds or is Maximum-Flow much Blossom Blossom simpler algorithm algorithm algorithm on on is general general much simpler graph. graph. This This is is actually actually the the solution solution of of the the to solve, as compared to usingto solve, Edmonds as compared Blossom to algorithmto using solve, Edmonds as on compared general Blossom graph. to usingto algorithm This solve, Edmonds is as actually on compared general Blossom the graph.solution to algorithm using This of Edmonds the on is5 actuallyth generalth subtasksubtask Blossom graph.the of of solution algorithm IOI IOI This 2014 2014 isof actually Friend. Friend.theon general the graph. solution This of the is actually the solution of the th th thth th 5 subtask of IOI 2014 Friend.5 subtask of IOI 20145 Friend.subtask of IOI 2014 Friend.5 subtask4.3. ofDirected IOI 20144.3 Acyclic Friend. Directed Graph Acyclic Graph A directed acyclic graph is a directed graph that does not contain any cycle. Similar to planar and bipartite graphs, there are several graph problems that are much easier to solve if the graph is a directed4.3 acyclic Directed graph. Acyclic Graph 4.3 Directed Acyclic4.3 GraphDirected AcyclicA4.3 directed Directed acyclic Graph graph Acyclic is a4.3 directed Directed Graph graph that does Acyclic not contain Graph any cycle. Similar to planar and bipartite graphs, Athere directed are several acyclic graph graph problems is a directed that graph are much that doeseasier not to contain any cycle. Similar to planar and bipartite graphs, A directed acyclic graph is aA directed directed graph acyclic that graph doesA is directed not a directed contain acyclic graph any graph cycle. that is does SimilarA a directed not tosolve contain planar graphacyclic if the any and that graph graph cycle. bipartite does is4.3.1is Similara not a directeddirected graphs, contain Minimum totherethere planar graphacyclic any are are cycle. thatand Pathgraph. several several bipartite does Similar Cover graph graphnot graphs, to contain problems problemsplanar any and that thatcycle. bipartite are are Similar much much graphs, to easier easier planar to to and solve solve bipartite if if the the graph graph graphs, is is a a directed directed acyclic acyclic graph. graph. there are several graph problemsthere are that several are much graph easier problems to solve that if are the much graph easier is a directed to solve acyclic if the graph graph. is a directed acyclic graph. there are several graph problemsthere are that several are much graph easierthere problems to are solve several thatMIN-PATH-COVER if theare graph muchgraph problems easier is a directed to is that solve a problem are acyclic if muchthe graph. graphthat easier requries is toa directed solve usto if the acyclic find graph the graph. minimum is a directed number acyclic of graph. vertex-disjoint paths needed 4.3.1. Minimum Path Cover to cover all of the vertices in a graph. By a simple reduction from Hamiltonian Path, this4.3.1 problem Minimum is NP-hard. Path Cover MIN-PATH-COVER4.3.1 Minimum is a Path problem Cover4.3.1 that requiresMinimum us Path to find Cover the minimum number of 4.3.1 Minimum PathA graph Cover4.3.1 has aMinimum Hamiltonian Path4.3.1 Path Cover if and Minimum only if Pathwe only Cover need one path to cover all of the vertices. However, this vertex-disjoint paths needed MIN-PATH-COVER to cover all of the vertices is a problem in a graph. that requries By a simple us to refind- the minimum number of vertex-disjoint paths needed G V,E MIN-PATH-COVER is a problemMIN-PATH-COVER that requries usisMIN-PATH-COVER a to problem find the thatproblem minimum requries can is number a be us problemMIN-PATH-COVER solvedto find ofduction vertex-disjointthat in the polynomial requriesminimum from isHamiltonian us time paths anumber to problem findfor needed a ofthe directed Path,that vertex-disjointtoto minimum cover cover requries this acyclic problem all all number usof of graph. paths theto the is find vertices ofvertices NP-hard. needed For vertex-disjoint the a graphminimum in in A a a graph graph. graph.=( numberpaths has By By a aneeded a) Hamiltonian, simpleof simple we vertex-disjoint create reduction reduction a new from from paths Hamiltonian Hamiltonian needed Path, Path, this this problem problem is is NP-hard. NP-hard. graph G =(V V ,E), where V = V = V and E = (u, v) V V :(u, v) E . Then it can be to cover all of the verticesto in cover a graph. all of By the a simple verticesto reduction cover in a allgraph. of from the By Hamiltonian vertices a simpleoutto in cover∪ reduction a Path, graph.inPath all this of if Byfrom andthe problem a verticesHamiltoniansimpleonlyout if is reduction we NP-hard.in in a only graph.Path, A need from graph this By one Hamiltonian problem a has simplepath{ a toHamiltonian is reduction cover NP-hard.∈ Path, out all this × offrom Path thein problem Hamiltonian if vertices. and is only∈ NP-hard. However,} if Path, we only this this need problem one path is NP-hard. to cover all of the vertices. However, this shown by Konig’s Theorem that G has a matching of size m if and only if there exist V m vertex-disjoint A graph has a HamiltonianA Path graph if andhas a only Hamiltonian if weA only graph Path need has if one and a Hamiltonian path only to if cover weA only Path graph all need of ifproblem has theand one a vertices. only Hamiltonian path can if bewe to However, solved coveronly Path need all in this ofif polynomial one andproblem the path onlyvertices. tocan if time wecover be However, only for solved all a need of directed in the this one polynomial vertices. pathacyclic to However, time graph.cover| |− for all For a this of directed a the graph vertices. acyclic However, graph. For this a graph G =(V,E)),, we we create create a a new new G problem can be solved in polynomialproblem can time be for solved a directed inproblem polynomial acyclic canpaths be graph. time solved that for For covera in directed a polynomialproblem graph all of acyclicG the can=( time vertices beV,E graph. forsolved) , awe wein directed For increate create. polynomial a graph a acyclic anew newG graphgraph=( time graph.V,E G for) For=(, a we directedV aout create graphV acyclicinG a,E,E new=())V,E ,, graph. where where where), we ForVout create a= graphVin a new=GV=( andandV,E E),= we(( createu, v)) aV newout Vin :(:(u, v)) E .. Then Then it it can can be be out ∪ in out in { ∈ out × in ∈ } graph G =(Vout Vin,E)graph, whereGV=(outV=outVin V=inVgraph,Eand), whereGE =(= VV(outoutu, v=) VVininV,Eout=graphV),, where whereVandinG:(E u,V=(=out vV) out(=u,EV vin)V.=in ThenV,EVoutand) it, where canVEin = be:(shownVshownu,out(u, v)= v) by byVEinV Konig’s Konig’s ..out= Then ThenV and Vit Theoremitin Theorem can canE:(:( beu,= be vshown)( that thatu,E v )byG.. Konig’s Then ThenVhasout a it itmatching VTheorem can canin :( be beu,v that of) size E .m Thenifif and and it can only only be if if there there exist exist V m vertex-disjoint ∪ ∪ { ∪ ∈ × {∈ ∪} ∈ × { ∈ ∈ } × { ∈ }∈ × ∈ } || |−|− shown by Konig’s Theoremshown that G by has Konig’s a matching Theoremshown of that size by Konig’sGm ifhas and a Theorem matching only ifshown there that of size byG exist Konig’shashasmV if a and matching Theoremm onlyvertex-disjoint ifof of4.4 there thatsize size G existm Miscellaneouspaths hasififif and andandV a that matching only onlym cover vertex-disjoint if ifif there therethere all of of size exist exist them verticesVif andm only in vertex-disjointvertex-disjointG. if. there exist pathsV m vertex-disjoint | |− | |− | |− | |− paths that cover all of the verticespaths that in G cover. all of thepaths vertices that cover in G. all of thepaths vertices thatthat in coverGcover. allall ofof thethe vertices in in G .. 4.4.1 Special case of CNF-SAT problem 4.4 Miscellaneous We will use Google Code Jam4.4 2008 Round Miscellaneous 1A ‘Milkshake’4.4 problem Miscellaneous for this example. This problem requires the 4.4 Miscellaneous4.4 Miscellaneous4.4. Miscellaneous4.4 Miscellaneous contestant to find a solution with the minimum number of true variables that satisfy4.4.1 a CNF-SAT Special problem case with of CNF-SAT up problem 4.4.1 Special case of4.4.1 CNF-SAT Special problem case4.4.1 of CNF-SAT Special problem case of4.4.1 CNF-SAT Special problem case of CNF-SAT problem 4.4.1. Special Case of CNF-SATWe willProblem use 2008 Round 1A ‘Milkshake’ problem for this example. This problem requires the We will use Google Code JamWe will2008 use Round Google 1A Code ‘Milkshake’We Jam will 2008use problemJonathan Google Round for Code 1A Irvin this ‘Milkshake’ JamWe GUNAWANexample. will 2008We use ThisRoundproblem will Google problemuse 1A forGoogle Code ‘Milkshake’ this requires Jam example.Code 2008 theJam problemcontestantcontestant Round This2008 forproblem Round 1A this to to ‘Milkshake’ find find example. 1A requires a‘Milkshake’ a solution solution problemthe This with with problem problem for the the this minimum minimum requires for example. this the numberexample. number This of ofproblem true true variables variables requires that that the satisfy satisfy a a CNF-SAT CNF-SAT problem problem with with up up contestant to find a solutioncontestant with the minimum to find a solution numbercontestant withof true the to variables find minimum a solution that numbercontestant satisfy with ofThis the a true CNF-SAT to minimum problem findvariables a problemsolution numberrequires that satisfy withof the true theupcontestant a CNF-SATvariables minimum to that problemfind number satisfy a solution withof a true CNF-SAT up variableswith the problem thatminimum satisfy with number up a CNF-SAT of problem with up true variables that satisfy a JonathanCNF-SAT Irvin problem GUNAWAN with up to 2,000 variables (Google Jonathan Irvin GUNAWANJonathan Irvin GUNAWANJonathan Irvin GUNAWANJonathanCode Irvin Jam GUNAWAN 2008 Round 1A, ‘Milkshake’ problem, n.d.). The CNF-SAT is a satisfiability problem given in a conjunctive normal form (i.e. conjunction of disjunction of literals) which was proven to be NP-hard (Cook, 1971). Therefore, it is unlikely that there is an algorithm to solve a CNF-SAT problem with 2,000 variables in less than 8 minutes3. However, there is a special property in this problem, in which at most one unnegated literal exists in each clause. Therefore, all clauses can be converted into Horn clauses. With this property, a linear time algorithm exists. (Google Code Jam 2008 Round 1A, ‘Milkshake’ solution, n.d.).

3 In Google Code Jam, contestants are given 8 minutes to produce the output upon downloading the input. Understanding Unsolvable Problem 97

5. Conclusion

In conclusion, we can use a well-known reduction technique to prove that a problem that we are currently attempting to solve is impossible (or at least it is very hard such that no people has been able to solve it for more than 40 years). In competitive programming (including IOI), understanding this technique is essential so that we will not be stuck at trying to solve an impossible problem, thus prompting us to find another way to solve the problem. To prove that a problem is NP-hard, it is good to know as many NP-hard problems as possible, so that we can reduce from any one of the problems that we know to the new problem. Some of the classic NP-hard problems include 3-SAT, Vertex Cover, Independent Set, and Subset Sum. After realizing that the problem is NP-hard, we must be able to find the special case that makes the problem solvable. We must be able to find a special property that breaks the reduction proof. Having a lot of practice on these kind of problems will help us to familiarize with the possibilities of a special case. Some of the common special cases include planar, bipartite, and directed acyclic graph.

References

ACM ICPC World Finals 2010 Problem Statement (n.d.). Available via : http://icpc.baylor.edu/download/worldfinals/problems/2010WorldFinalProblemSet.pdf ACM ICPC World Finals 2010 Solutions (n.d.). Available via internet: http://www.csc.kth.se/~austrin/icpc/finals2010solutions.pdf Bondy, J.A., Murty, U. S. R. (1976). with Applications, Vol. 290, London: Macmillan. CEOI 2011 Solutions (n.d.). Available via internet: http://ceoi.inf.elte.hu/probarch/11/ceoi2011booklet.pdf CEOI 2011. ‘Traffic’ Problem(n.d.), available via internet: http://ceoi.inf.elte.hu/probarch/11/trazad.pdf Cook, S.A. (1971). The complexity of theorem-proving procedures. In: Proceedings of the Third Annual ACM Symposium on Theory of Computing. ACM, 151–158. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C. (2009). Introduction to (3rd ed.). MIT Press. Forišek, M. (2015). International olympiad in informatics 2015 syllabus. Available via internet: https://people.ksp.sk/~misof/ioi-syllabus/ioi-syllabus.pdf Gonthier, G. (2005). A computer-checked proof of the four colour theorem. Available via internet: http://research.microsoft.com/en-us/people/gonthier/4colproof.pdf Google Code Jam 2008 Round 1A, ‘Milkshake’ Problem (n.d.). Available via internet: https://code.google.com/codejam/contest/32016/dashboard#s=p1 Google Code Jam 2008 Round 1A, ‘Milkshake’ solution (n.d.). Available via internet: https://code.google.com/codejam/contest/32016/dashboard#s=a&a=1 Halim, S., Halim, F. (2013). Competitve Programming 3. lulu.com IOI 2008, ‘Island’ Problem (n.d.). Available via internet: http://www.ioinformatics.org/locations/ioi08/contest/day1/islands.pdf IOI 2014, ‘Friend’ Problem (n.d.). Available via internet: http://www.ioinformatics.org/locations/ioi14/contest/day2/friend/friend.pdf West, D. B. et al. (2001). Introduction to Graph Theory, Vol. 2. Prentice hall Upper Saddle River. 98 J.I. Gunawan

J.I. Gunawan is an undergraduate student studying Computer Science in National University of Singapore. He participated a lot of program- ming contests, including IOI 2012 and 2013 and ACM ICPC World Finals 2014 and 2015. He is also the lead of the Scientific Committee of Indonesian Computing Olympiad team (TOKI) training Indonesian teams for IOI in 2015–2016.