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.
Use it always anyway.
But be careful during interactive problems.
Use it always!!
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
vscin
, my suggestion is to always usescanf
. On online judges running on Linux,cin
withios::sync_with_stdio(false)
andcin.tie(0)
is slightly faster (it's not a typo) thanscanf
. But Codeforces is on Windows so I'm not sure, andscanf
is almost always fast enough.If you mean other languages (than C++), I can't give any advice since I don't know.
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.