Skip to content

Commit

Permalink
[auto-verifier] docs commit 014164b
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow authored Jul 29, 2023
1 parent b7fdd75 commit e6f6c2a
Show file tree
Hide file tree
Showing 68 changed files with 819 additions and 340 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Library-Python

https://rin204.github.io/Library-Python/

## 注意事項
`***_global_mod` と書かれているものは MOD の値をグローバル変数で宣言しているものです.
基本的に 998244353 にしているので,違う値にしたいときは適宜検索をして使いたい値に変更してください

`***_Base` と書かれている / 書かれていないだけの差分があるものがあります.基本的にクラスを扱うのに関数を与えなければいけないもので,書かれていない場合は引数に与える,書かれている場合はクラスを継承して関数を定義することを想定しています.

`src/``expansion/` がありますが,コピペして使いたい場合は `expansion/` にあるものを使ってください.
MOD 系は 998244353 を暗に仮定しているものがいくつかあるので,適宜変更してください.

個人用競プロ用で作成したライブラリなので,書き方が変なものは一定すうあると思いますが,ご了承ください.
個人用競プロ用で作成したライブラリなので,書き方が変なものは一定数あると思いますが,ご了承ください (& バグがあったらごめんなさい)

一部 `Base_` と末尾についている class があります.これらは,主に引数で与える想定になる関数について,
- `Base_` が付いていない場合:引数に与える
- `Base_` が付いている場合:class を継承して各種関数を作成する
作成者が数学に明るくない人間なので,いくつか誤用等があると思います.ご了承ください.

使い方を想定しています.使用感は https://github.com/Rin204/Library-Python/blob/main/src/%24tests/data_structure/segtree.test.py https://github.com/Rin204/Library-Python/blob/main/src/%24tests/data_structure/segtree2.test.py あたりを見てください.

## expansion.py

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ data:
\ A[s][t] = 1\n A[t][s] = 1\n\nB = mat_exp_global_mod(A, B, T)\nprint(B[0])\n"
dependsOn: []
isVerificationFile: true
path: expansion/$tests/math/mat_pow_gloabal_mod.test.py
path: expansion/$tests/math/mat_pow_global_mod.test.py
requiredBy: []
timestamp: '2023-07-23 08:45:17+09:00'
timestamp: '2023-07-29 13:32:11+09:00'
verificationStatus: TEST_WRONG_ANSWER
verifiedWith: []
documentation_of: expansion/$tests/math/mat_pow_gloabal_mod.test.py
documentation_of: expansion/$tests/math/mat_pow_global_mod.test.py
layout: document
redirect_from:
- /verify/expansion/$tests/math/mat_pow_gloabal_mod.test.py
- /verify/expansion/$tests/math/mat_pow_gloabal_mod.test.py.html
title: expansion/$tests/math/mat_pow_gloabal_mod.test.py
- /verify/expansion/$tests/math/mat_pow_global_mod.test.py
- /verify/expansion/$tests/math/mat_pow_global_mod.test.py.html
title: expansion/$tests/math/mat_pow_global_mod.test.py
---
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ data:
\ sep=\"\")\n\n\nfor _ in range(int(input())):\n solve()\n"
dependsOn: []
isVerificationFile: true
path: expansion/$tests/string/wildcard_mathing.test.py
path: expansion/$tests/string/wildcard_matching.test.py
requiredBy: []
timestamp: '2023-07-23 08:45:17+09:00'
timestamp: '2023-07-29 13:32:11+09:00'
verificationStatus: TEST_WRONG_ANSWER
verifiedWith: []
documentation_of: expansion/$tests/string/wildcard_mathing.test.py
documentation_of: expansion/$tests/string/wildcard_matching.test.py
layout: document
redirect_from:
- /verify/expansion/$tests/string/wildcard_mathing.test.py
- /verify/expansion/$tests/string/wildcard_mathing.test.py.html
title: expansion/$tests/string/wildcard_mathing.test.py
- /verify/expansion/$tests/string/wildcard_matching.test.py
- /verify/expansion/$tests/string/wildcard_matching.test.py.html
title: expansion/$tests/string/wildcard_matching.test.py
---
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ data:
\ v, k))\n"
dependsOn: []
isVerificationFile: true
path: expansion/$tests/tree/JumoOnTree.test.py
path: expansion/$tests/tree/JumpOnTree.test.py
requiredBy: []
timestamp: '2023-07-23 08:45:17+09:00'
timestamp: '2023-07-29 13:32:11+09:00'
verificationStatus: TEST_WRONG_ANSWER
verifiedWith: []
documentation_of: expansion/$tests/tree/JumoOnTree.test.py
documentation_of: expansion/$tests/tree/JumpOnTree.test.py
layout: document
redirect_from:
- /verify/expansion/$tests/tree/JumoOnTree.test.py
- /verify/expansion/$tests/tree/JumoOnTree.test.py.html
title: expansion/$tests/tree/JumoOnTree.test.py
- /verify/expansion/$tests/tree/JumpOnTree.test.py
- /verify/expansion/$tests/tree/JumpOnTree.test.py.html
title: expansion/$tests/tree/JumpOnTree.test.py
---
24 changes: 20 additions & 4 deletions expansion/data_structure/ConvexHullTrick.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,24 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/ConvexHullTrick.py
layout: document
redirect_from:
- /library/expansion/data_structure/ConvexHullTrick.py
- /library/expansion/data_structure/ConvexHullTrick.py.html
title: expansion/data_structure/ConvexHullTrick.py
title: ConvexHullTrick
---

