Interesting Shortest Path Problem.

Правка en1, от mrphyx1312, 2023-10-09 19:34:08

There are N cities and two newly built cities X and Y among them (1 <=X<=Y<= N) There exists a road between cities:

i and i+1 for each 1 to N

X and Y.

The task is to tell for each k from 1 to N, the number of pairs of cities (such that the shortest path between city i and city is k

Consider the following example.

N number of cities-3

X, first special city-1

Y second special city-3

The pair of cities having the shortest distance-1 are (1,2) (1,3) and (2,3)

There is no pair of cities with the shortest distance-2.

There is no pair of cites with the shortest distance-2

Hence the answer returned is (3,0,0)

Can someone explain how to approach this problem?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский mrphyx1312 2023-10-09 19:34:08 732 Initial revision (published)