#C5070. Maximum Crops in a Straight Line
Maximum Crops in a Straight Line
Maximum Crops in a Straight Line
You are given a square grid of size (n \times n) where each cell contains either a crop, represented by the character 'C', or an empty field represented by the character 'E'. Your task is to determine the maximum number of contiguous crops that appear in a single straight line. The line may be horizontal, vertical, or diagonal (in both the main diagonal and anti-diagonal directions).
For example, given the grid below:
CECE CCEC EECC ECCE
one of the lines with consecutive crops contains 3 crops.
In mathematical terms, let (grid[i][j]) denote the character at row (i) and column (j). You need to find the maximum value of (k) such that there exists a valid straight line (horizontal, vertical, or diagonal) where (grid[i][j] = grid[i+\delta][j+\delta] = \cdots = 'C') for (k) consecutive indices.
The input will consist of several test cases. For each test case, output an integer representing the maximum contiguous sequence of 'C's in any permitted direction.
inputFormat
Input is given via standard input (stdin). The first line contains an integer (T), denoting the number of test cases. Each test case starts with an integer (n) which indicates the size of the square grid, followed by (n) lines each containing a string of length (n) comprised solely of the characters 'C' and 'E'.
outputFormat
For each test case, output a single integer on a new line representing the maximum number of contiguous crops in a single straight line found in the grid. The output should be written to standard output (stdout).## sample
3
4
CECE
CCEC
EECC
ECCE
3
EEC
CCE
ECE
1
C
3
2
1
</p>