TLE in FLIPCOIN -used lazy propagation

flipcoin

#1

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


#2

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


#3

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.


#4

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


#5

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


#6

Thanks …It worked…:slight_smile:


#7

BufferedWriter worked too…thanks…


#8

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


#9

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


#10

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!