I’ve recently come across the following three types of fast IO:
ios_base::sync_with_stdio(0); cin.tie(0); (probably the most common)
cin.tie(0)->sync_with_stdio(0); (I use this because it feels cool to type)
cin.sync_with_stdio(0); (Polish problemsetters use this sometimes)
My understanding is that ios_base::sync_with_stdio(0) disables synchronization between C and C++ standard streams (i.e. scanf/printf and cin/cout), while cin.tie(0) unties cin from cout.
What’s the difference between the three types above? If there is a speed difference, is it significant?
Notice that this is a static member function, and a call to this function using this member of any stream object toggles on or off synchronization for all standard iostream objects.
So the first two are essentially equivalent aside from calling the functions in different orders. Last one doesn’t have tie, not sure how significant the speed difference is.