I was solving [problem:1955G], and I made 2 submissions. The first one [submission:262439330] which gave TLE. The second one [submission:262487569] ran in just 765ms.↵
↵
↵
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.↵
↵
![ ](/predownloaded/5f/36/5f3615a6cbb667429d88ef9e54d6c48c0d82f828.png)↵
Added screenshot of diff
↵
↵
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.↵
↵
![ ](/predownloaded/5f/36/5f3615a6cbb667429d88ef9e54d6c48c0d82f828.png)↵
Added screenshot of diff