Some unexpected Behavior in CLBRKT

https://www.codechef.com/problems/CLBRKT

Using memset it gives TLE. https://www.codechef.com/viewsolution/35709202

In place of memset if loop is used then it is AC. https://www.codechef.com/viewsolution/35709184
Is this because of the fact that memset will always run from i=0 to 1=1e7 but in case of loop it runs till size of string only? This means there were more than 100 TC. Have you faced this before?

Also, can we declare an array of size 1e7 in main ?
https://www.codechef.com/viewsolution/35709227 I have declared an array of size of string. I think max size of array can be 1e6 in main. But this was acceted.

@akshitm16 @everule1 @galencolin

Don’t know much about cpp, but this gives AC in 0.33 sec in C++ 17. Wait for others to answer.

Is this because of the fact that memset will always run from i=0 to 1=1e7 but in case of loop it runs till size of string only? This means there were more than 100 TC.

This maybe a reason 10^7 \cdot 10^3