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

建议使用的浏览器:

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

6911:Keeping A Secret

题目描述
Little Y is a Riddler. He always says that this is a secret.

One day, he got a undirected tree. He met Jessica and say, “Hey! I’ve got a new tree. Do you want to guess? This is a secret.”

- The depth of node $i$ in the tree is $d_i$.
- The position of $i$ in the BFS sequence of tree should be less than or equal to $x_i$.
- If $x$ is before $y$ in BFS sequence, either the parent node of $x$ is also the parent node of $y$, or the parent node of $x$ is before the parent node of $y$ in BFS sequence.

However, Jessica quickly finds that too many trees satisfy his conditions. To give him a lesson, she wants to figure out the number of the trees satisfying all these restrictions. Can you help her?
输入解释
The first line contains one integer T (1 ≤ T ≤ 10) denoting the count of testcase.

For each testcase,

The first line contains one integer n (1 ≤ n ≤ 100000) denoting the number of nodes in the tree.

The next n lines each contains two integer $d_i,x_i$ (1 ≤ $d_i,x_i$ ≤ n) denoting the restriction of node i.

It is guaranteed that $\sum n ≤ 5.1\times 10^5$.
输出解释
For each testcase, output one line containing the number of trees modulo $10^9$ + 7.
输入样例
1
9
1 1
2 3
2 3
2 5
3 6
3 7
3 8
3 8
3 9
输出样例
336

提示
The depth of root is 1. 

Note that the BFS sequence of following two trees are different.They are 1-2-3 and 1-3-2 respectively.

来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6911

最后修改于 2021-06-22T18:18:51+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)