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

建议使用的浏览器:

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

5989:Pattern

题目描述
Alice and Bob are playing a game. Alice takes a paper with $N \times M$ points arranging in $N$ rows and $M$ columns. First, Alice colors some points with one of $5$ colors: $c_0, c_1, c_2, c_3, c_4$. And then, Bob draws some lines between adjacent points which own a common edge. If the color of a point is $c_i$, Bob must draw exactly $i$ lines linking this point. Otherwise, Bob can draw any number of lines linking it. At last, Alice would color the rest points, with the same rules that the point which links $i$ lines should be painted the color $c_i$. After the game, Alice might get different patterns of the colors. Suppose the initial colored paper can lead to totally $K$ patterns, and there are $P_i$ ways for Bob to draw lines for the $i$-th patterns. Alice wants to know $\sum_{i=1}^K P_i^2$.
输入解释
The first line of input contains an integer t which is the number of test cases. Then t test cases follow.
For each test case, the first line consists of two integers N(N ≤ 66), and M(M ≤ 6). The i-th line of the next N lines contains M integers, and among them the j-th integer donates the point (i, j). If the point is panted color $c_i$ , the integer is i, otherwise it is -1.
输出解释
For each test cases, output $\sum_{i=1}^{K} P_i^2$ modulo 10007.
输入样例
2
2 2
-1 -1
-1 -1
3 3
1 1 1
1 0 1
1 1 1
输出样例
18
4
提示
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

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

源链接: HDU-5989

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

共提交 0

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