Okay I must admit that this problem really pissed me off. For everyone getting WA continously, listen. The input description is perfectly fine, the judge data set is correct too (May be it was incorrect before I don't know, but it is sure fixed at the time Im writing this). The input will consist of only lowercase characters. Use gets or fgets instead of scanf, and it is not necessary to print the NULL character. However blank lines might be given as input and in that case make sure you program is printing ONLY a newline if the given string/s are empty. Another possible mistake could be the array size. If you used ch, then if there are 1000 characters, then there would be no room left for the NULL character(My AC code had Array size 100000).
Finally, after checking all these cases, if you still get WA, then I hardly doubt that your algorithm is incorrect after going through all these posts. I made a very silly mistake. count1 and count2 is supposed to be integer type, but I mistakenly declared them as character array
. It worked perfectly on my pc for all the inputs but the judge verdict was WA. I Got 6 WA because of that(and also partially because of this thread, as I found it very confounding and misleading
). So check for silly mistakes like this in your code.
Note : If the problem description is unclear then read the previous posts.