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

建议使用的浏览器:

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

4955:Tree

题目描述
Teacher Mai has a directed graph with n nodes and n edges. This graph is special: Out degree of each node is 1, and there is no self loop.

For every node Teacher Mai wrote down a set of nodes which directly links to this node.

For example, the graph contains 4 edges: {1->2,2->4,3->1,4->1}, the set of each node is {3,4},{1},{},{2}

But Teacher Mai found that he forgot writing which node the set belonged to.

Teacher Mai wanted to recover it, but he found there are many graphs with the same node sets.

You should count the number of different graphs have the same node sets as the given one.

The number can be very large, just output the number modulo 1000000007 (10^9+7).

If there is no solution, the answer is 0.
输入解释
There are multiple test cases, terminated by a line "0".

For each test case, the first line contains a integer n (1<=n<=1000).

The following are n lines representing the set of each node. For every line, there is a integer p first, indicating the size of the set. Then there are p integers, indicating the node with index from 1 to n in this set.
输出解释
For each test case, output one line "Case #k: ans", where k is the case number, counting from 1, ans is the number module 10^9+7.
输入样例
6
1 1
0
0
0
2 2 3
3 4 5 6
0
输出样例
Case #1: 38
来自杭电HDUOJ的附加信息
Author xudyh
Recommend

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

源链接: HDU-4955

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

共提交 0

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