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

建议使用的浏览器:

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

5181:numbers

题目描述
Now you have a stack and $n$ numbers $1,2,3,…,n$. These $n$ numbers are pushed in the order and popped if the number is at the top of the stack. You can read the sample to get more details.
This question is quite easy. Therefore I must give you some limits.
There are $m$ limits, each is expressed as a pair$<A,B>$ means the number $A$ must be popped before $B$.
Could you tell me the number of ways that are legal in these limits?
I know the answer may be so large, so you can just tell me the answer mod $1000000007({10}^{9}+7)$.
输入解释
The first line contains an integer $T$(about 5),indicating the number of cases.
Each test case begins with two integers $n(1 \leq n \leq 300)$ and $m(1 \leq m \leq 90000)$.
Next $m$ lines contains two integers $A$ and $B(1 \leq A \leq n,1 \leq B \leq n)$
(P.S. there may be the same limits or contradict limits.)
输出解释
For each case, output an integer means the answer mod $1000000007$.
输入样例
5
1 0
5 0
3 2
1 2
2 3
3 2
2 1
2 3
3 3
1 2
2 3
3 1
输出样例
1
42
1
2
0

提示
The only legal pop-sequence of case 3 is 1,2,3.
The legal pop-sequences of case 4 are 2,3,1 and 2,1,3.
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #31

源链接: HDU-5181

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

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 196608/196608K(Java/Others)