QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#3704. Travel

Statistics

The country frog lives in has $n$ towns which are conveniently numbered by $1, 2, \dots, n$.

Among $\frac{n(n - 1)}{2}$ pairs of towns, $m$ of them are connected by bidirectional highway, which needs $a$ minutes to travel. The other pairs are connected by railway, which needs $b$ minutes to travel.

Find the minimum time to travel from town $1$ to town $n$.

Input

The input consists of multiple tests. For each test:

The first line contains $4$ integers $n, m, a, b$ ($2 \leq n \leq 10^5, 0 \leq m \leq 5 \cdot 10^5, 1 \leq a, b \leq 10^9$). Each of the following $m$ lines contains $2$ integers $u_i, v_i$, which denotes cities $u_i$ and $v_i$ are connected by highway. ($1 \leq u_i, v_i \leq n, u_i \neq v_i$).

Output

For each test, write $1$ integer which denotes the minimum time.

Sample Input

3 2 1 3
1 2
2 3
3 2 2 3
1 2
2 3

Sample Output

2
3

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.