問題一覧 > 通常問題

No.2178 Payable Magic Items

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 88
作問者 : MasKoaTS / テスター : mine691 👑 potato167
お気に入りにしたユーザー ProblemId : 8311 / 自分の提出
問題文最終更新日: 2024-11-28 20:31:52
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 372 (順位表) の他の問題:

Problem Statement

The wizard Koa has made $N$ magic items numbered $1,2,\dots,N$.

Each magic item has $K$ values representing its performance, and the $j$-th $(1 \leq j \leq K)$ value of magic item $i$ $(1 \leq i \leq N)$ is $S_{i,j}$.

Koa wants to keep the cost of storing these magic items as low as possible, so
she has decided to sell all magic items $x$ $(1 \leq x \leq N)$ that satisfy the following condition.

  • There exists an integer $y$ $(1 \leq y \leq N)$ different from $\boldsymbol{x}$ such that $S_{x,k} \leq S_{y,k}$ holds for every integer $k$ $(1 \leq k \leq K)$.

Find the number of magic items Koa sells.

Constraints

  • $1 \leq N \leq \min(2 \times 10^{5}, 5^{K})$

  • $1 \leq K \leq 8$

  • $0 \leq S_{i,j} \leq 4$ $(1 \leq i \leq N \text{ and } 1 \leq j \leq K)$

  • $( S_{i,1}, S_{i,2}, \dots, S_{i,K} ) \neq ( S_{j,1}, S_{j,2}, \dots, S_{j,K} )$ $(1 \leq i < j \leq N)$

  • $N, K$ and $S_{i,j}$ $(1 \leq i \leq N \text{ and } 1 \leq j \leq K)$ are all integers

Input

The input is given in the following format.

$N$ $K$
$S_{1,1} S_{1,2} \cdots S_{1,K}$
$S_{2,1} S_{2,2} \cdots S_{2,K}$
 $\vdots$    $\ddots$    $\vdots$
$S_{N,1} S_{N,2} \cdots S_{N,K}$
  • Line $1$ contains $N, K$ in this order, separated by a half-width space

  • Line $(1 + i)$ $(1 \leq i \leq N)$ contains $S_{i,1}, S_{i,2} \dots, S_{i,K}$ in this order as a string of length $K$

Output

Print the answer on $1$ line.

Sample

Sample 1
Input
3 3
210
420
004
Output
1

Koa sells only magic item $1$.

For example, when comparing the performance of magic item $1$ and magic item $2$, $S_{1,k} \leq S_{2,k}$ holds for every integer $k$ $(1 \leq k \leq 3)$.

Also, when comparing the performance of magic item $1$ and magic item $3$, $S_{3,1} \leq S_{1,1}$ and $S_{3,2} \leq S_{1,2}$ hold, but
$S_{3,3} > S_{1,3}$, so magic item $3$ is not sold.

Sample 2
Input
2 2
40
04
Output
0

Koa sells no magic items.

Sample 3
Input
5 1
2
3
0
1
4
Output
4
Sample 4
Input
1 8
44444444
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。