Random increase in memory usage?

Правка en1, от caterpillow, 2023-11-01 15:35:38

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!

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский caterpillow 2023-11-01 15:35:38 862 Initial revision (published)