Skip to content

Commit

Permalink
abc322 a, b, c, d, e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Sep 30, 2023
1 parent d356a31 commit e355f91
Show file tree
Hide file tree
Showing 10 changed files with 442 additions and 0 deletions.
169 changes: 169 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc322/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/abc322/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "abc322"
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/abc322/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.70.0
29 changes: 29 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc322/src/bin/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use proconio::input;

fn main() {
input! {
n: usize,
s: String,
};
if !s.contains("ABC") {
println!("-1");
return;
}
let chars = s.chars().collect::<Vec<char>>();
for i in 0..n {
if chars[i] != 'A' {
continue;
}
let mut ok = true;
for j in 0..3 {
if chars[i + j] != ['A', 'B', 'C'][j] {
ok = false;
break;
}
}
if ok {
println!("{}", i + 1);
return;
}
}
}
17 changes: 17 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc322/src/bin/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use proconio::input;

fn main() {
input! {
_n: usize,
_m: usize,
s: String,
t: String,
};
let ans = match (t.starts_with(&s), t.ends_with(&s)) {
(true, true) => 0,
(true, false) => 1,
(false, true) => 2,
(false, false) => 3,
};
println!("{}", ans);
}
26 changes: 26 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc322/src/bin/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use proconio::{input, marker::Usize1};

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

let mut ans = vec![n + 1; n];
for a_i in a {
ans[a_i] = 0;
}
let mut count = 0_usize;
for i in (0..n).rev() {
if ans[i] == 0 {
count = 0;
} else {
count += 1;
ans[i] = count;
}
}
for i in 0..n {
println!("{}", ans[i]);
}
}
98 changes: 98 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc322/src/bin/d.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
use proconio::{input, marker::Chars};

fn rotate(p: &[Vec<usize>]) -> Vec<Vec<usize>> {
let mut v = vec![vec![0; 4]; 4];
for i in 0..4 {
for j in 0..4 {
v[j][4 - 1 - i] = p[i][j];
}
}
v
}

#[allow(dead_code)]
fn print(p: &[Vec<usize>]) {
for i in 0..4 {
for j in 0..4 {
print!("{}", p[i][j]);
}
println!();
}
}

fn f(p: &[Vec<Vec<usize>>], o: &[(i64, i64)]) -> bool {
let mut board = vec![vec![0_usize; 4]; 4];
for k in 0..3 {
for i in 0..4 {
for j in 0..4 {
if p[k][i][j] != 1 {
continue;
}
if !(0..4).contains(&(o[k].0 + i as i64)) || !(0..4).contains(&(o[k].1 + j as i64))
{
return false;
}
let (bi, bj) = ((o[k].0 + i as i64) as usize, (o[k].1 + j as i64) as usize);
board[bi][bj] += p[k][i][j];
if board[bi][bj] > 1 {
return false;
}
}
}
}

for i in 0..4 {
for j in 0..4 {
if board[i][j] != 1 {
return false;
}
}
}

true
}

fn main() {
input! {
mut p: [[Chars; 4]; 3],
};
let mut p = {
let mut v = vec![vec![vec![0_usize; 4]; 4]; 4];
for k in 0..3 {
for i in 0..4 {
for j in 0..4 {
v[k][i][j] = if p[k][i][j] == '#' { 1 } else { 0 };
}
}
}
v
};

let mut offsets = vec![];
for i in -3..=3 {
for j in -3..=3 {
offsets.push((i, j));
}
}

for _ in 0..4 {
p[0] = rotate(&p[0]);
for o0 in offsets.iter().copied() {
for _ in 0..4 {
p[1] = rotate(&p[1]);
for o1 in offsets.iter().copied() {
for _ in 0..4 {
p[2] = rotate(&p[2]);
for o2 in offsets.iter().copied() {
if f(&p, &vec![o0, o1, o2]) {
println!("Yes");
return;
}
}
}
}
}
}
}
println!("No");
}

0 comments on commit e355f91

Please sign in to comment.