Skip to content

Instantly share code, notes, and snippets.

@leshow
Created July 31, 2019 18:24
Show Gist options
  • Save leshow/110cbd405248cee4c785ea8e77ea788e to your computer and use it in GitHub Desktop.
Save leshow/110cbd405248cee4c785ea8e77ea788e to your computer and use it in GitHub Desktop.
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::io::{BufWriter, stdin, stdout, Write};
#[derive(Default)]
struct Scanner {
buffer: Vec<String>
}
impl Scanner {
fn next<T: std::str::FromStr>(&mut self) -> T {
loop {
if let Some(token) = self.buffer.pop() {
return token.parse().ok().expect("Failed parse");
}
let mut input = String::new();
stdin().read_line(&mut input).expect("Failed read");
self.buffer = input.split_whitespace().rev().map(String::from).collect();
}
}
}
fn main() {
let mut scan = Scanner::default();
let out = &mut BufWriter::new(stdout());
// ex:
// let n = scan.next::<usize>();
// let q = scan.next::<usize>();
// let a: Vec<usize> = (0..n).map(|_| scan.next()).collect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment