Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopgraphs · shortest-paths · all-pairs
The organizer’s problem statement is available at the official source link.
distance matrix
Find the most expensive cheapest route
For every city pair, compare the cost of its cheapest route; choose the pair whose shortest distance is largest.
| From / to | u | v |
|---|---|---|
| u | 0 | dist(u,v) |
| v | dist(v,u) | 0 |
- 1
Compute shortest routes
Compute shortest-path distances across the connected flight network. - 2
Compare city pairs
Ignore direct-route cost when a cheaper connection exists. - 3
Choose the widest pair
Select the city pair with the greatest resulting shortest-path distance.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.