report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Second shortest path - FlandreOJ: Flandre Online Judge

Second shortest path

Time limit: 1000 ms
Memory limit: 256 MB
Given an undirected connected graph with $n$ vertices and $m$ edges, find the second shortest path from $1$ to $n$. The length of this path must be greater than the shortest path. ### Input - The first line contains two integers $n$ and $m$. - The next $m$ lines each contain three integers $u$, $v$, and $w$, indicating a path of length $w$ between $u$ and $v$. ### Output - Print an integer representing the length of the second shortest path. ### Constraints - $1 \le n, m \le 10^5$. - $1 \le u, v \le n$. - $1 \le w \le 10^4$. ### Example Input: ``` 4 4 1 2 100 2 4 200 2 3 250 3 4 100 ``` Output: ``` 450 ```
Shortest path
Shortest path
Delete edge
3D path
Number of shortest paths
Double edge
Second shortest path
Bye bye maximum edge
Boardgame
Teleport
?
Math
Festival 3
Arbitrage
Festival 4
String construction
Bye bye maximum edge 2
Elevator
Holiday
Fortress defense
Topic
Graph
Shortest path
Rating 1400
Solution (0) Solution