Skip to content

Commit

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

fn main() {
input! {
r: i64,
g: i64,
};
let ans = r + (g - r) * 2;
println!("{ans}");
}
14 changes: 14 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc076/src/bin/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use proconio::input;

fn main() {
input! {
n: usize,
k: usize,
};
let mut cur = 1_usize;
for _ in 0..n {
cur = (cur * 2).min(cur + k);
}
let ans = cur;
println!("{}", ans);
}
47 changes: 47 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc076/src/bin/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use std::collections::BTreeSet;

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

fn main() {
input! {
s: Chars,
t: Chars,
};
let n = s.len();
let m = t.len();
if n < m {
println!("UNRESTORABLE");
return;
}
let mut set = BTreeSet::new();
for i in 0..n - m + 1 {
let mut ok = true;
for j in 0..m {
if s[i + j] != '?' && s[i + j] != t[j] {
ok = false;
break;
}
}
if !ok {
continue;
}

let mut x = vec![];
for c in s[0..i].iter().copied() {
x.push(if c == '?' { 'a' } else { c });
}
for c in t.iter().copied() {
x.push(c);
}
for c in s[i + m..].iter().copied() {
x.push(if c == '?' { 'a' } else { c });
}
set.insert(x);
}

let ans = set
.first()
.map(|s| s.iter().copied().collect::<String>())
.unwrap_or_else(|| "UNRESTORABLE".to_string());
println!("{ans}");
}
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc076/src/bin/d.rs
Original file line number Diff line number Diff line change
@@ -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 1cd022f

Please sign in to comment.