問題一覧 > 通常問題

No.2473 Fraises dans une boîte

レベル : / AI推定難易度 : 2675 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 9
作問者 : SPD_9X2 / テスター : akakimidori りあん tsutaj beet 👑 tute7627 nok0 👑 rin204 だれ momoyuu KKT89
お気に入りにしたユーザー ProblemId : 9735 / 自分の提出
問題文最終更新日: 2023-11-28 23:05:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Japan Alumni Group Summer Camp 2023 Day 2 (順位表) の他の問題:

Problem Statement

There is a box divided into a grid of cells with $H$ rows and $W$ columns. It contains some strawberries.

The state of the box is represented by $S$. If $S_{x,y} = 1$, the cell in row $x$, column $y$ contains 1 strawberry. If $S_{x,y} = 0$, the cell in row $x$, column $y$ is empty.

Tomoe came up with the following method to distinguish these strawberries.

  1. Define $A_{x,y}$ as the sum of $S_{i,j}$ over all pairs of integers $(i,j)$ satisfying $i = x, 1 \le j \le y$.
  2. Define $B_{x,y}$ as the sum of $S_{i,j}$ over all pairs of integers $(i,j)$ satisfying $1 \le i \le x, j = y$.
  3. If a strawberry exists in the cell in row $x$, column $y$, label that strawberry with the tuple $(A_{x,y},B_{x,y})$.

However, with this method, multiple strawberries may receive the same label, making them indistinguishable from each other. Therefore, she decided to add some strawberries before labeling.

More formally, she performed the operation of setting $S_{x,y} \leftarrow 1$ for some $(x,y)$ with $S_{x,y} = 0$, any number of times (0 or more).

What is the minimum number of strawberries she must add so that, when the labeling is done afterward, all strawberries receive pairwise distinct labels?

Input

$H\ W$
$S_{1,1}\ S_{1,2}\ ...\ S_{1,W}$
$S_{2,1}\ S_{2,2}\ ...\ S_{2,W}$
$\vdots$
$S_{H,1}\ S_{H,2}\ ...\ S_{H,W}$

  • All inputs are integers.
  • $1 \le H \le 300$
  • $1 \le W \le 300$
  • $0 \le S_{x,y} \le 1$

Output

Output the answer on 1 line.
Print a newline at the end.

Sample

Sample 1
Input
3 2
1 0
0 1
0 1
Output
1

This can be achieved by placing a strawberry in the top-right cell.

Sample 2
Input
4 4
0 1 1 1
1 1 1 0
1 0 1 1
1 0 1 0
Output
2

Sample 3
Input
5 5
0 0 1 0 1
0 1 0 1 0
0 0 1 0 1
0 1 0 1 0
0 0 1 0 1
Output
8

Sample 4
Input
1 1
0
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。