Skip to content

Commit

Permalink
Add atcoder/abc317/a.rs atcoder/abc317/remain.txt atcoder/abc324/a.rs…
Browse files Browse the repository at this point in the history
… atcoder/abc324/remain.txt atcoder/abc335/a.rs atcoder/abc335/remain.txt atcoder/abc338/a.rs atcoder/abc338/remain.txt atcoder/abc341/a.rs atcoder/abc341/remain.txt atcoder/abc342/a.rs atcoder/abc342/remain.txt atcoder/abc348/a.rs atcoder/abc348/b.rs atcoder/abc348/c.rs atcoder/abc348/d.rs atcoder/abc348/e.rs atcoder/abc348/f.rs atcoder/abc348/g.rs
  • Loading branch information
koba-e964 committed Apr 18, 2024
1 parent 743a250 commit c2acca7
Show file tree
Hide file tree
Showing 22 changed files with 938 additions and 7 deletions.
43 changes: 43 additions & 0 deletions atcoder/abc317/a.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! {
n: usize, h: i32, x: i32,
a: [i32; n],
}
for i in 0..n {
if h + a[i] >= x {
println!("{}", i + 1);
return;
}
}
}
6 changes: 6 additions & 0 deletions atcoder/abc317/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
40 changes: 40 additions & 0 deletions atcoder/abc324/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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,
a: [i32; n],
}
let mut a = a;
a.dedup();
println!("{}", if a.len() == 1 { "Yes" } else { "No" });
}
6 changes: 6 additions & 0 deletions atcoder/abc324/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
11 changes: 11 additions & 0 deletions atcoder/abc335/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
let mut s = getline();
s.pop(); s.pop(); s.push('4');
println!("{}", s);
}
6 changes: 6 additions & 0 deletions atcoder/abc335/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
11 changes: 11 additions & 0 deletions atcoder/abc338/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
let mut s = getline().trim().chars().collect::<Vec<_>>();
let ok = s[0].is_ascii_uppercase() && s[1..].iter().all(|&c| c.is_ascii_lowercase());
println!("{}", if ok { "Yes" } else { "No" });
}
6 changes: 6 additions & 0 deletions atcoder/abc338/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
30 changes: 30 additions & 0 deletions atcoder/abc341/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 n: i32 = get();
for _ in 0..n { print!("10"); }
println!("1");
}
6 changes: 6 additions & 0 deletions atcoder/abc341/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
16 changes: 16 additions & 0 deletions atcoder/abc342/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
let mut s = getline().trim().bytes().collect::<Vec<_>>();
let n = s.len();
for i in 0..n {
if (0..n).all(|j| i == j || s[j] != s[i]) {
println!("{}", i + 1);
return;
}
}
}
6 changes: 6 additions & 0 deletions atcoder/abc342/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
32 changes: 32 additions & 0 deletions atcoder/abc348/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 n: i32 = get();
for i in 0..n {
print!("{}", if i % 3 == 2 { "x" } else { "o" });
}
println!();
}
48 changes: 48 additions & 0 deletions atcoder/abc348/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use std::cmp::*;
// 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),* )) => { ($(read_value!($next, $t)),*) };
($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,
xy: [(i64, i64); n],
}
for i in 0..n {
let mut ans = (0, 0);
for j in 0..n {
let x = xy[j].0 - xy[i].0;
let y = xy[j].1 - xy[i].1;
ans = min(ans, (-x * x - y * y, j));
}
println!("{}", ans.1 + 1);
}
}
49 changes: 49 additions & 0 deletions atcoder/abc348/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use std::cmp::*;
// 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),* )) => { ($(read_value!($next, $t)),*) };
($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,
bc: [(i64, i64); n],
}
let mut hm = std::collections::HashMap::new();
for (b, c) in bc {
let x = hm.entry(c).or_insert(1 << 30);
*x = std::cmp::min(*x, b);
}
let mut ans = 0;
for (_, v) in hm {
ans = std::cmp::max(ans, v);
}
println!("{}", ans);
}
Loading

0 comments on commit c2acca7

Please sign in to comment.