Skip to content

Commit

Permalink
abc225 a, b, c, d, e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Oct 30, 2021
1 parent 0f2e685 commit 373c687
Show file tree
Hide file tree
Showing 11 changed files with 373 additions and 0 deletions.
161 changes: 161 additions & 0 deletions abc225/Cargo.lock

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

14 changes: 14 additions & 0 deletions abc225/Cargo.toml
@@ -0,0 +1,14 @@
[package]
name = "abc225"
version = "0.1.0"
edition = "2018"

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

[profile.release]
lto = true
panic = 'abort'
1 change: 1 addition & 0 deletions abc225/rust-toolchain
@@ -0,0 +1 @@
1.42.0
21 changes: 21 additions & 0 deletions abc225/src/bin/a.rs
@@ -0,0 +1,21 @@
use std::collections::HashSet;

use proconio::{input, marker::Chars};
use superslice::Ext;

fn main() {
input! {
s: Chars,
};
let mut set = HashSet::new();
let mut is = (0..3).collect::<Vec<usize>>();
loop {
let t = is.iter().map(|&i| s[i]).collect::<String>();
set.insert(t);
if !is.next_permutation() {
break;
}
}
let ans = set.len();
println!("{}", ans);
}
26 changes: 26 additions & 0 deletions abc225/src/bin/b.rs
@@ -0,0 +1,26 @@
use proconio::{input, marker::Usize1};

fn adjacency_list(n: usize, uv: &[(usize, usize)]) -> Vec<Vec<usize>> {
let mut e = vec![vec![]; n];
for &(u, v) in uv.iter() {
e[u].push(v);
e[v].push(u);
}
e
}

fn main() {
input! {
n: usize,
ab: [(Usize1, Usize1); n - 1],
};

let e = adjacency_list(n, &ab);
for u in 0..n {
if e[u].len() == n - 1 {
println!("Yes");
return;
}
}
println!("No");
}
26 changes: 26 additions & 0 deletions abc225/src/bin/c.rs
@@ -0,0 +1,26 @@
use proconio::input;

fn main() {
input! {
n: usize,
m: usize,
b: [[usize; m]; n],
};
if !(0..(7 - m + 1)).contains(&((b[0][0] - 1) % 7)) {
println!("No");
return;
}

let mut c = vec![vec![0; m]; n];
c[0][0] = b[0][0];
for i in 0..n {
if i + 1 < n {
c[i + 1][0] = c[i][0] + 7;
}
for j in 0..m - 1 {
c[i][j + 1] = c[i][j] + 1;
}
}
let ans = b == c;
println!("{}", if ans { "Yes" } else { "No" });
}
54 changes: 54 additions & 0 deletions abc225/src/bin/d.rs
@@ -0,0 +1,54 @@
use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
q: usize,
};
let mut prev = vec![n; n];
let mut next = vec![n; n];
for _ in 0..q {
input! {
t: usize,
};
match t {
1 => {
input! {
x: Usize1,
y: Usize1,
};
prev[y] = x;
next[x] = y;
}
2 => {
input! {
x: Usize1,
y: Usize1,
};
prev[y] = n;
next[x] = n;
}
3 => {
input! {
x: Usize1,
};
let mut start = x;
while prev[start] != n {
start = prev[start];
}
let mut ans = vec![];
while next[start] != n {
ans.push(start + 1);
start = next[start];
}
ans.push(start + 1);

print!("{} ", ans.len());
for (i, a) in ans.iter().copied().enumerate() {
print!("{}{}", a, if i == ans.len() - 1 { "\n" } else { " " });
}
}
_ => unreachable!(),
}
}
}
34 changes: 34 additions & 0 deletions abc225/src/bin/e.rs
@@ -0,0 +1,34 @@
use num::Rational;
use proconio::input;

fn main() {
input! {
n: usize,
xy: [(isize, isize); n],
};

let mut a = vec![];
for (x, y) in xy {
let a1 = if x - 1 == 0 {
Rational::new(std::isize::MAX, 1)
} else {
Rational::new(y, x - 1)
};
let a2 = Rational::new(y - 1, x);
a.push((a1, a2));
}
a.sort();

let mut count = 0_usize;
let mut p = Rational::new(-1, 1);
for (a1, a2) in a {
if a2 < p {
continue;
}
count += 1;
p = a1;
}

let ans = count;
println!("{}", ans);
}
16 changes: 16 additions & 0 deletions abc225/src/bin/f.rs
@@ -0,0 +1,16 @@
use proconio::input;

fn main() {
input! {
n: usize,
k: usize,
mut s: [String; n],
};
s.sort();
let mut t = String::new();
for s_i in s.iter().take(k) {
t.push_str(s_i);
}
let ans = t;
println!("{}", ans);
}
10 changes: 10 additions & 0 deletions abc225/src/bin/g.rs
@@ -0,0 +1,10 @@
use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
a: [Usize1; n],
};
let ans = n - a.len();
println!("{}", ans);
}
10 changes: 10 additions & 0 deletions abc225/src/bin/h.rs
@@ -0,0 +1,10 @@
use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
a: [Usize1; n],
};
let ans = n - a.len();
println!("{}", ans);
}

0 comments on commit 373c687

Please sign in to comment.