Universal Cup Judging System

Universal Cup

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100 الصعوبة: [عرض]
الإحصائيات

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. Pang は Prof. Shou がいる頂点にテレポートし、$d$ のダメージを与えます。($dis$ が $d$ 未満の場合、Prof. Pang は現在の頂点にとどまります。)

Prof. Shou が頂点 $1$ から頂点 $n$ に到達するまでに受けるダメージの合計の最小値を求めてください。Prof. Shou は頂点 $n$ で最後の攻撃を受けます。

入力

入力は以下の形式で与えられます。

$n$ $m$ $k$ $d$ $a_1$ $b_1$ $a_2$ $b_2$ $\vdots$ $a_m$ $b_m$

最初の行には $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$ 行の各行には、グラフの辺を表す $2$ つの整数 $a, b$ ($1 \le a, b \le n, a \neq b$) が含まれます。 辺は区別されます。($a$ $b$ と $b$ $a$ は同じ辺を表します。したがって、これら $2$ 行のうち一方のみが入力に含まれます。)

グラフは連結であることが保証されています。

出力

Prof. Shou が受けるダメージの合計の最小値を $1$ 行で出力してください。

入出力例

入力 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.