0 1 矩阵平衡
在维基百科http://en.wikipedia.org/wiki/Dynamic_programming#A_type_of_balanced_0。 E2.80.931_matrix,统计0 1平衡矩阵的个数为给出动态规划的例子。但我发现实现那里给出的算法真的很难。有更好的算法吗?
如果没有,那么任何人都可以以一种更容易实现的方式解释那里提出的算法。这个算法中的递归关系是什么?因为一旦我找到了它,记忆起来就很容易了。
任何人都可以告诉为什么这个特定问题看起来比该页面上给出的所有其他问题困难得多。
On wikipedia http://en.wikipedia.org/wiki/Dynamic_programming#A_type_of_balanced_0.E2.80.931_matrix, counting the number of 0 1 balanced matrices is given as an example of dynamic programming. But I found it really hard to implement the algorithm given there. Is there a better algorithm?
If not, then can anyone kindly explain the algorithm presented there in a way that makes it easier to implement. Like what would be the recurrence relation in this algorithm? Because once I have found it, it would be easy to do memoization.
Also can any one tell that why this particular problem seems so much harder than all the other problems given on that page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
动态编程会更快,但这里有一个简单的枚举方法。
平衡矩阵:双色0-1矩阵。这里s是0-1平衡方阵的维数,L[p][q]是矩阵的一个条目。最初调用 enumerate(s,1,1)。
Dynamic programming would be faster, but here is a simple way for enumeration.
Balanced matrix: bicolorable 0-1 matrix. Here s is the dimension of the 0-1 balanced square matrix, L[p][q] is an entry of the matrix. Initially call enumerate(s,1,1).
动态规划解决方案
Dynamic programming solution