tasmeemreza's blog

By tasmeemreza, history, 9 years ago, In English

In yesderday's contest, my submission for D got TLE in the 29 th case (17495055) where I used cin/cout with ios_base :: sync_with_stdio (0), which of course took more than 2 seconds to execute. :O

But today I re-submitted that same code, but changed the cin, couts into scanf and printf (17504450), and got AC! The weird part is that scanf/printf code took only 826 ms to execute, which is more than 2 times faster than ios_base :: sync_with_stdio (0)!

I knew ios_base :: sync_with_stdio (0) ensures almost same speed as scanf and printf. My question is that, does scanf/printf actually ensures significantly faster performance than ios_base :: sync_with_stdio (0) ?

  • Vote: I like it
  • +23
  • Vote: I do not like it

| Write comment?
»
9 years ago, # |
  Vote: I like it +2 Vote: I do not like it

no ios,scanf 17216504 685ms

using ios 17216440 327ms

scanf 17216479 93ms

»
9 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Ok. I'm NOT going to use cin/cout now :(

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I had the same problem, I think there should be a hint like: Input is huge, Fast I/O needed or something like that. Or big test cases on pretest, to have TLE on the competition and not later.

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Here are some bechmarks http://codeforces.me/blog/entry/562 (unfortunately only in Russian). I think it not so hard to understand them using google translate.

»
9 years ago, # |
  Vote: I like it -14 Vote: I do not like it

It's a bug in MinGW GCC build used by codeforces. Cin/cout should of course be just as fast as printf/scanf.

I wonder when it will be fixed, either by MinGW authors or by Mike. I mean, Microsoft distributes MSVC 2015 as free standalone package, why not to install it on codeforces servers?