loj#P3569. 「COCI 2021.11」磁铁
「COCI 2021.11」磁铁
Description
Problem from COCI 2021/2022 Contest #2 T4 Magnet
Little Marko is bored of playing with shady cryptocurrencies such as Shiba Inu or XRC, which is why he decided to play with magnets. He has different magnets and a board which has available empty slots in a row, in which the magnets can be placed. Each pair of adjacent slots is exactly one centimeter apart. Each of the magnets has a radius of activity that is equal to . This means that it will attract all magnets that are located strictly less than centimeters away (regardless of the radius of activity of the other magnet). It is possible that some magnets have the same radius of activity, but they are considered as different magnets.
Marko doesn’t like it when the magnets attract each other, so he is interested in the number of ways to place the magnets on the board so that no magnet attracts any other. All of the magnets should be placed on the board, and each empty slot may contain at most one magnet. Two ways of placing the magnets are considered different if there is magnet which is at a different position in the first way than in the second way. As the required number can be quite large, you should output it modulo .
Input
The first line contains positive integers and , the number of magnets and the number of empty slots.
The second line contains n positive integers , the radii of activity of the magnets.
Output
Print the required number of ways to place the magnets on the board so that no magnet attracts any other, modulo .
1 10
10
10
4 4
1 1 1 1
24
3 4
1 2 1
4
Limits And Hints
In every subtask, it holds that and .
Subtask | Points | Constraints |
---|---|---|
No additional constraints |