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

Автор showvike, история, 4 года назад, По-английски

see this link: https://codeforces.com/contest/1284/submission/68190516

ios_base :: sync_with_stdio(false); cin.tie(NULL);

when remove this two line it got ac.. but before wa.. why and how??

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

»
4 года назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

Do you need to use iosbase hacks? scanf is fast enough without them.

»
4 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

If you use

ios_base::sync_with_stdio(false);

You should not use scanf/printf, cin/cout at the same time. Or you can submit code on Visual C++

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

cin and cout are synced to stdin and stdout by default, so that people can use both C I/O and C++ I/O at the same time. You disabled it with ios_base::sync_with_stdio(false), so there are now two separate buffers which messes things up. This is why you don't write code which you don't understand. ios_base::sync_with_stdio(false) disables syncing between cin/cout and scanf/printf, and cin.tie(nullptr) disables cout being flushed automatically when you do stuff with cin. They're not magic lines of code that speeds everything up.