Map Tiles#5656

Map Tiles

20 seconds
256 megabytes
Very hard

Publishing maps is not an easy task. First, you need an appropriate transformation to display the Earth's spherical shape on a two-dimensional plane. Then, another issue arises: most high-quality maps are too large to be printed on a single sheet of paper. To cope with this, map publishers often split maps into several rectangular tiles and print each tile on a separate page. In this problem, you will examine this "tiling" process.

The International Cartographic Publishing Company (ICPC) wants to minimize their printing costs by reducing the number of tiles used for their maps. Even with a fixed tile size (determined by page size) and map scale, it is still possible to optimize the situation by adjusting the tile grid.

The left side of Figure 1 shows 14 map tiles covering a region. The right side shows how you can cover the same region with only 10 tiles, without changing the tile sizes or orientation.

Figure 1: Two possible ways of tiling Texas.

Your task is to help the ICPC find the minimum number of tiles needed to cover a given region. For simplicity, the region will be given as a closed polygon that does not intersect itself.

Note that the tiles must be part of a rectangular grid aligned with the -axis and -axis. That is, they must touch each other only along entire sides and cannot be rotated. Also note that although all input coordinates are integers, tiles may be located at non-integer coordinates.

The polygon may touch the edges of tile boundaries (as in Sample Input 2). However, to avoid floating-point issues, you may assume the optimal answer does not change even if the polygon is allowed to go outside the map tiles by a distance of 10^{-6}.

Input

The input consists of a single test case. The first line contains three integers: , x_s, and y_s. The number of polygon vertices is (3 \le n \le 50), and x_s and y_s (1 \le x_s, y_s \le 100) are the dimensions of each tile. Each of the next lines contains two integers and (0 \le x \le 10x_s,\ 0 \le y \le 10y_s), specifying the vertices of the polygon representing the region, in either clockwise or counter-clockwise order.

Output

Print the minimal number of tiles necessary to cover the whole interior of the polygon.

Examples

Example 1

Loading
Loading