#P12245. 共同兴趣
共同兴趣
Description
There are students in Little O's grade, numbered . The school surveyed activities. Each student is interested in some activities and not in others. Let indicate whether student is interested in activity , where means interested and means not interested.
For any two students and , their number of common interests is the count of activities where , i.e., the number of activities both students are interested in.
Each student will find all students who have the maximum number of common interests with and send them friendship invitations. If multiple students satisfy this condition, will send invitations to all of them.
Little O (student ) wants to receive as many invitations as possible. He can choose one activity where he is not initially interested (i.e., ) and change it to . He may also choose not to modify any activity. Note: At most one modification is allowed.
What is the maximum number of students who will send invitations to Little O after making at most one modification?
Input Format
The input consists of lines:
- Line : Two integers and , representing the number of students and activities.
- Lines to : Each line contains integers. The -th integer in line represents .
Output Format
Output one integer: the maximum number of students who will invite Little O.
3 3
0 0 0
1 0 1
0 1 1
2
4 3
0 0 0
1 0 1
0 1 1
1 1 1
0
Hint
Sample #1 Explanation
Initially, students and each have common interest with each other (activity ). Their common interests with Little O are . Modifications:
- No modification: invitations.
- Modify to : Student invites Little O ( invitation).
- Modify to : Student invites Little O ( invitation).
- Modify to : Both students and invite Little O ( invitations).
Thus, the maximum is .
Sample #2 Explanation
Adding student (who has common interests with students and ). Little O's maximum common interests with any student after modification cannot exceed , so the answer is .
For data:
| Test Case | Range | Range | Special Properties |
|---|---|---|---|
| None | |||
| A | |||
| B | |||
| None |
Special Properties:
- A: For all , .
- B: For all , .
京公网安备 11011102002149号