Skip to content
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
4 changes: 2 additions & 2 deletions docs/geometry/line-convex-polygon-intersection.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ documentation_of: geometry/line-convex-polygon-intersection.hpp

`hull` のサイズ を $N$ とおく。

- 時間: $O(\log N)$
- 空間: $O(1)$
- 時間計算量: $O(\log N)$
- 空間計算量: $O(1)$
8 changes: 3 additions & 5 deletions docs/graph/others/graph-isomorphism.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@ documentation_of: graph/others/graph-isomorphism.hpp
また、 $i=1,2$ について、`edges_i` を $E_i$ 、 $M_i=\lvert E_i\rvert$ とする。

- $M_i$ は多重辺を重複込みで数え、自己ループも入力 $1$ 個を $1$ 本として数える。
- $U$ を $2$ つのグラフの内部辺要素の個数の合計とする。内部辺要素は、同じ頂点対に入った辺を $1$ つにまとめ、本数を `count` として持つ。自己ループの頂点対も $1$ つと数える。
- 多重辺は重複を消して同一視するのではなく、内部辺要素の `count` まで比較される
- $U$ を、各グラフで同じ頂点対に入った辺を $1$ 本と数えたときの、 $2$ つのグラフでの本数の合計とする。自己ループの頂点対も $1$ つと数える。
- 多重辺は重複を消して同一視するのではなく、各頂点対に入った辺の本数まで比較される
- $D$ を内部隣接リストの全長の合計とする。 $D\le 2U$ である。
- $L$ を色分割中に作られる signature の最大長とする。 $L\le 2n+2$ である。
- $S$ を DFS で訪問した状態数、 $R$ を全状態を通した色分割更新回数の合計とする。 $R\le S(n+1)$ である。
- 探索メモは平衡二分探索木で持つ。状態キーの比較の最悪時間計算量は $O(n)$ である。
- $C_{\mathrm{build}}=M_1\log M_1+M_2\log M_2+n\log n+n+M_1+M_2$ とする。
- $C_{\mathrm{ref}}=D\log n+Ln\log n+Ln+D+n$ とする。
- $C_{\mathrm{memo}}=n\log S+n$ とする。
- $C_{\mathrm{check}}=U\log U+U+n$ とする。
- 構築は時間 $O(C_{\mathrm{build}})$ である。
- 色分割更新 $1$ 回は時間 $O(C_{\mathrm{ref}})$ である。
- 探索メモの検索または挿入は時間 $O(C_{\mathrm{memo}})$ である。
- 色がすべて単独になった状態での辺集合比較は時間 $O(C_{\mathrm{check}})$ である。
- 全体は時間 $O(C_{\mathrm{build}}+RC_{\mathrm{ref}}+S(C_{\mathrm{memo}}+C_{\mathrm{check}}))$ である。
- 全体は時間 $O(C_{\mathrm{build}}+RC_{\mathrm{ref}}+SC_{\mathrm{memo}})$ である。
- 最悪の場合、 $S$ は指数的に大きくなる。
4 changes: 2 additions & 2 deletions docs/graph/tree/hl-rec-dp.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ int main() {

## 計算量

- 木の根付き化と重い子の選択: $O(n)$ 。
- 軽い辺だけで再帰が深くなるため、再帰段数: $O(\log n)$ 。
- 木の根付き化と重い子の選択は時間 $O(n)$ 。
- 軽い辺だけで再帰が深くなるため、再帰段数は $O(\log n)$ 。
- $K$ を `Spec::K` の値とする。部分木 1 回分の値計算の呼び出し回数は $O(n^{\log_2(K+1)})$ 。
- 全頂点の `before_vertex` と `after_vertex` を回収する実行については、同様に $K\ge 2$ ならば $O(n^{\log_2(K+1)})$ 回、 $K=1$ ならば $O(n\log n)$ 回である。
- 各呼び出しで、`Spec` 側の処理時間が掛かる。典型的な場合として $K=2$ 、各処理が $O(X)$ ならば $O(n^{\log_2 3}X)$ である。
Expand Down
6 changes: 3 additions & 3 deletions docs/math/matrix/determinant-of-linear-matrix-polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ documentation_of: math/matrix/determinant-of-linear-matrix-polynomial.hpp

## 計算量

- `hessenberg_reduction`: $O(N^3)$
- `characteristic_polynomial`: $O(N^3)$
- `determinant_of_linear_matrix_polynomial`: $O(N^3)$
- `hessenberg_reduction`: 時間 $O(N^3)$
- `characteristic_polynomial`: 時間 $O(N^3)$
- `determinant_of_linear_matrix_polynomial`: 時間 $O(N^3)$
34 changes: 19 additions & 15 deletions docs/math/matrix/dynamic-matrix-rank.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ documentation_of: math/matrix/dynamic-matrix-rank.hpp
- 空に構築する。後で `build(matrix)` を呼ぶ。
- `DynamicMatrixRank(const std::vector<std::vector<T>>& matrix)`
- `matrix` で構築する。
- 前提: `matrix` は長方形であり、`T` は除算ができる
- 前提: `matrix` は長方形であり、`T` は体をなす
- `void build(const std::vector<std::vector<T>>& matrix)`
- `matrix` を現在の行列として前処理し直す。
- 前提: `matrix` は長方形であり、`T` は体をなす。
- `void build()`
- 現在保持している行列から前処理し直す。
- `int rank() const`
Expand All @@ -38,35 +39,38 @@ documentation_of: math/matrix/dynamic-matrix-rank.hpp
- 現在の行列を密行列として返す。
- `int rank_after_rank_one_update(const std::vector<T>& column_vector, const std::vector<T>& row_vector) const`
- $A+uv^{\top}$ の階数を返す。
- 前提: `column_vector` の長さは行数、`row_vector` の長さは列数
- 前提: `column_vector` の長さは行数に等しく、`row_vector` の長さは列数に等しい
- 備考: 内部状態は変更しない。
- `int rank_after_row_replacement(int row_index, const std::vector<T>& new_row) const`
- `row_index` 行目を `new_row` に差し替えた行列の階数を返す。
- 前提: $0\le i<r$ 、`new_row` の長さは列数
- 前提: $0\le i<r$ 、`new_row` の長さは列数に等しい
- 備考: 内部状態は変更しない。
- `int rank_after_column_replacement(int column_index, const std::vector<T>& new_column) const`
- `column_index` 列目を `new_column` に差し替えた行列の階数を返す。
- 前提: $0\le j<c$ 、`new_column` の長さは行数
- 前提: $0\le j<c$ 、`new_column` の長さは行数に等しい
- 備考: 内部状態は変更しない。
- `int apply_rank_one_update(const std::vector<T>& column_vector, const std::vector<T>& row_vector)`
- $A+uv^{\top}$ に内部状態を更新し、その階数を返す。
- 前提: `column_vector` の長さは行数に等しく、`row_vector` の長さは列数に等しい。
- `int apply_row_replacement(int row_index, const std::vector<T>& new_row)`
- `row_index` 行目を `new_row` に差し替え、変更後の階数を返す。
- 前提: $0\le i<r$ 、`new_row` の長さは列数に等しい。
- `int apply_column_replacement(int column_index, const std::vector<T>& new_column)`
- `column_index` 列目を `new_column` に差し替え、変更後の階数を返す。
- 前提: $0\le j<c$ 、`new_column` の長さは行数に等しい。

## 計算量

$k$ は現在の行列 $A$ の階数とする。

- `build`: $O(rc\min(r, c) + k^2(r + c))$
- `rank`: $O(1)$
- `get_row`: $O((k + 1)c)$
- `get_column`: $O((k + 1)r)$
- `materialize_matrix`: $O((k + 1)rc)$
- `rank_after_rank_one_update`: $O((k + 1)(r + c))$
- `rank_after_row_replacement`: $O((k + 1)(r + c))$
- `rank_after_column_replacement`: $O((k + 1)(r + c))$
- `apply_rank_one_update`: $O((k + 1)(r + c))$
- `apply_row_replacement`: $O((k + 1)(r + c))$
- `apply_column_replacement`: $O((k + 1)(r + c))$
- `build`: 時間 $O(r + rc\min(r, c) + k^2(r + c))$
- `rank`: 時間 $O(1)$
- `get_row`: 時間 $O((k + 1)c + 1)$
- `get_column`: 時間 $O((k + 1)r)$
- `materialize_matrix`: 時間 $O((k + 1)rc + r)$
- `rank_after_rank_one_update`: 時間 $O((k + 1)(r + c))$
- `rank_after_row_replacement`: 時間 $O((k + 1)(r + c))$
- `rank_after_column_replacement`: 時間 $O((k + 1)(r + c))$
- `apply_rank_one_update`: 時間 $O((k + 1)(r + c))$
- `apply_row_replacement`: 時間 $O((k + 1)(r + c))$
- `apply_column_replacement`: 時間 $O((k + 1)(r + c))$
4 changes: 2 additions & 2 deletions docs/math/multiplicative-function/prime-counting-modulo.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ documentation_of: math/multiplicative-function/prime-counting-modulo.hpp

## 計算量

- 時間: $O(m N^{3/4}/\log N)$
- 空間: $O(m\sqrt{N})$
- 時間計算量: $O(m N^{3/4}/\log N)$
- 空間計算量: $O(m\sqrt{N})$
6 changes: 3 additions & 3 deletions docs/math/number-theory/generalized-floor-sum-degree-le-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ documentation_of: math/number-theory/generalized-floor-sum-degree-le-2.hpp
- `Internal` は内部で計算結果の管理に用いる整数型である。
- `Internal` は省略できる。省略した場合、標準の 64 bit 以下の整数型では `NicheLibrary::Int128` を用いる。
- 前提: `T` と明示的に与える場合の `Internal` は整数型である。
- 前提: `T` が符号付きなら、明示的に与える場合の `Internal` も符号付きである。
- 前提: `T` が符号付きならば、明示的に与える場合の `Internal` も符号付きである。
- 前提: $n\ge 0,\;m>0$ 。
- 前提: 内部計算が `Internal` の範囲に収まる。
- 備考: `T` が符号付き整数型の場合、返り値が `T` の範囲に収まる必要がある。
Expand All @@ -39,5 +39,5 @@ documentation_of: math/number-theory/generalized-floor-sum-degree-le-2.hpp

## 計算量

- 時間: $O(\log m)$
- 空間: $O(\log m)$ (再帰)
- 時間計算量: $O(\log m)$
- 空間計算量: $O(\log m)$ (再帰)
5 changes: 3 additions & 2 deletions docs/math/number-theory/generalized-garner.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ documentation_of: math/number-theory/generalized-garner.hpp

## 計算量

- $N=\lvert a\rvert,\;V=\max_i M_i$ とする。
入力する式の個数を $N$ 、全ての法と $2$ の最大値を $V$ とする。

- 標準の 64 bit 以下の整数型では時間 $O(N\log V)$ 。
- それ以外の整数型で通常乗算を使えない場合は時間 $O(N\log^2 V)$ 。
- それ以外の整数型で通常の乗算を使えない場合は時間 $O(N\log^2 V)$ 。
- 空間 $O(1)$ 。
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ documentation_of: other/minimum-mod-range-increment-decrement-operations.hpp

## 使い方

- `T minimum_mod_range_increment_decrement_operations(std::vector<T> a, std::vector<T> b, T m)`
- `T minimum_mod_range_increment_decrement_operations(const std::vector<T> &a, const std::vector<T> &b, T m)`
- $a$ を $b$ に一致させるための最小操作回数を返す。
- 前提: `a[i]` を $a_i$ 、`b[i]` を $b_i$ として、 $\lvert a\rvert=\lvert b\rvert,\,m>0,\,0\le a_i,b_i<m$ 。
- 前提: `T` は 64 bit 整数型、 $m\le 10^9$ を想定する。
Expand All @@ -24,5 +24,5 @@ documentation_of: other/minimum-mod-range-increment-decrement-operations.hpp

入力列の長さを $N$ とおく。

- 時間: $O(N \log N)$
- 空間: $O(N)$
- 平均時間計算量: $O(N)$
- 空間計算量: $O(N)$
8 changes: 4 additions & 4 deletions docs/other/rectangle-add-max-get.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ documentation_of: other/rectangle-add-max-get.hpp
また、可変 y 範囲について、`lower_y` が表す関数を $f$ 、`upper_y` が表す関数を $g$ とおく。
そして、 $x$ を範囲 $[l,r)$ の座標として、 $Y=\max_x g(x)-\min_x f(x)$ とおく。

- `add_rectangle`: $O(1)$
- `CompressedRectangleAddMaxGet` の各 `calc_...`: $O(N\log N)$
- `RectangleAddMaxGet` の長方形範囲の各 `calc_...`: $O(H+W+N\log H)$
- `RectangleAddMaxGet` の可変 y 範囲の各 `calc_...`: $O(Y+(W+N)\log Y)$
- `add_rectangle`: 時間 $O(1)$
- `CompressedRectangleAddMaxGet` の各 `calc_...`: 時間 $O(N\log N)$
- `RectangleAddMaxGet` の長方形範囲の各 `calc_...`: 時間 $O(H+W+N\log H)$
- `RectangleAddMaxGet` の可変 y 範囲の各 `calc_...`: 時間 $O(Y+(W+N)\log Y)$
- `RectangleAddMaxGet` では、 $W,\,H,\,Y$ は `int` に収まる必要がある。
8 changes: 4 additions & 4 deletions docs/structure/others/dynamic-median.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ documentation_of: structure/others/dynamic-median.hpp
- 備考: 要素数が奇数の場合、 $3$ 種類は同じ値になる。
- `void add(T x)`
- 値 $x$ を $1$ 個追加する。
- `bool erase(T x)`
- `bool erase(const T &x)`
- 値 $x$ を $1$ 個削除する。
- 返り値: 削除に成功した場合は `true`、値 $x$ が存在しなかった場合は `false` が返る。
- 備考: 同じ値が複数ある場合はいずれか $1$ 個だけを削除する。
Expand All @@ -44,6 +44,6 @@ documentation_of: structure/others/dynamic-median.hpp

要素数を $N$ とする。

- `add`, `erase`: $O(\log N)$
- `median`: $O(1)$
- 空間: $O(N)$
- `add`, `erase`: 時間 $O(\log N)$
- `median`: 時間 $O(1)$
- 空間計算量: $O(N)$
Loading
Loading