AtCoder Beginner Contest 396
G
Flip Row or Col
AtCoder
⌀ 2195
原题
翻译中…

Problem Statement

翻译中…

There is a $H \times W$ grid, and each cell contains $0$ or $1$. The cell at the $i$-th row from the top and the $j$-th column from the left contains an integer $A_{i,j}$.

翻译中…

You can perform the following two operations any number of times in any order:

翻译中…
  • Operation X: Choose an integer $x$ ($1 \leq x \leq H$). For every integer $1 \leq y \leq W$, replace $A_{x,y}$ with $1 - A_{x,y}$.
  • Operation Y: Choose an integer $y$ ($1 \leq y \leq W$). For every integer $1 \leq x \leq H$, replace $A_{x,y}$ with $1 - A_{x,y}$.
翻译中…

Find the minimum possible value of $\displaystyle \sum_{x=1}^H\sum_{y=1}^W A_{x,y}$ after the process.

翻译中…

Constraints

翻译中…
  • $1 \leq H \leq 2\times 10^5$
  • $1 \leq W \leq 18$
  • $H$ and $W$ are integers.
  • $A_{i,1}A_{i,2}\ldots A_{i,W}$ is a length-$W$ string consisting of 0 and 1.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

H W
A_{1,1}A_{1,2}\ldots A_{1,W}
A_{2,1}A_{2,2}\ldots A_{2,W}
\vdots
A_{H,1}A_{H,2}\ldots A_{H,W}

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3 3
100
010
110
Output #1
2
By performing the following operations, the grid changes as shown below, and you get $\displaystyle \sum_{x=1}^H\sum_{y=1}^W A_{x,y} = 2$. 1. Operation Y with $y=1$ 2. Operation X with $x=2$ ![image](https://img.atcoder.jp/abc396/efeef604adf229d32bc42042f0a4e066.png) It is impossible to make $\displaystyle \sum_{x=1}^H\sum_{y=1}^W A_{x,y} \leq 1$, so the answer is $2$.
Input #2
3 4
1111
1111
1111
Output #2
0
Input #3
10 5
10000
00111
11000
01000
10110
01110
10101
00100
00100
10001
Output #3
13
题目信息
题号
abc396_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。