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

13242번 - Harps and Tails 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB81564976.562%

문제

Gary likes the Celtic Harp that appears in the 1 euro coins.

He has a grid of n rows and m columns of such coins. Each coin has either the harp or the tail facing up.

Gary also loves order, he wants as many rows as possible with all the coins showing the Celtic Harp. To make things interesting he can only do the following operation: choose any column and turn all the coins in this column. That is, any coin showing the Harp will change to tails and any coin showing tails will turn to the Harp.

Gary can perform this operation as many times as he wants to maximize the number of rows with all Harps. Can you help him?

Example: We have the following grid of coins. Coins with tails are represented with the character T and coins with the Harp are represented by H.

T H T H
H T T T
H H H H
T H T H

In this state, only one row show all Harps. If we change the first column we obtain:

H H T H
T T T T
T H H H
H H T H

Then we change the third row to obtain:

H H H H
T T H T
T H T H
H H H H

In this state the first and fourth rows are all Harps which is the best we can get. Hence our answer will be 2.

입력

The first line of input contains 2 integers n and m (1 ≤ n, m ≤ 1000) representing the number of rows and columns of the grid.

The next n lines will describe the state of the grid. The i-th line will contain a string with n characters denoting the state of the i-th row of the grid. The j-th character on this line is 'T' if the j-th square in the i-th row contains a tail, and 'H' if contains a Harp.

출력

The output should be a single line containing an integer equal to a maximum possible number of rows that are completely converted to Harps (‘H’).

제한

예제 입력 1

4 4
THTH
HTTT
HHHH
THTH

예제 출력 1

2

예제 입력 2

3 5
TTTTT
TTTTT
TTTTT

예제 출력 2

3

예제 입력 3

10 11
THHHTHTTHHH
THHHTHTTHHH
HTHTTHTTTHH
THHHTHTTHHH
TTTTHHTTTTH
THHHTHTTHHH
THHHTHTTHHH
TTTTHHTTTTH
HTHTTHTTTHH
THHHTHTTHHH

예제 출력 3

6

힌트

출처

Olympiad > All-Ireland Programming Olympiad > 2016 AIPO National Finals 3번

  • 잘못된 데이터를 찾은 사람: jh05013
(追記) (追記ここまで)

출처

대학교 대회

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

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