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

33138번 - Diverse T-Shirts 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 (추가 시간 없음) 2048 MB39121142.308%

문제

The Innovative Clothing Pattern Championship (ICPC) is approaching, and the organizers are determined to ensure that the selection of contestants’ T-shirts meets the competition’s high standards of variety and style.

To achieve this, they are negotiating with a T-shirt vendor that offers $N$ distinct models. Each model is defined by a unique combination of a text color and a background color, and is assigned an integer from 1ドル$ to $N$ to identify this combination.

To keep the selection visually diverse, the organizers have decided to follow a strict diversity rule: no two selected models can share the same text color or the same background color. For example, if one model has “red text on a blue background” and another has “red text on a white background”, only one of them can be chosen because they share the same text color. Conversely, models like “white text on a black background” and “black text on a white background” do not share either the text or background color, so both may be chosen.

To assist the organizers, the vendor has prepared an $N \times N$ binary matrix $A$ that identifies all incompatible pairs of models. Specifically:

  • $A_{i,j} = 1$ if $i \ne j$ and models $i$ and $j$ cannot both be chosen because they share either the text color or the background color, and
  • $A_{i,j} = 0$ otherwise.

The organizers need your help to determine if it is possible to select enough T-shirt models for the event while respecting the diversity rule. Using the vendor’s matrix, can you determine the maximum number of models that can be selected?

입력

The first line contains an integer $N$ (1ドル ≤ N ≤ 1000$) indicating the number of T-shirt models.

Each of the next $N$ lines contains a binary string of length $N$. In the $i$-th string, the $j$-th character indicates the value of $A_{i,j}$ ($i = 1, 2, \dots , N$ and $j = 1, 2, \dots , N$).

It is guaranteed that at least one set of T-shirt models corresponding to the input matrix exists.

출력

Output a single line with an integer indicating the maximum number of T-shirt models that can be chosen without violating the diversity rule.

제한

예제 입력 1

3
011
101
110

예제 출력 1

1

예제 입력 2

3
010
101
010

예제 출력 2

2

힌트

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > Latin America Regional Contests 2024 D번

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

출처

대학교 대회

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

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