# 概要
以下のクエリを処理します

- 1 次関数 $f(x) = ax + b$ を追加
- 追加された 1 次関数のうち ある x において最小値を取るもの(の $f(x)$ の値)を返す

ただし,
- 追加する 1 時間数の傾きが単調減少である
- 最小値クエリの x の値が単調増加である

必要があります.増加 / 減少を逆にしたい場合は適当に -1 をかけて調整してください



## 使い方
- \_\_init\_\_() :=
- add_line(a, b) := $f(x) = ax + b$ を追加します.
- get(x) := x における最小値を返します
14 changes: 10 additions & 4 deletions expansion/data_structure/DisjointSparseTable.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/DisjointSparseTable.py
layout: document
redirect_from:
- /library/expansion/data_structure/DisjointSparseTable.py
- /library/expansion/data_structure/DisjointSparseTable.py.html
title: expansion/data_structure/DisjointSparseTable.py
title: DisjointSparseTable
---

# 概要
- $f(a, f(b, c)) = f(f(a, b), c)$

を満たす二項演算を処理します.

## 使い方
- \_\_init\_\_(A, ope) := 配列 A と条件を満たす演算 ope を与えて初期化します.
- prod(l, r) := 区間 [l, r) の演算結果を返します.
20 changes: 16 additions & 4 deletions expansion/data_structure/LazySegmentTree.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,20 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/LazySegmentTree.py
layout: document
redirect_from:
- /library/expansion/data_structure/LazySegmentTree.py
- /library/expansion/data_structure/LazySegmentTree.py.html
title: expansion/data_structure/LazySegmentTree.py
title: LazySegmentTree
---

# 概要
主に 区間更新と区間に対する演算に高速に答えるためのデータ構造です._Base がついている方の使用法に関しては,SegmentTree の方と基本的に同様です

