| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 31 | 11 | 10 | 34.483% |
Soon after converting to Christianity, it is believed that the first and the only Lithuanian King Mindaugas ordered the construction of the Vilnius Cathedral. The construction is almost completed, except that the floor has to be covered with ceramic ornamented glazed tiles.
The floor of the Vilnius Cathedral is a polygon in a 2D plane with a Cartesian coordinate system. The polygon has $N$ distinct vertices, numbered from 1ドル$ to $N$. For each $i$ such that 1ドル ≤ i ≤ N,ドル vertex $i$ is located at point $(X[i],Y[i]),ドル where $X[i]$ and $Y[i]$ are nonnegative integers. There is an edge connecting vertex $i$ and vertex $i + 1$ (for each $i$ such that 1ドル ≤ i ≤ N - 1$), as well as an edge connecting vertex $N$ and vertex 1ドル$. The vertices are listed in either clockwise or counterclockwise order.
The cathedral is an axis-aligned polygon, which means that each of the edges is parallel to either the $x$-axis or the $y$-axis. Moreover, the cathedral is a simple polygon, that is:
The builders of the cathedral have infinitely many pieces of tiles. Each piece is a square with side length equal to 2ドル$. The builders would like to cover a big part of the cathedral with these pieces. Specifically, the builders want to pick some vertical line and cover the part of the cathedral to the left of the line. For any integer $k,ドル let $L_k$ denote the vertical line consisting of points with $x$-coordinate equal to $k$. A covering of the part of the cathedral to the left of $L_k$ is a placement of some number of pieces in the plane such that:
The minimum $x$-coordinate of any vertex in the cathedral is 0ドル$. Let $M$ denote the maximum $x$-coordinate of any vertex in the cathedral.
Help the builders of the Vilnius Cathedral by determining the largest integer $k,ドル such that $k ≤ M,ドル and there exists a covering of the part of the cathedral to the left of $L_k$. Note that by definition, there exists a covering of the part of the cathedral to the left of $L_0$ (which uses 0ドル$ pieces).
The first line of the input contains two integers $N$ and $M$ – the number of vertices and the maximum $x$-coordinate of any vertex.
Then, $N$ lines follow. The $i$-th of them contains two integer numbers $x_i$ and $y_i$ – the coordinates of $i$-th vertex. The vertices are listed in either clockwise or counterclockwise order.
Your program should output the maximum $k,ドル such that $k ≤ M$ and there exists a covering of the part of the cathedral to the left of $L_k$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 4 | $N = 4$. |
| 2 | 9 | $N ≤ 6$. |
| 3 | 11 | $x_N = 0,ドル $y_N = 0,ドル $x_i ≤ x_{i+1},ドル $y_i ≥ y_{i+1}$ (for each $i$ such that 1ドル ≤ i ≤ N - 2$). |
| 4 | 19 | $M ≤ 1000$ and all $y_i ≤ 1000$. |
| 5 | 22 | All values of $y_i$ are even. |
| 6 | 25 | All values of $x_i$ are even. |
| 7 | 10 | No additional constraints. |
14 6 0 1 0 3 2 3 2 4 0 4 0 6 3 6 3 7 4 7 6 7 6 5 3 5 3 2 3 1
2
The following picture shows the part of the cathedral to the left of line $L_k$ for $k = 2$:
There is a covering of the part of the cathedral to the left of $L_2$. The covering uses two pieces. For any $k > 2,ドル there is no covering of the part of the cathedral to the left of $L_k$.
4 3 0 0 0 3 3 3 3 0
0
There is no positive value of $k$ such that the part of the cathedral to the left of $L_k$ could be covered with tiles.
18 9 0 2 2 2 2 1 4 1 4 0 9 0 9 2 4 2 4 4 7 4 7 3 9 3 9 6 4 6 4 5 2 5 2 4 0 4
6
As illustrated below, it is possible to cover the part of the cathedral to the left of line $L_6$:
For each $k > 6,ドル there is no covering of the part of the cathedral to the left of $L_k$.