Maximal Color Rectangle

시간 제한2초메모리 제한1024 MB

문제

You are given an $N \times N$ grid $A$ where each cell contains an integer color ID $A_{ij}$. Your task is to find the largest axis-aligned rectangle whose cells all have the same color, and report its area.

In this figure, the maximal area satisfying the problem’s conditions is $6$. Note that rectangle must be axis-aligned and contiguous in rows and columns.

입력

The first line contains a single integer $N$, representing the size of the grid $A$. $(1 \leq N \leq 2\,000)$

The next $N$ lines each contain $N$ integers, integer denotes the color ID $A_{ij}$. $(-1\,000\,000 \leq A_{ij} \leq 1\,000\,000)$

출력

Print a single integer: the maximal area satisfying the problem’s conditions.