RBTREE - Editorial



One of the test case is accepted and the others are not. Can any one tell why ?



Getting all cases I could think of right. Submitted 11 times… still couldn’t get any points.
Any help would be appreciated. Also no issues as reported in earlier comments.
My solution:


Can you inspect this solution also. Only one subtask was giving WA and rest all were accepted. Can’t figure out the problem in this.


Cannot figure out the problem.Please inspect the solution.


Here it is!!

Fully commented solution:
link text


Getting all cases I could think of right. Submitted 3 times… still couldn’t get any points. I checked against all test cases in above editorial but working for all and giving right answer but on submission getting WA. Any help would be appreciated.


Hello all

If someone need setter’s solution here is the link…


Can someone help me with the 2 test cases where my code fails to give the correct answer?
My solution: http://www.codechef.com/viewsolution/5648945

It would be really helpful.Thank You.


This link is for different problem, is it a mistake?


Please tell me what am I doing wrong - your code return 2 for input from problem statement - http://ideone.com/yepUD3


yeah !! I am also inspired with that cool problem authored by lalit kundu :smiley:


I am so sorry for that. Here is the correct link.


It prints 2 as an output for problem statement example - see here http://ideone.com/APdHId


I didn’t test it, but why in is of length 2? try to make it 5… Ok, and I tested it and this is first problem (same link), it also seems, that you print additional empty lines between the outputs…


Same as @thegreatheisenberg above - use a[5] instead of a[2], in C, string is ended with '\0' and it’s a good habbit to alocate a little more memory than you need in contest programming…


I tried using this method, but WA!
can anyone fix this?


For input:

Qb 1 2
Qr 1 2
Qb 1 4
Qr 1 4
Qb 1 2
Qr 1 2
Qb 1 4
Qr 1 4
Qb 4 5
Qr 4 5
Qb 4 5
Qr 4 5

your output ends with


ans should end with



Okay, so I printed an extra line after each output because earlier in the sample output it seemed to me that they wanted me to print an extra line due to their formatting, now they corrected it (and it seems the online judge ignores extra line between outputs).
Secondly, it worked after changing in[2] to in[3] (no need for 5), but I don’t understand the logic behind this. Is it because ‘in’ needs to take a null character at the end so I need to provide extra space for that? If that’s true then why did the program run correctly on my pc before?
Thanks for your effort.


Thanks for the help.


It returns 1 for input

Qr 12 28