Universal Cup Judging System

Universal Cup

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100 Difficulté: [afficher]
Statistiques

Prof. Shou 正在一個無向、無權重的簡單圖上被 Prof. Pang 追逐。起初,Prof. Shou 位於頂點 1,他的目的地是頂點 $n$。Prof. Pang 位於頂點 $k$。

每一秒,Prof. Shou 可以選擇一個相鄰的頂點並移動到該頂點。接著,Prof. Shou 會受到 Prof. Pang 的攻擊。攻擊造成的傷害等於 $d - dis$,其中 $d$ 是 Prof. Pang 的攻擊範圍,$dis$ 是圖上 Prof. Shou 與 Prof. Pang 之間的距離(最短路徑上的邊數)。然而,當 $dis$ 大於或等於 $d$ 時,Prof. Pang 無法造成任何正數傷害。在這種情況下,他不會進行非正數傷害的攻擊,而是會直接傳送到 Prof. Shou 所在的頂點,並造成 $d$ 點傷害。(當 $dis$ 小於 $d$ 時,Prof. Pang 會停留在當前頂點。)

請找出 Prof. Shou 從頂點 1 到達頂點 $n$ 所受到的總傷害最小值。Prof. Shou 在到達頂點 $n$ 時會受到最後一次攻擊。

輸入格式

第一行包含 4 個整數 $n, m, k, d$ ($2 \le n \le 10^5, n-1 \le m \le 2 \times 10^5, 1 \le k \le n, 1 \le d \le 2 \times 10^5$)。

接下來 $m$ 行,每行包含兩個整數 $a, b$ ($1 \le a, b \le n, a \neq b$),代表圖中的一條邊。邊是相異的。($a \ b$ 和 $b \ a$ 代表同一條邊。因此,這兩行中只有一行會出現在輸入中。)

保證圖是連通的。

輸出格式

輸出一個整數,代表答案。

範例

輸入 1

5 5 3 1
1 2
2 4
4 5
1 3
3 5

輸出 1

2

輸入 2

13 17 12 3
1 2
2 3
3 4
4 13
5 13
7 8
7 9
7 10
7 11
7 6
12 7
1 8
8 9
9 10
10 11
11 6
6 13

輸出 2

7

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.