Why does global vector avoid TLE

Правка en1, от Itachi_Uchiha13, 2024-05-25 11:04:05

I was solving 1955G - GCD on a grid, and I made 2 submissions. The first one 262439330 which gave TLE. The second one 262439842 ran in just 671ms.

The only change I made in these 2 submissions is that I declared a vector isposs globally instead of declaring it again in the function isPoss. Does memory allocation in C++ really have such a large overhead, or is there any other reason? I mean it takes more than 4x time to run, which is unexpected to me.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский Itachi_Uchiha13 2024-05-25 12:41:07 57
en3 Английский Itachi_Uchiha13 2024-05-25 12:38:32 101
en2 Английский Itachi_Uchiha13 2024-05-25 12:22:51 13
en1 Английский Itachi_Uchiha13 2024-05-25 11:04:05 512 Initial revision (published)