← CSES Better

Free ticket

INOI · 2014 · Indian National Olympiad in Informatics · INOI1402

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

graphs · 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.

State table
From / touv
u0dist(u,v)
vdist(v,u)0
  1. 1

    Compute shortest routes

    Compute shortest-path distances across the connected flight network.
  2. 2

    Compare city pairs

    Ignore direct-route cost when a cheaper connection exists.
  3. 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 chars

Run output

Run your code to see output.