2021: [USACO 2024 January Contest Gold] Problem 2. Cowmpetency
题目描述
Farmer John is hiring a new herd leader for his cows. To that end, he has interviewed () cows for the position. After each interview, he assigned an integer "cowmpetency" score to the candidate ranging from to () that is correlated with their leadership abilities.
Because he has interviewed so many cows, Farmer John has forgotten all of their cowmpetency scores. However, he does remembers () pairs of numbers where cow was the first cow with a strictly greater cowmpetency score than cows through (so ).
Farmer John now tells you the pairs of . Help him count how many sequences of cowmpetency scores are consistent with this information! It is guaranteed that there is at least one such sequence. Because this number may be very large, output its value modulo .
输入
The next lines each contain a pair . It is guaranteed that all are distinct.
输出
样例输入
6 2 3
2 3
4 5
样例输出
6
提示
The following six sequences are the only ones consistent with what Farmer John remembers:
1 1 2 1 3 1
1 1 2 1 3 2
1 1 2 1 3 3
1 1 2 2 3 1
1 1 2 2 3 2
1 1 2 2 3 3
SAMPLE INPUT:
10 1 20
1 3
SAMPLE OUTPUT:
399988086
Make sure to output the answer modulo .
SCORING:
- Inputs 3-4 satisfy and .
- Inputs 5-7 satisfy .
- Inputs 8-10 satisfy and .
- Inputs 11-15 satisfy .
- Inputs 16-20 satisfy no additional constraints.