Rectangles
시간 제한5초메모리 제한1024 MB
직사각형 내부의 모든 셀이 사각형 바깥 같은 행과 열의 네 셀보다 낮아야 할 때, 격자 안쪽에 놓인 유효한 직사각형의 개수를 센다.
문제
In the early 19th century, the ruler Hoseyngulu Khan Sardar ordered a palace to be built on a plateau overseeing a beautiful river. The plateau is modeled as an grid of square cells. The rows of the grid are numbered through , and the columns are numbered through . We refer to the cell in row and column () as cell . Each cell has a specific height, denoted by .
Hoseyngulu Khan Sardar asked his architects to choose a rectangular area to build the palace. The area should not contain any cell from the grid boundaries (row , row , column , and column ). Hence, the architects should choose four integers , , , and ( and ), which define an area consisting of all cells such that and .
In addition, an area is considered valid, if and only if for every cell in the area, the following condition holds:
- Consider the two cells adjacent to the area in row (cell and cell ) and the two cells adjacent to the area in column (cell and cell ).
The height of cell should be strictly smaller than the heights of all these four cells.
Your task is to help the architects find the number of valid areas for the palace (i.e., the number of choices of , , and that define a valid area).
제한
- (for all )
예제
이 문제는 공개된 예제가 없습니다.