Three-Color Free-Flood-It on Fixed-Height Grids Is Polynomial-Time Solvable
Abstract
We give a deterministic algorithm for \textsc{Free-Flood-It} on rectangular grids with at most three colors. For every fixed height , it computes the minimum number of moves and an optimal sequence in time, where . This resolves the previously open three-color case on complete boards. The proof uses a representation of flooding strategies as paintings by connected regions. We show that an optimal painting can be chosen so that its regions form a rooted tree with strong restrictions on the colors along ancestral paths. These restrictions make the part of the tree visible in any fixed-size connected window admit only polynomially many descriptions. The remaining common ancestors may form an arbitrarily long chain. We retain that chain on a stack and use a finite context-free recurrence to minimize the total painting cost without enumerating all possible stack contents. Connectivity information at the boundary ensures that the resulting local descriptions assemble into one valid global painting. The argument also applies to graphs supplied with an ordering into connected layers of bounded size, provided every edge lies within one layer or joins consecutive layers, and consecutive layers are joined by an edge. For a family of three-row boards, every optimal admissible painting tree has a common-ancestor chain of depth linear in the board width. For any fixed height and palette size, we give a deterministic EPTAS via a separate budget-parameterized algorithm, and we show that no FPTAS exists for with at least four colors unless P = NP. We also provide a solver for boards, implemented with AI assistance based on the algorithm described in this paper. The implementation is available at GitHub
Create a lesson
Metadata
- Categories
- cs.CC, cs.DS
Related papers
No Polynomial-Time Algorithm For Tarski Fixed Points Unless Cryptographic Assumptions Fail
Shared title terminologycs.CCEleni Batziou, John Fearnley, Alexandros Hollender et al.
On Applications of Polynomial-Time Group Isomorphism Algorithm
Shared title terminologycs.CCWenkang Zhang, Zhinan Wang, Jincheng Zhuang
Irreducibility Testing of Sparse Polynomials over Integers is NP-hard and Probabilistic Polynomial Time
Shared title terminologycs.CCYichuan Cao, Xiao-Shan Gao, Qiao-Long Huang et al.
Marton's conjecture in polynomial time
Shared title terminologycs.CCSrinivasan Arunachalam, Arkopal Dutt, Sabee Grewal et al.
NP-Completeness of the Three-Dimensional Polyhedral Separation Problem
Shared title terminologycs.CCGuannan Guo
Pushdown Reachability Requires N^{3/2} Time on Multitape Turing Machines
Shared title terminologycs.CCA. R. Balasubramanian, Rupak Majumdar