Skip to content

Commit

Permalink
abc312 a, b, c, d
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jul 29, 2023
1 parent a902c35 commit 508b9bc
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 0 deletions.
161 changes: 161 additions & 0 deletions cargo-atcoder/contests/abc312/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 cargo-atcoder/contests/abc312/Cargo.toml
@@ -0,0 +1,14 @@
[package]
name = "abc312"
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 cargo-atcoder/contests/abc312/rust-toolchain
@@ -0,0 +1 @@
1.42.0
11 changes: 11 additions & 0 deletions cargo-atcoder/contests/abc312/src/bin/a.rs
@@ -0,0 +1,11 @@
use proconio::input;

fn main() {
input! {
s: String,
};
let ans = vec!["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GBD"]
.iter()
.any(|t| t == &s);
println!("{}", if ans { "Yes" } else { "No" });
}
71 changes: 71 additions & 0 deletions cargo-atcoder/contests/abc312/src/bin/b.rs
@@ -0,0 +1,71 @@
use proconio::{input, marker::Chars};

fn main() {
input! {
n: usize,
m: usize,
s: [Chars; n],
};
let mut ans = vec![];
for i_tl in 0..n {
'next: for j_tl in 0..m {
if s[i_tl][j_tl] == '.' {
continue;
}
if i_tl + 9 > n || j_tl + 9 > m {
continue;
}

for i_offset in 0..3 {
for j_offset in 0..3 {
let (i, j) = (i_tl + i_offset, j_tl + j_offset);
if s[i][j] == '.' {
continue 'next;
}
}
}
for i_offset in 0..4 {
let j_offset = 3;
let (i, j) = (i_tl + i_offset, j_tl + j_offset);
if s[i][j] == '#' {
continue 'next;
}
}
for j_offset in 0..4 {
let i_offset = 3;
let (i, j) = (i_tl + i_offset, j_tl + j_offset);
if s[i][j] == '#' {
continue 'next;
}
}

for i_offset in 6..9 {
let j_offset = 5;
let (i, j) = (i_tl + i_offset, j_tl + j_offset);
if s[i][j] == '#' {
continue 'next;
}
}
for j_offset in 6..9 {
let i_offset = 5;
let (i, j) = (i_tl + i_offset, j_tl + j_offset);
if s[i][j] == '#' {
continue 'next;
}
}
for i_offset in 6..9 {
for j_offset in 6..9 {
let (i, j) = (i_tl + i_offset, j_tl + j_offset);
if s[i][j] == '.' {
continue 'next;
}
}
}
ans.push((i_tl, j_tl));
}
}

for (i, j) in ans {
println!("{} {}", i + 1, j + 1);
}
}
24 changes: 24 additions & 0 deletions cargo-atcoder/contests/abc312/src/bin/c.rs
@@ -0,0 +1,24 @@
use proconio::input;

fn main() {
input! {
n: usize,
m: usize,
a: [usize; n],
b: [usize; m],
};
let mut ok = 1_000_000_001_usize;
let mut ng = 0_usize;
while ok - ng > 1 {
let mid = ng + (ok - ng) / 2;
let c_a = a.iter().filter(|&a_i| *a_i <= mid).count();
let c_b = b.iter().filter(|&b_i| *b_i >= mid).count();
if c_a >= c_b {
ok = mid;
} else {
ng = mid;
}
}
let ans = ok;
println!("{}", ans);
}
44 changes: 44 additions & 0 deletions cargo-atcoder/contests/abc312/src/bin/d.rs
@@ -0,0 +1,44 @@
use proconio::{input, marker::Chars};

fn main() {
input! {
s: Chars,
};
let p = 998_244_353_usize;
let mut dp = vec![0_usize; 3000 + 1];
dp[0] = 1_usize;
for s_i in s.iter().copied() {
let mut next = vec![0_usize; 3000 + 1];
for j in 0..=3000 {
match s_i {
'(' => {
if j + 1 <= 3000 {
next[j + 1] += dp[j];
next[j + 1] %= p;
}
}
')' => {
if j > 0 {
next[j - 1] += dp[j];
next[j - 1] %= p;
}
}
'?' => {
if j + 1 <= 3000 {
next[j + 1] += dp[j];
next[j + 1] %= p;
}
if j > 0 {
next[j - 1] += dp[j];
next[j - 1] %= p;
}
}
_ => unreachable!(),
}
}
dp = next;
}

let ans = dp[0];
println!("{}", ans);
}
10 changes: 10 additions & 0 deletions cargo-atcoder/contests/abc312/src/bin/e.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/contests/abc312/src/bin/ex.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/contests/abc312/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/contests/abc312/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 508b9bc

Please sign in to comment.