Logo
(追記) (追記ここまで)

31972번 - Tiles 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB31111034.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:

  • exactly two edges meet at each vertex;
  • any pair of edges can only meet at a vertex.

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:

  • each point which lies in the interior of the polygon and has $x$-coordinate less than $k$ is covered by some piece;
  • no point which lies outside of the polygon or has $x$-coordinate greater than $k$ is covered by some piece;
  • the interiors of the pieces do not overlap.

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$.

제한

  • 4ドル ≤ N ≤ 2 \cdot 10^5$
  • 1ドル ≤ M ≤ 10^9$
  • 0ドル ≤ y_i ≤ 10^9$ (for each 1ドル ≤ i ≤ N$)
  • The cathedral forms an axis-aligned simple polygon.
  • The minimum of $x_1 ,x_2 , \dots ,x_N$ is 0ドル,ドル and the maximum of $x_1 ,x_2 , \dots ,x_N$ is $M$.

서브태스크

번호배점제한
14

$N = 4$.

29

$N ≤ 6$.

311

$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$).

419

$M ≤ 1000$ and all $y_i ≤ 1000$.

522

All values of $y_i$ are even.

625

All values of $x_i$ are even.

710

No additional constraints.

예제 입력 1

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

예제 출력 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$.

예제 입력 2

4 3
0 0
0 3
3 3
3 0

예제 출력 2

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.

예제 입력 3

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

예제 출력 3

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$.

힌트

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2024 E번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /