I was solving the Planets Queries I problem in CSES (a standard binary lifting problem). ↵
↵
After getting a few TLE on one of the test cases, I finally got AC, but it took 1.00 seconds to pass that test case, which is way too close. ↵
On checking other submissions with exact same logic, and investigating a bit more, I changed vector\<vector\<int\>\> declaration in my code to static int array declaration, and my code, with everything being exact same, worked in 0.60 seconds. ↵
↵
Usually there shouldn't be such a drastic difference. While solving codeforces problem, I have observed that vectors and static array take the same time, and sometimes vectors are faster. ↵
↵
Can anyone explain the reason behind this? Thanks.↵
↵
Submission using vector\<vector\<int\>\> : https://cses.fi/paste/7d2b7a0b66df52a2ea28b6/ ↵
↵
Submission using static int array : https://cses.fi/paste/6d8b9ef1a192caa1ea28f1/
↵
After getting a few TLE on one of the test cases, I finally got AC, but it took 1.00 seconds to pass that test case, which is way too close. ↵
On checking other submissions with exact same logic, and investigating a bit more, I changed vector\<vector\<int\>\> declaration in my code to static int array declaration, and my code, with everything being exact same, worked in 0.60 seconds. ↵
↵
Usually there shouldn't be such a drastic difference. While solving codeforces problem, I have observed that vectors and static array take the same time, and sometimes vectors are faster. ↵
↵
Can anyone explain the reason behind this? Thanks.↵
↵
Submission using vector\<vector\<int\>\> : https://cses.fi/paste/7d2b7a0b66df52a2ea28b6/ ↵
↵
Submission using static int array : https://cses.fi/paste/6d8b9ef1a192caa1ea28f1/



