eolymp
bolt
Try our new interface for solving problems
Problems

LampsGrid

LampsGrid

You have a rectangular table containing a grid of lamps (\textbf{W} rows and \textbf{L} columns). Each lamp is initially either "\textbf{on}" or "\textbf{off}". There is a switch underneath each column, and when the switch is flipped, all the lamps in that column reverse their states ("\textbf{on}" lamps become "\textbf{off}" and vice versa). A row in the grid is considered lit if all the lamps in that row are "on". You must make exactly \textbf{K} flips. The \textbf{K} flips do not necessarily have to be performed on \textbf{K} distinct switches. Your goal is to have as many lit rows as possible after making those flips. \InputFile The first line contains three integers: \textbf{W}, \textbf{L} (\textbf{1} ≤ \textbf{L}, \textbf{W} ≤ \textbf{50}) and \textbf{K} (\textbf{0} ≤ \textbf{K} ≤ \textbf{1000}). Each of the next \textbf{W} lines contains \textbf{L} characters '\textbf{0}' or '\textbf{1}' and describe the rectangular grid of lamps: the \textbf{j}-th character of the \textbf{i}-th line is '\textbf{1}' (one) if the lamp in row \textbf{i}, column \textbf{j} is initially "on", and '\textbf{0}' (zero) otherwise. \OutputFile Print the maximal number of rows that can be lit after performing exactly \textbf{K} flips.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2 1
01
10
10
Output example #1
2