当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5145:NPY and girls

题目描述
NPY's girlfriend blew him out!His honey doesn't love him any more!However, he has so many girlfriend candidates.Because there are too many girls and for the convenience of management, NPY numbered the girls from 1 to n.These girls are in different classes(some girls may be in the same class).And the i-th girl is in class ai.NPY wants to visit his girls frequently.Each time he visits some girls numbered consecutively from L to R in some order. He can only visit one girl every time he goes into a classroom,otherwise the girls may fight with each other(-_-!).And he can visit the class in any order.
Here comes the problem,(NPY doesn't want to learn how to use excavator),he wonders how many different ways there can be in which he can visit his girls.The different ways are different means he visits these classrooms in different order.
输入解释
The first line contains the number of test cases $T(1 \leq T \leq 10)$.
For each test case,there are two integers $n, m(0 < n, m \leq 30000)$ in the first line.N is the number of girls,and M is the number of times that NPY want to visit his girls.
The following single line contains N integers, $a_1, a_2, a_3, \ldots , a_n$, which indicates the class number of each girl. $(0 < a_i \leq 30000)$
The following m lines,each line contains two integers $l, r(1 \leq l \leq r \leq n)$,which indicates the interval NPY wants to visit.
输出解释
For each visit,print how many ways can NPY visit his girls.Because the ans may be too large,print the ans mod 1000000007.
输入样例
2
4 2
1 2 1 3
1 3
1 4
1 1
1
1 1
输出样例
3
12
1
来自杭电HDUOJ的附加信息
Recommend heyang

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #22

源链接: HDU-5145

最后修改于 2020-10-25T23:20:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 32768/32768K(Java/Others)