krish2004's blog

By krish2004, history, 3 weeks ago, In English

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.

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by krish2004 (previous revision, new revision, compare).

»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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)]);