#P13012. 【MX-X13-T7】「KDOI-12」No one can be anything without comparison.
【MX-X13-T7】「KDOI-12」No one can be anything without comparison.
Description
Please note the special constraints on in this problem.
players participated in Tetris Tournaments. Each Tetris Tournament consists of rounds. In each round, two currently uneliminated players and are selected to compete, and the loser is eliminated. The last remaining player is the winner. You are given that the -th player was eliminated by in the -th Tetris Tournament. Here, is the winner of the -th tournament if and only if .
The players enjoy comparison. They all hope to surpass others in some way or at least be on a similar level.
Define that in the -th Tetris Tournament, strictly dominates if and only if there exists a sequence (where , i.e., ) such that for all , .
An ordered -tuple of players is called level-similar if and only if for all , strictly dominates in the -th tournament, and strictly dominates in the -th tournament.
Your task is to compute the number of level-similar -tuples, modulo .
Input Format
The first line contains two positive integers and . It is guaranteed that .
The next lines each contain non-negative integers , representing the elimination data for the -th tournament.
Output Format
Output a single non-negative integer: the number of level-similar -tuples, modulo .
3 3
0 1 2
3 0 2
3 1 0
2
6 5
0 1 1 2 3 4
3 3 0 6 6 1
2 4 1 0 1 1
3 0 2 6 6 2
5 3 6 1 0 4
18
Hint
Sample Explanation #1
The valid -tuples are: and .
Constraints
This problem uses bundling tests.
| Subtask | Points | Special Constraints | ||
|---|---|---|---|---|
| None | ||||
| A | ||||
| B | ||||
| None | ||||
- Special Constraint A: For , .
- Special Constraint B: For , there do not exist such that .
For all test cases:
- ,
- ,
- The array is consistent with the problem description, and:
- If , .
- If , .
- If , .
Translation by DeepSeek V3.
京公网安备 11011102002149号