Skip to content

Commit

Permalink
Add atcoder/abc361/a.rs atcoder/abc361/b.rs atcoder/abc361/remain.txt…
Browse files Browse the repository at this point in the history
… atcoder/abc363/a.rs atcoder/abc363/b.rs atcoder/abc363/remain.txt atcoder/abc369/a.rs atcoder/abc369/remain.txt atcoder/abc372/a.rs atcoder/abc372/b.rs atcoder/abc372/remain.txt
  • Loading branch information
koba-e964 committed Nov 9, 2024
1 parent 4d24251 commit a6c5455
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 0 deletions.
51 changes: 51 additions & 0 deletions atcoder/abc361/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes.by_ref().map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}

macro_rules! input_inner {
($next:expr) => {};
($next:expr,) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}

macro_rules! read_value {
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
let out = std::io::stdout();
let mut out = BufWriter::new(out.lock());
macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););}
macro_rules! putvec {
($v:expr) => {
for i in 0..$v.len() {
puts!("{}{}", $v[i], if i + 1 == $v.len() {"\n"} else {" "});
}
}
}
input! {
n: usize, k: usize, x: i64,
a: [i64; n],
}
let mut a = a;
a.insert(k, x);
putvec!(a);
}
43 changes: 43 additions & 0 deletions atcoder/abc361/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes.by_ref().map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}

macro_rules! input_inner {
($next:expr) => {};
($next:expr,) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}

macro_rules! read_value {
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
input!(x: [[i64; 3]; 4]);
let mut ok = true;
for i in 0..3 {
let lo = x[0][i].max(x[2][i]);
let hi = x[1][i].min(x[3][i]);
if lo >= hi {
ok = false;
}
}
println!("{}", if ok { "Yes" } else { "No" });
}
5 changes: 5 additions & 0 deletions atcoder/abc361/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
c
d
e
f
g
10 changes: 10 additions & 0 deletions atcoder/abc363/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
let r = getline().trim().parse::<i64>().unwrap();
println!("{}", (399 - r) % 100 + 1);
}
45 changes: 45 additions & 0 deletions atcoder/abc363/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes.by_ref().map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}

macro_rules! input_inner {
($next:expr) => {};
($next:expr,) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}

macro_rules! read_value {
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
input! {
n: usize, t: i32, p: usize,
l: [i32; n],
}
let mut x = 0;
loop {
if l.iter().filter(|&&h| h + x >= t).count() >= p {
println!("{x}");
return;
}
x += 1;
}
}
5 changes: 5 additions & 0 deletions atcoder/abc363/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
c
d
e
f
g
36 changes: 36 additions & 0 deletions atcoder/abc369/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::io::Read;

fn get_word() -> String {
let stdin = std::io::stdin();
let mut stdin=stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if buf.len() >= 1 {
let ret = String::from_utf8(buf).unwrap();
return ret;
}
}
}

fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
let a: i32 = get();
let b: i32 = get();
if a == b {
println!("1");
} else if (a + b) % 2 == 0 {
println!("3");
} else {
println!("2");
}
}
6 changes: 6 additions & 0 deletions atcoder/abc369/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
13 changes: 13 additions & 0 deletions atcoder/abc372/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
for c in getline().chars() {
if c != '.' {
print!("{c}");
}
}
}
56 changes: 56 additions & 0 deletions atcoder/abc372/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;

#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn get_word() -> String {
let stdin = std::io::stdin();
let mut stdin=stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if buf.len() >= 1 {
let ret = String::from_utf8(buf).unwrap();
return ret;
}
}
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
let mut x: i32 = get();
let mut a = vec![];
let mut pw = vec![1];
for i in 1..11 {
pw.push(pw[i - 1] * 3);
}
for i in (0..11).rev() {
while x >= pw[i] {
x -= pw[i];
a.push(i);
}
}
println!("{}", a.len());
for v in a {
print!("{v} ");
}
println!();
}
5 changes: 5 additions & 0 deletions atcoder/abc372/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
c
d
e
f
g

0 comments on commit a6c5455

Please sign in to comment.