Http://www.glenmccl.com/perf_006.htm
Is stream I/O slower than C-style standard I/O? This question is a bit hard to answer. For a simple case like:
# Ifdef cppio
# Include <iostream. h>
# Else
# Include <stdio. h>
# Endif
Main ()
{
Long CNT = 000000l;
while (CNT --> 0)
# ifdef cppio
cout <'X ';
# else
putchar ('x');
# endif
return 0;
}
The C ++ stream I/O approach is about 50% slower for a couple of popular C ++ compilers. but putchar () is a macro (equivalent to an inline function) that has been tuned, whereas the C ++ functions in iostream. h are less tuned, and in the 50% slower case not all the internal little helper functions are actually inlined. we will say more about C ++ function inlining some other time, but one of the issues with it is trading space for speed, that is, doing a lot of inlining can drive up code size.
And 50% may be irrelevant unless I/O is a bottleneck in your program in the first place
In many compilers, stream I/O is 50% slower than C-style. If I/O is not yoursProgramIf the bottleneck occurs, ignore it. c ++ stream I/O uses time space for security.
PS: If your program TLE uses Cin, try scanf instead.