Maximum borders
Practice
2.4 (536 votes)
Basic programming
Input/output
Problem
65% Success 65567 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a table with \(n\) rows and \(m\) columns. Each cell is colored with white or black. Considering the shapes created by black cells, what is the maximum border of these shapes? Border of a shape means the maximum number of consecutive black cells in any row or column without any white cell in between.

A shape is a set of connected cells. Two cells are connected if they share an edge. Note that no shape has a hole in it.

Input format

  • The first line contains \(t\) denoting the number of test cases.
  • The first line of each test case contains integers \(n,\ m\) denoting the number of rows and columns of the matrix. Here, '#' represents a black cell and '.' represents a white cell. 
  • Each of the next \(n\) lines contains \(m\) integers.

Output format

Print the maximum border of the shapes.

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:20
15 votes
Tags:
EasyMathSorting
Points:20
342 votes
Tags:
Ad-HocBasic ProgrammingEasyInput/Output
Points:30
18 votes
Tags:
AlgorithmsApprovedBreadth First SearchGraphsMediumOpen