-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add atcoder/abc317/a.rs atcoder/abc317/remain.txt atcoder/abc324/a.rs…
… 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
Showing
21 changed files
with
838 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.