Performance of endl vs \n

Правка en1, от jeqcho, 2020-05-08 11:53:51

I have been using endl for competitive programming until now. For 350C - Бомбы, both 79359924 and 79360060 have the same time complexity of $$$O(n \log{n})$$$, but the first gets TLE while the second gets AC. The reason is that the AC solution uses \n instead of endl. The difference in performance is significant because this problem requires $$$6\times 10^5+1$$$ lines of output at most!

Conclusion: Use endl only if it is a query problem.

Теги performance, c++, #tle

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский jeqcho 2020-05-08 11:53:51 498 Initial revision (published)