#P1736. 创意吃鱼法
创意吃鱼法
Description
After returning home, the cat moved all the fish from three buckets into her large rectangular pool and began to think: what method should she use to eat the fish (the cat is so cute—she even wants to figure out a tasty way to eat fish ^_*)? She finds that viewing the big pool as a matrix ( means the corresponding cell has no fish, means there is a fish) helps decide her eating strategy.
In the matrix representing the pool, there are many square submatrices. If, in some square submatrix, one of its diagonals has fish in every cell and all other cells in that submatrix have no fish, then the cat can start from one end of that diagonal and, with a single suck, pull all the fish on that diagonal into her mouth.
The cat is greedy, so she wants to eat as many fish as possible in one bite. Please help her compute the maximum number of fish she can eat in a single bite.
Input Format
The first line contains two integers and (), describing the size of the pool. The next lines each contain numbers (each is either or ). Adjacent numbers are separated by spaces.
Output Format
Output a single integer—the number of fish the cat can eat in one bite—on one line, followed by a newline.
4 6
0 1 0 1 0 0
0 0 1 0 1 0
1 1 0 0 0 1
0 1 1 0 1 0
3
Hint
For example, a square submatrix with fish only along a diagonal:
1 0 0
0 1 0
0 0 1
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号