diff --git a/.common/rust/src/main.rs b/.common/rust/src/main.rs index 66d6ec2..2b2cb86 100644 --- a/.common/rust/src/main.rs +++ b/.common/rust/src/main.rs @@ -38,6 +38,54 @@ fn main() { } // endregion runner +#[allow(dead_code)] +mod aliases { + use std::collections::{BTreeMap, BTreeSet, VecDeque}; + + pub type V = Vec; + pub type M = BTreeMap; + pub type S = BTreeSet; + pub type Q = VecDeque; +} + +#[allow(dead_code)] +mod input { + use std::collections::VecDeque; + use std::io; + use std::str::FromStr; + + pub struct Scanner { + buffer: VecDeque, + } + + impl Scanner { + pub fn new() -> Scanner { + Scanner { + buffer: VecDeque::new(), + } + } + + pub fn next(&mut self) -> T { + if self.buffer.is_empty() { + let mut input = String::new(); + + io::stdin().read_line(&mut input).ok(); + + for word in input.split_whitespace() { + self.buffer.push_back(word.to_string()) + } + } + + let front = self.buffer.pop_front().unwrap(); + front.parse::().ok().unwrap() + } + + pub fn next_vec(&mut self, n: usize) -> Vec { + (0..n).map(|_| self.next()).collect() + } + } +} + #[allow(dead_code)] mod math { #[derive(Copy, Clone, Default)] @@ -253,51 +301,3 @@ mod output { println!("{}", if ans { "YES" } else { "NO" }); } } - -#[allow(dead_code)] -mod input { - use std::collections::VecDeque; - use std::io; - use std::str::FromStr; - - pub struct Scanner { - buffer: VecDeque, - } - - impl Scanner { - pub fn new() -> Scanner { - Scanner { - buffer: VecDeque::new(), - } - } - - pub fn next(&mut self) -> T { - if self.buffer.is_empty() { - let mut input = String::new(); - - io::stdin().read_line(&mut input).ok(); - - for word in input.split_whitespace() { - self.buffer.push_back(word.to_string()) - } - } - - let front = self.buffer.pop_front().unwrap(); - front.parse::().ok().unwrap() - } - - pub fn next_vec(&mut self, n: usize) -> Vec { - (0..n).map(|_| self.next()).collect() - } - } -} - -#[allow(dead_code)] -mod aliases { - use std::collections::{BTreeMap, BTreeSet, VecDeque}; - - pub type V = Vec; - pub type M = BTreeMap; - pub type S = BTreeSet; - pub type Q = VecDeque; -}