import java.util.* fun main() { val (n, _, t) = readln().split(" ") val endNode = n.toInt() val switchTime = t.toLong() val graph = System.`in`.bufferedReader().lineSequence().flatMap { line -> val (x, y, l, v, w) = line.split(" ") listOf( Intersection(x.toInt(), y.toInt(), l.toDouble(), v.toLong(), w.toLong()), Intersection(y.toInt(), x.toInt(), l.toDouble(), v.toLong(), w.toLong()) ) }.groupBy { it.id } val queue = PriorityQueue { o1, o2 -> o1.time.compareTo(o2.time) } queue.add(State(0.0, 1)) val seen = mutableSetOf() while (queue.isNotEmpty()) { val current = queue.poll() if(current.location in seen) continue if (current.location == endNode) { return println(current.time) } seen.add(current.location) graph[current.location]!!.filter { it.to !in seen }.map { State(it.calculateTime(current.time, switchTime), it.to) }.toCollection(queue) } error("No route found") } data class Intersection( val id: Int, val to: Int, val length: Double, val velocity: Long, val secondVelocity: Long, ) { fun calculateTime(currentTime: Double, switchTime: Long): Double { if (currentTime >= switchTime) return currentTime + length / secondVelocity val otherTime = length / velocity if (currentTime + otherTime < switchTime) return currentTime + otherTime // calculate switching point // ct+l/v = sw // l/v = sw - ct // l = (sw-ct)*v val initialLength = (switchTime - currentTime) * velocity return currentTime + initialLength / velocity + (length - initialLength) / secondVelocity } } data class State( val time: Double, val location: Int )