But your code also has another bad place.
You calculate strlen(question) each time in the loop.
Note that strlen() function works in O(N) time.
So your solution is actually has complexity O(N * N).
If constraints would be higher (like question length up to 31415) you would probably get TLE.
It is always better to save the length at some variable like int this fix of your solution: http://www.codechef.com/viewsolution/1853057
it might be the dumb question but i want to know what’s wrong in writing if(‘a’ <= s[i] <= ‘z’) (than if(‘a’ <= s[i] && s[i] <= ‘z’)) in c? I am getting wrong answer for first case.
@anton_lunyov i have been using scanf("%d\n",&t) blindly without knowing how it is working.
“The \n format will skip all whitespaces until it finds a non-whitespace character” . why does it skips?
also please explain %d%*c format. what is %*c doing ?
can anyone tell me what is wrong with my code? I feel that my program is exactly according to the editorial, but it still gives me WA. http://www.codechef.com/viewsolution/1861051
The note in the problem statement clearly indicates that the number of new-lines should be exactly T. Additional new line in the end violates this rule so no wonder
this was never a concern untill today. I mean I always appended ans+"\n" and in the end used System.out.println() which caused an additional newline. And yes, i saw that T newline thing, and used the .print() instead. And bingo AC. Still, this kindov thing was rather lame. Gave me 3 WA’s.
OK. Next time I will try to write kinder judge from this perspective. At least existing special judge was easy to code. While allowing all possible new-lines features that contestants are used to is not so trivial to figured it out.
Try to solve something on UVA. They have very strict judge as well but no for all problems.
I meant it shouldn’t matter whatever i print after the T required output lines. Ideally those shouldn’t be processed. And statistically that should make the judge more efficient