I try to solve this problem 459C - Pashmak and Buses
It has Time limit exceeded on test 9
I printed the result to screen, it took nearly 25s:
But when I print to a file, run time is 94 ms:
Can you explain the different between two methods?
Thanks.
P/s: same code
I don't know really why, but Windows console output is really slow. Maybe it's even slowed down intentionally
Rendering a character on screen is just a lot slower operation than writing a byte to a file or a pipe. It involves a lot more computations.
Also this is unrelated to your TLE on the server, since the server doesn't render your output in a console (your program's standard input/output is redirected to files or pipes).
Thank andreyv, but I don't understand why it took more than 1s. Can you explain me more clearly.
Consider what happens in both cases:
Also in general the Windows console is horribly slow.
Thanks