Created
July 31, 2019 18:24
-
-
Save leshow/110cbd405248cee4c785ea8e77ea788e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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