Skip to content

Commit

Permalink
tessoku-book a43-a44, b43-b44
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 1, 2022
1 parent baae53a commit 89a1e3f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 12 deletions.
15 changes: 12 additions & 3 deletions tessoku-book/src/bin/a43.rs
@@ -1,10 +1,19 @@
use proconio::{input, marker::Usize1};
use proconio::input;

fn main() {
input! {
n: usize,
a: [Usize1; n],
l: usize,
ab: [(usize, char); n],
};
let ans = n - a.len();
let ans = ab
.into_iter()
.map(|(a, b)| match b {
'E' => l - a,
'W' => a,
_ => unreachable!(),
})
.max()
.unwrap();
println!("{}", ans);
}
30 changes: 27 additions & 3 deletions tessoku-book/src/bin/a44.rs
Expand Up @@ -3,8 +3,32 @@ use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
a: [Usize1; n],
q: usize,
};
let ans = n - a.len();
println!("{}", ans);
let mut a = (1..=n).collect::<Vec<usize>>();
let mut rev = false;
for _ in 0..q {
input! {
t: usize
}
match t {
1 => {
input! {
x: Usize1,
y: usize,
}
a[if rev { n - 1 - x } else { x }] = y;
}
2 => {
rev = !rev;
}
3 => {
input! {
x: Usize1,
}
println!("{}", a[if rev { n - 1 - x } else { x }]);
}
_ => unreachable!(),
}
}
}
12 changes: 9 additions & 3 deletions tessoku-book/src/bin/b43.rs
Expand Up @@ -3,8 +3,14 @@ use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
a: [Usize1; n],
m: usize,
a: [Usize1; m],
};
let ans = n - a.len();
println!("{}", ans);
let mut count = vec![0_usize; n];
for a_i in a {
count[a_i] += 1;
}
for c in count {
println!("{}", m - c);
}
}
18 changes: 15 additions & 3 deletions tessoku-book/src/bin/b44.rs
Expand Up @@ -3,8 +3,20 @@ use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
a: [Usize1; n],
a: [[usize; n]; n],
q: usize,
query: [(usize, Usize1, Usize1); q],
};
let ans = n - a.len();
println!("{}", ans);
let mut is = (0..n).collect::<Vec<usize>>();
for (t, x, y) in query {
match t {
1 => {
is.swap(x, y);
}
2 => {
println!("{}", a[is[x]][y]);
}
_ => unreachable!(),
}
}
}

0 comments on commit 89a1e3f

Please sign in to comment.