Logo
(追記) (追記ここまで)

30360번 - Fraises dans une boîte 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB3000.000%

문제

A box is divided into grids with $H$ rows and $W$ columns. Some squares contain strawberries.

The state of the box is denoted by $S,ドル and $S_{x,y} = 1$ means that the square in the $x$-th row and $y$-th column contains one strawberry. If $S_{x,y} = 0,ドル the square in the $x$-th row and $y$-th column is empty.

Tomoe devised the following method to distinguish between these strawberries.

  • Let $A_{x,y}$ be defined as the sum of $S_{i,j}$ for all integer pairs $(i,j)$ satisfying $i = x,ドル 1ドル \le j \le y$.
  • Let $B_{x,y}$ be defined as the sum of $S_{i,j}$ for all integer pairs $(i,j)$ satisfying 1ドル \le i \le x,ドル $j = y$.
  • If the square in the $x$-th row and $y$-th column contains a strawberry, label the strawberry with the tuple $(A_{x,y}, B_{x,y})$.

This method could result in multiple strawberries having the same label, and the strawberries could not be distinguished. Therefore, she decided to add some strawberries before labeling them.

More formally, for $(x,y)$ such that $S_{x,y} = 0,ドル we operated $S_{x,y} \leftarrow 1$ any number of times greater than 0ドル$.

What is the minimum number of strawberries that must be added to label all the strawberries differently?

입력

$H$ $W$

$S_{1,1}$ $S_{1,2}$ $\dots$ $S_{1,W}$

$S_{2,1}$ $S_{2,2}$ $\dots$ $S_{2,W}$

$\vdots$

$S_{H,1}$ $S_{H,2}$ $\dots$ $S_{H,W}$

출력

Output the answer in one line. Add a new line at the end of the output.

제한

  • All inputs consist of integers.
  • 1ドル \le H \le 300$
  • 1ドル \le W \le 300$
  • 0ドル \le S_{x,y} \le 1$

예제 입력 1

3 2
1 0
0 1
0 1

예제 출력 1

1

예제 입력 2

4 4
0 1 1 1
1 1 1 0
1 0 1 1
1 0 1 0

예제 출력 2

2

예제 입력 3

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

예제 출력 3

8

예제 입력 4

1 1
0

예제 출력 4

0

힌트

In Sample Input 1, Tomoe can achieve the condition by placing a strawberry in the upper right square.

출처

Contest > ICPC Japanese Alumni Group > JAG Summer Camp > JAG Summer Camp 2023 Day 2 G번

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 1: Welcome Contest G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /