Getting SIGSEGV on MKTHNUM problem on SPOJ

I’m trying to solve this problem using persistant segment tree. But I’m getting sigsegv error and I can’t figure out why as I tested my code on random test cases on my system and it works fine. Please help!
My Code

1 Like

Your code is correct. The issue is probably with the test case 16 (it shows “Running … (16)” just before the SIGSEGV verdict). If you replace your custom input function with cin or scanf you will get AC.

1 Like

Thanks a lot!!! It got AC by removing the custom input.