## 使い方
- \_\_init\_\_(n, ope, e, mapping, composition, id_ init=None) := 長さ $n$ の配列 A を作成します.各変数については [ac-library](https://atcoder.github.io/ac-library/master/document_ja/lazysegtree.html) のものと同様のものを想定しているので,それを参考にしてください.`init=None`に長さ$n$の配列を指定した場合はそれが初期値に,そうでない場合は `e` が初期値になります.
- set(i, x) := i 番目の値を x に変更します.
- get(i) := A[i] の値を求めます.
- \_\_getitem\_\_(i) := `get(i)` と同じ
- \_\_setitem\_\_(i) := `set(i, x)` と同じ
- prod(l, r) := 区間 $[l, r)$ の演算結果を返します.
- apply(l, r, f) := 区間 $[l, r)$ を.mapping で指定した更新ルールで更新します
- apply(x, f) := 区間 $[x, x + 1)$ を.mapping で指定した更新ルールで更新します
- max_right(self, l, f) := 関数 f を与えて segtree 上で二分探索をします.[ac-library](https://atcoder.github.io/ac-library/master/document_ja/lazysegtree.html) にあるものと同じ仕様です.
- max_left(self, r, f) := 関数 f を与えて segtree 上で二分探索をします.[ac-library](https://atcoder.github.io/ac-library/master/document_ja/lazysegtree.html) にあるものと同じ仕様です.
20 changes: 16 additions & 4 deletions expansion/data_structure/RollbackUnionFind.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,20 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/RollbackUnionFind.py
layout: document
redirect_from:
- /library/expansion/data_structure/RollbackUnionFind.py
- /library/expansion/data_structure/RollbackUnionFind.py.html
title: expansion/data_structure/RollbackUnionFind.py
title: RollbackUnionFind
---

# 概要
UnionFind に Rollback 機能を付けたものです.

## 使い方
- \_\_init\_\_(n) := 長さ $N$ で初期化します.
- find(x) := x の代表元を返します.
- unite(x, y) := x の属する集合と y の属する集合を合併し,True を返します.もともと同じ集合に属した場合 False を返します.
- size(x) := x の属する集合の大きさを返します.
- same(x, y) := x と y が同じ集合に属するなら True を,そうでないなら False を返します.
- group := 現在の集合の個数を返します.
- undo() := 1 手状態を戻します
- get_state() := 現在の状態を返します.(unite を行った回数)
- rollback(state) := ↑で取得した状態に戻します

24 changes: 20 additions & 4 deletions expansion/data_structure/SWAG.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,24 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/SWAG.py
layout: document
redirect_from:
- /library/expansion/data_structure/SWAG.py
- /library/expansion/data_structure/SWAG.py.html
title: expansion/data_structure/SWAG.py
title: SWAG
---

# 概要
deque に対して要素の追加 / 削除 / 現在の列に対する演算結果取得 を処理します.

演算については
- $f(a, f(b, c)) = f(f(a, b), c)$
- 単位元が存在する

ものを想定しています.(本当は単位元はいらないはずなんですが,実装の都合上要求しているので,ない場合は適当に取りえない値を設定して演算の中で if 文を入れてください)


## 使い方
- \_\_init\_\_(ope, e) := 扱う演算を定義します
- push(x) := deque の末尾に x を追加します.
- pop(x) := deque の先頭の要素を削除します.
- prod() := 現在の deque 列に対する演算結果を返します
- size() := deque 列の長さを返します.
- \_\_len\_\_ := 上記同様
- clear() := deque を空にします.
4 changes: 2 additions & 2 deletions expansion/data_structure/SegmentTree.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ title: SegmentTree
- \_\_getitem\_\_(i) := `get(i)` と同じ
- \_\_setitem\_\_(i) := `set(i, x)` と同じ
- prod(l, r) := 区間 $[l, r)$ の演算結果を返します.
- max_right(self, l, f) := 関数 f を与えて segtree 上で二分探索をします.ac-library にあるものと同じ仕様です.
- max_left(self, r, f) := 関数 f を与えて segtree 上で二分探索をします.ac-library にあるものと同じ仕様です.
- max_right(self, l, f) := 関数 f を与えて segtree 上で二分探索をします.[ac-library](https://atcoder.github.io/ac-library/master/document_ja/segtree.html) にあるものと同じ仕様です.
- max_left(self, r, f) := 関数 f を与えて segtree 上で二分探索をします.[ac-library](https://atcoder.github.io/ac-library/master/document_ja/segtree.html) にあるものと同じ仕様です.
15 changes: 11 additions & 4 deletions expansion/data_structure/SparseTable.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/SparseTable.py
layout: document
redirect_from:
- /library/expansion/data_structure/SparseTable.py
- /library/expansion/data_structure/SparseTable.py.html
title: expansion/data_structure/SparseTable.py
title: SparseTable
---

# 概要
- $f(x, x) = x$
- $f(a, f(b, c)) = f(f(a, b), c)$

を満たす二項演算を処理します.

## 使い方
- \_\_init\_\_(A, ope) := 配列 A と条件を満たす演算 ope を与えて初期化します.
- prod(l, r) := 区間 [l, r) の演算結果を返します.
18 changes: 14 additions & 4 deletions expansion/data_structure/WeightedUnionFind.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ data:
verifiedWith: []
documentation_of: expansion/data_structure/WeightedUnionFind.py
layout: document
redirect_from:
- /library/expansion/data_structure/WeightedUnionFind.py
- /library/expansion/data_structure/WeightedUnionFind.py.html
title: expansion/data_structure/WeightedUnionFind.py
title: WeightedUnionFind
---

# 概要
UnionFind の各辺に重みを付けたものです.
各頂点に重みD[i]があるのを想定して差分を管理したりします

## 使い方
- \_\_init\_\_(n) := 長さ $N$ で初期化します.
- find(x) := x の代表元を返します.
- unite(x, y, d) := x の属する集合と y の属する集合を合併し,True を返します.もともと同じ集合に属した場合 False を返します.ここで,D[x] - D[y] = d となるように合併を行い,既に合併済みかつ長さ制約に矛盾がある場合は assert で落ちます
- size(x) := x の属する集合の大きさを返します.
- same(x, y) := x と y が同じ集合に属するなら True を,そうでないなら False を返します.
- group := 現在の集合の個数を返します.
- diff(x, y) := D[x] - D[y] を返します.x, y の属する集合が異なる場合は None を返します.
14 changes: 10 additions & 4 deletions expansion/geometry/arg_sort.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ data:
verifiedWith: []
documentation_of: expansion/geometry/arg_sort.py
layout: document
redirect_from:
- /library/expansion/geometry/arg_sort.py
- /library/expansion/geometry/arg_sort.py.html
title: expansion/geometry/arg_sort.py
title: "\u504F\u89D2\u30BD\u30FC\u30C8"
---

# 概要
与えられた頂点群を偏角ソートします.

## 使い方

```
sorted_points = arg_sort(points)
```
16 changes: 12 additions & 4 deletions expansion/geometry/convex_hull.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ data:
verifiedWith: []
documentation_of: expansion/geometry/convex_hull.py
layout: document
redirect_from:
- /library/expansion/geometry/convex_hull.py
- /library/expansion/geometry/convex_hull.py.html
title: expansion/geometry/convex_hull.py
title: "\u51F8\u5305"
---

# 概要
凸包を求めます.
$[(x_1, y_1), (x_2, y_2), \ldots]$
の形式で頂点を与えてください.

## 使い方

```
convex_hull_points = convex_hull(points)
```
17 changes: 13 additions & 4 deletions expansion/graph/Hungarian.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ data:
verifiedWith: []
documentation_of: expansion/graph/Hungarian.py
layout: document
redirect_from:
- /library/expansion/graph/Hungarian.py
- /library/expansion/graph/Hungarian.py.html
title: expansion/graph/Hungarian.py
title: Hungarian
---

# 概要
割り当て問題を解きます.

$N \times M, (N \le M)$ の行列 $A$ があるときに。
$\sum_{i = 0}^{N - 1} A_{i, p_i}$ を最小化する $p_i$ (重複なし) を構成します。

## 使い方
inf は十分に大きい値を適当に設定してください
```
cost, assignment = Hungarian(A, inf=1 << 60):
```
15 changes: 11 additions & 4 deletions expansion/graph/SCC.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ data:
verifiedWith: []
documentation_of: expansion/graph/SCC.py
layout: document
redirect_from:
- /library/expansion/graph/SCC.py
- /library/expansion/graph/SCC.py.html
title: expansion/graph/SCC.py
title: SCC
---

# 概要
強連結成分分解をします.

## 使い方

- \_\_init\_\_(n, edges=None) := 頂点数 n でグラフを初期化します.edges を与える場合は,$edges = [(from_1, to_1), (from_2, to_2), \ldots]$ の形式で与えてください
- add_edge(u, v) := u -> v の有向辺を追加します.
- read_edges(m, indexed=1) := m 辺の情報を標準入力として受け取ります.
- build() := 構築します.強連結成分の個数と,各頂点がどの連結成分に属するかを返します.連結成分の番号はトポロジカル順序です.
17 changes: 13 additions & 4 deletions expansion/graph/bellmanFord.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ data:
verifiedWith: []
documentation_of: expansion/graph/bellmanFord.py
layout: document
redirect_from:
- /library/expansion/graph/bellmanFord.py
- /library/expansion/graph/bellmanFord.py.html
title: expansion/graph/bellmanFord.py
title: bellmanFord
---

# 概要
ベルマンフォードです.

$edges = [(from1, to1, cost1), (from2, to2, cost2), ...)]$の形式で辺情報を与えてください

## 使い方
inf は十分に大きい値を適当に設定してください
```
dist = bellmanFord(n, edges, s, inf=1 << 60)
```
負閉路がある場合は None を返します.
16 changes: 12 additions & 4 deletions expansion/graph/dijkstra.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ data:
verifiedWith: []
documentation_of: expansion/graph/dijkstra.py
layout: document
redirect_from:
- /library/expansion/graph/dijkstra.py
- /library/expansion/graph/dijkstra.py.html
title: expansion/graph/dijkstra.py
title: dijkstra
---

# 概要
ダイクストラ法です.

$edges[from] = [(to1, cost1), (to2, cost2), ...)]$の形式で辺情報を与えてください

## 使い方
inf は十分に大きい値を適当に設定してください
```
dist = dijkstra(edges, s=0, inf=1 << 60)
```
Loading

0 comments on commit e6f6c2a

Please sign in to comment.