Skip to content

Commit

Permalink
Add atcoder/abc355/a.rs atcoder/abc355/b.rs atcoder/abc355/c.rs atcod…
Browse files Browse the repository at this point in the history
…er/abc355/remain.txt atcoder/abc357/a.rs atcoder/abc357/b.rs atcoder/abc357/remain.txt
  • Loading branch information
koba-e964 committed Jun 18, 2024
1 parent 570b83e commit e86819e
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 0 deletions.
30 changes: 30 additions & 0 deletions atcoder/abc355/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 a: i32 = get();
let b: i32 = get();
println!("{}", if a == b { -1 } else { 6 - a - b });
}
46 changes: 46 additions & 0 deletions atcoder/abc355/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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: usize = get();
let m: usize = get();
let a = (0..n).map(|_| get::<i32>()).collect::<Vec<_>>();
let b = (0..m).map(|_| get::<i32>()).collect::<Vec<_>>();
let mut c = vec![];
for a in a {
c.push((a, 0));
}
for b in b {
c.push((b, 1));
}
c.sort();
for i in 0..c.len() - 1 {
if c[i].1 + c[i + 1].1 == 0 {
println!("Yes");
return;
}
}
println!("No");
}
61 changes: 61 additions & 0 deletions atcoder/abc355/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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: usize = get();
let t: i32 = get();
let mut ans = -1;
let mut row = vec![0; n];
let mut col = vec![0; n];
let mut diag0 = 0;
let mut diag1 = 0;
for turn in 1..t + 1 {
let x = get::<usize>() - 1;
row[x / n] += 1;
if row[x / n] == n {
ans = turn;
}
col[x % n] += 1;
if col[x % n] == n {
ans = turn;
}
if x / n == x % n {
diag0 += 1;
if diag0 == n {
ans = turn;
}
}
if x / n + x % n == n - 1 {
diag1 += 1;
if diag1 == n {
ans = turn;
}
}
if ans != -1 {
break;
}
}
println!("{}", ans);
}
4 changes: 4 additions & 0 deletions atcoder/abc355/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
d
e
f
g
38 changes: 38 additions & 0 deletions atcoder/abc357/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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();
let mut m: i32 = get();
let mut ans = 0;
for _ in 0..n {
let a: i32 = get();
m -= a;
if m >= 0 {
ans += 1;
}
}
println!("{}", ans);
}
19 changes: 19 additions & 0 deletions atcoder/abc357/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
let s: String = getline().trim().to_string();
let n = s.len();
let low = s.chars().filter(|&c| c.is_ascii_lowercase()).count();
for c in s.chars() {
if low > n - low {
print!("{}", c.to_ascii_lowercase());
} else {
print!("{}", c.to_ascii_uppercase());
}
}
println!();
}
5 changes: 5 additions & 0 deletions atcoder/abc357/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 e86819e

Please sign in to comment.