시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB38211751.515%

문제

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.

서브태스크

번호배점제한
140

$1 \leq N \leq 10$

All color IDs $A_{ij}$ in the grid are either 0 or 1.

215

$1 \leq N \leq 2\,000$

All color IDs $A_{ij}$ in the grid are either 0 or 1.

315

$1 \leq N \leq 80$

415

$1 \leq N \leq 400$

515

$1 \leq N \leq 2\,000$

예제 입력 1

4
1 0 0 0
1 0 1 0
1 1 0 0
0 1 1 0

예제 출력 1

4

This example satisfies the conditions of Subtask 1, 2, 3, 4 and 5.

예제 입력 2

4
1 2 2 2
1 2 2 2
1 2 2 2
3 3 0 -1

예제 출력 2

9

This example satisfies the conditions of Subtask 3, 4 and 5.

예제 입력 3

6
1 1 2 2 2 4
1 1 1 2 2 4
3 1 1 2 2 2
3 3 3 3 3 2
4 4 4 4 4 5
5 5 5 5 1 1

예제 출력 3

6

This example satisfies the conditions of Subtask 3, 4 and 5.

출처

University > 서강대학교 > CSE4152 문제해결프로그래밍실습 > 2025-2학기 중간고사 코딩 테스트 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.