>>107702444
That's the unoptimized I/O that I pointed out in >>107701214. This should be faster:
use std::io::{self, Read, Write};
fn main() -> io::Result<()> {
let mut input = Vec::new();
io::stdin().read_to_end(&mut input)?;
let mut lines: Vec<_> = input.split_inclusive(|&c| c == b'\n').collect();
lines.sort_unstable();
let mut out = io::BufWriter::with_capacity(64 * 1024, io::stdout().lock());
for line in lines {
out.write_all(line)?;
}
out.flush()?;
Ok(())
Comment too long. Click here to view the full text.