F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Distinct Sub-matrix

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 165768/165768 K (Java/Others)
Total Submission(s): 1098    Accepted Submission(s): 361


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
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-03 22:36:06, Gzip enabled