NOLOGIC - Editorial

Guys! Why you all even not try to look through the editorial?
Did you see section “NOTES TO C/C++ USERS” there?

2 Likes

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.

Simply one of them will work too.

And i thought codechef was at fault for not accepting my solution.Quite an easy problem with a twisting catch.Well set Admin.

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 :stuck_out_tongue:

“Ideally those shouldn’t be processed.” It is completely wrong. The judge should validate the full conformation of the answer to the output format. If for example in the challenge problem you need to print N followed by N lines describing some operations but you print N+1 lines with operation on the last line then it is wrong and actually AC could only make you worse since you may get low score while thinking that all is right with the solution.

@anton_lunyov My bad :frowning: thankyou very much

Expression ('a' <= s[i] <= 'z') is equivalent to ('a' <= s[i]) <= 'z'.
So it compares bool value ('a' <= s[i]) with char value 'z'.
Hence, it casts both values to int: 'z' to 122 and
('a' <= s[i]) to 0 if it is false or to 1 if it is true.
So ('a' <= s[i] <= 'z') is always true :slight_smile:

1 Like

P.S. the ascii character 92 and ‘*’ is not working in comments here.

I seriously don’t feel the above explaination you gave justifies this being rejected

StringBuilder out=new StringBuilder();
while(t-->0){
    // ...
    out.append(ans+" \n");
}
System.out.println(out);

it is, but you have to realize what markdown formatting is doing with it…

Your code is not working, see the test case here - LTvWXq - Online C++ Compiler & Debugging Tool - Ideone.com

but if you are using such low level functions you should handle case in which line is ending with \r\n

@aichemzee: your code simply contains T+1 x \n and as stated in statement

Special judge is very strict for this problem and check your output character-by-character. Be sure that you follow the mentioned output format precisely. For instance, your output should contain exactly T new-line characters (ASCII code 10) - one after each answer.

so it’s incorrect…

@anton_lunyov thanks for such problem, I hope a lot of coders learnt lesson in this contest

If it’s specified in statement so precisely as in this I think it is perfectly fine to reject such submissions.

On the other hand I prefer no so strict judge, for example if one have to print N numbers in line, typically it’s ok when there is space after the last one or so, because one can use FOR(i,0,N) printf("%d ", a[i]) instead of printf("%d", a[0]); FOR(i,1,N) printf(" %d", a[i]) and AFAIK in ACM contest there is special judgement result “wrong format” that is shown sometime in such cases…

@betlista As I said above try to solve something on UVA.
After struggling to solve some simple problem you will reconsider your opinion :slight_smile:
To output N space separated integers you could use code
FOR(i,0,N) printf("%d%c", a[i], i<N-1?' ':'\n')
So nothing ugly.

@aichemzee Usually special judge at codechef ignores extra white spaces.
So not need to worry about that in the future.

Actually both ways with scanf("%d%*c") and with getchar() do not handle the case with '\r\n'.
So the most general way is to use gets() or do getchar() / scanf("%c") in a loop.

@shimanshu Refer to this:
http://www.cplusplus.com/reference/cstdio/scanf/

Search for “Whitespace character: the function will read” and then for “An optional starting asterisk indicates” at this page to clear your doubts.

@anton_lunyov: thanks for your tip, good point :wink: I just said I prefer no so strict judge, but I’m always sticking with format specified in statement, because I never know if the judge is or is not strict :wink: