SIGSEGV in COOK42 - ABCSTR

I’ve employed the same method described in the editorial just the implementation is a bit different.
For each index calculate the no. of A’s, B’s, and C’s till that index. Then calculate A[i]-B[i], B[i]-C[i] for each index. Store them in a structure. Sort them out. If there are X continuous pairs for which these are equal, add C(x,2) to the final count.
I am getting SIGSEGV and am not able to spot out the error. Any help would be appreciated.

Link for the code : link text

you should declare the structure variable (pp) as global with max size (1000000).On declaring the variable memory is given at runtime from stack which is not enough so SIGSEGV comes. On the other hand global declarations have static memory which is enough w.r.t to the test cases.

1 Like

Yes, made a very stupid mistake. Submitted. AC.
Thanks a lot :smiley:

We would request you to post the queries on the editorial page. Closing the question.