Skip to content

Commit

Permalink
abc103 a, b, c, d
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Aug 8, 2022
1 parent 4951274 commit b6e5699
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 29 deletions.
88 changes: 86 additions & 2 deletions abc103/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion abc103/Cargo.toml
@@ -1,11 +1,11 @@
[package]
name = "abc103"
version = "0.1.0"
authors = ["bouzuya <m@bouzuya.net>"]
edition = "2018"

# dependencies added to new project
[dependencies]
num = "=0.2.1"
proconio = { version = "=0.3.6", features = ["derive"] }
superslice = "=1.0.0"

Expand Down
2 changes: 1 addition & 1 deletion abc103/src/bin/a.rs
Expand Up @@ -5,6 +5,6 @@ fn main() {
mut a: [i64; 3],
};
a.sort();
let ans = (a[1] - a[0]).abs() + (a[2] - a[1]).abs();
let ans = a[2] - a[1] + a[1] - a[0];
println!("{}", ans);
}
19 changes: 7 additions & 12 deletions abc103/src/bin/b.rs
@@ -1,21 +1,16 @@
use proconio::input;
use proconio::marker::Chars;
use proconio::{input, marker::Chars};

fn main() {
input! {
s: Chars,
mut s: Chars,
t: Chars,
};
let mut ans = false;
let mut deque = s
.iter()
.map(|&x| x)
.collect::<std::collections::VecDeque<_>>();
for _ in 0..s.len() {
if deque.iter().zip(t.iter()).all(|(s_i, t_i)| s_i == t_i) {
ans = true;
if s == t {
println!("Yes");
return;
}
deque.rotate_left(1);
s.rotate_right(1);
}
println!("{}", if ans { "Yes" } else { "No" });
println!("No");
}
6 changes: 3 additions & 3 deletions abc103/src/bin/c.rs
@@ -1,10 +1,10 @@
use proconio::input;
use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
a: [i64; n],
a: [Usize1; n],
};
let ans = a.iter().map(|a_i| a_i - 1).sum::<i64>();
let ans = a.into_iter().sum::<usize>();
println!("{}", ans);
}
24 changes: 14 additions & 10 deletions abc103/src/bin/d.rs
Expand Up @@ -2,19 +2,23 @@ use proconio::input;

fn main() {
input! {
_: usize,
_n: usize,
m: usize,
mut ab: [(i64, i64); m],
mut ab: [(usize, usize); m],
};
ab.sort_by_key(|&(_, b)| b);
let mut c = 0;
let mut l = 0;
for &(a_i, b_i) in ab.iter() {
if a_i >= l {
c += 1;
l = b_i;
ab.sort();
let mut count = 1;
let mut l = ab[0].0;
let mut r = ab[0].1;
for (l_i, r_i) in ab.into_iter().skip(1) {
if (l..r).contains(&l_i) {
r = r.min(r_i);
} else {
count += 1;
l = l_i;
r = r_i;
}
}
let ans = c;
let ans = count;
println!("{}", ans);
}

0 comments on commit b6e5699

Please sign in to comment.