run time error

run
runtimeerror
time

#1

https://www.codechef.com/viewsolution/19323296

this is my code in C.I am getting a run time error.
Please help me out.


#2

Hmm…there are several mistakes in your code-
1.Run Time Error(SIGSEGV) - due to gets() fuction (WHY - refer this link -
). Use scanf() instead of gets() or anything else.


2.Even after using scanf() you will get NZEC(Non Zero Exit Code) error, why because at the end of main() function you have return 1 instead of return 0.


3.Now you will get wrong answer because-
I-Max size of string given by you is 100 inside struct which is equal to constraint given in the question. It may lead to overflow. Remember always declare size more than the constraint. Here declaring size 102 gives AC. (see the solution link given below)


II.You should check the output before submitting. There was no newline comment in printf() function in your code causing WA. printf("%s
", aa[k].s).


Well as a newbie your logic was really nice but using structure to store all the test cases and solving them offline is not a good strategy always. You should check other solutions and learn the basic format of a solution code used in competitive coding.
Happy coding:)
link:solution


#3

nice answer https://www.codechef.com/users/knightware101[gujjar]