## CCCHK '15 S3 - Symmetric Cross

View as PDF

Points: 12 (partial)
Time limit: 3.0s
Memory limit: 256M

Problem types

You are given an matrix . Each of its elements is either or .

A cross of size is a subregion of , centering at one of its elements, containing the center and elements in each of the four orthogonal directions (i.e., horizontal and vertical directions).

A cross is called "symmetric" if it does not change after being rotated by degrees. Please find the cross with the largest size in . It is guaranteed that there is exactly one such cross.

#### Input specification:

The first line contains two integers and , the number of rows and columns of . The next lines, each contain numbers separated by one space, representing .

• In of the test cases, .
• In of the test cases, .

#### Output specification:

The output contains a single line with three integers: the size of the largest symmetric cross in , and the row and column number of its center.

#### Sample Input 1

5 5
0 0 1 0 0
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
0 0 1 0 0

#### Sample Output 1

2 3 3

#### Sample Input 2

5 5
0 0 1 0 0
0 1 0 0 1
1 0 1 0 0
0 0 1 0 1
0 0 1 0 0

#### Sample Output 2

1 2 2