Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
390 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
[package] | ||
name = "abc273" | ||
version = "0.1.0" | ||
edition = "2018" | ||
|
||
# dependencies added to new project | ||
[dependencies] | ||
num = "=0.2.1" | ||
proconio = { version = "=0.3.6", features = ["derive"] } | ||
superslice = "=1.0.0" | ||
|
||
[profile.release] | ||
lto = true | ||
panic = 'abort' |
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 @@ | ||
1.42.0 |
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,17 @@ | ||
use proconio::input; | ||
|
||
fn f(n: usize) -> usize { | ||
if n == 0 { | ||
1 | ||
} else { | ||
n * f(n - 1) | ||
} | ||
} | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
}; | ||
let ans = f(n); | ||
println!("{}", ans); | ||
} |
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,33 @@ | ||
use proconio::{input, marker::Chars}; | ||
|
||
fn main() { | ||
input! { | ||
mut x: Chars, | ||
k: usize, | ||
}; | ||
x.reverse(); | ||
let mut c = 0_usize; | ||
let mut ans = vec![]; | ||
for (i, x_i) in x.iter().copied().enumerate() { | ||
let d = (x_i as u8 - b'0') as usize + c; | ||
if i < k { | ||
ans.push('0'); | ||
if d <= 4 { | ||
c = 0; | ||
} else { | ||
c = 1; | ||
} | ||
} else { | ||
ans.push(((d % 10) as u8 + b'0') as char); | ||
c = d / 10; | ||
} | ||
} | ||
if c > 0 && k <= x.len() { | ||
ans.push('1'); | ||
} | ||
ans.reverse(); | ||
println!( | ||
"{}", | ||
ans.iter().collect::<String>().parse::<usize>().unwrap() | ||
); | ||
} |
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,25 @@ | ||
use std::collections::{BTreeSet, HashMap}; | ||
|
||
use proconio::input; | ||
use superslice::Ext; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [usize; n], | ||
}; | ||
let set = a | ||
.iter() | ||
.copied() | ||
.collect::<BTreeSet<usize>>() | ||
.into_iter() | ||
.collect::<Vec<usize>>(); | ||
let mut map = HashMap::new(); | ||
for a_i in a { | ||
let count = set.len() - 1 - set.lower_bound(&a_i); | ||
*map.entry(count).or_insert(0) += 1; | ||
} | ||
for i in 0..n { | ||
println!("{}", map.get(&i).unwrap_or(&0)); | ||
} | ||
} |
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,99 @@ | ||
use std::collections::{BTreeSet, HashMap}; | ||
|
||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
h: usize, | ||
w: usize, | ||
r_s: Usize1, | ||
c_s: Usize1, | ||
n: usize, | ||
rc: [(Usize1, Usize1); n], | ||
q: usize, | ||
dl: [(char, usize); q], | ||
}; | ||
|
||
let mut rs = HashMap::new(); | ||
for (r, c) in rc.iter().copied() { | ||
rs.entry(r).or_insert_with(BTreeSet::new).insert(c); | ||
} | ||
let mut cs = HashMap::new(); | ||
for (r, c) in rc.iter().copied() { | ||
cs.entry(c).or_insert_with(BTreeSet::new).insert(r); | ||
} | ||
|
||
let mut cr = r_s; | ||
let mut cc = c_s; | ||
for (d, l) in dl { | ||
match d { | ||
'L' => { | ||
let mut nc = if (0..w as i64).contains(&(cc as i64 - l as i64)) { | ||
cc - l | ||
} else { | ||
0 | ||
}; | ||
if nc < cc { | ||
if let Some(c) = rs | ||
.get(&cr) | ||
.and_then(|rs_cs| rs_cs.range(nc..cc).rev().next()) | ||
{ | ||
nc = *c + 1; | ||
} | ||
} | ||
cc = nc; | ||
} | ||
'R' => { | ||
let mut nc = if (0..w as i64).contains(&(cc as i64 + l as i64)) { | ||
cc + l | ||
} else { | ||
w - 1 | ||
}; | ||
if cc + 1 <= nc { | ||
if let Some(c) = rs | ||
.get(&cr) | ||
.and_then(|rs_cs| rs_cs.range(cc + 1..=nc).next()) | ||
{ | ||
nc = *c - 1; | ||
} | ||
} | ||
cc = nc; | ||
} | ||
'U' => { | ||
let mut nr = if (0..h as i64).contains(&(cr as i64 - l as i64)) { | ||
cr - l | ||
} else { | ||
0 | ||
}; | ||
if nr < cr { | ||
if let Some(r) = cs | ||
.get(&cc) | ||
.and_then(|rs_cs| rs_cs.range(nr..cr).rev().next()) | ||
{ | ||
nr = *r + 1; | ||
} | ||
} | ||
cr = nr; | ||
} | ||
'D' => { | ||
let mut nr = if (0..h as i64).contains(&(cr as i64 + l as i64)) { | ||
cr + l | ||
} else { | ||
h - 1 | ||
}; | ||
if cr + 1 <= nr { | ||
if let Some(r) = cs | ||
.get(&cc) | ||
.and_then(|rs_cs| rs_cs.range(cr + 1..=nr).next()) | ||
{ | ||
nr = *r - 1; | ||
} | ||
} | ||
cr = nr; | ||
} | ||
_ => unreachable!(), | ||
} | ||
|
||
println!("{} {}", cr + 1, cc + 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,10 @@ | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [Usize1; n], | ||
}; | ||
let ans = n - a.len(); | ||
println!("{}", ans); | ||
} |
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,10 @@ | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [Usize1; n], | ||
}; | ||
let ans = n - a.len(); | ||
println!("{}", ans); | ||
} |
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,10 @@ | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [Usize1; n], | ||
}; | ||
let ans = n - a.len(); | ||
println!("{}", ans); | ||
} |
Oops, something went wrong.