QOJ.ac

QOJ

Time Limit: 10 s Memory Limit: 2048 MB Total points: 100

#2338. 美麗的橋樑

Statistics

是什麼把我們所有人連結起來?嗯,往往是橋樑。自古以來,人們一直為道路、鐵路和行人建橋,也建造高架水道來輸水。這是人類不肯向不便的地形妥協的方式。

Arch Bridges Construction(ABC)公司專門從事——你猜對了——拱橋建造。這種古典風格的橋樑由從橋下地面延伸而起的橋墩支撐。橋墩之間的拱將橋樑的重量分散到相鄰的橋墩上。

problem_2338_af5f9761b646daa916cba4f04e2f05b7.png

羅馬式拱橋的例子。來源:Wikimedia Commons

ABC 建造的橋樑,其橋墩往往以不規則的間距排列。出於美觀考量,ABC 的橋樑總是採用半圓形拱,如圖 B.1 所示。然而,橋拱雖然可以接觸地面,卻不能伸入地面以下。這使某些橋墩配置無法實現。

problem_2338_c39ea985324a74f3662c1f7d1d79ab66.png

(a) 相鄰橋墩的距離為 $d$,以半徑 $r=d/2$ 的半圓形拱連接。

(b) 無效的橋墩配置(拱不能伸入地面以下)。

(c) 對應範例輸入 1 的橋樑。

圖 B.1:橋樑範例。

給定地面輪廓與期望的橋面高度 $h$,通常有許多建造拱橋的方法。我們用一個分段線性函數來描述地面輪廓,它由 $n$ 個關鍵點 $(x_1,y_1),(x_2,y_2),\ldots,(x_n,y_n)$ 指定,其中一點的 $x$ 座標是沿橋方向的位置,$y$ 座標是該位置的地面海拔。第一個與最後一個橋墩必須分別建在第一個與最後一個關鍵點上,任何中間橋墩也只能建在這些關鍵點上。橋樑的成本是橋墩成本(與其高度成正比)加上拱的成本(與所用材料的量成正比)。因此,一座具有 $k$ 個橋墩、橋墩高度為 $h_1,\ldots,h_k$、相鄰橋墩水平距離為 $d_1,\ldots,d_{k-1}$ 的橋樑,其總成本為

$$\alpha\cdot\sum_{i=1}^{k}h_i+\beta\cdot\sum_{i=1}^{k-1}d_i^2$$

其中 $\alpha$ 與 $\beta$ 是給定的常數。ABC 想以盡可能低的成本建造每座橋樑。

輸入格式

輸入第一行包含四個整數 $n,h,\alpha,\beta$,其中 $n$($2\le n\le 10^4$)是描述地面輪廓的點數,$h$($1\le h\le 10^5$)是期望的橋面海拔,$\alpha,\beta$($1\le\alpha,\beta\le 10^4$)是前述成本係數。接下來有 $n$ 行,第 $i$ 行包含兩個整數 $x_i,y_i$($0\le x_1<x_2<\ldots<x_n\le 10^5$ 且 $0\le y_i<h$),描述地面輪廓。

輸出格式

輸出在海拔 $h$ 處、從水平位置 $x_1$ 到 $x_n$ 建造橋樑的最小成本。如果無法建造這樣的橋樑,輸出 impossible。

範例

輸入格式 1

5 60 18 2
0 0
20 20
30 10
50 30
70 20

輸出格式 1

6460

輸入格式 2

4 10 1 1
0 0
1 9
9 9
10 0

輸出格式 2

impossible

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.