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
373 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 = "abc225" | ||
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,21 @@ | ||
use std::collections::HashSet; | ||
|
||
use proconio::{input, marker::Chars}; | ||
use superslice::Ext; | ||
|
||
fn main() { | ||
input! { | ||
s: Chars, | ||
}; | ||
let mut set = HashSet::new(); | ||
let mut is = (0..3).collect::<Vec<usize>>(); | ||
loop { | ||
let t = is.iter().map(|&i| s[i]).collect::<String>(); | ||
set.insert(t); | ||
if !is.next_permutation() { | ||
break; | ||
} | ||
} | ||
let ans = set.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,26 @@ | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn adjacency_list(n: usize, uv: &[(usize, usize)]) -> Vec<Vec<usize>> { | ||
let mut e = vec![vec![]; n]; | ||
for &(u, v) in uv.iter() { | ||
e[u].push(v); | ||
e[v].push(u); | ||
} | ||
e | ||
} | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
ab: [(Usize1, Usize1); n - 1], | ||
}; | ||
|
||
let e = adjacency_list(n, &ab); | ||
for u in 0..n { | ||
if e[u].len() == n - 1 { | ||
println!("Yes"); | ||
return; | ||
} | ||
} | ||
println!("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,26 @@ | ||
use proconio::input; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
m: usize, | ||
b: [[usize; m]; n], | ||
}; | ||
if !(0..(7 - m + 1)).contains(&((b[0][0] - 1) % 7)) { | ||
println!("No"); | ||
return; | ||
} | ||
|
||
let mut c = vec![vec![0; m]; n]; | ||
c[0][0] = b[0][0]; | ||
for i in 0..n { | ||
if i + 1 < n { | ||
c[i + 1][0] = c[i][0] + 7; | ||
} | ||
for j in 0..m - 1 { | ||
c[i][j + 1] = c[i][j] + 1; | ||
} | ||
} | ||
let ans = b == c; | ||
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,54 @@ | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
q: usize, | ||
}; | ||
let mut prev = vec![n; n]; | ||
let mut next = vec![n; n]; | ||
for _ in 0..q { | ||
input! { | ||
t: usize, | ||
}; | ||
match t { | ||
1 => { | ||
input! { | ||
x: Usize1, | ||
y: Usize1, | ||
}; | ||
prev[y] = x; | ||
next[x] = y; | ||
} | ||
2 => { | ||
input! { | ||
x: Usize1, | ||
y: Usize1, | ||
}; | ||
prev[y] = n; | ||
next[x] = n; | ||
} | ||
3 => { | ||
input! { | ||
x: Usize1, | ||
}; | ||
let mut start = x; | ||
while prev[start] != n { | ||
start = prev[start]; | ||
} | ||
let mut ans = vec![]; | ||
while next[start] != n { | ||
ans.push(start + 1); | ||
start = next[start]; | ||
} | ||
ans.push(start + 1); | ||
|
||
print!("{} ", ans.len()); | ||
for (i, a) in ans.iter().copied().enumerate() { | ||
print!("{}{}", a, if i == ans.len() - 1 { "\n" } else { " " }); | ||
} | ||
} | ||
_ => unreachable!(), | ||
} | ||
} | ||
} |
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,34 @@ | ||
use num::Rational; | ||
use proconio::input; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
xy: [(isize, isize); n], | ||
}; | ||
|
||
let mut a = vec![]; | ||
for (x, y) in xy { | ||
let a1 = if x - 1 == 0 { | ||
Rational::new(std::isize::MAX, 1) | ||
} else { | ||
Rational::new(y, x - 1) | ||
}; | ||
let a2 = Rational::new(y - 1, x); | ||
a.push((a1, a2)); | ||
} | ||
a.sort(); | ||
|
||
let mut count = 0_usize; | ||
let mut p = Rational::new(-1, 1); | ||
for (a1, a2) in a { | ||
if a2 < p { | ||
continue; | ||
} | ||
count += 1; | ||
p = a1; | ||
} | ||
|
||
let ans = count; | ||
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,16 @@ | ||
use proconio::input; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
k: usize, | ||
mut s: [String; n], | ||
}; | ||
s.sort(); | ||
let mut t = String::new(); | ||
for s_i in s.iter().take(k) { | ||
t.push_str(s_i); | ||
} | ||
let ans = t; | ||
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); | ||
} |