AtCoder ARC218 A - Many Sets

AtCoder ARC218 A - Many Sets

暂无测试数据。

题目背景

来自AtCoder ARC 218 A题。
ARC 218 A

题目描述

You are given \( N \) sequences of positive integers, each of length \( M \) . The \( i \) -th sequence is \( A_i=(A_{i,1},A_{i,2},\dots,A_{i,M}) \) .

There are \( M^N \) ways to choose one element from each of these \( N \) sequences. Find the sum, modulo \( 998244353 \) , of "the number of distinct integers among the chosen elements" over all such ways.

输入格式

The input is given from Standard Input in the following format:

\( N \) \( M \) \( A_{1,1} \) \( A_{1,2} \) \( \dots \) \( A_{1,M} \) \( A_{2,1} \) \( A_{2,2} \) \( \dots \) \( A_{2,M} \) \( \vdots \) \( A_{N,1} \) \( A_{N,2} \) \( \dots \) \( A_{N,M} \)

输出格式

Output the answer.

输入输出样例 #1

输入 #1

2 2
1 3
2 3

输出 #1

7

输入输出样例 #2

输入 #2

2 2
1 1
1 2

输出 #2

6

输入输出样例 #3

输入 #3

3 5
3 1 3 4 2
5 2 1 2 3
4 6 2 5 6

输出 #3

327

说明/提示

Sample Explanation 1

For example, if \( A_{1,1} \) and \( A_{2,1} \) are chosen, there are two distinct integers among the chosen elements: \( 1 \) and \( 2 \) .

The number of distinct integers is \( 1 \) only when \( A_{1,2} \) and \( A_{2,2} \) are chosen, and it is \( 2 \) in the other three cases, so the answer is \( 7 \) .

Constraints

  • \( 1 \le N,M \le 500 \)
  • \( 1 \le A_{i,j} \le NM \)
  • All input values are integers.

信息

ID
1005
难度
5
分类
组合数学 | 容斥原理 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者