-
Notifications
You must be signed in to change notification settings - Fork 0
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
369 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,15 @@ | ||
[package] | ||
name = "abc223" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# dependencies added to new project | ||
[dependencies] | ||
ac-library-rs = "=0.1.1" | ||
num = "=0.4.0" | ||
proconio = { version = "=0.4.3", 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.70.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,9 @@ | ||
use proconio::input; | ||
|
||
fn main() { | ||
input! { | ||
x: usize, | ||
} | ||
let ans = x >= 100 && x % 100 == 0; | ||
println!("{}", if ans { "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,21 @@ | ||
use proconio::{input, marker::Chars}; | ||
|
||
fn main() { | ||
input! { | ||
mut s: Chars, | ||
}; | ||
let mut min = s.clone(); | ||
let mut max = s.clone(); | ||
let n = s.len(); | ||
for _ in 0..n { | ||
if s < min { | ||
min = s.clone(); | ||
} | ||
if s > max { | ||
max = s.clone(); | ||
} | ||
s.rotate_left(1); | ||
} | ||
println!("{}", min.into_iter().collect::<String>()); | ||
println!("{}", max.into_iter().collect::<String>()); | ||
} |
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,58 @@ | ||
use proconio::input; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
ab: [(i64, i64); n], | ||
}; | ||
let sum_a = ab.iter().map(|&(a_i, _)| a_i).sum::<i64>(); | ||
let mut ok = 0_f64; | ||
let mut ng = 1e18_f64; | ||
for _ in 0..100 { | ||
let s = ok + (ng - ok) / 2_f64; | ||
let mut s_l = 0_f64; | ||
let mut l = 0_f64; | ||
for (a_i, b_i) in ab.iter().copied() { | ||
let s_i = a_i as f64 / b_i as f64; | ||
if s_l + s_i <= s { | ||
s_l += s_i; | ||
l += a_i as f64; | ||
} else { | ||
l += (s - s_l) * b_i as f64; | ||
break; | ||
} | ||
} | ||
let mut s_r = 0_f64; | ||
let mut r = sum_a as f64; | ||
for (a_i, b_i) in ab.iter().copied().rev() { | ||
let s_i = a_i as f64 / b_i as f64; | ||
if s_r + s_i <= s { | ||
s_r += s_i; | ||
r -= a_i as f64; | ||
} else { | ||
r -= (s - s_r) * b_i as f64; | ||
break; | ||
} | ||
} | ||
if l <= r { | ||
ok = s; | ||
} else { | ||
ng = s; | ||
} | ||
} | ||
let s = ng; | ||
let mut s_l = 0_f64; | ||
let mut l = 0_f64; | ||
for (a_i, b_i) in ab.iter().copied() { | ||
let s_i = a_i as f64 / b_i as f64; | ||
if s_l + s_i <= s { | ||
s_l += s_i; | ||
l += a_i as f64; | ||
} else { | ||
l += (s - s_l) * b_i as f64; | ||
break; | ||
} | ||
} | ||
let ans = l; | ||
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,56 @@ | ||
use std::{cmp::Reverse, collections::BinaryHeap}; | ||
|
||
use proconio::{input, marker::Usize1}; | ||
|
||
fn topological_sort(e: &[Vec<usize>]) -> Option<Vec<usize>> { | ||
let n = e.len(); | ||
let mut c_in = vec![0; n]; | ||
for e_u in e.iter() { | ||
for &v in e_u.iter() { | ||
c_in[v] += 1; | ||
} | ||
} | ||
// u の小さいものを取り出す | ||
let mut pq = BinaryHeap::new(); | ||
for u in 0..n { | ||
if c_in[u] == 0 { | ||
pq.push(Reverse(u)); | ||
} | ||
} | ||
let mut res = vec![]; | ||
while let Some(Reverse(u)) = pq.pop() { | ||
res.push(u); | ||
for &v in e[u].iter() { | ||
c_in[v] -= 1; | ||
if c_in[v] == 0 { | ||
pq.push(Reverse(v)); | ||
} | ||
} | ||
} | ||
if res.len() == n { | ||
Some(res) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
m: usize, | ||
ab: [(Usize1, Usize1); m], | ||
}; | ||
|
||
let mut edges = vec![vec![]; n]; | ||
for (a, b) in ab { | ||
edges[a].push(b); | ||
} | ||
|
||
if let Some(sorted) = topological_sort(&edges) { | ||
for u in sorted { | ||
println!("{}", u + 1); | ||
} | ||
} else { | ||
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,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); | ||
} |
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); | ||
} |