We can still claim the answer is 0 because the connected component is still part of the graph. Instead of thinking in binary letâ€™s suppose that they ask us for the decimal number of ways we can plant grass in the field. (The answer to the sample test case will be 2). Then, to find the answer, we will keep multiplying the number of ways we can plant grass in each connected component. If the component has a valid configuration, then we can say the number of ways we can plant grass in that connected component is 2. However, if the connected component does not have a valid configuration, then the number of ways we can plant grass in that configuration is 0. Suppose we have k valid connected components and n-k invalid connected components. Then, the answer is

2^k\cdot 0^{n-k}

Based on this, you can see that the number of connected components is either a power of 2, or is 0. You can also see that if we have even 1 invalid connected component, then we have 0 possible configurations for the field. And of course 0 in binary is 0.