ZNANSTVE - ZNANSTVENIK
In this economy, we all know how hard it is to get a job. Mirko, a recent college graduate, however, got lucky - he is now employed as a runeologist by the Language Institute of Croatia. His friend Slavko believes runeology isn’t a science and is hence angry at Mirko for believing the opposite. One foggy Christmas day, Mirko’s laptop broke. Since he isn’t great with computers, he gave it to Slavko to repair it. Slavko, felling a little naughty, decided to mess up a particular file Mirko was working on.
This file contains a matrix of R rows and C columns. Each element of the matrix is a single letter. No two columns of the matrix are equal. To have some fun with pseudo-scientist Mirko, Slavko decided he will delete as much rows as possible from the top of the table, without breaking the no-equalcolumn rule.
The first line of input contains two integers R and C (2 ≤ R, C ≤ 1000), the number of rows and the
number of columns, respectively.
In each of the next R lines there are C small letters of the English alphabet. These R x C letters
represent Mirko’s table (which does not have two same columns).
Output a single integer, the maximum number of rows which can be deleted from the top of the table
so that no two columns are equal.
EXAMPLE TEST DATA
There are blanklines between rows, nasty trap for line-reading languages when input is made of strings!
Finally AC after so many attempts.
Try this input :
easy pgm in python but i am getting tle :(
Getting wrong in 9th case ..pl suggest.
the only difference between my second last and third last submissions is declaring the variable max as local and global...yet one gives TLE while other gives WA..how is that possible?
adhikari vushesh babu:
simple got acc :)by brute force
brute force is accepted :P
If you delete row 1 and 2, columns 1 and 6 will be identical with "aa", so you can delete only one.
what is meant by "top of the table"