Skip to content

Commit

Permalink
abc329 a, b, c, d
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 18, 2023
1 parent b1d1309 commit 881f8cc
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 0 deletions.
169 changes: 169 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc329/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/abc329/Cargo.toml
@@ -0,0 +1,15 @@
[package]
name = "abc329"
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/abc329/rust-toolchain
@@ -0,0 +1 @@
1.70.0
15 changes: 15 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc329/src/bin/a.rs
@@ -0,0 +1,15 @@
use proconio::{input, marker::Chars};

fn main() {
input! {
s: Chars,
};
let mut t = vec![];
for s_i in s {
t.push(s_i);
t.push(' ');
}
t.pop();
let ans = t.into_iter().collect::<String>();
println!("{}", ans);
}
15 changes: 15 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc329/src/bin/b.rs
@@ -0,0 +1,15 @@
use std::collections::BTreeSet;

use proconio::input;

fn main() {
input! {
n: usize,
a: [usize; n],
};
let set = a.into_iter().collect::<BTreeSet<usize>>();
let mut it = set.iter().rev();
it.next();
let ans = it.next().unwrap();
println!("{}", ans);
}
38 changes: 38 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc329/src/bin/c.rs
@@ -0,0 +1,38 @@
use proconio::{input, marker::Chars};

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

fn main() {
input! {
_n: usize,
s: Chars,
};
let mut set = vec![0_usize; 26];
let mut prev = vec![];
for s_i in s {
match prev.last() {
Some(c) => {
if *c == s_i {
prev.push(s_i);
} else {
prev = vec![s_i];
}
}
None => {
prev = vec![s_i];
}
}
chmax!(set[(prev[0] as u8 - b'a') as usize], prev.len());
}
let ans = set.into_iter().sum::<usize>();
println!("{}", ans);
}
34 changes: 34 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc329/src/bin/d.rs
@@ -0,0 +1,34 @@
use std::collections::BTreeSet;

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

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

let mut ans = vec![];
let mut count = vec![0_usize; n];
let mut map = vec![BTreeSet::new(); 200_000 + 1];
let mut keys = BTreeSet::new();
for a_i in a {
let entry = &mut map[count[a_i]];
entry.remove(&a_i);
if entry.is_empty() {
keys.remove(&count[a_i]);
}

count[a_i] += 1;
keys.insert(count[a_i]);
map[count[a_i]].insert(a_i);

let top = *map[*keys.iter().rev().next().unwrap()].first().unwrap();
ans.push(top);
}

for a in ans {
println!("{}", a + 1);
}
}
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc329/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-1.70.0/contests/abc329/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/abc329/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 881f8cc

Please sign in to comment.