#C1198. Minimum Operations to Convert Matrices

    ID: 41355 Type: Default 1000ms 256MiB

Minimum Operations to Convert Matrices

Minimum Operations to Convert Matrices

You are given two matrices \( M_1 \) and \( M_2 \) of size \( n \times m \). An operation is defined as changing one element of a matrix (from 0 to 1 or from 1 to 0). Your task is to compute the minimum number of operations required to transform matrix \( M_1 \) into matrix \( M_2 \).

Note: The matrices always have the same dimensions and contain only 0s and 1s.

inputFormat

The input is given through standard input (stdin) and has the following format:

n m
a11 a12 ... a1m
...
an1 an2 ... anm
b11 b12 ... b1m
...
bn1 bn2 ... bnm

Where:

  • The first line contains two integers \( n \) and \( m \) representing the number of rows and columns of the matrices.
  • The next \( n \) lines each contain \( m \) integers (either 0 or 1), representing the first matrix \( M_1 \).
  • The following \( n \) lines each contain \( m \) integers (either 0 or 1), representing the second matrix \( M_2 \).

outputFormat

Output a single integer to standard output (stdout): the minimum number of operations required to convert \( M_1 \) to \( M_2 \). An operation is counted each time a cell in \( M_1 \) differs from the corresponding cell in \( M_2 \).

## sample
3 4
0 1 1 0
1 0 0 1
0 0 1 1
0 1 1 1
1 0 0 0
0 0 1 0
3

</p>