Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

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

Автор monsij, история, 6 лет назад, По-английски

Hello Codeforces!,

We already have a algorithm to find all pairs shortest path in a weighted graph.This solution depends on dynamic programming ideas and hence utilizes one/two 2-D matrices.But I wonder what would be the approach if the number of vertices increased to say 10^4 or maybe as large as 10^6. Thanks in Advance!!

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

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

Well, as you are asking for O(V2) paths there can't be anything better than O(V2) — so you should probably forget about the V = 106 case.

Anyway, for sparse graphs, you can run Dijkstra's algorithm for each vertex and obtain a O(VE + V2logV) algorithm known as the Johnson's algorithm.