시간 제한메모리 제한제출정답맞힌 사람정답 비율
12 초 512 MB74261629.630%

문제

A mosaic is a picture made from square tiles arranged in a grid, at least for today’s purposes.

We would like to make a mosaic with exactly the same number of tiles of each colour. We will do this by taking an existing design and removing some of the rows from it.

Figure M.1: Illustration of a solution to Sample Input 1. The three rows annotated with white can be kept, giving 6 of each colour of tile.

What is the greatest number of rows we can keep?

입력

  • The first line of input contains the number of rows, n (1 ≤ n ≤ 40), the number of columns, m (1 ≤ m ≤ 105), and the number of colours, c (1 ≤ c ≤ 105) in the mosaic respectively.
  • Each of the next n lines contains m colours of cells p1 . . . pm (1 ≤ p ≤ c).

출력

Output the greatest number of rows that can be kept while keeping equal representation for each colour in the input, or 0 if no rows can be kept.

예제 입력 1

4 10 5
1 2 1 2 3 1 2 3 4 3
5 2 5 3 5 5 5 5 1 4
2 3 2 1 4 3 3 2 1 4
1 2 3 4 4 4 4 1 2 3

예제 출력 1

3

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2019 M번

  • 문제를 만든 사람: Robin Lee