Getting SIGSEGV on MKTHNUM problem on SPOJ

mkthnum
spoj

#1

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


#2

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.


#3

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