No.709 Possibility of Winning
Problem Statement
There are $N$ people, numbered from $1$ to $N$. Every person has $M$ types of ability parameters, and the parameter of ability $j$ of person $i$ is $R_{i,j}$.
A total of $N$ programming contests will be held. In the $k$-th contest, the $k$ people from person $1$ to person $k$ participate.
For each contest, the only people who have a possibility of winning are those who attain the maximum value among the participants in at least $1$ type of ability parameter. For each contest, determine how many people have a possibility of winning.
Input
$N$ $M$
$R_{1,1}$ $R_{1,2}$ ... $R_{1,M}$
$R_{2,1}$ $R_{2,2}$ ... $R_{2,M}$
:
$R_{N,1}$ $R_{N,2}$ ... $R_{N,M}$
The $1$-st line contains the number of people $N(1 \le N \le 10^5)$ and the number of types of ability parameters $M(1 \le M \le 10)$.
The $i$-th of the following $N$ lines contains $M$ space-separated integers $R_{i,j}(1 \le R_{i,j} \le 10^9)$, where the $j$-th value is the parameter of ability $j$ of person $i$.
Output
The output consists of $N$ lines. On the $i$-th line, print the number of people who have a possibility of winning the $i$-th contest.
Sample
Sample 1
Input
5 1 5 4 5 6 7
Output
1 1 2 1 1
- In contests $1, 2$, person $1$ always wins.
- In contest $3$, persons $1, 3$ have a possibility of winning. Both have the maximum value $5$ for the parameter of ability $1$.
- In contest $4$, person $4$ always wins.
- In contest $5$, person $5$ always wins.
Sample 2
Input
7 3 1 2 3 3 1 2 1 2 1 3 3 4 1000000000 1000000000 1000000000 334 57 119 114 1333 514
Output
1 2 3 2 1 1 1
- In contest $1$, person $1$ always wins.
- In contest $2$, persons $1, 2$ have a possibility of winning. Person $1$ attains the maximum for abilities $2, 3$, and person $2$ for ability $1$.
- In contest $3$, persons $1, 2, 3$ have a possibility of winning. Person $1$ attains the maximum for abilities $2, 3$, person $2$ for ability $1$, and person $3$ for ability $2$.
- In contest $4$, persons $2, 4$ have a possibility of winning. Person $2$ attains the maximum for ability $1$, and person $4$ for abilities $1, 2, 3$.
- In contest $5$ and later, person $4$ always wins.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ei1333333