https://mirror.codeforces.com/contest/616/submission/295220955
https://mirror.codeforces.com/contest/616/problem/C
This is my solution. It is coming runtime error in cf but it is coming correct for that particular test case in my editor. Ik it can be solved using normal dfs just wanna practice dsu so if anyone can help in this particular code.
Auto comment: topic has been updated by krish2004 (previous revision, new revision, compare).
Your dsu.findupar doesnt return the answer, which causes illegal instruction runtime error. Returning the value should resolve the runtime error.
Also you seem to use dsu.parent instead of dsu.findupar on this line:
st.insert(d1.parent[indx(i-1,j,m)]);
Thankyou !! Solved..