As a competitive programmer, I've always used ios::sync_with_stdio(0);
to speed up cin
and cout
. But I've also seen other people use optimizations like cin.sync_with_stdio(0);
or cout.sync_with_stdio(0);
. For example, the latter two were used in this website: https://usaco.guide/general/fast-io?lang=cpp.
I know that ios::sync_with_stdio(0);
unsyncs iostream
(cin
and cout
) from stdio
(scanf
and printf
), so why would someone unsync only the input cin
or only the output cout
when doing competitive programming (which usually has a large amount of both input and output)?
sync_with_stdio
is a static method, cin.sync_with_stdio(0)
does "exactly" the same as ios::sync_with_stdio(0);
.
Not really exactly as it odr-uses std::cin
but it is no-op.