eolymp
bolt
Try our new interface for solving problems
Məsələlər

InterCity

InterCity

A couple of years ago the Ukrainian Railway System seemed to be very convenient. For any two cities there was a direct train (don't be confused with "directed"), which travelled between them. Anyone had to pay only \textbf{B} UAH (the local currency) to get from his current place to the desired destination. But not long agogreat changes happened in Ukraine. A lot of new trains have been launched. Each of the new trains replaced an old one and the cost of its journey has been established to \textbf{A} UAH. So there is a single direct train (new or old) which still runs between any pair of cities now. Each train runs in both directions and the cost of the journey doesn’t depend on it. There are \textbf{N} large cities in Ukraine and you live in the city number \textbf{1}. You want to get to the city number \textbf{N}, and you look for the cheapest way of going there, regardless of the number of transfers. \InputFile The first line contains four integers \textbf{N}, \textbf{K}, \textbf{A} and \textbf{B} (\textbf{2} ≤ \textbf{N} ≤ \textbf{500000}, \textbf{0} ≤ \textbf{K} ≤ \textbf{500000}, \textbf{1} ≤ \textbf{A}, \textbf{B} ≤ \textbf{500000}), which are the number of cities, the number of new trains, the new cost of the journey and the old cost of the journey. \textbf{K} lines follow. Each of them contains two integers \textbf{u_i} and \textbf{v_i} (\textbf{1} ≤ \textbf{u_i}, \textbf{v}_\{i \}≤ \textbf{N}) which means that a new train is launched between city \textbf{u_i} and city \textbf{v_i}. \textbf{u_i} and \textbf{v_i} don't coincide. Every pair of cities appears at most once. \OutputFile Single integer \textbf{P} which is the cost of the cheapest way to go from city \textbf{1} to city \textbf{N}.
Zaman məhdudiyyəti 2 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB
Giriş verilənləri #1
5 4 1 4
1 2
2 3
2 4
3 5
Çıxış verilənləri #1
3
Mənbə 2013 South Eastern European Regional Programming Contest, Vinnica & Bucharest, October 12, Problem B