#P9333. [JOIST 2023] 议会 / Council

[JOIST 2023] 议会 / Council

Description

In the council of JOI City, there are NN assembly members, numbered from 11 to NN. The council will open a meeting, and the assembly members will take votes on MM proposed ordinances, numbered from 11 to MM. If Ai,j=1A_{i, j} = 1, the assembly member i (1iN)i \ (1 \le i \le N) will cast an affirmative vote on the proposed ordinance j (1jM)j \ (1 \le j \le M). If Ai,j=0A_{i, j} = 0, the assembly member ii will cast a negative vote on the proposed ordinance jj.

The council of JOI City will be performed as follows.

  1. Among the NN assembly members, they will randomly choose a chairperson by drawing lots.
  2. The chairperson will choose a deputy chairperson among the N1N - 1 assembly members except for the chairperson.
  3. The votes will be taken on MM proposed ordinances. Each of the N2N - 2 assembly members except for the chairperson and the deputy chairperson will cast an affirmative vote or a negative vote on each proposed ordinance. The council will approve a proposed ordinance if a majority of the assembly members (i.e., more than or equal to N2\lfloor \frac{N}{2} \rfloor assembly members) cast affirmative votes on it. Here, x\lfloor x \rfloor is the largest integer not exceeding xx.

Mayor K, the mayor of JOI City, wants the council to approve as many proposed ordinances as possible. Mayor K collected information on assembly members. Mayor K knows, on each proposed ordinance, who will cast an affirmative vote and who will cast a negative vote.

Write a program which, given information of the votes of the assembly members, calculates, for each assembly member, the maximum possible number of proposed ordinances approved by the council if that assembly member is chosen as the chairperson.

Input Format

Read the following data from the standard input.

N MN \ M

A1,1 A1,2  A1,MA_{1, 1} \ A_{1, 2} \ \cdots \ A_{1, M}

A2,1 A2,2  A2,MA_{2, 1} \ A_{2, 2} \ \cdots \ A_{2, M}

\vdots

AN,1 AN,2  AN,MA_{N, 1} \ A_{N, 2} \ \cdots \ A_{N, M}

Output Format

Write NN lines to the standard output. The ii-th line (1iN)(1 \le i \le N) of output should contain the maximum possible number of proposed ordinances approved by the council if the assembly member ii is chosen as the chairperson.

3 3
1 0 0
1 1 0
1 1 1

3
3
2

4 12
1 1 1 0 1 1 0 1 0 1 1 0
1 1 0 1 1 0 1 1 1 1 1 0
0 0 1 1 1 0 0 0 0 0 1 1
1 0 0 0 1 1 1 1 1 0 0 0

5
4
6
6

16 4
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1

3
3
3
2
3
2
2
1
3
2
2
1
2
1
1
0

4 2
1 0
0 1
1 1
1 1

2
2
1
1

Hint

【样例解释 #1】

  • Let’s consider the case where the assembly member 11 is chosen as the chairperson. If the assembly member 22 is chosen as the deputy chairperson, the council will approve three proposed ordinances, i.e., the proposed ordinances 1,2,31, 2, 3. If the assembly member 33 is chosen as the deputy chairperson, the council will approve two proposed ordinances, i.e., the proposed ordinances 1,21, 2. Therefore, the maximum number of proposed ordinances approved by the council is 33. Output 33 in the first line.
  • Let’s consider the case where the assembly member 22 is chosen as the chairperson. If the assembly member 11 is chosen as the deputy chairperson, the council will approve three proposed ordinances, i.e., the proposed ordinances 1,2,31, 2, 3. If the assembly member 33 is chosen as the deputy chairperson, the council will approve one proposed ordinance, i.e., the proposed ordinance 11. Therefore, the maximum number of proposed ordinances approved by the council is 33. Output 33 in the second line.
  • Let’s consider the case where the assembly member 33 is chosen as the chairperson. If the assembly member 11 is chosen as the deputy chairperson, the council will approve two proposed ordinances, i.e., the proposed ordinances 1,21, 2. If the assembly member 22 is chosen as the deputy chairperson, the council will approve one proposed ordinance, i.e., the proposed ordinance 11. Therefore, the maximum number of proposed ordinances approved by the council is 22. Output 22 in the third line.

该样例满足子任务 1,2,4,5,6,71, 2, 4, 5, 6, 7 的限制。

【样例解释 #2】

该样例满足子任务 1,2,5,6,71, 2, 5, 6, 7 的限制。

【样例解释 #3】

该样例满足子任务 1,2,4,5,6,71, 2, 4, 5, 6, 7 的限制。

【样例解释 #4】

该样例满足所有子任务的限制。

【数据范围】

对于所有测试数据,3N3×1053 \le N \le 3 \times 10 ^ 51M201 \le M \le 200Ai,j10 \le A_{i, j} \le 1,保证所有输入均为整数。

子任务编号 分值 限制
11 88 N300N \le 300
22 N3000N \le 3000
33 66 M2M \le 2
44 1919 M10M \le 10
55 1515 M14M \le 14
66 2222 M17M \le 17
77