A code design problem for memory devices with restricted state transitions is formulated as a combinatorial optimization problem that is called a subgraph domatic partition (subDP) problem. If any neighbor set of a given state transition graph contains all the colors, then the coloring is said to be valid. The goal of a subDP problem is to find the valid coloring that has the largest number of colors for a subgraph of a given directed graph. The number of colors in an optimal valid coloring indicates the writing capacity of that state transition graph. The subDP problems are computationally hard; it is proved to be NP-complete in this paper. One of our main contributions in this paper is to show the asymptotic behavior of the writing capacity C(G) for sequences of dense bidirectional graphs; this is given by C(G) = Ω(n/ ln n), where n is the number of nodes. A probabilistic method, Lovász local lemma (LLL), plays an essential role in deriving the asymptotic expression.