#P12152. 【MX-X11-T6】「蓬莱人形 Round 1」催眠术
【MX-X11-T6】「蓬莱人形 Round 1」催眠术
Description
Given , a length- integer sequence with values in , and an matrix .
An integer sequence is defined as good if and only if:
- All its values are in .
- Every length- integer sequence with values in is a subsequence of it.
For a good sequence of length , its value is defined as , where is the maximum prefix length of such that is a subsequence of . If no such prefix exists, .
Find the sum of values of all length- good sequences, modulo .
Input Format
- The first line contains three positive integers .
- The second line contains positive integers .
- The next lines each contain positive integers .
Output Format
Output a single integer: the sum of values of all good sequences modulo .
2 1 2
2
2 3
2 3
15
10 2 5
2 3
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
14400
10 3 3
2 3 3
2 3 1 4
5 2 3 1
5 6 6 6
2 2 3 1
7 6 5 7
2 2 3 1
7 6 5 7
2 2 3 1
7 6 5 7
9 8 1 2
350920080
Hint
Explanation #1
The valid good sequences are and . Their values are and , respectively. The total sum is .
Constraints
This problem uses subtask scoring.
For all test data: , , .
| Subtask | Special Property | Points | |||
|---|---|---|---|---|---|
| 1 | 8 | None | 5 | ||
| 2 | 400 | A | 10 | ||
| 3 | 50 | None | |||
| 4 | 400 | 30 | 8 | 15 | |
| 5 | 400 | ||||
| 6 | 400 | B | |||
| 7 | None | 30 | |||
- Special Property A: All are equal.
- Special Property B: All are equal.
Translated by DeepSeek R1
京公网安备 11011102002149号