Thanks for replying ,i understood where i did mistake.
https://www.codechef.com/viewsolution/39844684
can anyone help me with this? where am i getting this wrong .
https://www.codechef.com/viewsolution/46630201
I have tried multiple test-cases with all correct answers. I donât know where I am getting wrong. It will be very helpful, if someone help me in finding the bug.
Consider the test input:
1
7
APAPAPP
Thank you for the correction!
But, I am still getting a SIGSEGV error (Runtime error). I tried to check for any divide by 0 error , but there is no such division. Also, memory usage is not too much. I donât know why still I am getting such error .
Please link to your updated code.
It looks like you applied the fix, but then broke it by additionally switching to using a std::string
and using it wrongly
cin>>S[i];
S
is empty, so attempting to reference S[i]
is undefined behaviour.
Again thank you so much !
I just started solving practice questions, any tips or suggestion from you would be great.
- Set up
gcc
on your local machine - Use debugging flags until you are ready to submit - I generally use
-D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
, which would have pointed out your Runtime Error immediately - only use Codechefâs compiler when you are ready to submit, which you shouldnât do until (at least) the sample testcase passes with the debugging flags enabled.