Magic Land
Practice
2.9 (7 votes)
Data structures
Easy
Implementation
Approved
Problem
41% Success 3414 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a grid of size \(N * M\) where N and M denotes the number of rows and columns respectively. Each cell of the grid is filled with some number.

Now, We define a quantity called Magic Number for each row and column as the maximum number of consecutive adjacent elements having the same number. Now the password of the entry gate is the defined as the \(MAX\) of \(M_R\)[i]\( \)*\( M_C\)[j]\( \) where \(M_R\)[i] and \(M_C\)[j]\( \) refers to Magic number of \(i^{th}\) row and \(j^{th}\) column respectively.

Can you find the password ?

Input:

First line containts T denoting number of test cases. For each of the test case, the first line contains N and M. After that N lines having M integers are provided.

Output:

For each test case, output the value of password in a separate line.

Constraints:

\( 1 \le T \le 5 \)

\(1 \le N,M \le 1000\)

\( 1 \le A[i] \le 100 \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
57 votes
Tags:
Ad-HocEasyMathOpen
Points:30
19 votes
Tags:
Basic ProgrammingBasics of ImplementationImplementation
Points:30
16 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation