#PU1378. USACO 2024 January Contest, Gold — Problem 2. Cowmpetency
USACO 2024 January Contest, Gold — Problem 2. Cowmpetency
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 first line contains , , and . The next lines each contain a pair . It is guaranteed that all are distinct.
输出格式
The number of sequences of cowmpetency scores consistent with what Farmer John remembers, modulo .
数据范围
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. Problem credits: Suhas Nagar
样例
样例 1
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
样例 2
10 1 20
1 3
399988086
Make sure to output the answer modulo $10^9+7$.