Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Update Article #612

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion content/blog/LearningRustThoughKyouPro/Ex1/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "[番外編] アルゴリズム・データ構造ごとに問題を分類してみる"
postdate: "2023-11-23"
update: "2024-07-13"
update: "2024-07-22"
seriesName: "競プロで学ぶRust"
seriesSlug: "LearningRustThoughKyouPro"
description: "アルゴリズムやデータ構造ごとに解ける問題を分類しました。"
Expand Down Expand Up @@ -2636,6 +2636,74 @@ mod tests {
```
</details>

### ABC363 C - Avoid K Palindrome 2

[C - Avoid K Palindrome 2 ](https://atcoder.jp/contests/abc363/tasks/abc363_c)(<span style="color: brown">Difficulty : 602</span>)

<details>
<summary>コード例を見る</summary>

```rust
// https://atcoder.jp/contests/abc363/tasks/abc363_c

use itertools::Itertools;
use std::collections::HashSet;

fn check(chars: &[char]) -> bool {
chars.iter().eq(chars.iter().rev())
}

fn run(n: usize, k: usize, s: &str) -> usize {
let chars: Vec<char> = s.chars().collect();

// 文字列の重複を防ぐ
let mut hash_set: HashSet<Vec<char>> = HashSet::new();

for str in chars.into_iter().permutations(n) {
hash_set.insert(str);
}

let mut ans = 0;

'outer: for str in hash_set.into_iter() {
// k文字の部分文字列生成
for arr in str.windows(k) {
// 部分文字列に一つでも回文があったら次の文字に進む
if check(arr) == true {
continue 'outer;
}
}

ans += 1;
}

ans
}

#[cfg(test)]
mod tests {
use super::*;

struct TestCase(usize, usize, &'static str, usize);

#[test]
fn test() {
let tests = [
TestCase(3, 2, "aab", 1),
TestCase(5, 3, "zzyyx", 16),
TestCase(10, 5, "abcwxyzyxw", 440640),
];

for TestCase(n, k, s, expected) in tests {
assert_eq!(run(n, k, s), expected);
}
}
}

```

</details>

## n進数

### ABC336 C - Even Digits
Expand Down
14 changes: 7 additions & 7 deletions src/__generated__/gatsby-types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading