3 ms·
Is printing really so slow and unbuffered, and output so voluminous, that output is really hotspot? The advice is completely opposite from real world best pract
by Drbble 15y ago
Is printing really so slow and unbuffered, and output so voluminous, that output is really hotspot? The advice is completely opposite from real world best practices. You should print as soon as you have any output, so that your consumer can process output in a concurrent pipeline, and use a lower-level (concurrent!) buffer to batch output in an environment-appropriate batch size, for TCP or disk or whatever is underneath your app.
The other points, about using an efficient algorithm instead of a merely correct one that assumes unreasonably large resources, are more on target.
Before coding any algorithm, always plug in the problem size bounds to your O() function estimate. In these contests there is usually one obvious large number that tells you where your algorithm needs to be sub-quadratic