| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 40 | 14 | 8 | 33.333% |
The IOI Kingdom is represented as a square grid of $L$ rows and $L$ columns. The rows are numbered $1, 2, \dots , L$ from top to bottom and the columns are numbered $1, 2, \dots , L$ from left to right. A cell at row $i$ ($1 ≤ i ≤ L$) and column $j$ ($1 ≤ j ≤ L$) is denoted as cell $(i, j)$.
Recently, due to a widespread infection in the IOI Kingdom, the demand for improved medical facilities has increased. In response, the king, Bitaro, has decided to build hospitals in the four corners of the grid, which are cell $(1, 1)$, cell $(1, L)$, cell $(L, 1)$, and cell $(L, L)$. Each hospital is equipped with one ambulance.
The cautious Bitaro decided to run a simulation to prepare for actual emergency calls from patients. In the scenario he envisioned, emergency calls from $N$ patients arrive at time $0$, and he wants to determine whether all patients can be transported to one of the hospitals by time $T$. The $k$-th patient ($1 ≤ k ≤ N$) is located at cell $(X_k, Y_k)$.
The ambulances transport patients according to the following rules:
Unfortunately, Bitaro was unable to determine the outcome of his envisioned scenario, so he has asked you to investigate it on his behalf.
Given the size of the IOI Kingdom and the scenario envisioned by Bitaro, write a program to determine whether all patients can be transported to a hospital by time $T$.
The input is given from Standard Input in the following format:
$L$ $N$ $T$
$X_1$ $Y_1$
$X_2$ $Y_2$
$\vdots$
$X_N$ $Y_N$
Print Yes if all patients can be transported to a hospital by time $T$ in the scenario envisioned by Bitaro. Otherwise, print No. The output should consist of a single line.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 4 | $T ≤ 50$. |
| 2 | 8 | $T ≤ 160$. |
| 3 | 5 | $N ≤ 10$. |
| 4 | 18 | $N ≤ 20$. |
| 5 | 15 | $N ≤ 45$. $L$ is a odd number, and $Y_k = \frac{L+1}{2}$ ($1 ≤ k ≤ N$). |
| 6 | 31 | $N ≤ 45$. |
| 7 | 19 | No additional constraints. |
6 4 8 1 3 2 2 3 4 5 5
Yes
By transporting the $1$st and $2$nd patients to the hospital at $(1, 1)$, the $3$rd patient to the hospital at $(1, 6)$, and the $4$th patient to the hospital at $(6, 6)$, all patients can be transported to a hospital by time $8$, so the output is Yes.
For example, if the ambulance stationed at the hospital in $(1, 1)$ moves in the following order, it can transport both the $1$st and $2$nd patients to the hospital by time $8$.
| Time | Ambulance Status |
|---|---|
| $0$ | Departs from cell $(1, 1)$ |
| $1$ | Arrives at cell $(2, 1)$ |
| $2$ | Arrives at cell $(2, 2)$, picks up the $2$nd patient, and departs |
| $3$ | Arrives at cell $(1, 2)$ |
| $4$ | Arrives at cell $(1, 1)$, drops off the $2$nd patient, and departs |
| $5$ | Arrives at cell $(1, 2)$ |
| $6$ | Arrives at cell $(1, 3)$, picks up the $1$st patient, and departs |
| $7$ | Arrives at cell $(1, 2)$ |
| $8$ | Arrives at cell $(1, 1)$, drops off the $1$st patient |
This sample input satisfies the constraints of subtasks 1, 2, 3, 4, 6 and 7.
9 5 19 5 5 5 5 7 5 2 5 9 5
No
Since it is not possible to transport all patients to a hospital by time $19$, the output is No.
This sample input satisfies the constraints of all subtasks.
7 7 16 6 1 2 4 4 5 5 5 3 4 6 4 5 1
Yes
This sample input satisfies the constraints of subtasks 1, 2, 3, 4, 6 and 7.
200 15 800 126 45 196 40 43 58 96 13 28 33 44 55 60 22 58 156 135 183 44 29 92 182 157 138 30 132 175 87 166 57
No
This sample input satisfies the constraints of subtasks 4, 6 and 7.