CF878C.Tournament

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

最近,贝兰德正在举行一场包含 kk 种运动项目的锦标赛。瓦西娅希望借此下注赚钱。

该锦标赛的赛制十分神秘,且未完全公开。比赛连续进行,每场比赛由两名尚未被淘汰的运动员参与。每场比赛可在 kk 种运动项目中的任意一种中进行。失败者将被淘汰出锦标赛。最后剩下的那名运动员成为冠军。除此之外,整个赛制可以是任意的,且不会提前公布。

瓦西娅知晓每位运动员在每种运动项目中的实力。他相信:在某项运动中,实力更强的运动员总会获胜。

该锦标赛每年举办一次,且每年会新增一名参赛者。第一届锦标赛仅有 1 名运动员参加,第二届有 2 名运动员,依此类推。瓦西娅已观看了最近 nn 年的锦标赛。请帮助他求出这 nn 届锦标赛中每一届可能的冠军人数。

输入格式

The first line contains two integers n and k (1 ≤ n ≤ 5·104, 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__i_1, _s__i_2, ..., s__ik (1 ≤ s__ij ≤ 109), 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.

第一行包含两个整数 nn 和 kk(1≤n≤5⋅1041 \leq n \leq 5 \cdot 10^4,1≤k≤101 \leq k \leq 10),分别表示锦标赛的场数和运动项目的种类数。

接下来的 nn 行中,每行包含 kk 个整数 si1, si2, …, siks_{i1},\,s_{i2},\,\dots,\,s_{ik}(1≤sij≤1091 \leq s_{ij} \leq 10^9),其中 sijs_{ij} 表示第 ii 位运动员在第 jj 种运动项目中的实力值。实力值更高的运动员总是获胜。保证对于任意一种运动项目,所有运动员的实力值互不相同。

输出格式

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.

在第一个样例中:

在第一场比赛中只有一名运动员,他即为获胜者。

在第二场比赛中,有两名运动员,而谁击败谁取决于运动项目种类。

在第三场比赛中,第三名运动员在两种运动项目中都是最强的,因此无论采用何种赛制,他都是获胜者。

输入解题思路,AI测评打分。不知道怎么写?

首页