■ Description of topic
[Return the number of non-1 elements in the matrix]
There is a two-dimensional array of m*n, and the value range of its members is 0, 1, 2.
Among them, the elements with a value of 1 have the assimilation feature, and the elements with a value of 0 at the top, bottom, left, and right are assimilated to 1 every time 1S.
And elements with a value of 2 are immune to assimilation.
Randomly initialize all members of the array to 0 or 2, then modify the [0, 0] elements of the matrix to 1, and find out
how many elements in the matrix are 0 or 2 after a long enough time (that is, the number between 0 and 2 and).
enter description
The first two numbers entered are the matrix size. Followed by the digital matrix content.
output description
Returns the number of non-1 elements in the matrix.
Example 1 The input and output examples are only for debugging, and the background judgment data generally does not include examples
enter
4 4
0 0 0 0
0 2 2 2
0 2 0 0
0 2 0 0
output
9
illustrate
The first two digits of the input number are the matrix size. The following numbers are the matrix contents.
After the starting position (0,0) is modified to 1, the final assimilation matrix can only be:
4 4
0 0 0 0
0