| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3.5 초 | 1024 MB | 148 | 22 | 17 | 17.708% |
Nagyerdő is a square-shaped forest located in the city of Debrecen, which can be modeled as an $N \times N$ grid of cells. The rows of the grid are numbered from $0$ to $N - 1$ from north to south, and the columns are numbered from $0$ to $N - 1$ from west to east. We refer to the cell located at row $r$ and column $c$ of the grid as cell $(r, c)$.
In the forest, each cell is either empty or contains a tree. At least one cell in the forest is empty.
DVSC, the famous sports club of the city, is planning to build a new soccer stadium in the forest. A stadium of size $s$ (where $s \ge 1$) is a set of $s$ distinct empty cells $(r_0, c_0), \ldots, (r_{s - 1}, c_{s - 1})$.
Soccer is played using a ball that is moved around the cells of the stadium. A straight kick is defined to be either of the following two actions:
A stadium is regular if it is possible to move the ball from any cell contained by the stadium to any other cell contained by the stadium with at most $2$ straight kicks. Note that any stadium of size $1$ is regular.
For example, consider a forest of size $N = 5$, with cells $(1,0)$ and $(4,2)$ containing trees and every other cell being empty. The figure below shows three possible stadiums. Cells with trees are darkened, and cells contained by the stadium are striped.
The stadium on the left is regular. However, the stadium in the middle is not regular, because at least $3$ straight kicks are needed to move the ball from cell $(4,1)$ to $(4,3)$. The stadium on the right is also not regular, because it is impossible to move the ball from cell $(3,0)$ to $(1,3)$ using straight kicks.
The sports club wants to build a regular stadium that is as big as possible. Your task is to find the maximum value of $s$ such that there exists a regular stadium of size $s$ in the forest.
You should implement the following procedure.
int biggest_stadium(int N, int[][] F)
Consider the following call:
biggest_stadium(5, [[0, 0, 0, 0, 0],
[1, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0]])
In this example, the forest is displayed on the left and a regular stadium of size $20$ is displayed on the right of the following figure:
Since there is no regular stadium of size $21$ or greater, the procedure should return $20$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 6 | There is at most one cell containing a tree. |
| 2 | 8 | $N \le 3$ |
| 3 | 22 | $N \le 7$ |
| 4 | 18 | $N \le 30$ |
| 5 | 16 | $N \le 500$ |
| 6 | 30 | No additional constraints. |
In each subtask, you can obtain 25% of the subtask score if your program judges correctly whether the set consisting of all the empty cells is a regular stadium.
More precisely, for each test case in which the set consisting of all the empty cells is a regular stadium, your solution:
For each test case in which the set consisting of all the empty cells is not a regular stadium, your solution:
The score for each subtask is the minimum of the points for the test cases in the subtask.
The sample grader reads the input in the following format:
The sample grader prints your answer in the following format:
biggest_stadiumOlympiad > International Olympiad in Informatics > IOI 2023 > Day 1 3번
C++17, C++20, C++17 (Clang), C++20 (Clang)