Strange_Matrices
题号:NC231087
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

As for a 01-matrix(whose entries are all either 0 or 1, similarly hereinafter) M of size , an index set S of the matrix is considered good if following two conditions are satisfied:

  1. , for all
  2.  For each entry , there exists an index satisfying the following two conditions at the same time:
                   ·   or 
                   ·  for all x,y such that and


Moreover, the value of a 01-matrix is the minimum size among all of its good index sets.

Now given a 012-matrix, you should replace all the 2 entries to 0 or 1, and determine the minimum possible value among all replacing schemes. As can be seen, there are totally replacing schemes, where cnt_2 denotes the number of 2 entries in the given matrix.

输入描述:

The first line contains two integers , denoting the size of given 012-matrix.

Following n lines each contains one 012-string of length m, where the j-th character in the i-th line among the n lines denotes entry .

输出描述:

Output one line containing one integer, denoting the minimum possible value after replacing.
示例1

输入

复制
3 7
0001101
0201020
0001101

输出

复制
3

说明

One possible replacing scheme is:
\begin{aligned}<br />0001101 \\<br />0101000 \\<br />0001101<br />\end{aligned}
One possible good set of the minimum size is \{(1,1),(2,6),(3,3)\}