Skip to content

Commit

Permalink
abc327 a, b, c, d, e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 4, 2023
1 parent ed1d992 commit 8990cd7
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 0 deletions.
169 changes: 169 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/Cargo.lock

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

15 changes: 15 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/Cargo.toml
@@ -0,0 +1,15 @@
[package]
name = "abc327"
version = "0.1.0"
edition = "2021"

# dependencies added to new project
[dependencies]
ac-library-rs = "=0.1.1"
num = "=0.4.0"
proconio = { version = "=0.4.3", features = ["derive"] }
superslice = "=1.0.0"

[profile.release]
lto = true
panic = 'abort'
1 change: 1 addition & 0 deletions cargo-atcoder-1.70.0/contests/abc327/rust-toolchain
@@ -0,0 +1 @@
1.70.0
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/src/bin/a.rs
@@ -0,0 +1,10 @@
use proconio::input;

fn main() {
input! {
_n: usize,
s: String,
};
let ans = s.contains("ab") || s.contains("ba");
println!("{}", if ans { "Yes" } else { "No" });
}
18 changes: 18 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/src/bin/b.rs
@@ -0,0 +1,18 @@
use proconio::input;

fn main() {
input! {
b: usize,
};
for a in 1_usize.. {
if let Some(x) = a.checked_pow(a as u32) {
if x == b {
println!("{}", a);
return;
}
} else {
break;
}
}
println!("-1");
}
39 changes: 39 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/src/bin/c.rs
@@ -0,0 +1,39 @@
use std::collections::HashSet;

use proconio::input;

fn main() {
input! {
a: [[usize; 9]; 9],
};

for i in 0..9 {
if (0..9).map(|j| a[i][j]).collect::<HashSet<usize>>().len() != 9 {
println!("No");
return;
}
}
for j in 0..9 {
if (0..9).map(|i| a[i][j]).collect::<HashSet<usize>>().len() != 9 {
println!("No");
return;
}
}

for bi in 0..3 {
for bj in 0..3 {
let mut b = HashSet::new();
for i in 0..3 {
for j in 0..3 {
b.insert(a[bi * 3 + i][bj * 3 + j]);
}
}
if b.len() != 9 {
println!("No");
return;
}
}
}

println!("Yes");
}
41 changes: 41 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/src/bin/d.rs
@@ -0,0 +1,41 @@
use std::collections::VecDeque;

use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
m: usize,
a: [Usize1; m],
b: [Usize1; m],
};

let mut edges = vec![vec![]; n];
for (a, b) in a.into_iter().zip(b.into_iter()) {
edges[a].push(b);
edges[b].push(a);
}

let mut color = vec![2; n];
for start in 0..n {
if color[start] != 2 {
continue;
}
let mut q = VecDeque::new();
q.push_back(start);
color[start] = 0;
while let Some(u) = q.pop_front() {
for v in edges[u].iter().copied() {
if color[v] == 2 {
color[v] = 1 - color[u];
q.push_back(v);
} else if color[v] == color[u] {
println!("No");
return;
}
}
}
}

println!("Yes");
}
41 changes: 41 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/src/bin/e.rs
@@ -0,0 +1,41 @@
use proconio::input;

macro_rules! chmax {
($max_v: expr, $v: expr) => {
if $v > $max_v {
$max_v = $v;
true
} else {
false
}
};
}

fn main() {
input! {
n: usize,
p: [f64; n],
};

let inf = 1e18_f64;
let mut dp = vec![vec![-inf; n + 1]; n + 1];
dp[0][0] = 0_f64;
for (i, p_i) in p.iter().copied().enumerate() {
for j in 0..=i {
chmax!(dp[i + 1][j + 1], dp[i][j] * 0.9 + p_i);
chmax!(dp[i + 1][j], dp[i][j]);
}
}

let mut ans = -inf;
for k in 1..=n {
let mut x = 0_f64;
let mut y = 1_f64;
for _ in 0..k {
x += y;
y *= 0.9;
}
chmax!(ans, dp[n][k] / x - (1200_f64 / (k as f64).sqrt()));
}
println!("{}", ans);
}
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc327/src/bin/f.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 cargo-atcoder-1.70.0/contests/abc327/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);
}

0 comments on commit 8990cd7

Please sign in to comment.