n crossings numbered 0 to n - 1. Two-way roads are listed in roads: an entry [u, v, d] means a road of length d joins crossings u and v. Two crossings may be joined by several roads.
A courier rides an e-scooter, and each trip has its own charge. A trip trips[j] = [from, to, limit] allows any chain of roads, but **every** road on the way must be strictly shorter than limit: the scooter cannot handle a longer stretch without recharging.
Return a boolean array whose j-th element is true if to can be reached from from on the j-th trip, and false otherwise.n=4, roads=[[0, 1, 3], [1, 2, 7], [2, 3, 2], [0, 3, 9]], trips=[[0, 2, 8], [0, 3, 7], [1, 3, 10]] → [True, False, True]
The first trip goes 0 → 1 → 2 over roads of length 3 and 7, both shorter than 8. The second needs roads shorter than 7: from 0 only the road of length 3 to crossing 1 is usable, and the roads of length 7 and 9 are off-limits, so the answer is false. In the third trip every road is usable.
n=3, roads=[[0, 1, 5], [0, 1, 1]], trips=[[0, 1, 2], [1, 2, 100]] → [True, False]
Crossings 0 and 1 are linked by two roads, and the short one (length 1) fits under the limit of 2. Crossing 2 has no roads at all.
n=4, roads=[[0, 1, 3], [1, 2, 7], [2, 3, 2], [0, 3, 9]], trips=[[0, 2, 8], [0, 3, 7], [1, 3, 10]]
[True, False, True]
Run checks the first 3 tests in your browser. Submit checks all 64 tests on the server, hidden ones included.