QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100 الصعوبة: [عرض]

#2010. Today's Menu for Emiya Family

الإحصائيات

Emiya is a high school student who excels at cooking. He has mastered $n$ cooking methods and uses $m$ main ingredients. For convenience, we number the cooking methods from $1$ to $n$ and the main ingredients from $1$ to $m$.

Each dish Emiya prepares uses exactly one cooking method and exactly one main ingredient. Specifically, Emiya can prepare $a_{i,j}$ different dishes using cooking method $i$ and main ingredient $j$ ($1 \le i \le n, 1 \le j \le m$), which means Emiya can prepare a total of $\sum_{i=1}^n \sum_{j=1}^m a_{i,j}$ different dishes.

Today, Emiya is preparing a meal to host his good friends Yazid and Rin. However, the three of them have different requirements for the combination of dishes. Specifically, for a combination of $k$ dishes:

  • Emiya will not let everyone go hungry, so he will prepare at least one dish, i.e., $k \ge 1$.
  • Rin wishes to taste dishes made with different cooking methods, so she requires that the cooking method for each dish must be distinct.
  • Yazid does not wish to taste too many dishes made with the same ingredient, so he requires that each main ingredient is used in at most half of the dishes (i.e., $\lfloor \frac{k}{2} \rfloor$ dishes).
    • Here, $\lfloor x \rfloor$ is the floor function, representing the largest integer not exceeding $x$.

These requirements do not stump Emiya, but he wants to know how many different valid combinations of dishes exist. Two combinations are different if and only if there exists at least one dish that appears in one combination but not in the other.

Emiya has come to you for help. Please calculate the number of valid combinations and output the result modulo $998,244,353$.

Input

The input is read from the file meal.in.

The first line contains two integers $n$ and $m$, separated by a single space.

From the second line to the $(n+1)$-th line, each line contains $m$ integers separated by single spaces. The $m$ integers in the $(i+1)$-th line are $a_{i,1}, a_{i,2}, \dots, a_{i,m}$ respectively.

Output

The output is written to the file meal.out.

The output contains a single integer, representing the number of valid combinations modulo $998,244,353$.

Examples

Input 1

2 3
1 0 1
0 1 1

Output 1

3

Note 1

In this example, since Emiya can prepare at most one dish for each pair $(i, j)$, we describe a dish simply by the indices of its cooking method and main ingredient.

Valid combinations include: One dish using cooking method 1 and main ingredient 1, and one dish using cooking method 2 and main ingredient 2. One dish using cooking method 1 and main ingredient 1, and one dish using cooking method 2 and main ingredient 3. * One dish using cooking method 1 and main ingredient 3, and one dish using cooking method 2 and main ingredient 2.

Thus, the result is $3 \pmod{998,244,353} = 3$.

Note that all combinations containing only one dish are invalid because the single main ingredient used would appear in $1$ dish, which is greater than $\lfloor \frac{1}{2} \rfloor = 0$, failing Yazid's requirement.

Input 2

3 3
1 2 3
4 5 0
6 0 0

Output 2

190

Note 2

Emiya must prepare at least 2 dishes. The number of valid combinations with 2 dishes is 100. The number of valid combinations with 3 dishes is 90. Thus, the total number of valid combinations is $100 + 90 = 190$.

Input 3

5 5
1 0 0 1 1
0 1 0 1 0
1 1 1 1 0
1 0 1 0 1
0 1 1 0 1

Output 3

742

Examples 4 & 5

See files meal/meal4.in and meal/meal4.ans, and meal/meal5.in and meal/meal5.ans in the contestant directory.

Constraints

Test Case ID $n =$ $m =$ $a_{i,j} <$
1 2 2 2
2 2 3 2
3 5 2 2
4 5 3 2
5 10 2 2
6 10 3 2
7 10 2 1000
8 10 3 1000
9~12 40 2 1000
13~16 40 3 1000
17~21 100 500 1000
22~25 100 2000 998,244,353

For all test cases, it is guaranteed that $1 \le n \le 100$, $1 \le m \le 2000$, and $0 \le a_{i,j} < 998,244,353$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.