Skip to content

Commit b51a09e

Browse files
committed
Remove proconio::input! from the examples other than abc121-b
1 parent da78cd5 commit b51a09e

File tree

12 files changed

+231
-348
lines changed

12 files changed

+231
-348
lines changed

examples/abc054-c.rs

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,41 @@
33
use petgraph::csr::Csr;
44
use petgraph::Undirected;
55

6-
fn main() {
7-
// use std::io::{self, Read as _};
8-
//
9-
// let mut input = "".to_owned();
10-
// io::stdin().read_to_string(&mut input).unwrap();
11-
// let mut input = input.split_whitespace();
12-
// macro_rules! read {
13-
// ([$t:tt; $n:expr]) => {
14-
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
15-
// };
16-
// (($($t:tt),+)) => {
17-
// ($(read!($t)),*)
18-
// };
19-
// (_1based) => {
20-
// read!(usize) - 1
21-
// };
22-
// (_bytes) => {
23-
// read!(String).into_bytes()
24-
// };
25-
// ($ty:ty) => {
26-
// input.next().unwrap().parse::<$ty>().unwrap()
27-
// };
28-
// }
29-
//
30-
// let (n, m) = read!((usize, usize));
31-
// let mut abs = read!([(_1based, _1based); m]);
32-
33-
use proconio::input;
34-
use proconio::marker::Usize1;
6+
use std::io::{self, Read as _};
357

36-
input! {
37-
n: usize,
38-
m: usize,
39-
mut abs: [(Usize1, Usize1); m],
8+
fn main() {
9+
let mut input = "".to_owned();
10+
io::stdin().read_to_string(&mut input).unwrap();
11+
let mut input = input.split_whitespace();
12+
macro_rules! read {
13+
([$tt:tt; $n:expr]) => {
14+
(0..$n).map(|_| read!($tt)).collect::<Vec<_>>()
15+
};
16+
(($($tt:tt),+)) => {
17+
($(read!($tt)),*)
18+
};
19+
(_1based) => {
20+
read!(usize) - 1
21+
};
22+
(_bytes) => {
23+
read!(String).into_bytes()
24+
};
25+
($ty:ty) => {
26+
input.next().unwrap().parse::<$ty>().unwrap()
27+
};
4028
}
4129

42-
abs.sort();
43-
let mut g = Csr::<(), (), Undirected, usize>::with_nodes(n);
30+
let (n, m) = read!((usize, usize));
31+
let abs = read!([(_1based, _1based); m]);
32+
33+
let mut graph = Csr::<(), (), Undirected, usize>::with_nodes(n);
4434
for (a, b) in abs {
45-
g.add_edge(a, b, ());
35+
graph.add_edge(a, b, ());
4636
}
4737
let mut ans = 0;
48-
let mut es = (0..n).collect::<Vec<_>>();
49-
permutohedron::heap_recursive(&mut es, |es| {
50-
if es[0] == 0 && es.windows(2).all(|w| g.contains_edge(w[0], w[1])) {
38+
let mut nodes = (0..n).collect::<Vec<_>>();
39+
permutohedron::heap_recursive(&mut nodes, |nodes| {
40+
if nodes[0] == 0 && nodes.windows(2).all(|w| graph.contains_edge(w[0], w[1])) {
5141
ans += 1;
5242
}
5343
});

examples/abc084-d.rs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,42 @@
33
use itertools_num::ItertoolsNum as _;
44
use primal::Sieve;
55

6+
use std::io::{self, Read as _};
7+
8+
// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40.
9+
macro_rules! macro_rules_hack {
10+
($name:ident { $($tt:tt)* }) => {
11+
macro_rules! $name {
12+
$($tt)*
13+
}
14+
};
15+
}
16+
617
#[proconio::fastout]
718
fn main() {
8-
// use std::io::{self, Read as _};
9-
//
10-
// let mut input = "".to_owned();
11-
// io::stdin().read_to_string(&mut input).unwrap();
12-
// let mut input = input.split_whitespace();
13-
// macro_rules! read {
14-
// ([$t:tt; $n:expr]) => {
15-
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
16-
// };
17-
// (($($t:tt),+)) => {
18-
// ($(read!($t)),*)
19-
// };
20-
// (_1based) => {
21-
// read!(usize) - 1
22-
// };
23-
// (_bytes) => {
24-
// read!(String).into_bytes()
25-
// };
26-
// ($ty:ty) => {
27-
// input.next().unwrap().parse::<$ty>().unwrap()
28-
// };
29-
// }
30-
//
31-
// let q = read!(usize);
32-
// let lrs = read!([(usize, usize); q]);
19+
let mut input = "".to_owned();
20+
io::stdin().read_to_string(&mut input).unwrap();
21+
let mut input = input.split_whitespace();
22+
macro_rules_hack!(read {
23+
([$tt:tt; $n:expr]) => {
24+
(0..$n).map(|_| read!($tt)).collect::<Vec<_>>()
25+
};
26+
(($($tt:tt),+)) => {
27+
($(read!($tt)),*)
28+
};
29+
(_1based) => {
30+
read!(usize) - 1
31+
};
32+
(_bytes) => {
33+
read!(String).into_bytes()
34+
};
35+
($ty:ty) => {
36+
input.next().unwrap().parse::<$ty>().unwrap()
37+
};
38+
});
3339

34-
use proconio::input;
35-
36-
input! {
37-
q: usize,
38-
lrs: [(usize, usize); q],
39-
}
40+
let q = read!(usize);
41+
let lrs = read!([(usize, usize); q]);
4042

4143
// サンプルケースでしか試してないので嘘かもしれない。
4244

examples/abc120-d.rs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,55 @@
22

33
use union_find::{QuickFindUf, UnionBySize, UnionFind as _};
44

5+
use std::io::{self, Read as _};
6+
7+
// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40.
8+
macro_rules! macro_rules_hack {
9+
($name:ident { $($tt:tt)* }) => {
10+
macro_rules! $name {
11+
$($tt)*
12+
}
13+
};
14+
}
15+
516
#[proconio::fastout]
617
fn main() {
7-
// use std::io::{self, Read as _};
8-
//
9-
// let mut input = "".to_owned();
10-
// io::stdin().read_to_string(&mut input).unwrap();
11-
// let mut input = input.split_whitespace();
12-
// macro_rules! read {
13-
// ([$t:tt; $n:expr]) => {
14-
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
15-
// };
16-
// (($($t:tt),+)) => {
17-
// ($(read!($t)),*)
18-
// };
19-
// (_1based) => {
20-
// read!(usize) - 1
21-
// };
22-
// (_bytes) => {
23-
// read!(String).into_bytes()
24-
// };
25-
// ($ty:ty) => {
26-
// input.next().unwrap().parse::<$ty>().unwrap()
27-
// };
28-
// }
29-
//
30-
// let (n, m) = (read!((usize, usize)));
31-
// let abs = read!([(_1based, _1based); m]);
32-
33-
use proconio::input;
34-
use proconio::marker::Usize1;
18+
let mut input = "".to_owned();
19+
io::stdin().read_to_string(&mut input).unwrap();
20+
let mut input = input.split_whitespace();
21+
macro_rules_hack!(read {
22+
([$tt:tt; $n:expr]) => {
23+
(0..$n).map(|_| read!($tt)).collect::<Vec<_>>()
24+
};
25+
(($($tt:tt),+)) => {
26+
($(read!($tt)),*)
27+
};
28+
(_1based) => {
29+
read!(usize) - 1
30+
};
31+
(_bytes) => {
32+
read!(String).into_bytes()
33+
};
34+
($ty:ty) => {
35+
input.next().unwrap().parse::<$ty>().unwrap()
36+
};
37+
});
3538

36-
input! {
37-
n: usize,
38-
m: usize,
39-
abs: [(Usize1, Usize1); m],
40-
}
39+
let (n, m) = read!((usize, usize));
40+
let abs = read!([(_1based, _1based); m]);
4141

42-
let mut u = QuickFindUf::<UnionBySize>::new(n);
42+
let mut uf = QuickFindUf::<UnionBySize>::new(n);
4343
let mut k = n * (n - 1) / 2;
44-
let mut r = vec![k];
45-
r.extend(abs.into_iter().rev().map(|(a, b)| {
46-
let p = u.get(a).size() * u.get(b).size();
47-
if u.union(a, b) {
44+
let mut ans_rev = vec![k];
45+
ans_rev.extend(abs.into_iter().rev().map(|(a, b)| {
46+
let p = uf.get(a).size() * uf.get(b).size();
47+
if uf.union(a, b) {
4848
k -= p;
4949
}
5050
k
5151
}));
52-
assert_eq!(r.pop(), Some(0));
53-
for r in r.into_iter().rev() {
54-
println!("{}", r);
52+
assert_eq!(ans_rev.pop(), Some(0));
53+
for x in ans_rev.into_iter().rev() {
54+
println!("{}", x);
5555
}
5656
}

examples/abc129-f.rs

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,23 @@
11
// https://atcoder.jp/contests/abc129/tasks/abc129_f
22

3+
use defmac::defmac;
34
use derive_more::Display;
45
use ndarray::{array, Array2, LinalgScalar};
56
use num::{PrimInt, Unsigned};
67
use num_derive::{One, Zero};
78

89
use std::cell::Cell;
910
use std::cmp;
11+
use std::io::{self, Read as _};
1012
use std::ops::{Add, Div, Mul, Sub};
1113

1214
fn main() {
13-
// use std::io::{self, Read as _};
14-
//
15-
// let mut input = "".to_owned();
16-
// io::stdin().read_to_string(&mut input).unwrap();
17-
// let mut input = input.split_whitespace();
18-
// macro_rules! read {
19-
// ([$t:tt; $n:expr]) => {
20-
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
21-
// };
22-
// (($($t:tt),+)) => {
23-
// ($(read!($t)),*)
24-
// };
25-
// (_1based) => {
26-
// read!(usize) - 1
27-
// };
28-
// (_bytes) => {
29-
// read!(String).into_bytes()
30-
// };
31-
// ($ty:ty) => {
32-
// input.next().unwrap().parse::<$ty>().unwrap()
33-
// };
34-
// }
35-
//
36-
// let (l, a, b, m) = read!((u64, u64, u64, u64));
37-
38-
use proconio::input;
39-
40-
input! {
41-
l: u64,
42-
a: u64,
43-
b: u64,
44-
m: u64,
45-
}
15+
let mut input = "".to_owned();
16+
io::stdin().read_to_string(&mut input).unwrap();
17+
let mut input = input.split_whitespace();
18+
defmac!(read => input.next().unwrap().parse().unwrap());
19+
20+
let (l, a, b, m): (u64, u64, u64, u64) = (read!(), read!(), read!(), read!());
4621

4722
MOD.with(|cell| cell.set(m));
4823

examples/abc142-d.rs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,19 @@
11
// https://atcoder.jp/contests/abc142/tasks/abc142_d
22

3+
use defmac::defmac;
34
use primal::Sieve;
45

56
use std::cmp::max;
67
use std::collections::HashSet;
8+
use std::io::{self, Read as _};
79

810
fn main() {
9-
// use std::io::{self, Read as _};
10-
//
11-
// let mut input = "".to_owned();
12-
// io::stdin().read_to_string(&mut input).unwrap();
13-
// let mut input = input.split_whitespace();
14-
// macro_rules! read {
15-
// ([$t:tt; $n:expr]) => {
16-
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
17-
// };
18-
// (($($t:tt),+)) => {
19-
// ($(read!($t)),*)
20-
// };
21-
// (_1based) => {
22-
// read!(usize) - 1
23-
// };
24-
// (_bytes) => {
25-
// read!(String).into_bytes()
26-
// };
27-
// ($ty:ty) => {
28-
// input.next().unwrap().parse::<$ty>().unwrap()
29-
// };
30-
// }
31-
//
32-
// let (n, m) = read!((usize, usize));
11+
let mut input = "".to_owned();
12+
io::stdin().read_to_string(&mut input).unwrap();
13+
let mut input = input.split_whitespace();
14+
defmac!(read => input.next().unwrap().parse().unwrap());
3315

34-
use proconio::input;
35-
36-
input! {
37-
a: usize,
38-
b: usize,
39-
}
16+
let (a, b): (usize, usize) = (read!(), read!());
4017

4118
// サンプルケースでしか試してないので嘘かもしれない。
4219

examples/apg4b-a.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// https://atcoder.jp/contests/APG4b/tasks/APG4b_a
2+
13
use aho_corasick as _;
24
use alga as _;
35
use approx as _;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy