Randomized solution in Div2 E

Правка en4, от _shanky, 2020-03-15 10:32:14

In yesterday's Div2 E I was stuck at finding the shortest cycle. I was using dfs and each time a backedge (x,y) occurred I was keeping the minimum of level[x]-level[y]+1 only to realize it was wrong. The answer would depend on the order of dfs traversal. So I randomly shuffled adjacency lists few times and used dfs each time while keeping the minimum. I managed to pass all test cases. Is there any proof that the correct answer will be found with high probability with this approach or I just managed to be lucky?

Link to the submission

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский _shanky 2020-03-15 10:32:14 0 (published)
en3 Английский _shanky 2020-03-15 10:31:31 8 Tiny change: 'each time and keeping t' -> 'each time while keeping t'
en2 Английский _shanky 2020-03-15 10:30:14 60
en1 Английский _shanky 2020-03-15 10:28:26 570 Initial revision (saved to drafts)