Yuvraj_007's blog

By Yuvraj_007, 3 months ago, In English

Disjoint Set Union (DSU)

If you're learning DSU for the first time, I recommend solving them in the following order:

  1. 755C - PolandBall and Forest — my solution(381760852)
  2. 217A - Ice Skating — my solution(381800055)
  3. 445B - DZY Loves Chemistry — my solution(382353172)
  4. 1263D - Secret Passwords — my solution(381810414)
  5. 939D - Love Rescue — my solution(381830505)
  6. 1012B - Chemical table — my solution(384865311)
  7. 1167C - News Distribution — my solution(388674692)
  8. 1249B1 - Books Exchange (easy version) — my solution(382086807)
  9. 893C - Rumor — my solution(394841571)
  10. 277A - Learning Languages
  11. 25D - Roads not only in Berland — my solution(382417740)
  12. 1609D - Social Network — my solution(382447487)
  13. 1559D1 - Mocha and Diana (Easy Version)
  14. 1559D2 - Mocha and Diana (Hard Version)
  15. 292D - Connected Components
  16. 891C - Envy
  17. 1618G - Trader Problem
  18. 920E - Connected Components?

Remaining answer i will add shortly.

Tip: Don't solve these problems by simply memorizing the DSU template. Before coding, always ask yourself:

  • What do the sets represent?
  • When should two sets be merged?
  • What does the representative of a set signify?

Once you can answer these questions, identifying DSU in future graph problems becomes much easier.

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

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

Obligatory shameless plug for my full proof writeup https://codeforces.me/blog/entry/154298

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

Learnt a lot from this one

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

You could just post a link to the chatgpt convo