Блог пользователя Virtual_Contestant

Автор Virtual_Contestant, история, 4 года назад, По-английски

Can anyone please explain me the problem? i have been trying hard to understand this. https://www.e-olymp.com/en/contests/16462/problems/170299 the asked for maximum distance so in their second testcase isn't from 4 to 5 the distance is minimum?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Given a directed graph with n vertices and m edges. Find the maximum shortest distance from some vertex to the given vertex s.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

It asks for the distance, not the node. 4 is the distance from the farthest node to S.

Just build the inverted graph and do one single BFS from S. The maximum depth of the BFS is the answer.