Блог пользователя Aden_blizzard

Автор Aden_blizzard, история, 5 лет назад, По-английски

i was practicing this question https://www.codechef.com/problems/COPR16G/ and i found that endl gives TLE but \n doesnot why? is it because endl is flushing after giving a newline?

  • Проголосовать: нравится
  • -14
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

cout << endl; is the same as cout << "\n" << flush;. Flushing a buffer is very slow, because if you output just a small string, it's something like 1 flush per 10 characters, and if you let cout do the buffering automatically, it's something like 1 flush per several thousand characters. That's why the runtime is so different.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

define endl "\n"

you can use this in your template