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

建议使用的浏览器:

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

6026:Deleting Edges

题目描述
Little Q is crazy about graph theory, and now he creates a game about graphs and trees.
There is a bi-directional graph with $n$ nodes, labeled from 0 to $n-1$. Every edge has its length, which is a positive integer ranged from 1 to 9.
Now, Little Q wants to delete some edges (or delete nothing) in the graph to get a new graph, which satisfies the following requirements:
(1) The new graph is a tree with $n-1$ edges.
(2) For every vertice $v(0<v<n)$, the distance between 0 and $v$ on the tree is equal to the length of shortest path from 0 to $v$ in the original graph.
Little Q wonders the number of ways to delete edges to get such a satisfied graph. If there exists an edge between two nodes $i$ and $j$, while in another graph there isn't such edge, then we regard the two graphs different.
Since the answer may be very large, please print the answer modulo $10^9+7$.
输入解释
The input contains several test cases, no more than 10 test cases.
In each test case, the first line contains an integer $n(1\leq n\leq 50)$, denoting the number of nodes in the graph.
In the following $n$ lines, every line contains a string with $n$ characters. These strings describes the adjacency matrix of the graph. Suppose the $j$-th number of the $i$-th line is $c(0\leq c\leq 9)$, if $c$ is a positive integer, there is an edge between $i$ and $j$ with length of $c$, if $c=0$, then there isn't any edge between $i$ and $j$.
The input data ensure that the $i$-th number of the $i$-th line is always 0, and the $j$-th number of the $i$-th line is always equal to the $i$-th number of the $j$-th line.
输出解释
For each test case, print a single line containing a single integer, denoting the answer modulo $10^9+7$.
输入样例
2
01
10
4
0123
1012
2101
3210
输出样例
1
6
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

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

源链接: HDU-6026

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

共提交 0

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