Skip to main content

Practice · 4 of 5

Even Number of Tolls

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** Undirected weighted graph; find the minimum-cost walk from 1 to n that uses an **even number of edges** (revisiting allowed). **Constraints:** 1 ≤ n ≤ 100000; 1 ≤ m ≤ 200000; 1 ≤ w ≤ 10^9. **Output:** the minimum cost, or −1 if impossible.

Back to lesson: Practice: Combination Drill — Five Fusions