Solution link: CodeChef: Practical coding for everyone
Here are two cases in the screenshot. Have a look at case ‘ababc’
That submission processes the testcases in the reverse order.
Replace:
while(i--) {
with
for(i=0; i<t; i++) {
The program worked but its still showing runtime error. Although memory usage is far below what others have used and there isn’t any posibility of division by zero. Could you please help me figure out the problem?
Please link to the solution instead of pasting a screenshot
Edit:
Oh, I think I can figure it out:
char str[t][1000];
The 1000
is not enough to hold the largest input string - there’s the null-terminator to consider as well, remember!
Also - there’s absolutely no need to read in and store all test inputs - just read in one; process it; output the result; read in the next; process that; etc.
Edit2:
There’s also no need to test for t>100
- the constraints are guarantees you are given, not things you have to check.
Sorry, I would take care of that next time.
Here’s the link: CodeChef: Practical coding for everyone
Thanks - see my Edit(s)
Oh, right! Thanks
SIGSEGV is segmentation fault. Which is most probably access out of bounds.
Division by 0 is SIGFPE (floating point exception).
There is SIGABRT (Abort) too, but I’m not sure what it is.
And exceeding memory limit will give you code MLE. And ofc exceeding time limit gives TLE.
Justing putting this out here, so you can debug your next RE easily.