TLE in FLIPCOIN -used lazy propagation

I used lazy propagation but still time limit exceeds. Please someone tell if I am wrong and what else I need to do?
This is my solution:
http://www.codechef.com/viewsolution/5262502

Try to use BufferedWriter or OutputWriter to print the results of the query operation.

2 Likes

What am I doing in such cases (when there is a huge output) - instead of printing immediately I’m updateing StringBuilder instance and then I print it using one System.out.print() statement.

2 Likes

I haven’t done it yet! But my friend did in C++ with lazy propagation with fast I/O

I know only Java. What is more fast than BufferedReader in Java?

Thanks …It worked…:slight_smile:

BufferedWriter worked too…thanks…

Hadn’t seen your answer @betlista… Just now I noticed that you answered before me.

@junior94: No, you were first, I just added my approach for the same problem…

1 Like

Yeah sometimes I make weird mistakes: Your time is lower than mine so I assumed you answered earlier but should have been the other way around!