AT_arc218_a.Many Sets
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given N sequences of positive integers, each of length M. The i-th sequence is Ai=(Ai,1,Ai,2,…,Ai,M).
There are MN 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.
给你 N 个正整数序列,每个序列的长度均为 M。第 i 个序列为 Ai=(Ai,1,Ai,2,…,Ai,M)。
从这 N 个序列中各选一个元素,共有 MN 种选择方式。对所有这些选择方式,求“所选元素中不同整数的个数”的总和,并将结果对 998244353 取模。
输入格式
The input is given from Standard Input in the following format:
N M
A1,1 A1,2 … A1,M
A2,1 A2,2 … A2,M
⋮
AN,1 AN,2 … AN,M
输入从标准输入中按以下格式给出:
N M
A1,1 A1,2 … A1,M
A2,1 A2,2 … A2,M
⋮
AN,1 AN,2 … AN,M
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
2 2 1 3 2 3
输出#1
7
输入#2
2 2 1 1 1 2
输出#2
6
输入#3
3 5 3 1 3 4 2 5 2 1 2 3 4 6 2 5 6
输出#3
327
说明/提示
Sample 1 Explanation:
For example, if A1,1 and A2,1 are chosen, there are two distinct integers among the chosen elements: 1 and 2.
The number of distinct integers is 1 only when A1,2 and A2,2 are chosen, and it is 2 in the other three cases, so the answer is 7.
Constraints
- 1≤N,M≤500
- 1≤Ai,j≤NM
- All input values are integers.
样例 1 解释:
例如,若选择 A1,1 和 A2,1,则所选元素中包含两个不同的整数:1 和 2。
仅当选择 A1,2 和 A2,2 时,所选元素中不同整数的个数为 1;其余三种情况中,不同整数的个数均为 2,因此答案为 7。
约束条件
- 1≤N,M≤500
- 1≤Ai,j≤NM
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?