This problem shows how Floyd-Warshall enables post-processing on the distance matrix. Once you have dist[i][j] for all pairs, you can answer complex queries: count neighbors within threshold, find min/max paths, etc.
The precomputation pays off when you need flexible queries on distances. The pattern is: build the matrix once, use it many times. This is common in graph problems with multiple queries.