1650.
Limited Permutation
时间限制 2000 ms
内存限制 128 MB
As to a permutation p1,p2,⋯,pn from 1 to n, it is uncomplicated for each 1≤i≤n to calculate (li,ri) meeting the condition that min(pL,pL+1,⋯,pR)=pi if and only if li≤L≤i≤R≤ri for each 1≤L≤R≤n.
Given the positive integers n, (li,ri) (1≤i≤n), you are asked to calculate the number of possible permutations p1,p2,⋯,pn from 1 to n, meeting the above condition.
The answer may be very large, so you only need to give the value of answer modulo 109+7.
输入数据
输出数据
For each test case, output "Case #x: y" in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
样例输入
复制
3
1 1 3
1 3 3
5
1 2 2 4 5
5 2 5 5 5
\n
· · \n
· · \n
\n
· · · · \n
· · · · \n
样例输出
复制
Case #1: 2
Case #2: 3
· · \n
· · \n