304613: CF878C. Tournament

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Tournament

题意翻译

最近Berland开始了一场有k种运动的比赛。瓦萨亚希望在赌场上赚钱。 比赛的计划非常神秘,并没有完全公开。比赛选手背靠背举行,每场比赛都涉及两名尚未淘汰的运动员。每场比赛都可以举行k种运动里的任意一种,失败者则遭到淘汰。最后剩下的运动员成为冠军。除此之外,该方案可以是任意的,不提前公开。 瓦西亚了解各种运动中的运动员的力量。他认为,拥有更高力量的运动员总能获胜。 比赛每年举行一次,每年都有一名新参赛者加入比赛。在第一场比赛中,只有一名运动员参加,第二场比赛有两名运动员,依此类推。 请你帮助他找到每一年可能获得冠军的人数。

题目描述

Recently a tournament in $ k $ kinds of sports has begun in Berland. Vasya wants to make money on the bets. The scheme of the tournament is very mysterious and not fully disclosed. Competitions are held back to back, each of them involves two sportsmen who have not left the tournament yet. Each match can be held in any of the $ k $ kinds of sport. Loser leaves the tournament. The last remaining sportsman becomes the winner. Apart of this, the scheme can be arbitrary, it is not disclosed in advance. Vasya knows powers of sportsmen in each kind of sport. He believes that the sportsmen with higher power always wins. The tournament is held every year, and each year one new participant joins it. In the first tournament, only one sportsman has participated, in the second there were two sportsmen, and so on. Vasya has been watching the tournament for the last $ n $ years. Help him to find the number of possible winners for each of the $ n $ tournaments.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 1<=n<=5·10^{4} $ , $ 1<=k<=10 $ ) — the number of tournaments and the number of kinds of sport, respectively. Each of the next $ n $ lines contains $ k $ integers $ s_{i1},s_{i2},...,s_{ik} $ ( $ 1<=s_{ij}<=10^{9} $ ), where $ s_{ij} $ is the power of the $ i $ -th sportsman in the $ j $ -th kind of sport. The sportsman with higher powers always wins. It's guaranteed that for any kind of sport all of these powers are distinct.

输出格式


For each of the $ n $ tournaments output the number of contenders who can win.

输入输出样例

输入样例 #1

3 2
1 5
5 1
10 10

输出样例 #1

1
2
1

输入样例 #2

3 2
2 2
3 3
1 10

输出样例 #2

1
1
3

输入样例 #3

3 2
2 3
1 1
3 2

输出样例 #3

1
1
2

说明

In the first sample: In the first tournament there is only one sportsman, and he is the winner. In the second tournament, there are two sportsmen, and everyone can defeat another, depending on kind of sports. In the third tournament, the third sportsman in the strongest in both kinds of sports, so he is the winner regardless of the scheme.

Input

题意翻译

最近Berland开始了一场有k种运动的比赛。瓦萨亚希望在赌场上赚钱。 比赛的计划非常神秘,并没有完全公开。比赛选手背靠背举行,每场比赛都涉及两名尚未淘汰的运动员。每场比赛都可以举行k种运动里的任意一种,失败者则遭到淘汰。最后剩下的运动员成为冠军。除此之外,该方案可以是任意的,不提前公开。 瓦西亚了解各种运动中的运动员的力量。他认为,拥有更高力量的运动员总能获胜。 比赛每年举行一次,每年都有一名新参赛者加入比赛。在第一场比赛中,只有一名运动员参加,第二场比赛有两名运动员,依此类推。 请你帮助他找到每一年可能获得冠军的人数。

加入题单

上一题 下一题 算法标签: