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

Автор mgajabi, 12 лет назад, По-английски

I have not been able to solve this problem.Can any tell me how to solve it.The best i can think is of djikstra,but that will obviously give me time limit exceeded.Can anyone tell me the solution.

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

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

You can use binary search. Then for fixed answer X you may check it in O(N+M) — bfs over modified graph with states [vertice of original graph][number of edges with weight >X in path].

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I didn't get the modified graph part.Can you please ellaborate.

    • »
      »
      »
      12 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +3 Проголосовать: не нравится

      We are interested in weight of second heaviest edge on the path. If we'll use binary search — then question is modified to can we find a way from start to finish with second heaviest edge of weight no more than X, and this one is equal to can we find a way from start to finish wish <=1 edges of weight more than X in it.

      And now it is clear that you are interested only in your current vertex and number of used "heavy" edges (because you can't use "heavy" edge if you used 1 before — then you'll have 2 "heavy" edges in your path).

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

How to solve problem L :) http://codeforces.me/gym/100460/problem/L Thanks in advance :)