Reachable using only short roads
There are n places numbered 0 to n - 1 and two-way roads, each [a, b, length]. Each query [start, goal, limit] asks: can you get from start to goal using only roads strictly shorter than limit? Return one boolean per query, in the order given. A place always reaches itself. Several roads may join the same pair, and a road may loop back to its own place.
There can be thousands of roads and queries, so a fresh search for every query is too slow.
Besides the tests, one large input (2,000 places, 3,998 roads, 1,000 queries) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
reachable_below(4, [[0,1,3],[1,2,5],[2,3,2],[0,3,9]], [[0,2,6],[0,2,5],[0,3,6],[3,1,4]])→[true,false,true,false]reachable_below(3, [[0,1,4],[0,1,2]], [[0,1,3],[0,1,2],[1,2,100]])→[true,false,false]reachable_below(5, [[0,1,10],[1,2,1],[2,3,7],[3,4,3],[0,4,4]], [[1,4,8],[1,4,7],[0,2,11],[2,4,5],[0,3,5]])→[true,false,true,false,true]