#P12486. [集训队互测 2024] 木桶效应
[集训队互测 2024] 木桶效应
Background
The parts that make up an organization are often uneven in quality, and the weaker parts often determine the overall level of the whole organization.
Problem Description
Little D has barrels. Each barrel is made of wooden planks, and the planks are all of different types. For a barrel, if the plank lengths are , then the volume of liquid it can hold is . Little D’s barrels are magical: the profit they produce is not simply the sum of the liquid volumes of each barrel, but the product of the liquid volumes of all barrels. That is, for these barrels, if the height of the -th plank of the -th barrel is , then the profit produced by these barrels is .
Little D has already bought some planks from the lumber store, but the number of planks in the store is limited. Specifically, for each of the types of planks, Little D has exactly one plank of each length from to . Little D has now placed planks, but he has not decided how to place the remaining planks. Therefore, he wants you to compute the sum of profits over all valid placement schemes. Since this number can be very large, you only need to output the result modulo .
Formal Statement
There are permutations of length . Among them, the values at positions have been fixed, and the remaining positions are unfixed. Find the sum, over all essentially different permutation groups, of , modulo . Two permutation groups and are essentially different if and only if there exist such that . It is guaranteed that at least one valid scheme exists.
Input Format
The first line contains three integers , with meanings as described above.
The next lines each contain three integers , meaning that is required.
Output Format
Output one integer, the sum of contributions of all schemes modulo .
2 2 0
6
3 2 1
1 1 1
38
50 50 5
6 18 17
10 2 14
43 12 40
11 50 37
45 23 4
830538815
Hint
This problem uses bundled tests.
For all testdata, , , , , .
- Subtask 1 (4 pts): .
- Subtask 2 (8 pts): .
- Subtask 3 (8 pts): .
- Subtask 4 (12 pts): .
- Subtask 5 (16 pts): .
- Subtask 6 (12 pts): .
- Subtask 7 (20 pts): .
- Subtask 8 (12 pts): .
- Subtask 9 (8 pts): No special constraints.
Translated by ChatGPT 5