RoAlgo Contest #12 - NiceContest | F. Nice Scam

This was the problem page during the contest. Access the current page here.
Time limit: 0.2s Memory limit: 128MB Input: Output:

Baiatu' Bombonel has just finished setting up the Scam School curriculum. The first lesson included in the Scam School curriculum is that to be a successful scammer, you must know how not to get scammed. To teach this introductory lesson, Baiatu' Bombonel has promised to place as many students who are friends with each other in a classroom. But, being an expert scammer, Baiatu' Bombonel wants to scam them to the maximum; he wants to place as many students in a classroom who do not know each other. The IDs of each of the NN students are known, represented by a binary string of length MM each, and it is known that students ii and jj are friends only if their IDs differ by exactly one bit.

Task

Given NN, MM and the NN IDs of the students, determine the maximum number of students Baiatu' Bombonel can place in a classroom, under the condition that none of them know any other student in the classroom.

Input data

The first line will contain the numbers NN and MM, representing the number of students and the length of the IDs, respectively. Each of the next NN lines will contain a binary string of length MM, representing the IDs of the students.

Output data

Print the maximum number of students Baiatu' Bombonel can place in a classroom, with the condition that none of them know any other student in the classroom.

Constraints and clarifications

  • 1N,M1 0001 \leq N, M \leq 1\ 000;
  • For tests worth 1010 points, N17,M10N \leq 17, M \leq 10;
  • For other tests worth 1010 points, N17,M1 000N \leq 17, M \leq 1\ 000;
  • For other tests worth 3030 points, N1 000,M30N \leq 1\ 000, M \leq 30;
  • Each of the NN students have distinct IDs.

Example 1

stdin

4 4
0000
1100
0011
1111

stdout

4

Explanation

Baiatu' Bombonel can put all of the students in the same classroom, since none are friends with each other.

Example 2

stdin

4 4
0000
1100
0011
1000

stdout

3

Explanation

We can choose students 00, 11 and 22 and leave 33 out.

Log in or sign up to be able to send submissions!