in this paper we consider the complexity of problems related to the one - player combinatorial game flood - it , introduced by arthur , clifford , jalsenius , montanaro and sach in @xcite .
the original game is played on a board consisting of an @xmath1 grid of coloured squares , each square given a colour from some fixed colour - set , but we can more generally regard the game as being played on a vertex - coloured graph . a move
then consists of picking a vertex @xmath2 and a colour @xmath3 , and giving all vertices in the same monochromatic component as @xmath2 colour @xmath3 .
the goal is to make the entire graph monochromatic with as few such moves as possible .
when the game is played on a planar graph , it can be regarded as modelling repeated use of the flood - fill tool in microsoft paint .
implementations of the game , played on a square grid , are widely available online , and include a flash game @xcite as well as popular smartphone apps @xcite
. there also exist implementations using a hexagonal grid : mad virus @xcite is the same one - player game described above , while the honey bee game @xcite is a two player variant , and has been studied by fleischer and woeginger @xcite .
all these implementations are based on the `` fixed '' version of the game , where all moves must be played at the same fixed vertex ( usually the vertex corresponding to the top left square when the board is an @xmath1 grid ) .    for any coloured graph , we define the following problems .    * free - flood - it is the problem of determining the minimum number of moves required to flood the graph , if we are allowed to make moves anywhere in the graph .
* fixed - flood - it is the same problem when all moves must be played at a single specified vertex . * @xmath4-free - flood - it and @xmath4-fixed - flood - it respectively are the variants of free - flood - it and fixed - flood - it in which only colours from some fixed set of size @xmath4 are used .
note that we can trivially flood an @xmath5-vertex graph with @xmath6 moves , and that if @xmath4 colours are present in the initial colouring we require at least @xmath7 moves .
these problems are known to be computationally difficult in many situations . in @xcite ,
arthur , clifford , jalsenius , montanaro and sach proved that @xmath4-free - flood - it is np - hard in the case of an @xmath1 grid , for every @xmath8 , and that this result also holds for the fixed variant .
lagoutte , noual and thierry @xcite showed that the same result holds when the game is played instead on a hexagonal grid , as in mad virus or a one - player version of the honey bee game .
fleischer and woeginger @xcite proved that @xmath4-fixed flood it remains np - hard when restricted to trees , for every @xmath9 , and fukui , nakanishi , uehara , uno and uno @xcite demonstrated that this result can be extended to show the hardness @xmath4-free flood it under the same conditions .
a few positive results are known , however .
2-free - flood - it is solvable in polynomial time on arbitrary graphs , a result shown independently by clifford et .
@xcite , lagoutte @xcite and meeks and scott @xcite .
it is also known that fixed - flood - it and free - flood - it are solvable in polynomial time on paths @xcite and cycles @xcite , and more generally on any graph with only a polynomial number of connected subgraphs @xcite .
meeks and scott also show that the number of moves required to create a monochromatic component containing an arbitrary , bounded - size subset of the vertices can be computed in polynomial time , even when the number of colours is unbounded @xcite .    a major focus of previous research has been the restriction of the game to rectangular boards of fixed height .
although an additive approximation for @xmath4-free - flood - it can be computed in polynomial time @xcite , solving either @xmath4-free - flood - it or @xmath4-fixed - flood - it exactly remains np - hard on @xmath10 boards , whenever @xmath9 @xcite .
however , clifford et .
al .  @xcite
give a linear time algorithm for fixed - flood - it on @xmath0 boards .
they also raise the question of the complexity of the free variant in this setting .    here
we address this remaining case of ( @xmath4-)free - flood - it restricted to @xmath0 boards , which turn out to be a particularly interesting class of graphs on which to analyse the game .
the majority of the paper describes an algorithm to demonstrate that @xmath4-free - flood - it , restricted to @xmath0 boards , is fixed parameter tractable with parameter @xmath4 . to do this
we exploit some general results from @xcite about the relationship between the number of moves required to flood a graph and its spanning trees .    on the other hand ,
we also show that free - flood - it remains np - hard in this setting .
this is a somewhat surprising result , as it gives the first example of a class of graphs on which the complexity of fixed - flood - it and free - flood - it has been shown to be different .    the rest of the paper is organised as follows .
we begin with notation and definitions in section [ notation ] , before giving our algorithm for @xmath4-free - flood - it in section [ fpt ] .
finally , in section [ nphard ] , we show that the problem remains np - hard when the number of colours used is unbounded .
although the original flood - it game is played on a square grid , and our main results here concern the game restricted to a rectangular grid , it is convenient to consider the generalisation of the game to an arbitrary graph @xmath11 , equipped with an initial colouring @xmath12 using colours from the _ colour - set _ @xmath13
. then each move @xmath14 consists of choosing some vertex @xmath15 and a colour @xmath16 , and assigning colour @xmath3 to all vertices in the same monochromatic component as @xmath2 .
the goal is to give every vertex in @xmath17 the same colour , using as few moves as possible .    given any connected graph @xmath17 , equipped with a colouring @xmath12 ( not necessarily proper ) , we define @xmath18 to be the minimum number of moves required in the free variant to give all its vertices colour @xmath3 , and @xmath19 to be @xmath20 . if @xmath21 is a sequence of moves played on a graph @xmath17 with initial colouring @xmath12 , we denote by @xmath22 the new colouring obtained by playing @xmath21 in @xmath17 .
note that , if the initial colouring @xmath12 of @xmath17 is not proper , we may obtain an equivalent coloured graph @xmath23 ( with colouring @xmath24 ) by contracting monochromatic components of @xmath17 with respect to @xmath12 .
let @xmath25 be any subset of @xmath26 .
we denote by @xmath27 the set of colours assigned to vertices of @xmath25 by @xmath12 .
we say a move @xmath28 is _ played in _
@xmath25 if @xmath29 , and that @xmath25 is _ linked _ if it is contained in a single monochromatic component .
subsets @xmath30 are _ adjacent _ if there exists @xmath31 with @xmath32 and @xmath33 .
when we consider the game played on a rectangular board @xmath34 , we are effectively playing the game in a corresponding coloured graph @xmath17 , obtained from the planar dual of @xmath34 ( in which there is one vertex corresponding to each square of @xmath34 , and vertices are adjacent if they correspond to squares which are either horizontally or vertically adjacent in @xmath34 ) by giving each vertex the colour of the corresponding square in @xmath34 .
we identify areas of @xmath34 with the corresponding subgraphs of @xmath17 , and may refer to them interchangeably .
we define a _ border _ of @xmath34 to be a union of edges of squares on the original board @xmath34 that forms a path from the top edge of the board to the bottom ( but not including any edges that form the top or bottom edge of the board ) .
thus , a border in @xmath34 corresponds to an edge - cut in the corresponding graph . observe that a border is uniquely defined by the points at which it meets the top and bottom of the board ,
so there are @xmath35 borders in total .
we denote by @xmath36 and @xmath37 the borders corresponding to the left - hand and right - hand edges of the board respectively . given two borders @xmath38 and @xmath39 , we write @xmath40 if and only if @xmath38 meets both the top and bottom of the board to the left of ( or at the same point as ) @xmath39 , and write @xmath41 if @xmath40 and @xmath42
. note that if @xmath40 then @xmath38 lies entirely to the left of @xmath39 ( the two borders may meet but never cross ) ; this is a special property of @xmath0 boards and does not hold for @xmath43 boards for @xmath44 .
if @xmath17 is the graph corresponding to the @xmath0 board @xmath34 , we say that a vertex ( or subgraph ) is _ incident _ with a border @xmath45 if the vertex ( or some vertex in the subgraph ) corresponds to a square on @xmath34 whose edge forms part of @xmath45 .
if @xmath41 are borders , we denote the subgraph induced by vertices lying between @xmath38 and @xmath39 by @xmath46 $ ] , and we say @xmath46 $ ] is a _ section _ if it is connected .    finally , given any tree @xmath47 ,
we denote by @xmath48 the subtree obtained by deleting all leaves of @xmath47 , and given any @xmath49 we set @xmath50 to be the unique path from @xmath51 to @xmath52 in @xmath47 .
in this section , we give an algorithm to solve @xmath4-free - flood - it on @xmath0 boards . more specifically ,
we prove the following result , which shows that @xmath4-free - flood - it , restricted to @xmath0 boards , is fixed parameter tractable , parameterised by @xmath4 .
this answers an open question of clifford , jalsenius , montanaro and sach @xcite .
when restricted to @xmath0 boards , @xmath4-free - flood - it can be solved in time @xmath53 .
[ 2xn - fpt ]    we begin with some background and auxiliary results in section [ background ] , and then describe the algorithm in section [ algorithm ] .      before describing our algorithm in the next section , we need a number of results which will be used to prove its correctness .
we begin with some previous results from @xcite .
meeks and scott prove that it suffices to consider spanning trees in order to determine the minimum number of moves required to flood a graph . for any connected graph @xmath17 ,
let @xmath54 denote the set of all spanning trees of @xmath17 .
let @xmath17 be a connected graph with colouring @xmath12 from colour - set @xmath13 .
then , for any @xmath16 , @xmath55 [ spanning - tree ]    for any @xmath16 , we say that @xmath47 is a _
@xmath3-minimal _ spanning tree for @xmath17 if @xmath56 .    in the remainder of this section
, we prove that in the special case in which @xmath17 corresponds to a @xmath0 board , there is always a @xmath3-minimal spanning tree @xmath47 such that @xmath48 is a path .    in doing so , and in proving the correctness of our algorithm in the next section
, we make use of a corollary of theorem [ spanning - tree ] , again proved in @xcite , which shows that the number of moves required to flood a graph is bounded above by the sum of the numbers of moves required to flood connected subgraphs which cover the vertex - set .
let @xmath17 be a connected graph , with colouring @xmath12 from colour - set @xmath13 , and let @xmath25 and @xmath34 be subsets of @xmath57 such that @xmath58 and @xmath59 , g[b]$ ] are connected .
then , for any @xmath16 , @xmath60 [ non - interference ]    a key step used to prove theorem [ spanning - tree ] in @xcite is to prove a special case of corollary [ non - interference ] , where the underlying graph @xmath17 is a tree and @xmath25 and @xmath34 are disjoint .
we will need the following result , proved using an extension of part of this proof from @xcite .
let @xmath47 be a tree , with colouring @xmath12 from colour - set @xmath13 , let @xmath25 and @xmath34 be disjoint subsets of @xmath61 such that @xmath62 and @xmath63 , t[b]$ ] are connected , and let @xmath51 be the unique vertex of @xmath34 with a neighbour in @xmath25 .
suppose that    * the sequence @xmath64 floods @xmath63 $ ] with colour @xmath65 , * the sequence @xmath66 floods @xmath67 $ ] with colour @xmath68 , * at least one move of @xmath66 changes the colour of @xmath51 , and * playing @xmath64 in @xmath47 changes the colour of @xmath51 .
then @xmath69 [ compatible - ordering ]    we proceed by induction on @xmath70 .
note that we may assume without loss of generality that @xmath12 gives a proper colouring of @xmath34 ; otherwise we may contract monochromatic components .
suppose @xmath71 .
then @xmath64 must change the colour of the only vertex in @xmath34 ( linking it to some @xmath32 ) , and so playing @xmath64 in @xmath47 makes the whole tree monochromatic with colour @xmath65 .
thus @xmath72 , and @xmath73 as required , since by assumption @xmath74 .
now suppose @xmath75 , so @xmath34 is not monochromatic initially , and assume that the result holds for smaller @xmath34
. set @xmath76 to be the initial segment of @xmath66 , up to and including the move that first makes @xmath34 monochromatic ( in any colour @xmath77 ) , so any final moves that simply change the colour of @xmath34 are omitted .
we may , of course , have @xmath78 ( and so @xmath79 ) , if @xmath34 is not monochromatic before the final move of @xmath66 .
suppose that @xmath80 does not change the colour of @xmath51 ( which is only possible in the case @xmath81 ) .
then playing @xmath80 in @xmath47 to make @xmath34 monochromatic can not change the colour of any vertex in @xmath25 , so if we play @xmath80 in @xmath47 and then play @xmath64 , this will still flood @xmath25 with colour @xmath65 .
moreover , as playing @xmath80 has not changed the colour of @xmath51 , playing @xmath64 will still change the colour of @xmath51 , thus linking all of @xmath34 to @xmath25 and so flooding @xmath47 with colour @xmath65 .
hence , in this case , we have @xmath82 and so , as we must in this case have @xmath83 , @xmath84 as required .
suppose now that @xmath80 does change the colour of @xmath51 .
before the final move of @xmath76 there are @xmath85 monochromatic components in @xmath34 ( all but one of which have colour @xmath77 ) , with vertex - sets @xmath86 . for @xmath87 , set @xmath88 to be the subsequence of @xmath76 consisting of moves played in @xmath89 , and note that these subsequences partition @xmath76 .
observe also that playing @xmath88 in @xmath90 $ ] gives @xmath89 colour @xmath77 , so @xmath91 .
let @xmath92 be the unique component adjacent to @xmath25 , and set @xmath93 $ ] .
note that @xmath64 floods @xmath94 $ ] with colour @xmath65 , and @xmath95 floods @xmath96 $ ] with colour @xmath77 . moreover , as playing @xmath64 in @xmath47 changes the colour of @xmath51 , playing @xmath64 in @xmath97 must also change the colour of @xmath51 . also , at least one move from @xmath66 changes the colour of @xmath51 , the unique vertex of @xmath92 with a neighbour in @xmath25 , and this move must belong to @xmath95 .
thus we can apply the inductive hypothesis to see that @xmath98
now suppose without loss of generality that @xmath99 is adjacent to @xmath92
. we can then apply corollary [ non - interference ] to @xmath100 $ ] to see that @xmath101 continuing in this way , each time adding an adjacent component , we see that @xmath102 now , if @xmath78 , this immediately gives the desired result , as @xmath79 . otherwise , note that @xmath103 and so @xmath104 as required .    in the next result
, we exploit this lemma to give a strengthening of corollary [ non - interference ] under additional assumptions .
this can be applied to show that , in certain situations , we may assume that _ no _ optimal sequence to flood a subtree can change the colour of any vertex outside the subtree , when played in a larger tree .
let @xmath47 be a tree , with colouring @xmath12 from colour - set @xmath13 , and let @xmath105 and @xmath106 be disjoint sutbrees of @xmath47 such that @xmath107 $ ] is connected , and such that    * there is a sequence @xmath108 of @xmath109 moves that floods @xmath105 with some colour @xmath110 , * there is a sequence @xmath111 of @xmath112 moves that floods @xmath106 with colour @xmath3 , and that changes the colour of the unique vertex @xmath113 , and * playing @xmath108 in @xmath47 changes the colour of at least one vertex in @xmath106 .
then , setting @xmath114 and @xmath115 , we have @xmath116 [ strong - non - int ]    note that @xmath108 must change the colour of @xmath2 , so we can apply lemma [ compatible - ordering ] to see that @xmath117,\omega , d ) \leq |s_x| + |s_y| = \alpha + \beta.\ ] ] corollary [ non - interference ] then gives @xmath118 , \omega , d ) + m(t',\omega',d ) \\                & \leq m(t',\omega',d ) + \alpha + \beta,\end{aligned}\ ] ] as required .    before proving the main result of this section ,
we need one further result , relating the number of moves required to flood the same graph with different initial colourings .
let @xmath17 be a connected graph , and let @xmath12 and @xmath24 be two colourings of the vertices of @xmath17 ( from colour - set @xmath13 ) .
let @xmath119 be the set of all monochromatic components of @xmath17 with respect to @xmath24 , and for each @xmath120 let @xmath121 be the colour of @xmath25 under @xmath24 .
then , for any @xmath16 , @xmath122 [ change - colouring ]    we proceed by induction on @xmath123 .
note that if @xmath124 then the result is trivially true : in this case @xmath119 contains a single monochromatic component @xmath17 , with colour @xmath3 , so we have @xmath125    suppose now that @xmath126 , and let @xmath21 be an optimal sequence of moves to flood @xmath17 with colour @xmath3 , when the initial colouring is @xmath24 .
we proceed by case analysis on the final move , @xmath109 , of @xmath21 .
first suppose that @xmath17 is already monochromatic before @xmath109 , so this final move just changes the colour of the entire graph to @xmath3 from some colour @xmath110 .
in this case , @xmath127 , and so we may apply the inductive hypothesis to see that @xmath128 as required .    now suppose that @xmath17 is not monochromatic before @xmath109 , and so this move links monochromatic components @xmath129 .
we may assume that @xmath109 changes the colour of @xmath130 from @xmath77 to @xmath3 , and that all the components @xmath131 have colour @xmath3 before @xmath109 .
let @xmath88 denote the subsequence of @xmath21 consisting of moves played in @xmath132 , and observe that playing @xmath88 in the isolated subgraph @xmath132 must flood this graph with colour @xmath3 , so @xmath133 .
note that , as no move can split a monochromatic component , the sets @xmath134 ( for @xmath87 ) partition @xmath119 .
observe that , for @xmath135 , @xmath136 , and so we may apply the inductive hypothesis to see that @xmath137 similarly , the inductive hypothesis gives @xmath138 and so , as @xmath139 , we have @xmath140 now we can apply corollary [ non - interference ] to see that @xmath141 and so @xmath142 completing the proof .    using the previous results
, we are now ready to prove the key result of this section .
let @xmath17 with colouring @xmath12 ( from colour - set @xmath13 ) be the graph corresponding to a @xmath0 flood - it board @xmath34 , let @xmath143 be a connected induced subgraph of @xmath17 , and let @xmath144 and @xmath145 be vertices lying in the leftmost and rightmost columns of @xmath143 respectively .
then , for any @xmath16 , there exists a @xmath3-minimal spanning tree @xmath47 for @xmath143 such that @xmath146 .
[ leafy - path ]    we proceed by induction on @xmath147 .
note that the result is trivially true if @xmath148 as the graph is initially monochromatic with colour @xmath3 and so any spanning tree will do .
suppose then that @xmath149 .
let @xmath21 be an optimal sequence to flood @xmath143 with colour @xmath3 , and suppose that the last move of @xmath21 is @xmath109 .
if @xmath143 is monochromatic in some colour @xmath110 before @xmath109 is played , and so this final move just changes the colour of the whole graph to @xmath3 , we see that @xmath150 .
thus we may apply the inductive hypothesis to obtain a @xmath77-minimal spanning tree @xmath47 for @xmath143 such that @xmath146 .
but then @xmath151 and so @xmath47 is also a @xmath3-minimal spanning tree for @xmath143 .
thus we may assume that @xmath143 is not monochromatic immediately before @xmath109 is played .
this means that @xmath109 must change the colour of a monochromatic component @xmath25 from some @xmath110 to @xmath3 , where @xmath152 is nonempty and has colour @xmath3 before @xmath109 is played .
since @xmath143 is a connected induced subgraph of a @xmath0 board , @xmath152 has at most one component @xmath153 which contains vertices lying in columns to the left of all columns containing a vertex of @xmath25 , and correspondingly at most one component @xmath154 containing vertices lying in columns entirely to the right of @xmath25 .
there may additionally be some components @xmath129 of @xmath152 which contain only vertices which lie in the same column as some vertex of @xmath25 .
a possible structure for @xmath143 is illustrated in figure [ h - cpts ] . in the remainder of the proof
, we will exploit the structure of @xmath152 to define a @xmath3-minimal spanning tree @xmath47 for @xmath143 whose non - leaf vertices lie on @xmath155 .
observe that we may have @xmath156 , as illustrated in figure [ l = r ] ; we will deal with this case later , so for the moment we assume that @xmath157
.    set @xmath2 ( respectively @xmath158 ) to be any vertex lying in the leftmost ( respectively rightmost ) column of @xmath25 that has at least one neighbour in @xmath153 ( respectively @xmath154 ) ; if @xmath153 ( respectively @xmath154 ) is empty , we set @xmath159 ( respectively @xmath160 ) .
if two vertices of @xmath153 lie in the rightmost column of @xmath153 , one of these must be adjacent to @xmath2 , in which case we set this vertex to be @xmath161 ; otherwise @xmath161 is defined to be the unique vertex of @xmath153 that lies in the rightmost column .
we define @xmath162 symmetrically , so that @xmath162 lies in the leftmost column of @xmath154 , and so that if there is a choice of vertices of @xmath154 in this column then @xmath162 is the vertex adjacent to @xmath158 .
note that @xmath163 and so , by the inductive hypothesis , there exists a @xmath3-minimal spanning tree @xmath164 for @xmath153 such that @xmath165 .
similarly , there exists a @xmath3-minimal spanning tree @xmath166 for @xmath154 such that @xmath167 , and a @xmath77-minimal spanning tree @xmath168 for @xmath25 such that @xmath169 .
let @xmath64 be an optimal sequence of moves to flood @xmath168 with colour @xmath77 , and @xmath170 and @xmath171 be optimal sequences to flood @xmath164 and @xmath166 respectively with colour @xmath3 .
observe that , as well as containing vertices that lie in columns to the left ( respectively right ) of @xmath25 , @xmath153 ( respectively @xmath154 ) may additionally contain some vertices that lie in the same column as a vertex of @xmath25 .
we set @xmath172 to be the subtree of @xmath164 induced only by those vertices in @xmath153 that lie in the same column as or to the left of the leftmost vertex of @xmath25 , and define @xmath173 symmetrically .
we further define @xmath174 ( respectively @xmath175 ) to be the subsequence of @xmath170 ( respectively @xmath171 ) consisting of moves that change the colour of at least one vertex in @xmath172 ( respectively @xmath173 ) , and note then that @xmath174 ( respectively @xmath175 ) floods @xmath172 ( respectively @xmath173 ) with colour @xmath3 ( implying that @xmath176 , and @xmath177 ) .
now set @xmath178 to be the spanning tree for @xmath179 obtained from @xmath168 by adding an edge from every vertex @xmath180 of this subgraph that does _ not _ lie in @xmath25 to the vertex of @xmath25 that lies in the same column as @xmath180 ( and observe that @xmath181 ) .
finally , we obtain a spanning tree @xmath47 for @xmath143 by connecting @xmath172 , @xmath173 and @xmath178 .
if @xmath182 , we use the edge @xmath183 to connect @xmath172 and @xmath178 ; otherwise we use the edge of @xmath164 with exactly one endpoint in @xmath172 . in either case
we must have @xmath184 ) \subseteq p(t , u , v')$ ] .
similarly , if @xmath185 then we connect @xmath173 and @xmath178 with @xmath186 , and otherwise use the edge of @xmath166 with exactly one endpoint in @xmath173 .
the construction of @xmath47 is illustrated in figure [ t - construction ] .
it is clear from the construction that @xmath47 is a spanning tree for @xmath143 , and that @xmath146 ; we will argue that in fact @xmath47 is a @xmath3-minimal spanning tree for @xmath143
.    for the rest of the argument , it will be useful to identify two important vertices of @xmath47 .
we set @xmath51 to be the last vertex on the path @xmath155 before @xmath25 , and @xmath52 the first vertex after @xmath25 , when this path is traversed from left to right ( as illustrated in figure [ t - construction ] ) ; if @xmath153 ( respectively @xmath154 ) is empty then @xmath51 ( respectively @xmath52 ) is not defined .
assuming @xmath153 ( respectively @xmath154 ) is nonempty , let @xmath187 ( respectively @xmath188 ) be the neighbour in @xmath25 of @xmath51 ( respectively @xmath52 ) .
note that @xmath189 and @xmath190 .
having defined the spanning tree @xmath47 for @xmath143 , we now consider how to flood @xmath47 with colour @xmath3 .
first , observe that @xmath191    we will say that a colour @xmath192 is _ autonomous _ either if @xmath193 appears in the initial colouring in one or more component @xmath132 , or else if a move of @xmath170 or @xmath171 is is played in a monochromatic component of colour @xmath193 that does not intersect @xmath172 or @xmath173 .
let @xmath194 denote the set of all autonomous colours .
note then that , for each @xmath195 that does not have colour @xmath3 initially , at least one of the following must hold in order for @xmath2 to be given colour @xmath3 :    1 .
@xmath196 , or 2 .
either initially , or after some move of @xmath170 , @xmath51 has colour @xmath197 .
let @xmath198 be the set of vertices @xmath195 such that the first statement holds , so @xmath199 if and only if @xmath196 .
we then set @xmath200 , and note that the second statement must hold for every @xmath201 .
we can apply exactly the same reasoning to @xmath202 ( replacing @xmath51 with @xmath52 ) , and define @xmath203 and @xmath204 analogously .
observe that @xmath205 , and @xmath206 .
thus , by ( [ |s| ] ) , we see that @xmath207    in order to flood @xmath47 with colour @xmath3 , we will first play @xmath64 , flooding @xmath25 , and then repeatedly change the colour of @xmath25 to cycle through all colours in @xmath194 .
note that these first @xmath208 moves create a monochromatic component @xmath209 containing @xmath210 .
there are now three cases to consider , depending on whether none , both or one of @xmath211 and @xmath203 are non - empty .
first suppose that @xmath212 .
note in this case that our first @xmath208 moves make @xmath178 monochromatic in some colour , so @xmath213 .
thus we can apply corollary [ non - interference ] to see that @xmath214 as required .
now suppose that exactly one of @xmath211 and @xmath203 is nonempty , and without loss of generality suppose that @xmath215 .
we claim that playing @xmath64 in @xmath47 does not change the colour of any vertex in @xmath172 .
indeed , if this sequence does change the colour of a vertex in @xmath172 , it must change the colour of @xmath51 , and this colour change will be due to moves in @xmath64 changing the colour of @xmath187 .
thus , if we played @xmath64 in the tree @xmath97 , obtained by connecting @xmath164 , @xmath168 and @xmath166 with the edges @xmath216 and @xmath217 , it would would still change the colour of @xmath51 ( which is the unique vertex of @xmath164 adjacent to @xmath168 ) .
however , as @xmath215 , we know that @xmath170 must change the colour of @xmath51 , and so by proposition [ strong - non - int ] ( setting @xmath218 , @xmath219 , @xmath220 and @xmath221 ) we would have @xmath222 , implying ( by theorem [ spanning - tree ] ) that @xmath223 , a contradiction .
we may further assume that then cycling @xmath25 through all colours in @xmath194 does not change the colour of any vertex in @xmath172 : if @xmath224 we can choose this to be the last colour we play in @xmath25 , and so our sequence will link @xmath25 to @xmath51 but will not change the colour of @xmath51 ( or therefore of any other vertex in @xmath172 ) .    next , if playing @xmath64 and cycling through the colours of @xmath194 has not already linked @xmath209 to @xmath51 , we play one further move to give @xmath209 the same colour as @xmath51 . since the sequence of moves we play up to this point does not change the colour of any vertex in @xmath172 , we can now play the sequence @xmath174 to give every vertex in @xmath172 colour @xmath3 . as @xmath51 is in the same monochromatic component as @xmath209 this
will also give all vertices in @xmath209 colour @xmath3 .
moreover , playing this sequence will at some point give @xmath51 , and hence @xmath209 , every colour in @xmath225 , and so will link every vertex in @xmath203 to @xmath209 and ultimately give these vertices colour @xmath3 .
thus , playing @xmath64 , cycling through @xmath194 , if necessary linking @xmath51 to @xmath209 , and then playing @xmath174 will flood all the vertices of @xmath226 with colour @xmath3 ( as @xmath227 ) , so we see that @xmath228 but then , once again , we can apply corollary [ non - interference ] to see that @xmath229 as required .    for the final subcase , we suppose that @xmath230 .
we begin once again by playing @xmath64 , cycling @xmath25 through all colours in @xmath194 , and then ( if required ) playing an additional move to change the colour of the monochromatic component containing @xmath25 to be the same as @xmath51 ; as before we may assume that these initial moves do not change the colour of any vertex in @xmath174 .
note that , as @xmath215 , the colour of @xmath51 must change at least once when we play @xmath174 in @xmath172 .
set @xmath112 to be the last move in @xmath174 to change the colour of @xmath51 , and note then that @xmath112 must change the colour of some component @xmath231 , containing @xmath51 , to @xmath3 .
set @xmath232 , and let @xmath233 be the subsequence of @xmath174 consisting of moves played in @xmath231 ( so @xmath233 floods @xmath231 with colour @xmath3 , and @xmath112 is the final move of @xmath233 ) . as @xmath231 is monochromatic before @xmath112 , playing @xmath234 in @xmath231 must flood this component with some colour @xmath235 . observe also that the sequence @xmath236 must , when played in the forest @xmath237 , give every vertex of @xmath237 colour @xmath3 .
suppose that , after playing @xmath64 and linking @xmath25 to @xmath51 , we then play @xmath234 .
this will ensure that @xmath51 and hence @xmath25 at some point receives every colour in @xmath238 ( except possibly d ) , so every vertex in @xmath211 is either linked to @xmath25 or has colour @xmath3 ( in which case it will certainly end up with colour @xmath3 , as its colour can only change if it is linked to another vertex which will ultimately be given colour @xmath3 ) .
note that we now have a monochromatic component @xmath34 that contains @xmath25 , @xmath231 and all vertices of @xmath239 that do not initially have colour @xmath3 .
we claim that the sequence of moves we play up to this point can not change the colour of any vertex in @xmath173 .
to prove the validity of this claim , first observe that @xmath175 , played in @xmath166 , floods a subtree @xmath240 of @xmath166 with colour @xmath3 , where @xmath241 .
now set @xmath242 to be the spanning tree for @xmath143 obtained by connecting @xmath240 and @xmath243 with the edge @xmath217 .
it is clear that , if our sequence of moves so far changes the colour of any vertex in @xmath173 when played in @xmath47 , playing the same sequence in @xmath242 would change the colour of @xmath244 .
however , as @xmath245 , we also know that @xmath171 changes the colour of @xmath52 .
note also that all vertices of @xmath246 that do not belong to @xmath237 have colour @xmath3 initially , so @xmath247 moves suffice to flood @xmath246 with colour @xmath3
. we can now apply proposition [ strong - non - int ] , setting @xmath248 , @xmath108 to be the sequence of moves we have played up to this point , @xmath249 and @xmath250 to see that @xmath251 theorem [ spanning - tree ] would then imply that @xmath252 a contradiction .
if the monochromatic component containing @xmath25 does not already have the same colour as @xmath52 , we now play one further move to link it to this vertex ( and note that such a move will not change the colour of any vertex in @xmath173 ) . hence ,
if we now play @xmath175 , this will flood @xmath173 with colour @xmath3 ; as @xmath25 and @xmath52 lie in the same monochromatic component before these moves are played , this sequence will also give every vertex in the same monochromatic component as @xmath25 colour @xmath3 .
moreover , linking @xmath25 to @xmath52 and playing @xmath175 will at some point give @xmath52 , and hence @xmath25 , every colour in @xmath225 , and so all vertices in @xmath203 will be linked to @xmath25 and thus end up with colour @xmath3 .
hence this sequence of moves gives every vertex in @xmath253 colour @xmath3 , and so we have @xmath254 finally , we apply corollary [ non - interference ] to give @xmath255 as required .
this completes the proof in the case that @xmath157 .
it remains to consider the case in which @xmath156 , as in figure [ l = r ] .
we define @xmath47 exactly as before ( as shown in figure [ t , l = r ] ) , and again identify the important vertices @xmath51 and @xmath52 .
the previous reasoning only fails in the case @xmath156 because it is not necessarily true , in this case , that @xmath174 floods @xmath172 with colour @xmath3 and @xmath175 floods @xmath173 with colour @xmath3 .
however , by considering more carefully the sequence of moves that floods @xmath152 , we are able to deal with this problem .
if @xmath51 and @xmath52 belong to the same monochromatic component @xmath256 of @xmath257 , with colour @xmath258 , under the initial colouring @xmath12 , then we can flood @xmath259 $ ] by playing @xmath64 and then changing the colour of @xmath25 to @xmath258 , so @xmath260 , \omega , d_{xy } ) \leq |s_a| + 1 $ ] .
let @xmath24 be the colouring of @xmath47 which agrees with @xmath12 on every vertex in @xmath164 , and gives every vertex in @xmath25 colour @xmath258 .
then @xmath47 with colouring @xmath24 is equivalent ( when monochromatic components are contracted ) to @xmath164 with colouring @xmath12 , implying that @xmath261 .
we can then apply lemma [ change - colouring ] to give @xmath262 , \omega , d_{xy } ) \\                  & \leq |s_l| + |s_a| + 1 \\                  & = |s| \\                  & = m(h,\omega , d).\end{aligned}\ ] ]    so we may assume that @xmath51 and @xmath52 do not belong to the same monochromatic component initially . let @xmath263 be the initial segment of @xmath170 up to and including the move that first links @xmath51 and @xmath52 ; let @xmath256 be the monochromatic component of @xmath264 that contains @xmath51 and @xmath52 at this point , and suppose that it has colour @xmath265 and that @xmath266 moves of @xmath263 are played in @xmath256 .
we now consider flooding the subtree @xmath259 $ ] with colour @xmath265 .
note that the subsequence of @xmath263 consisting of moves played in @xmath267 must in this case flood @xmath267 with colour @xmath265 , and similarly the subsequence consisting of moves played in @xmath268 must flood @xmath268 with colour @xmath265 .
thus , applying exactly the same arguments as in the case that @xmath157 , we see that @xmath269    now set @xmath24 to be the colouring of @xmath61 that agrees with @xmath270 on @xmath164 and gives all vertices of @xmath25 colour @xmath265 . note that @xmath47 with colouring @xmath24 is equivalent ( when monochromatic components are contracted ) to @xmath164 with colouring @xmath270 , and so @xmath271 . if @xmath119 is the set of monochromatic components of @xmath47 with respect to @xmath24 , and each @xmath120 has colour @xmath121 under this colouring , then observe that @xmath272 } } m(a,\omega , c_a ) \leq |s'| - k,\ ] ] and so @xmath273 we can now apply lemma [ change - colouring ] to see that @xmath274 in this case also , completing the proof .    in our analysis of the algorithm in the next section
, we will need one additional result : we show in the next lemma that any tree can be flooded by an optimal sequence in which no moves are played at leaves .
let @xmath47 be any tree , and @xmath12 a colouring of the vertices of @xmath47 .
then there exists a sequence of moves @xmath21 , of length @xmath275 , which makes @xmath47 monochromatic and in which all moves are played in @xmath48 .
[ no - leaf - moves ]    let @xmath276 be any optimal sequence to flood @xmath47 , and set @xmath277 to be the subsequence of @xmath276 consisting of moves that change the colour of a vertex in @xmath48 . note that we may assume without loss of generality that all moves of @xmath277 are played in @xmath48 .
note further that @xmath278 contains only moves played at leaves , and let @xmath279 be the set of leaves in which moves of @xmath278 are played .
observe that playing @xmath277 in @xmath47 will make @xmath280 monochromatic , and so we can flood the entire tree by playing a sequence @xmath21 which consists of @xmath277 followed by a further @xmath281 moves , cycling through the colours still present in leaves of @xmath47 ( playing all moves in @xmath48 ) . thus @xmath282 however , it is clear that @xmath283 , as @xmath278 contains at least one move played at each vertex in @xmath279 .
hence we see that @xmath284 , and so @xmath21 is an optimal sequence to flood @xmath47 in which all moves are played in @xmath48 , as required .      in this section
we describe our algorithm to solve @xmath4-free - flood - it on @xmath0 boards , and use results from the previous section to prove its correctness .
we begin with some further definitions . for any section
@xmath46 $ ] , we define @xmath285 $ ] to be the set of all spanning trees for @xmath46 $ ] . given any @xmath0 flood - it board @xmath34 , corresponding to a graph @xmath17 with colouring @xmath12 from colour - set @xmath13 , we define a set of vectors @xmath286 , where @xmath287 \text { is a section } , \\                  & r_1 , r_2 \in v(b[b_1,b_2 ] ) , \\
& \exists t \in \mathcal{t}[b_1,b_2 ] \text { such that } \operatorname{trunk}(t ) \subseteq p(t , r_1,r_2 ) , \\                  & r_1 \text { incident with } b_1 , r_2 \text { incident with } b_2 , \\                  & d \in c , \\
& i \subseteq c \}.\end{aligned}\ ] ] note that there always exists a tree @xmath288 $ ] such that @xmath289 unless one of the following holds :    1 .
there is more than one vertex of @xmath46 $ ] lying strictly to the left of @xmath290 or strictly to the right of @xmath291 , or 2 .
there is exactly one vertex of @xmath46 $ ] lying strictly to the left of @xmath290 ( respectively to the right of @xmath291 ) , which is not adjacent to @xmath290 ( respectively @xmath291 ) and whose neighbour in the same column as @xmath290 ( respectively @xmath291 ) has no neighbour in @xmath46 $ ] other than @xmath290 ( respectively @xmath291 ) .
thus we can check whether this condition is satisfied in constant time .
we now introduce a function @xmath292 which is closely related to the minimum number of moves required to flood a @xmath0 board . for any @xmath293
we define @xmath294 to be the minimum , taken over all @xmath288 $ ] such that @xmath289 , of the number of moves that must be played in @xmath295 to flood @xmath295 with colour @xmath3 , and link to @xmath295 all leaves of @xmath47 that do not have colours from @xmath296 .
it follows immediately from lemmas [ leafy - path ] and [ no - leaf - moves ] that @xmath297    our algorithm in fact computes recursively a function @xmath298 , with the same parameters as @xmath292 .
we will argue that , for every @xmath299 , @xmath300 and hence that it suffices to compute all values of @xmath298 in order to calculate @xmath19 .    the first step of the algorithm is to initialise certain values of @xmath298 to zero .
we set @xmath301 if and only if , under the initial colouring , there exists a @xmath290-@xmath291 path of colour @xmath3 in @xmath46 $ ] , and all vertices in @xmath46 $ ] that do not lie on this path are adjacent to the path and have colours from @xmath302 .
all other values of @xmath303 are initially set to infinity .
note that , under this definition , @xmath304 , and that for each @xmath299 we can easily determine in time @xmath305 whether @xmath298 should be initialised to zero or infinity .    in order to define further values of @xmath298
, we introduce two more functions .
first , for any @xmath306 , we set @xmath307 we also define , for any @xmath299 , @xmath308 finally , we set @xmath309    for the reasoning below , it will be useful to introduce another function @xmath310 , taking the same parameters as @xmath292 and @xmath298 . for any @xmath306 , we define @xmath311    in the following two lemmas , we show that @xmath300 for all @xmath299 , as claimed .
we begin by demonstrating that @xmath303 gives an upper bound for @xmath294 .
let @xmath17 with colouring @xmath12 ( from colour - set @xmath13 ) be the coloured graph corresponding to a @xmath0 flood - it board @xmath34 .
then @xmath312 for all @xmath306 .
[ f*>=f ]    we proceed by induction on @xmath313 .
recall that we have equality between @xmath294 and @xmath303 whenever @xmath314 , so certainly the base case for @xmath315 must hold .
assume therefore that @xmath316 , and that the result holds for all @xmath317 with @xmath318 .    since @xmath316 , we must have @xmath319 .
suppose first that @xmath320 .
then , for some @xmath110 , @xmath321 but then we know , by definition of @xmath292 , that there exists @xmath288 $ ] and a sequence @xmath21 of @xmath322 moves , all played in @xmath295 , which , when played in @xmath47 , floods @xmath323 with colour @xmath77 and links all leaves to @xmath295 except possibly those with colours from @xmath302 . by appending one further move to @xmath21 , which changes the colour of @xmath295 to @xmath3 , we obtain a sequence @xmath263 of length @xmath324 ( with all moves played in @xmath295 ) which , when played in @xmath47 , floods @xmath295 with colour @xmath3 and is such that all leaves of @xmath47 not linked to @xmath295 by @xmath21 have colours from @xmath296 .
hence @xmath325 , and so @xmath326 , as required .
now suppose that @xmath327 .
then , by definition of @xmath328 , there exists a border @xmath45 with @xmath329 and an edge @xmath330 such that @xmath331 and @xmath332 note that @xmath333 and @xmath334 are both strictly smaller than @xmath335 , so by the inductive hypothesis we have @xmath336 by definition of @xmath292 , there exist trees @xmath337 $ ] and @xmath338 $ ] , and sequences @xmath95 and @xmath339 of length @xmath340 and @xmath341 respectively , such that ( for @xmath342 ) all moves of @xmath88 are played in @xmath343 and @xmath88 floods @xmath343 with colour @xmath3 , additionally linking all leaves of @xmath344 to @xmath343 except possibly those with colours from @xmath296 .
now set @xmath345 .
it is clear that @xmath288 $ ] , and moreover that @xmath289 .
suppose @xmath346 and @xmath347 are the subtrees of @xmath97 and @xmath242 respectively that are given colour @xmath3 by @xmath95 and @xmath339 , and set @xmath348 .
note that @xmath349 and that @xmath350 , so @xmath351 . we can then apply corollary [ non - interference ] to see that @xmath352 completing the proof .    next
we show that the reverse inequality also holds .
let @xmath17 with colouring @xmath12 ( from colour - set @xmath13 ) be the coloured graph corresponding to a @xmath0 flood - it board @xmath34 .
then @xmath353 for all @xmath306 .
[ f*<=f ]    we proceed by induction on @xmath294 , noting again that we have equality in the base case for @xmath354 .
suppose that @xmath355 , and that the result holds for @xmath317 whenever @xmath356 .
by definition , there exists a tree @xmath288 $ ] and a sequence @xmath21 of length @xmath357 such that @xmath289 , all moves of @xmath21 are played in @xmath295 , and @xmath21 floods @xmath295 with colour @xmath3 , leaving only leaves with colours from @xmath296 not linked to @xmath295 .
we proceed by case analysis on @xmath109 , the final move of @xmath21 .
suppose first that @xmath295 is already monochromatic before @xmath109 , and that this final move just changes its colour to @xmath3 from some @xmath110 ( possibly flooding some additional leaves of colour @xmath3 in the process ) . in this case
it is clear that @xmath358 and so we can apply the inductive hypothesis to see that @xmath359 .
but then , by definition of @xmath360 , we know that @xmath361 as required .
so we may assume that @xmath295 is not monochromatic before @xmath109 : it may have either two or three monochromatic components .
suppose first that @xmath295 has exactly three monochromatic components before @xmath109 is played , @xmath362 , @xmath363 and @xmath364 ; we may assume that @xmath362 and @xmath364 have colour @xmath3 before @xmath109 , and that this final move gives @xmath363 colour @xmath3 to flood the entire path . for @xmath365 , set @xmath88 to be the subsequence of @xmath366 consisting of moves played in @xmath367 , and set @xmath368 to be @xmath367 together with all leaves of @xmath47 that lie in the same column as a vertex of @xmath367 or whose only neighbour on @xmath295 is in @xmath367 .
note that that @xmath369 , @xmath370 and @xmath371 partition the vertex set of @xmath47 , and that @xmath95 , @xmath339 and @xmath372 partition @xmath366 .
we may assume without loss of generality that @xmath373 and @xmath374 .
observe that there must exist borders @xmath45 and @xmath375 , with @xmath376 , such that @xmath377 $ ] , @xmath378 $ ] and @xmath379 $ ] .
set @xmath380 to be the edge of @xmath47 such that @xmath381 , @xmath382 and @xmath383 the edge of @xmath47 such that @xmath384 and @xmath385 .
note that @xmath386 \in \mathcal{t}[b_1,b]$ ] , @xmath387 \in \mathcal{t}[b , b']$ ] , and @xmath388 \in \mathcal{t}[b',b_2]$ ] , and moreover that we have @xmath389 ) \subseteq p(t[a_1],r_1,x_1)$ ] , @xmath390 ) \subseteq p(t[a_2],x_2,y_1)$ ] and @xmath391 \subseteq p(t[a_3],y_2,r_2)$ ] .
observe also that @xmath95 is a sequence of moves played in @xmath392,r_1,x_1)$ ] that floods @xmath392,r_1,x_1)$ ] with colour @xmath3 and links all leaves , except possibly those with colours from @xmath296 , to @xmath392,r_1,x_1)$ ] , so we must have @xmath393 .
similarly , we see that @xmath394 and @xmath395 .
since @xmath396 , we can apply the inductive hypothesis to see that @xmath397 and @xmath398 the inductive hypothesis also gives @xmath399 and we can then apply the definition of @xmath360 to see that @xmath400 now we can apply the definition of @xmath298 to see that @xmath401 as required .    for the remaining case ,
in which @xmath295 has exactly two monochromatic components before @xmath109 , we can use the same reasoning as in the previous case for three components to show that we must once again have @xmath402 , completing the proof .
the final step to is to show that all values of @xmath298 can be computed in time @xmath403 .    for any @xmath0 flood - it board @xmath34 ,
the function @xmath303 can be computed , for all @xmath299 , in time @xmath404 .
[ complexity ]    we compute values of @xmath298 recursively using a dynamic programming technique .
our table has one entry for each pair of borders , for each possible vertex incident with each of the borders , for each colour in the colour - set and for each possible subset of colours , so the total number of entries is at most @xmath405    the table is initialised by setting all values to either zero or infinity , and for each entry we can determine which of these values it should take in time at most @xmath305 , so we can initialise the entire table in time @xmath406 .
the next step is to apply the recursive definition of @xmath298 repeatedly to all entries in the table that are not already set to zero .
each time we apply this definition to a single entry , we take the minimum of at most @xmath407 values ( one for each choice of colour , plus one for each combination of a border and a pair of adjacent vertices on either side ) , each a combination of at most two other entries in the table , so each entry can be calculated in time @xmath407 .
we can therefore perform one iteration in which we apply the definition to each non - zero entry in the table in time @xmath408 .
note that once we have initialised the table , we have the correct value of @xmath303 for any @xmath409 such that @xmath410 .
moreover , the value of @xmath303 depends only on values of @xmath411 where @xmath318 , so after @xmath266 iterations we will have correctly computed the value of @xmath303 for all @xmath409 with @xmath412 .
note that for every @xmath299 , @xmath413 , as there are at most @xmath414 borders in total , and no more than @xmath415 moves can be required to flood a graph with at most this many vertices , so @xmath416 iterations are sufficient to guarantee we have computed all values of @xmath298 correctly .    thus , we can compute all values of @xmath303 for @xmath299 in time @xmath417 , as required .
we now combine the previous three results to give the proof of our main theorem .
recall that , from the definition of @xmath292 and lemmas [ leafy - path ] and [ no - leaf - moves ] , @xmath297 thus , in order to compute @xmath19 in time @xmath417 , it suffices to compute all relevant values of @xmath292 in time @xmath417 .
however , we know from lemmas [ f*>=f ] and [ f*<=f ] that @xmath418 for all @xmath299 , and from proposition [ complexity ] we know that we can compute @xmath303 for all @xmath299 in time @xmath417 .
this completes the proof of the theorem .
in this section we prove the following theorem .    free - flood - it remains np - hard when restricted to @xmath0 boards .
[ 2xnnp ]    this is somewhat surprising , as we have seen in the previous section that @xmath4-free - flood - it can be solved in polynomial time on @xmath0 boards , while @xcite gives a linear time algorithm to solve fixed flood it in this situation .
we demonstrate here that the problem is almost certainly not in * p * if we remove both these restrictions ( that moves are always played at the same vertex , or the number or colours is bounded ) .
this is the first class of graphs for which such a result has been shown .
the proof is by means of a reduction from vertex cover , shown to be np - hard by karp in @xcite . given a graph @xmath11 , we construct a @xmath0 flood - it board @xmath419 as follows .
suppose @xmath420 .
for each edge @xmath421 we construct the gadget @xmath422 , as illustrated in figure [ gadget - g_e ] .
we will refer to the single - square components incident with the bottom edge in @xmath423 as _
@xmath423 is then embedded in the larger gadget @xmath424 , as shown in figure [ gadget - g_e ] .
distinct colours @xmath425 are used for each @xmath426 , where @xmath427 .
we then obtain the board @xmath419 by placing these gadgets @xmath424 in a row , as illustrated in figure [ board-2xn - inf - b ] .
observe that we can take @xmath428 .
let us also set @xmath429 .
[ h ] , title="fig : " ]    [ h ] , title="fig : " ]    [ h ]     in the two following lemmas , we show that we can flood this board @xmath34 in @xmath430 steps if and only if @xmath17 has a vertex cover of size at most @xmath266 .
if @xmath17 has a vertex cover of size at most @xmath266 , then we can flood the board @xmath419 in @xmath430 steps .
[ vc=>strat ]    first observe that , if @xmath431 , then with @xmath432 moves we can flood the gadget @xmath424 , except for a single island of colour @xmath433 , so that it is monochromatic in colour @xmath434 : first play a single move to make all of @xmath423 except for a single island monochromatic , then play colours @xmath425 in this central component . ignoring the islands for the moment , the components corresponding to each @xmath424 now have distinct colours , so we can link these components with a minimum of @xmath435 moves .
finally , we need to flood the islands , and this requires exactly @xmath436 moves .
but we know that @xmath17 has a vertex cover of size at most @xmath266 , say @xmath437 . by the definition of a vertex cover , if the gadget @xmath423 uses colours @xmath144 and @xmath2 , then at least one of @xmath438 .
so for each @xmath424 , we may choose to leave an island of colour @xmath3 where @xmath439 .
following this strategy , we are left in the final stage with islands of at most @xmath266 distinct colours , and can flood these in @xmath266 steps ( by cycling through each colour in turn in the external monochromatic component ) . hence we can flood @xmath419 in @xmath430 steps .    if we can flood @xmath419 in @xmath440 steps ( for some @xmath441 ) , then @xmath17 has a vertex cover of size at most @xmath266 .
[ strat=>vc ]    suppose the sequence @xmath21 floods @xmath419 , where @xmath442 .
observe that , if we contract monochromatic components of the coloured graph corresponding to @xmath419 , we obtain a tree @xmath47 .
let @xmath443 be the unique path in @xmath443 joining the two vertices in @xmath47 that correspond to the monochromatic components incident with opposite ends of the board and note that , by lemma [ no - leaf - moves ] , we may assume that all moves of @xmath21 are played in @xmath444 .
moreover , @xmath21 must flood @xmath443 when played in this isolated path .
we will say that a component of colour @xmath3 is _ eliminated _ by the move @xmath109 if @xmath109 changes the colour of that component , linking it to an adjacent component of colour @xmath445 .
we say that @xmath109 _ eliminates the colour @xmath3 _ if it removes the last component of colour @xmath3 remaining in the graph .
suppose that , for some @xmath15 , a single move @xmath446 eliminates two components @xmath362 and @xmath363 of @xmath443 that both have colour @xmath2 initially .
@xmath362 and @xmath363 can not belong to the same gadget @xmath424
so , for @xmath109 to eliminate them both , the moves played in @xmath21 before @xmath109 must create a single monochromatic component @xmath25 containing both @xmath362 and @xmath363 .
such a component @xmath25 must contain @xmath447 different colours under the original colouring , and so @xmath21 must include at least @xmath448 moves played in this section of the path before @xmath109 ( so in total at least @xmath449 moves of @xmath21 are played in @xmath25 ) .
but there are at least @xmath450 colours on the path outside @xmath25 ( as at least @xmath451 of the colours in @xmath25 must also appear outside @xmath25 ) , and all but one of these must be eliminated by moves played outside @xmath25 .
this gives @xmath452 a contradiction .
so we may assume that no move in @xmath21 eliminates more than one component that originally has colour @xmath15 .
now consider the leaves of @xmath47 , and let @xmath453 be the set of moves in @xmath21 that eliminate the second leaf in each @xmath423 .
suppose that one leaf in @xmath423 has already been eliminated , and that the move @xmath454 removes the second leaf . since one leaf has already been eliminated , no components in @xmath455 which originally had a colour @xmath15 still have colour @xmath2 .
suppose that @xmath109 reduces the number of monochromatic components on @xmath443 . by the reasoning
above , if @xmath109 links @xmath423 to another component outside @xmath424 that originally had colour @xmath2 , we would have a contradiction with @xmath456 , so in fact @xmath109 must link @xmath423 to a component in @xmath424 whose colour was previously changed to @xmath2 by some move @xmath112 ; such a move @xmath112 could not decrease the number of monochromatic components of @xmath443 .
thus , for every @xmath454 , there is at least one move of @xmath21 that does not decrease the number of monochromatic components of @xmath443 .
hence we see that @xmath457 and so @xmath458 .
however , we know that @xmath453 eliminates at least one leaf from every @xmath423 , and clearly each move in @xmath453 can eliminate leaves of only one colour .
hence there exists some set @xmath459 such that @xmath460 and at least one leaf in each @xmath423 has a colour from @xmath461 .
in other words , @xmath462 , and for every edge @xmath463 , @xmath464 , so @xmath461 is in fact a vertex cover for @xmath17 of size at most @xmath266 .
the reduction from vertex cover is immediate from lemmas [ vc=>strat ] and [ strat=>vc ] .
we have demonstrated an algorithm which shows that the problem @xmath4-free - flood - it , restricted to @xmath0 boards , is fixed parameter tractable with parameter @xmath4 , and on the other hand we have shown that free - flood - it remains np - hard in this setting .
this answers an open question from @xcite , in which clifford , jalsenius , montanaro and sach showed that fixed - flood - it can be solved in time @xmath305 on such boards .
our results therefore give the first example of a class of graphs on which the complexity status of the fixed and free versions of the game differ .
david arthur , raphal clifford , markus jalsenius , ashley montanaro , and benjamin sach , the complexity of flood filling games , in paolo boldi and luisa gargano , editors , _ fun _ , volume 6099 of _ lecture notes in computer science _ ,
springer , isbn 978 - 3 - 642 - 13121 - 9 , 2010 , pages 307 - 318 .
kitty meeks and alexander scott , spanning trees and the complexity of flood - filling games , in kranakis , krizanc and luccio , editors , _ fun _ , volume 7288 of _ lecture notes in computer science _ , springer , isbn 978 - 3 - 642 - 30346 - 3 , 2012 , pages 282 - 292 .