Skip to content

Instantly share code, notes, and snippets.

@yasukotelin
Last active August 16, 2020 07:30
Show Gist options
  • Save yasukotelin/d9394fdc180284726ef5645bb1e7e0d3 to your computer and use it in GitHub Desktop.
Save yasukotelin/d9394fdc180284726ef5645bb1e7e0d3 to your computer and use it in GitHub Desktop.
Rust 競技プログラミング用テンプレート
fn main() {
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
(0..n).map(|_| read_vec()).collect()
}
@yasukotelin
Copy link
Author

参考: [Qiita: https://qiita.com/penguinshunya/items/cd96803b74635aebefd6]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment