From a6c545518544f0aa4a79970971fffd729eecc4f1 Mon Sep 17 00:00:00 2001 From: koba-e964 <3303362+koba-e964@users.noreply.github.com> Date: Sat, 9 Nov 2024 16:55:33 +0900 Subject: [PATCH] Add atcoder/abc361/a.rs atcoder/abc361/b.rs atcoder/abc361/remain.txt 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 --- atcoder/abc361/a.rs | 51 +++++++++++++++++++++++++++++++++++ atcoder/abc361/b.rs | 43 ++++++++++++++++++++++++++++++ atcoder/abc361/remain.txt | 5 ++++ atcoder/abc363/a.rs | 10 +++++++ atcoder/abc363/b.rs | 45 +++++++++++++++++++++++++++++++ atcoder/abc363/remain.txt | 5 ++++ atcoder/abc369/a.rs | 36 +++++++++++++++++++++++++ atcoder/abc369/remain.txt | 6 +++++ atcoder/abc372/a.rs | 13 +++++++++ atcoder/abc372/b.rs | 56 +++++++++++++++++++++++++++++++++++++++ atcoder/abc372/remain.txt | 5 ++++ 11 files changed, 275 insertions(+) create mode 100644 atcoder/abc361/a.rs create mode 100644 atcoder/abc361/b.rs create mode 100644 atcoder/abc361/remain.txt create mode 100644 atcoder/abc363/a.rs create mode 100644 atcoder/abc363/b.rs create mode 100644 atcoder/abc363/remain.txt create mode 100644 atcoder/abc369/a.rs create mode 100644 atcoder/abc369/remain.txt create mode 100644 atcoder/abc372/a.rs create mode 100644 atcoder/abc372/b.rs create mode 100644 atcoder/abc372/remain.txt diff --git a/atcoder/abc361/a.rs b/atcoder/abc361/a.rs new file mode 100644 index 00000000..9e0c3534 --- /dev/null +++ b/atcoder/abc361/a.rs @@ -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::>() + }; + ($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); +} diff --git a/atcoder/abc361/b.rs b/atcoder/abc361/b.rs new file mode 100644 index 00000000..e2f9152d --- /dev/null +++ b/atcoder/abc361/b.rs @@ -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::>() + }; + ($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" }); +} diff --git a/atcoder/abc361/remain.txt b/atcoder/abc361/remain.txt new file mode 100644 index 00000000..3a91954e --- /dev/null +++ b/atcoder/abc361/remain.txt @@ -0,0 +1,5 @@ +c +d +e +f +g diff --git a/atcoder/abc363/a.rs b/atcoder/abc363/a.rs new file mode 100644 index 00000000..b468ee86 --- /dev/null +++ b/atcoder/abc363/a.rs @@ -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::().unwrap(); + println!("{}", (399 - r) % 100 + 1); +} diff --git a/atcoder/abc363/b.rs b/atcoder/abc363/b.rs new file mode 100644 index 00000000..5f651e9b --- /dev/null +++ b/atcoder/abc363/b.rs @@ -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::>() + }; + ($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; + } +} diff --git a/atcoder/abc363/remain.txt b/atcoder/abc363/remain.txt new file mode 100644 index 00000000..3a91954e --- /dev/null +++ b/atcoder/abc363/remain.txt @@ -0,0 +1,5 @@ +c +d +e +f +g diff --git a/atcoder/abc369/a.rs b/atcoder/abc369/a.rs new file mode 100644 index 00000000..f839c8c5 --- /dev/null +++ b/atcoder/abc369/a.rs @@ -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 = 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 { 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"); + } +} diff --git a/atcoder/abc369/remain.txt b/atcoder/abc369/remain.txt new file mode 100644 index 00000000..9fbb6235 --- /dev/null +++ b/atcoder/abc369/remain.txt @@ -0,0 +1,6 @@ +b +c +d +e +f +g diff --git a/atcoder/abc372/a.rs b/atcoder/abc372/a.rs new file mode 100644 index 00000000..21da99c0 --- /dev/null +++ b/atcoder/abc372/a.rs @@ -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}"); + } + } +} diff --git a/atcoder/abc372/b.rs b/atcoder/abc372/b.rs new file mode 100644 index 00000000..893af3fe --- /dev/null +++ b/atcoder/abc372/b.rs @@ -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 = 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 { 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!(); +} diff --git a/atcoder/abc372/remain.txt b/atcoder/abc372/remain.txt new file mode 100644 index 00000000..3a91954e --- /dev/null +++ b/atcoder/abc372/remain.txt @@ -0,0 +1,5 @@ +c +d +e +f +g