编程介的小学生 2020-02-16 01:55 采纳率: 20.5%
浏览 82

Distinct Sub-matrix 矩阵的问题

Problem Description
In this problem, let us consider an N*M matrix of capital letters. By selecting consecutive columns and rows, we can define the sub-matrix as the elements on chosen columns and rows.
Two sub-matrices should be regarded the same if and only if they have the same dimensions and characters (which, of course, are capital letters) on corresponding position. It is your task to find the number of distinct sub-matrices of a given letter matrix.

Input
The input contains a lot of test cases. The first line of input contains exactly one integer, indicating the number of test cases.
For each of the test case, the first line contains two integers N and M, denoting the number of rows and columns of the given matrix. (1 <= N, M <= 128)
The next N lines contain only capital letters, indicating the given matrix.

Output
For each test case, output a single integer denoting the number of distinct sub-matrices.

Sample Input
2
2 2
AB
BA
3 3
ABA
BAA
AAA

Sample Output
Case #1: 7
Case #2: 22

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!