Why cin/cout so slow when process doubles?

Правка en1, от HandIeNeeded, 2015-07-04 20:06:41

I was solving Problem B of Andrew Stankevich Contest 45.And I got endless TLE on test 2.It took me about an hour to debug but find nothing wrong. So my last hope is to change the cin/cout with scanf/printf in the IO, since this problem need to read and write about 105 doubles. And it got AC. 11925037 11925015. Check it out! WTF is this?

I have read some post on CF discussing the difference about speed of cin/cout and scanf/printf. But how ever in general cases they talk about read integers. But it seems even if I add ios :: sync_with_stdio(0); in my code, cin/cout is much slower than scanf/printf. Why is this? Anyone knows? Thx in advance.

BTW, how can I share my code in gym so everybody can see it? (since gym has the rule U must got accepted first then U can read the others' code. However I remember once I saw a coder share his code in gym, but I don't need to got AC in advance.)

Теги cin/cout, scanf/printf

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский HandIeNeeded 2015-07-04 20:06:41 1008 Initial revision (published)