#K1116. Minimum Days to Water the Garden
Minimum Days to Water the Garden
Minimum Days to Water the Garden
You are given a garden represented as an N x M grid, where each cell is either dry (represented by 0) or already watered (represented by 1).
The task is to determine the minimum number of days required to water the entire garden. Each dry cell requires one day to water. In other words, you need to count the number of dry cells. This can be formulated as:
\( \text{days} = \#\{(i, j) \mid garden[i][j] = 0 \} \)
Note: The garden is represented in row-major order, and the input sizes can be up to 1000 x 1000.
inputFormat
The first line contains two integers N and M, representing the number of rows and columns of the garden, respectively.
The next N lines each contain M integers (each either 0 or 1), which represent the state of each cell in the garden.
outputFormat
Output a single integer indicating the minimum number of days required to water the entire garden.
## sample2 2
0 0
0 0
4
</p>