Created
April 15, 2020 00:54
-
-
Save segfo/502357e4261b4eaa2e23ef2b5a763cd7 to your computer and use it in GitHub Desktop.
AtCoder入力マクロ
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
use std::io::BufRead; | |
macro_rules! readlines { | |
($cnt:expr) => { | |
{ | |
let stdin = std::io::stdin(); | |
let mut handle = stdin.lock(); | |
let mut result = Vec::new(); | |
for i in 0..$cnt{ | |
let mut buf = String::new(); | |
handle.read_line(&mut buf); | |
result.push(buf.trim().to_owned()); | |
} | |
result | |
} | |
}; | |
} | |
macro_rules! string2splittedvec { | |
($t:ty,$sep:expr,$line:expr) => { | |
{ | |
$line.split($sep) | |
.map(|s|s.parse::<$t>().unwrap()) | |
.collect::<Vec<_>>() | |
} | |
}; | |
($t:ty,$line:expr) => { | |
{ | |
string2splittedvec!($t,' ',$line) | |
} | |
}; | |
($sep:expr,$line:expr) => { | |
{ | |
$line.split($sep) | |
.map(|s|s.to_owned()) | |
.collect::<Vec<_>>() | |
} | |
}; | |
($line:expr)=>{ | |
{ | |
string2splittedvec!(' ',$line) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment