-
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
8 changed files
with
134 additions
and
28 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
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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
use std::collections::BTreeMap; | ||
|
||
use proconio::input; | ||
|
||
fn cumsum(a: &[i64]) -> Vec<i64> { | ||
std::iter::once(0) | ||
.chain(a.iter().scan(0, |acc, &i| { | ||
*acc += i; | ||
Some(*acc) | ||
})) | ||
.collect() | ||
} | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [i64; n], | ||
}; | ||
let s = std::iter::once(0) | ||
.chain(a.iter().scan(0, |acc, &a_i| { | ||
*acc += a_i; | ||
Some(*acc) | ||
})) | ||
.collect::<Vec<i64>>(); | ||
let mut m = std::collections::BTreeMap::new(); | ||
let s = cumsum(&a); | ||
let mut map = BTreeMap::new(); | ||
for &s_i in s.iter() { | ||
let entry = m.entry(s_i).or_insert(0); | ||
*entry += 1; | ||
*map.entry(s_i).or_insert(0) += 1; | ||
} | ||
let mut count = 0_usize; | ||
for (_, v) in map { | ||
count += v * (v - 1) / 2; | ||
} | ||
let ans = m | ||
.values() | ||
.filter(|&&v| v >= 2) | ||
.map(|&v| v * (v - 1) / 2) | ||
.sum::<i64>(); | ||
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 |
---|---|---|
@@ -1,11 +1,31 @@ | ||
use proconio::input; | ||
use proconio::marker::Usize1; | ||
use proconio::{input, marker::Chars}; | ||
|
||
fn main() { | ||
input! { | ||
n: usize, | ||
a: [Usize1; n], | ||
s: [Chars; n], | ||
}; | ||
let ans = n - a.len(); | ||
let mut count = 0; | ||
for a in 0..n { | ||
let b = 0; | ||
let mut t = vec![vec![' '; n]; n]; | ||
for i in 0..n { | ||
for j in 0..n { | ||
t[i][j] = s[(i + a) % n][(j + b) % n]; | ||
} | ||
} | ||
let mut ok = true; | ||
for i in 0..n { | ||
for j in 0..n { | ||
if t[i][j] != t[j][i] { | ||
ok = false; | ||
} | ||
} | ||
} | ||
if ok { | ||
count += 1; | ||
} | ||
} | ||
let ans = count * 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
use proconio::input; | ||
use proconio::marker::Usize1; | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
use proconio::input; | ||
use proconio::marker::Usize1; | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
use proconio::input; | ||
use proconio::marker::Usize1; | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
use proconio::input; | ||
use proconio::marker::Usize1; | ||
use proconio::{input, marker::Usize1}; | ||
|
||
fn main() { | ||
input! { | ||
|