题库练习 Politics
← 上一题 下一题 →

A15951 | Politics

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

In a debate club with $n$ members, including yourself (member $1$ ), there are $k$ opinions to be discussed in sequence. During each discussion, members express their agreement or disagreement with the opinion. Let's define $Y$ as the number of members who agree and $N$ as the number of members who disagree. After each discussion, members leave the club based on the following criteria:

- If more members agree than disagree ( $Y > N$ ), all members who disagreed leave the club.
- If more members disagree than agree ( $Y < N$ ), all members who agreed leave the club.
- If there is a tie ( $Y = N$ ), all members leave the club.

As the club president, your goal is to stay in the club and maximize the number of members remaining after the meeting. You have access to each member's stance on all $k$ opinions before the meeting starts, and you can expel any number of members (excluding yourself) before the meeting begins.

Determine the maximum number of members, including yourself, who can remain in the club after the meeting. You don't need to provide the specific expulsion strategy but only the maximum number of members that can stay. Ensure that you remain in the club after the meeting as well.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 1000$ ). Description of the test cases follows.

The first line of each test case contains two positive integers $n$ and $k$ ( $1 \le n, k \le 100$ ) — the number of members and the number of discussions.

The $i$ -th of the following $n$ lines contains a string $t_i$ of length $k$ . The $j$ -th character in the string $t_i$ indicates whether the $i$ -th member agrees or disagrees with the $j$ -th opinion if they are present during that discussion. A "+" symbol means the member agrees, while a "-" symbol means the member disagrees.

It is guaranteed that the sum of $n \cdot k$ over all test cases does not exceed $5 \cdot 10^4$ .

输出格式

For each test case, output the maximum number of members, including yourself, who can remain in the club after the meeting.

输入输出样例

输入 #1
5
2 2
++
+-
1 3
+-+
4 1
+
-
-
+
5 4
++++
+--+
++-+
+-++
++++
4 2
++
--
--
-+
输出 #1
1
1
2
2
1
C++ 编辑器
输入
输出