taap_cader's blog

By taap_cader, history, 4 years ago, In English

Sometimes when I do question of around 10^7 operations, I don't need to use fast io but the questions which can be solved with 10^5 operations gets TLE without using fast io. Is there some trick to guess when do we need to use fast io or it we have to use it in every question.

  • Vote: I like it
  • -17
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it +19 Vote: I do not like it

Use it always anyway.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    But be careful during interactive problems.

»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Use it always!!

»
4 years ago, # |
Rev. 3   Vote: I like it +9 Vote: I do not like it

What do you mean by "fast io"?

If you mean some customized input implemented with getchar, it's almost never needed. I've never seen a problem on Codeforces needing this.

If you mean scanf vs cin, my suggestion is to always use scanf. On online judges running on Linux, cin with ios::sync_with_stdio(false) and cin.tie(0) is slightly faster (it's not a typo) than scanf. But Codeforces is on Windows so I'm not sure, and scanf is almost always fast enough.

If you mean other languages (than C++), I can't give any advice since I don't know.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +15 Vote: I do not like it

    I just take a look at the OP's submissions. I think he/she gets TLE on large number of operations because he/she used endl everywhere.

    Don't use it — it does not give any advantage in competitive programming, but just slows down the output. Use plain '\n'.

    I'm very annoyed by the fact that many C++ teachers implies to the student to use endl, without even telling what it is.