caterpillow's blog

By caterpillow, history, 14 months ago, In English

Hi,

I was writing a solution for Sereja and Brackets where I used a struct called DSU. However, the struct contained some unnecessary code and used generics, so I removed the struct and moved the relevant code outside. This somehow resulted in slower execution with over 50% more memory usage.

After playing around, I created these two submissions where the only difference as far as I could see was my usage of a struct. Submission 1 (struct, faster) and Submission 2 (no struct, slower).

I'm still pretty new to C++ and I come from a Java/Python background, so if someone could explain this behavior it would be very much appreciated.

Thanks!

  • Vote: I like it
  • 0
  • Vote: I do not like it