QOJ.ac

QOJ

Süre Sınırı: 20 s Bellek Sınırı: 2048 MB Toplam puan: 100

#8858. 地圖分幅

İstatistikler

出版地圖唔係一件容易嘅事。首先,你要用適當嘅變換,將地球嘅球面形狀顯示喺二維平面上。跟住又有另一個問題:大部分高質素地圖都太大,印唔落一張紙。為咗解決呢個問題,地圖出版商通常會將地圖分成幾塊長方形圖幅,每塊各印喺一頁上。喺呢題入面,你會研究呢個「分幅」過程。

International Cartographic Publishing Company(ICPC)需要將地圖用嘅圖幅數量減到最少,從而減低印刷成本。就算圖幅大小(由紙張大小決定)同地圖比例尺固定,你仍然可以調整圖幅網格,令結果更好。

圖 G.1 左邊顯示咗覆蓋一個區域嘅 14 塊圖幅。右邊就顯示點樣喺唔改變圖幅大小或者方向嘅情況下,只用 10 塊圖幅覆蓋同一個區域。

problem_8858_072de00871fc24a0923a002dc8691c5e.png

圖 G.1:Texas兩種可能嘅分幅方法。

你嘅任務係幫 ICPC 搵出覆蓋指定區域所需嘅最少圖幅數。為咗簡單啲,區域會用一個唔會自交嘅封閉多邊形表示。

留意,圖幅一定要屬於一個同 $x$ 軸、$y$ 軸對齊嘅長方形網格。即係話,佢哋只可以沿住完整嘅邊互相接觸,而且唔可以旋轉。另外,雖然所有輸入座標都係整數,圖幅可以放喺非整數座標。

多邊形可以掂到外圍邊界線嘅邊緣(好似例子輸入 2)。不過,為咗避免浮點數問題,你可以假設就算容許多邊形超出地圖圖幅 $10^{-6}$ 嘅距離,最佳答案都唔會變。

輸入格式

輸入只有一組測試資料。第一行有三個整數 $n$、$x_s$ 同 $y_s$。多邊形有 $n$ 個頂點($3\le n\le 50$),$x_s$ 同 $y_s$($1\le x_s,y_s\le 100$)係每塊圖幅嘅尺寸。之後 $n$ 行每行有兩個整數 $x$ 同 $y$($0\le x\le 10x_s$、$0\le y\le 10y_s$),按順時針或者逆時針次序列出代表嗰個區域嘅多邊形頂點。

輸出格式

輸出覆蓋多邊形全部內部所需嘅最少圖幅數。

例子

輸入格式 1

12 9 9
1 8
1 16
6 16
9 29
19 31
23 24
30 23
29 18
20 12
22 8
14 0
14 8

輸出格式 1

10

輸入格式 2

4 5 7
10 10
15 10
15 17
10 17

輸出格式 2

1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.