Almost Union-Find problem solution, HELP

Revision en5, by ThirtyDays, 2020-12-29 16:48:24

Problem link In this all first and third operation is the same as DSU. But in the second operation move(a, b) we have to move element 'a' to group containing b.

My approach: Instead of changing parent structure, I am using a different a vector parent2 for updating parent of element in move operation.

Code. Code . Correct code

I am getting the wrong answer.

Tags #dsu, disjiont-set-union

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English ThirtyDays 2020-12-29 16:48:24 3 Tiny change: '/eGhngn)\n[Correct' -> '/eGhngn)\n.\n[Correct'
en4 English ThirtyDays 2020-12-29 16:47:56 43 Tiny change: '/eGhngn)\n\nI am ' -> '/eGhngn)\n[Correct code](https://ideone.com/ilHep5)\n\nI am '
en3 English ThirtyDays 2020-12-29 16:11:14 7 Tiny change: 'tunionfindhttp://)\nIn this' -> 'tunionfind)\nIn this'
en2 English ThirtyDays 2020-12-29 14:36:08 24
en1 English ThirtyDays 2020-12-29 14:34:51 466 Initial revision (published)