{"id":13480515,"url":"https://github.com/drken1215/algorithm","last_synced_at":"2025-03-27T11:30:33.220Z","repository":{"id":64842284,"uuid":"123235335","full_name":"drken1215/algorithm","owner":"drken1215","description":"Implementation of various algorithms","archived":false,"fork":false,"pushed_at":"2025-03-11T03:04:39.000Z","size":712,"stargazers_count":254,"open_issues_count":0,"forks_count":12,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-20T08:56:08.793Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drken1215.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-28T05:42:35.000Z","updated_at":"2025-03-11T03:04:42.000Z","dependencies_parsed_at":"2024-04-06T20:28:50.801Z","dependency_job_id":"8458791b-427e-4447-8c49-007d35e9f881","html_url":"https://github.com/drken1215/algorithm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drken1215%2Falgorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drken1215%2Falgorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drken1215%2Falgorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drken1215%2Falgorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drken1215","download_url":"https://codeload.github.com/drken1215/algorithm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245835876,"owners_count":20680283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:40.792Z","updated_at":"2025-03-27T11:30:33.209Z","avatar_url":"https://github.com/drken1215.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# 様々なアルゴリズムの実装例\nデータ構造や数論的アルゴリズムまで、様々な分野のアルゴリズムたちを C++17 で実装しています。  \nアルゴリズム系の研究開発において計算機実験が必要になる場面や、\nプログラミングコンテストに参加する場面などを想定して、\n「実装例」または「ライブラリ」として使用することを念頭に置いています。\n\n　\n\n|分類|内容|具体例|\n|---|---|---|\n|**[DATA STRUCTURE](#ds)**|各種データ構造|Union-Find、Sparse Table など|\n|**[DATA STRUCTURE : SEGMENT](#dss)**|区間クエリに強いデータ構造|セグメント木、BIT など|\n|**[GEOMETRY](#ge)**|計算幾何|円の交点など|\n|**[GRAPH](#gt)**|グラフアルゴリズム|強連結成分分解など|\n|**[GRAPH : NETWORK FLOW](#gnf)**|ネットワークフローアルゴリズム|Ford-Fulkerson 法など|\n|**[MATH : ALGEBRA](#ma)**|代数的アルゴリズム|行列計算など|\n|**[MATH : COMBINATORICS](#mc)**|組合せ論的アルゴリズム|modint、Nim など|\n|**[MATH : NUMBER THEORY](#mmt)**|整数論的アルゴリズム|素因数分解、最大公約数など|\n|**[OPTIMIZATION](#opt)**|最適化や探索のアルゴリズム|二分探索, 三分探索など|\n|**[STRING](#st)**|文字列アルゴリズム|Suffix Array、KMP 法など|\n|**[TREE](#tr)**|木上のデータ構造とアルゴリズム|Euler ツアー、木の直径など|\n|**[OTHERS](#ot)**|その他|xorshift、サイコロなど|\n\n\n　\n\u003ca name=\"ds\"\u003e\u003c/a\u003e\n# データ構造 (DATA STRUCTURE)\n各種データ構造の実装です\n\n## Union-Find\n\n- (★☆☆☆) [Union-Find (union by size)](https://github.com/drken1215/algorithm/blob/master/DataStructure/union_find_size.cpp)\n- (★☆☆☆) [Union-Find (union by rank)](https://github.com/drken1215/algorithm/blob/master/DataStructure/union_find_rank.cpp)\n- (★★☆☆) [重みつき Union-Find](https://github.com/drken1215/algorithm/blob/master/DataStructure/weighted_union_find.cpp)\n- (★★★☆) [列挙可能 Union-Find](https://github.com/drken1215/algorithm/blob/master/DataStructure/union_find_enumerable.cpp)\n- (★★★☆) [undo つき Union-Find](https://github.com/drken1215/algorithm/blob/master/DataStructure/union_find_can_undo.cpp)\n- (★★★☆) [部分永続 Union-Find](https://github.com/drken1215/algorithm/blob/master/DataStructure/partially_persistent_union_find.cpp)\n\n## キュー, ヒープ\n\n- (★☆☆☆) [二分ヒープ](https://github.com/drken1215/algorithm/blob/master/DataStructure/heap.cpp)\n- (★★☆☆) [削除可能 priority queue](https://github.com/drken1215/algorithm/blob/master/DataStructure/removable_queue.cpp)\n- (★★★☆) [両端 priority queue (削除も可能)](https://github.com/drken1215/algorithm/blob/master/DataStructure/double_ended_priority_queue.cpp)\n- (★★★★) Skew Heap (マージ可能ヒープ)\n- (★★★★) Paring Heap (マージ可能ヒープ)\n- (★★★★) Radix Heap\n- (★★★★) Fibonacci Heap\n\n## ハッシュ\n\n- (★★☆☆) [ハッシュ](https://github.com/drken1215/algorithm/blob/master/DataStructure/hash.cpp)\n- (★★★☆) [Zobrist ハッシュ](https://github.com/drken1215/algorithm/blob/master/DataStructure/zobrist_hash.cpp)\n- (★★★☆) ローリングハッシュ\n- (★★★★) 根付き木のハッシュ\n\n## N 以下の非負整数値の順序つき集合\n\n- (★★★☆) [BIT と BIT 上の二分探索](https://github.com/drken1215/algorithm/blob/master/DataStructure/predecessor_bit.cpp)\n- (★★★★) [64 分木](https://github.com/drken1215/algorithm/blob/master/DataStructure/predecessor_64_tree.cpp)\n- (★★★★) van Emde Boas 木\n\n## 永続データ構造\n\n- (★★★★) 永続配列\n- (★★★★) 完全永続 Union-Find\n- (★★★★) 永続キュー\n- (★★★★) 永続セグメント木\n- (★★★★) 永続赤黒木\n\n## その他\n\n- (★★★☆) [区間の集合を set で管理する](https://github.com/drken1215/algorithm/blob/master/DataStructure/intervals_management.cpp)\n- (★★★☆) [並列二分探索](https://github.com/drken1215/algorithm/blob/master/DataStructure/parallel_binary_search.cpp)\n- (★★★☆) [Cartesian 木](https://github.com/drken1215/algorithm/blob/master/DataStructure/cartesian_tree.cpp)\n- (★★★★) [Binary Trie](https://github.com/drken1215/algorithm/blob/master/DataStructure/binary_trie.cpp)\n- (★★★★) Dynamic Connectivity\n\n\n\n\n　 \n\u003ca name=\"dss\"\u003e\u003c/a\u003e\n# 区間系データ構造 (DATA STRUCTURE : SEGMENT)\nセグメント木や BIT など、区間クエリに強いデータ構造の実装です\n\n## セグメント木, Binary Indexed 木\n\n- (★★☆☆) [セグメント木](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/segment_tree.cpp)\n- (★★★☆) [セグメント木 (遅延評価)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/segment_tree_lazy.cpp)\n- (★★☆☆) [BIT](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/binary_indexed_tree.cpp)\n- (★★★☆) [BIT (区間加算, 区間和取得に両対応)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/binary_indexed_tree_RAQ.cpp)\n- (★★★★) Segment Tree Beats (俗称)\n\n## セグメント木の応用\n- (★★☆☆) [RMQ (セグメント木)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/range_minimum_query.cpp)\n- (★★★☆) [Starry Sky 木 (俗称)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/starry_sky_tree.cpp)\n- (★★★☆) [マージソート過程木 (領域木)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/merge_sort_tree.cpp)\n\n## 動的・二次元セグメント木\n\n- (★★★☆) 動的セグメント木\n- (★★★☆) [二次元セグメント木](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/segment_tree_2d.cpp)\n- (★★★☆) [二次元 BIT](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/binary_indexed_tree_2D.cpp)\n- (★★★★) [二次元 BIT (領域加算, 領域和取得に両対応)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/binary_indexed_tree_2D_RAQ.cpp)\n- (★★★★) 動的二次元セグメント木\n- (★★★★) 動的二次元 BIT\n\n## Sparse Table\n\n- (★★★☆) [Sparse Table](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/sparse_table.cpp)\n- (★★★★) [Disjoint Sparse Table](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/disjoint_sparse_table.cpp)\n- (★★★★) 二次元 Sparse Table\n\n## ウェーブレット行列\n\n- (★★★★) [ウェーブレット行列](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/wavelet_matrix.cpp)\n- (★★★★) [BIT on ウェーブレット行列 (一点加算対応)](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/BIT_on_wavelet_matrix.cpp)\n- (★★★★) [セグメント木 on ウェーブレット行列](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/segment_tree_on_wavelet_matrix.cpp)\n- (★★★★) 動的ウェーブレット行列\n\n## 平衡二分探索木\n\n- (★★★★) [RBST](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/randomized_binary_search_tree.cpp)\n- (★★★★) Treap 木\n- (★★★★) AVL 木\n- (★★★★) Splay 木\n- (★★★★) 赤黒木\n\n## 各種高速化アルゴリズム\n\n- (★☆☆☆) [累積和](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/cumulative_sum.cpp)\n- (★☆☆☆) [二次元累積和](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/cumulative_sum_2D.cpp)\n- (★★★☆) [スライド最小値](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/sliding_minimum.cpp)\n- (★★★☆) [SWAG](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/swag.cpp)\n- (★★★☆) [Mo 法](https://github.com/drken1215/algorithm/blob/master/DataStructureSegment/mo.cpp)\n\n\n\n\n　\n\u003ca name=\"ge\"\u003e\u003c/a\u003e\n# 幾何 (GEOMETRY)\n幾何ライブラリです\n\n## 全般\n\n- (★★★☆) [全部乗せ](https://github.com/drken1215/algorithm/blob/master/Geometry/All.cpp)\n- (★★☆☆) [基本要素 (点, 線分, 円)](https://github.com/drken1215/algorithm/blob/master/Geometry/basic_elements.cpp)\n- (★★☆☆) [偏角ソート](https://github.com/drken1215/algorithm/blob/master/Geometry/arg_sort.cpp)\n\n## 点, 線分, 三角形などの位置関係\n\n- (★★☆☆) [点と線分の位置関係 (ccw)](https://github.com/drken1215/algorithm/blob/master/Geometry/ccw.cpp)\n- (★★☆☆) [点と三角形の包含関係](https://github.com/drken1215/algorithm/blob/master/Geometry/is_contain_in_the_triangle.cpp)\n\n## 射影, 交差判定, 距離\n\n- (★★☆☆) [射影](https://github.com/drken1215/algorithm/blob/master/Geometry/projection.cpp)\n- (★★☆☆) [線分と線分の交差判定](https://github.com/drken1215/algorithm/blob/master/Geometry/is_intersect_two_segments.cpp)\n- (★★☆☆) [線分と線分との距離](https://github.com/drken1215/algorithm/blob/master/Geometry/distance_two_segments.cpp)\n\n## 直線や円の交点\n\n- (★★☆☆) [直線と直線の交点](https://github.com/drken1215/algorithm/blob/master/Geometry/crosspoint_two_lines.cpp)\n- (★★★☆) [円と直線の交点](https://github.com/drken1215/algorithm/blob/master/Geometry/crosspoint_line_circle.cpp)\n- (★★★☆) [円と円の交点](https://github.com/drken1215/algorithm/blob/master/Geometry/crosspoint_two_circles.cpp)\n- (★★★☆) [円と線分の交点](https://github.com/drken1215/algorithm/blob/master/Geometry/crosspoint_segment_circle.cpp)\n\n## 接線\n\n- (★★★☆) [接線](https://github.com/drken1215/algorithm/blob/master/Geometry/tanline.cpp)\n- (★★★☆) [共通接線 (2 円)](https://github.com/drken1215/algorithm/blob/master/Geometry/common_tanline.cpp)\n\n## 多角形\n\n- (★★☆☆) [多角形の面積](https://github.com/drken1215/algorithm/blob/master/Geometry/area_polygon.cpp)\n- (★★☆☆) [点と多角形の包含判定](https://github.com/drken1215/algorithm/blob/master/Geometry/is_contain_in_the_polygon.cpp)\n- (★★☆☆) [凸性判定](https://github.com/drken1215/algorithm/blob/master/Geometry/is_convex.cpp)\n- (★★★☆) [凸包](https://github.com/drken1215/algorithm/blob/master/Geometry/convex_hull.cpp)\n- (★★★☆) [凸多角形の直径](https://github.com/drken1215/algorithm/blob/master/Geometry/diameter.cpp)\n- (★★★☆) [凸多角形の切断](https://github.com/drken1215/algorithm/blob/master/Geometry/convex_cut.cpp)\n- (★★★★) 凸多角形と直線の交点 O(log N)\n- (★★★★) [円と円の共通部分の面積](https://github.com/drken1215/algorithm/blob/master/Geometry/area_common_two_circles.cpp)\n- (★★★★) [円と多角形との共通部分の面積](https://github.com/drken1215/algorithm/blob/master/Geometry/area_common_circle_polygon.cpp)\n- (★★★☆) [ボロノイ図 (単純ver, O(N^3))](https://github.com/drken1215/algorithm/blob/master/Geometry/voronoi.cpp)\n- (★★★★) ボロノイ図 (単純ver, O(N log N))\n- (★★★★) ドロネーの三角形分割 (期待値 O(N^2))\n\n\n## 三次元幾何\n\n- (★★★★) [三次元幾何一式](https://github.com/drken1215/algorithm/blob/master/Geometry/basic_elements_3D.cpp)\n\n## その他\n\n- (★★☆☆) [垂直二等分線](https://github.com/drken1215/algorithm/blob/master/Geometry/perpendicular_bisector.cpp)\n- (★★★☆) [3 点を通る円](https://github.com/drken1215/algorithm/blob/master/Geometry/circumscribed_circle.cpp)\n- (★★★☆) [アポロニウスの円](https://github.com/drken1215/algorithm/blob/master/Geometry/apollonius.cpp)\n- (★★★☆) [最近点対](https://github.com/drken1215/algorithm/blob/master/Geometry/closest_two_points.cpp)\n- (★★★★) 最小包含円\n- (★★★☆) 線分併合\n- (★★★☆) 線分アレンジメント\n- (★★★☆) 双対変換\n- (★★★★) kd 木\n\n\n\n\n\u003ca name=\"gt\"\u003e\u003c/a\u003e\n# グラフ (GRAPH)\nグラフアルゴリズムです\n\n## DFS, BFS\n\n- (★☆☆☆) [連結成分の個数 (DFS)](https://github.com/drken1215/algorithm/blob/master/Graph/dfs.cpp)\n- (★☆☆☆) [連結成分の個数 (BFS)](https://github.com/drken1215/algorithm/blob/master/Graph/bfs.cpp)\n- (★☆☆☆) [二部グラフ判定 (DFS)](https://github.com/drken1215/algorithm/blob/master/Graph/is_bipartite_dfs.cpp)\n- (★☆☆☆) [二部グラフ判定 (BFS)](https://github.com/drken1215/algorithm/blob/master/Graph/is_bipartite_bfs.cpp)\n- (★★☆☆) [トポロジカルソート (DFS)](https://github.com/drken1215/algorithm/blob/master/Graph/topological_sort_dfs.cpp)\n- (★★☆☆) [トポロジカルソート (BFS)](https://github.com/drken1215/algorithm/blob/master/Graph/topological_sort_bfs.cpp)\n\n## 連結成分分解\n\n- (★★☆☆) [閉路検出 (サイクル検出)](https://github.com/drken1215/algorithm/blob/master/Graph/cycle_detection.cpp)\n- (★★☆☆) [Functional グラフの閉路検出 (サイクル検出)](https://github.com/drken1215/algorithm/blob/master/Graph/functional_graph_cycle_detection.cpp)\n- (★★★☆) [強連結成分分解](https://github.com/drken1215/algorithm/blob/master/Graph/strongly_connected_components.cpp)\n- (★★★☆) [橋, 関節点列挙 (Low-Link)](https://github.com/drken1215/algorithm/blob/master/Graph/low_link.cpp)\n- (★★★★) [二重辺連結成分分解 (Bridge-Block 木)](https://github.com/drken1215/algorithm/blob/master/Graph/two_edge_connected_components.cpp)\n- (★★★★) [二重頂点連結成分分解 (Block-Cut 木)](https://github.com/drken1215/algorithm/blob/master/Graph/biconnected_components.cpp)\n- (★★★★) 三重辺連結成分分解 (SPQR 木)\n\n## 最短路問題 (基本)\n\n- (★☆☆☆) [重みなしグラフの最短路 (BFS, O(E))](https://github.com/drken1215/algorithm/blob/master/Graph/shortest_path_bfs.cpp)\n- (★★☆☆) [重みが 0, 1 のみのグラフの最短路 (0-1 BFS, O(E))](https://github.com/drken1215/algorithm/blob/master/Graph/shortest_path_01bfs.cpp)\n- (★★☆☆) [単一始点最短路 (Dijkstra 法, 正辺のみ, O(V + E log V))](https://github.com/drken1215/algorithm/blob/master/Graph/shortest_path_dijkstra.cpp)\n- (★★☆☆) [単一始点最短路 (Bellman-Ford 法, 負辺対応, O(VE))](https://github.com/drken1215/algorithm/blob/master/Graph/shortest_path_bellman_ford.cpp)\n- (★★☆☆) [全頂点対間最短路 (Floyd-Warshall 法, O(V^3))](https://github.com/drken1215/algorithm/blob/master/Graph/floyd_warshall.cpp)\n- (★★★☆) 全頂点対間最短路 (Johnson 法, O(EV log V))\n\n## 最短路問題 (応用)\n\n- (★★★☆) SPFA\n- (★★★★) 補グラフの最短路\n- (★★★★) d-辺最短路\n- (★★★★) Monge グラフ上の d-辺最短路\n\n## 全域木, 路に関する問題\n\n- (★★☆☆) 最小全域木 (Kruskal 法)\n- (★★★☆) 有向 Euler 路\n- (★★★☆) [無向 Euler 路](https://github.com/drken1215/algorithm/blob/master/Graph/euler_tour_undirected.cpp)\n- (★★★★) 最小有向全域木 (Chu-Liu/Edmonds 法)\n- (★★★★) 行列木定理\n- (★★★★) 最小シュタイナー木 (O(V 3^t + V^2 2^t + V^3))\n\n## グラフ上の有名問題\n\n- (★★★☆) [最大安定集合問題 (O(1.381^V))](https://github.com/drken1215/algorithm/blob/master/Graph/maximum_stable_set.cpp)\n- (★★★★) 最大クリーク列挙（O(1.443^V)）\n- (★★★★) [頂点彩色 (O(2^V V))](https://github.com/drken1215/algorithm/blob/master/Graph/vertex_coloring.cpp)\n- (★★★★) 辺彩色\n- (★★★★) 二部グラフの辺彩色 (Alon 法, O(E log E))\n\n\n　\n\u003ca name=\"gnf\"\u003e\u003c/a\u003e\n# ネットワークフロー (GRAPH : NETWORK FLOW)\nグラフネットワークフロー関連のアルゴリズムです\n\n## 最大流\n\n- (★★★☆) [最大流 (Ford-Fulkerson 法)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/max_flow_ford_fulkerson.cpp)\n- (★★★☆) [最大流 (Dinic 法)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/max_flow_dinic.cpp)\n- (★★★☆) 下限容量つき最大流\n\n## 最小費用流\n\n- (★★★☆) [最小費用流 (Primal-Dual 法, 正辺のみ)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/min_cost_flow_primal_dual.cpp)\n- (★★★☆) [最小費用流 (Primal-Dual 法, 負辺対応)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/min_cost_flow_primal_dual_negative.cpp)\n- (★★★★) [最小費用循環流 (Goldberg-Tarjan 法, by cost-scaling, 負閉路 OK)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/min_cost_circulating_flow.cpp)\n- (★★★★) 最小費用 b-flow (下限容量つき, 供給点・需要点つき)\n- (★★★★) 最小凸費用流\n\n## 劣モジュラ関数のグラフ表現\n\n- (★★★☆) [Project Selection Problem (俗称: 燃やす埋める)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/project_selection_problem.cpp)\n- (★★★★) [2 変数劣モジュラ関数の和を表す最小カット (燃やす埋めるの一般化)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/two_variable_submodular_optimization.cpp)\n- (★★★★) [3 変数劣モジュラ関数の和を表す最小カット (燃やす埋めるの一般化)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/three_variable_submodular_optimization.cpp)\n\n## カット\n\n- (★★★☆) [最小カット (= 最大流)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/min_cut.cpp)\n- (★★★★) 全域最小カット（Stoer-Wanger 法）\n- (★★★★) 全頂点対間最小カット (Nagamochi-Ibaraki 法)\n- (★★★★) Gomory-Hu 木\n\n## マッチング\n\n- (★★★☆) [二部マッチング (Hopcroft-Karp 法)](https://github.com/drken1215/algorithm/blob/master/GraphNetworkFlow/hopcroft_karp.cpp)\n- (★★★☆) 重みつき二部マッチング (Hungarian 法)\n- (★★★★) 一般グラフの最大マッチング (Edmonds 法)\n- (★★★★) 一般グラフの最大マッチング (行列補間)\n- (★★★★) 重み付き一般グラフの最大マッチング\n\n\n　\n\u003ca name=\"ma\"\u003e\u003c/a\u003e\n# 代数 (MATH : ALGEBRA)\n行列計算など代数的計算に関するアルゴリズムです\n\n## 行列\n\n- (★★★☆) [行列累乗, 連立一次方程式 (実数)](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/matrix_double.cpp)\n- (★★★☆) [行列累乗, ランク, 連立一次方程式 (mod. p)](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/matrix_modp.cpp)\n- (★★★☆) [行列累乗, ランク, 連立一次方程式 (binary)](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/matrix_binary.cpp)\n- (★★★★) Black Box Linear Algebra\n\n## 特殊な行列\n\n- (★★★★) Toeplitz 行列 (乗算, 連立方程式が O(n^2))\n- (★★★★) 巡回行列 (乗算が O(n^2))\n- (★★★★) コンパニオン行列\n- (★★★★) 三重対角行列 (連立方程式が O(n))\n\n## FFT, NTT, Convolution\n\n- (★★★☆) [FFT (高速フーリエ変換)](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/FFT.cpp)\n- (★★★☆) [NTT (高速剰余変換)](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/NTT.cpp)\n- (★★★★) [任意 mod 畳み込み](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/NTT_any_mod.cpp)\n- (★★★★) [添字 GCD 畳み込み](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/fast_gcd_convolution.cpp)\n- (★★★★) Karatsuba 法\n\n## 多項式 (Polynomial)\n\n- (★★★★) [多項式：全部乗せ](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/polynomial.cpp)\n- (★★★☆) [多項式の乗算 (by NTT, O(N log N))](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/polynomial_mul.cpp)\n- (★★★★) [多項式の除算 (by NTT, inv of FPS, O(N log N))](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/polynomial_div.cpp)\n- (★★★★) 多項式補間\n- (★★★☆) [Polynomial Taylor Shift](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/polynomial_taylor_shift.cpp)\n- (★★★★) 多項式 GCD\n\n## 形式的冪級数 (FPS)\n\n- (★★★★) [形式的冪級数：全部乗せ](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/formal_power_series.cpp)\n- (★★★★) Sparse な形式的冪級数\n- (★★★★) [Bostan-Mori 法](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/bostan_mori.cpp)\n- (★★★★) Fiduccia 法 (高速きたまさ法)\n- (★★★★) Berlekamp-Massey 法\n- (★★★★) 関数の合成\n- (★★★★) 逆関数\n\n## さまざまな和\n\n- (★★★☆) [floor sum](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/floor_sum.cpp)\n- (★★★★) Bk = Σ{i=0}^{n-1} i^k を係数とする多項式\n- (★★★★) Σ{i=0}^{n-1} r^i i^d\n- (★★★★) Σ{i=0}^{∞} r^i i^d\n\n\n　\n\u003ca name=\"mc\"\u003e\u003c/a\u003e\n# 組合せ (MATH : COMBINATORICS)\n組合せ論的アルゴリズムたちです\n\n## 二項係数\n\n- (★★☆☆) [二項係数 (オーソドックス, n\u003c=10^7, r\u003c=10^7, p\u003c=10^9)](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/mod_binomial_coefficient.cpp)\n- (★★☆☆) [二項係数 (愚直計算, n\u003c=10^9, r\u003c=10^7, p\u003c=10^9)](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/mod_binomial_coefficient_naive.cpp)\n- (★★☆☆) [二項係数 (漸化式計算, n\u003c=5000, r\u003c=5000, p\u003c=10^9)](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/mod_binomial_coefficient_dp.cpp)\n- (★★★★) [二項係数 (任意 mod, n\u003c=10^7, r\u003c=10^7, m\u003c=10^9)](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/mod_binomial_coefficient_any_mod.cpp)\n\n## さまざまな数\n\n- (★★☆☆) [重複組合せ](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/combination_with_repetition.cpp)\n- (★★★☆) [分割数 P(N, K) (O(NK))](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/partition_number_pnk.cpp)\n- (★★★★) [分割数 P(N) (O(N√N))](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/partition_number_pn.cpp)\n- (★★★☆) スターリング数\n- (★★★☆) ベル数\n- (★★★☆) [カタラン数](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/catalan_number.cpp)\n- (★★★☆) ベルヌーイ数\n- (★★★☆) モンモール数\n\n## 高速なソート\n\n- (★☆☆☆) [クイックソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/quick_sort.cpp)\n- (★☆☆☆) [マージソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/merge_sort.cpp)\n- (★★☆☆) [ヒープソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/heap_sort.cpp)\n- (★★☆☆) [計数ソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/counting_sort.cpp)\n\n## さまざまなソート\n\n- (★☆☆☆) [挿入ソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/insertion_sort.cpp)\n- (★☆☆☆) [選択ソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/selection_sort.cpp)\n- (★☆☆☆) [バブルソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/bubble_sort.cpp)\n- (★☆☆☆) [シェルソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/shell_sort.cpp)\n- (★☆☆☆) [コムソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/comb_sort.cpp)\n- (★☆☆☆) [ボゴソート](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/bogo_sort.cpp)\n\n## 集合族に関する問題\n\n- (★★★☆) [2-SAT](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/two_sat.cpp)\n- (★★★☆) マトロイド上の Greedy 法\n- (★★★★) マトロイド交差\n\n## 集合冪級数 (SPS)\n\n- (★★★☆) [高速ゼータ変換](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/fast_zeta_transform.cpp)\n- (★★★★) [高速アダマール変換](https://github.com/drken1215/algorithm/blob/master/MathAlgebra/fast_hadmard_transform.cpp)\n- (★★★★) AND Convolution\n- (★★★★) OR Convolution\n- (★★★★) XOR Convolution\n- (★★★★) Subset Convolution\n- (★★★★) 集合冪級数の exp\n- (★★★★) 集合冪級数の合成\n\n## その他\n\n- (★★★☆) [Nim](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/nim.cpp)\n- (★★★☆) [LIS and LDS](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/LIS_and_LDS.cpp)\n- (★★★☆) [転倒数](https://github.com/drken1215/algorithm/blob/master/MathCombinatorics/inversion_number.cpp)\n\n\n　\n\u003ca name=\"mmt\"\u003e\u003c/a\u003e\n# 整数 (MATH : NUMBER THEORY)\n整数論的アルゴリズムたちです\n\n## Mod の処理\n\n- (★★☆☆) [a^n, a^{-1} (mod m)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/mod_pow_inv.cpp)\n- (★★☆☆) [Modint](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/modint.cpp)\n- (★★☆☆) [実行時に法が決まる Modint](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/modint_runtime.cpp)\n- (★★★★) [モンゴメリ乗算を用いた Modint (mod は 2^62 未満の奇数)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/modint_montgomery.cpp)\n\n## 約数, 倍数\n\n- (★☆☆☆) [約数列挙](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/divisor.cpp)\n- (★☆☆☆) [最大公約数 (Euclid の互除法)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/GCD.cpp)\n- (★☆☆☆) [最小公倍数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/LCM.cpp)\n- (★★☆☆) [拡張 Euclid の互除法](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/extended_GCD.cpp)\n\n## 素数\n\n- (★☆☆☆) [素数判定](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/is_prime.cpp)\n- (★☆☆☆) [素因数分解](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/prime_factorization.cpp)\n- (★★★☆) [Euler のトーティエント関数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/euler_function.cpp)\n- (★★★★) [確率的な高速素数判定 (Miller-Rabin 法)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/is_prime_Miller_Rabin.cpp)\n- (★★★★) [確率的な高速素因数分解 (Pollard のロー法)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/pollard_rho.cpp)\n- (★★★★) [原始根](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/primitive_root.cpp)\n- (★★★★) [位数 (a^x ≡ 1 (mod p) となる最小の x)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/order.cpp)\n- (★★★★) N 以下の素数の個数 (O(N^2/3))\n\n## エラトステネスの篩\n\n- (★☆☆☆) [エラトステネスの篩](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/Eratosthenes.cpp)\n- (★★☆☆) [エラトステネスの区間篩](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/Eratosthenes_segment.cpp)\n- (★★★☆) [高速素因数分解, 約数列挙, メビウス関数 (エラトステネスの篩風)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/fast_prime_factorization_eratosthenes.cpp)\n- (★★★★) 線形篩\n- (★★★★) アトキンの篩\n\n## 方程式\n\n- (★★★☆) 一次合同方程式\n- (★★★☆) [中国剰余定理](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/chinese_reminder_theorem.cpp)\n- (★★★☆) [中国剰余定理 (Garner 法)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/garner.cpp)\n- (★★★☆) [離散対数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/mod_log.cpp)\n- (★★★★) [ペル方程式](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/Pell_equation.cpp)\n- (★★★★) 平方剰余 (Tonelli–Shanks 法)\n\n## さまざまな数\n\n- (★★★☆) [128 ビット整数 (ラッパー)](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/int128.cpp)\n- (★★★☆) [多倍長整数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/big_integer.cpp)\n- (★★★☆) [有理数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/rational_number.cpp)\n- (★★★★) [ガウス整数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/gauss_integer.cpp)\n\n## その他\n\n- (★☆☆☆) [m で割って r 余る, x 以上の最小の整数](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/amari_lower_bound.cpp)\n- (★★☆☆) [平衡三進法展開](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/power_of_three.cpp)\n- (★★★☆) [x^K \u003c= N となる最大の整数 x](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/kth_root.cpp)\n- (★★★☆) [Stern-Brocot 木](https://github.com/drken1215/algorithm/blob/master/MathNumberTheory/Stern_Brocot.cpp)\n\n\n　\n\u003ca name=\"opt\"\u003e\u003c/a\u003e\n# 最適化, 探索 (OPTIMIZATION, SEARCH)\n最適化や探索に関するアルゴリズムです\n\n## さまざまな全探索\n\n- (★★☆☆) [next_combination (nCk 通りの全探索)](https://github.com/drken1215/algorithm/blob/master/Optimization/next_combination.cpp)\n- (★★☆☆) [部分集合の部分集合 (3^N 通りの全探索)](https://github.com/drken1215/algorithm/blob/master/Optimization/subset_enumeration.cpp)\n- (★★☆☆) [数独ソルバー](https://github.com/drken1215/algorithm/blob/master/Optimization/sudoku.cpp)\n\n## 動的計画法\n\n- (★☆☆☆) [ナップサック問題](https://github.com/drken1215/algorithm/blob/master/Optimization/knapsack.cpp)\n- (★☆☆☆) [LIS](https://github.com/drken1215/algorithm/blob/master/Optimization/longest_increasing_sequence.cpp)\n- (★☆☆☆) [LCS](https://github.com/drken1215/algorithm/blob/master/Optimization/lcs.cpp)\n- (★☆☆☆) [編集距離](https://github.com/drken1215/algorithm/blob/master/Optimization/edit_distance.cpp)\n- (★★☆☆) [グリッドに含まれる最大正方形](https://github.com/drken1215/algorithm/blob/master/Optimization/largest_square_in_grid.cpp)\n- (★★★☆) [ヒストグラム長方形面積最大化](https://github.com/drken1215/algorithm/blob/master/Optimization/histogram.cpp)\n- (★★★★) 最適二分探索木 (O(N^2), Monge 性を活かした区間 DP)\n- (★★★★) 最適二分探索木 (O(N log N), Hu-Tucker 法)\n\n## 動的計画法 (DP) の高速化技法\n\n- (★★★★) Slope Trick\n- (★★★★) Monotone Minima\n- (★★★★) Alien DP\n- (★★★★) LARSCH\n\n## Convex Hull Trick\n\n- (★★★☆) [Convex Hull Trick (傾き単調, クエリも単調)](https://github.com/drken1215/algorithm/blob/master/Optimization/convex_hull_trick_both_monotone.cpp)\n- (★★★☆) [Convex Hull Trick (傾き単調)](https://github.com/drken1215/algorithm/blob/master/Optimization/convex_hull_trick_slope_monotone.cpp)\n- (★★★★) [Convex Hull Trick (単調でなくてよい, Li Chao Tree)](https://github.com/drken1215/algorithm/blob/master/Optimization/convex_hull_trick.cpp)\n\n## 数理最適化 (Optimization)\n\n- (★★☆☆) 二次方程式\n- (★★☆☆) 二分探索法 (方程式の解を 1 つ求める)\n- (★★☆☆) 三分探索法\n- (★★☆☆) 黄金探索法\n- (★★★☆) Newton 法\n- (★★★★) [単体法 (二段階単体法)](https://github.com/drken1215/algorithm/blob/master/Optimization/simplex_method.cpp)\n- (★★★★) 分枝限定法\n\n## さまざまな探索法\n\n- (★★★☆) α-β 探索\n- (★★★☆) 焼き鈍し法\n- (★★★☆) A*\n- (★★★☆) IDA*\n\n## 指数時間アルゴリズム\n\n- (★★★★) Set Cover\n- (★★★★) k-Cover (O(2^N N))\n- (★★★★) k-partition (O(2^N N^3))\n\n\n　\n\u003ca name=\"st\"\u003e\u003c/a\u003e\n# 文字列 (String)\n文字列アルゴリズムです\n\n### 構文解析\n\n- (★★★☆) [LL(1) 再帰下降パーサ](https://github.com/drken1215/algorithm/blob/master/String/parser.cpp)\n\n### 文字列検索\n\n- (★★★☆) [Suffix Array](https://github.com/drken1215/algorithm/blob/master/String/suffix_array.cpp)\n- (★★★☆) [ローリングハッシュ](https://github.com/drken1215/algorithm/blob/master/String/rolling_hash.cpp)\n- (★★★☆) [単一パターン検索 (KMP 法)](https://github.com/drken1215/algorithm/blob/master/String/knuth_morris_pratt.cpp)\n- (★★★☆) 単一パターン検索 (Boyer-Moore 法)\n- (★★★★) 複数パターン検索 (Aho-Corasick 法)\n\n### さまざまな文字列アルゴリズム\n\n- (★★★☆) [Z 法](https://github.com/drken1215/algorithm/blob/master/String/z_algorithm.cpp)\n- (★★★☆) [Manacher 法](https://github.com/drken1215/algorithm/blob/master/String/manacher.cpp)\n\n### さまざまな文字列データ構造\n\n- (★★★☆) Trie 木\n- (★★★★) Palindromic 木 (AOJ 2292)\n\n### その他\n\n- (★★☆☆) [各 index 以降で各文字が最初に登場する index を求める関数](https://github.com/drken1215/algorithm/blob/master/String/next.cpp)\n- (★★★☆) [文字列の相異なる部分列の個数 (O(cN))](https://github.com/drken1215/algorithm/blob/master/String/num_of_subsequences.cpp)\n- (★★★☆) [文字列の相異なる連続部分文字列の個数 (O(N))](https://github.com/drken1215/algorithm/blob/master/String/num_of_substrings.cpp)\n\n\n　\n\u003ca name=\"tr\"\u003e\u003c/a\u003e\n# 木 (Tree)\n木上のクエリに答えるデータ構造や、木に関する問題を解くアルゴリズムの実装です\n\n## 木\n\n- (★★★☆) [木の走査 (部分木サイズ, LCA など)](https://github.com/drken1215/algorithm/blob/master/Tree/run_tree.cpp)\n- (★★★☆) [木の直径](https://github.com/drken1215/algorithm/blob/master/Tree/diameter.cpp)\n- (★★★☆) 木の重心\n- (★★★★) 木の Distance Frequency Table\n\n## 木 DP\n\n- (★★☆☆) 木 DP\n- (★★★☆) 二乗の木 DP (俗称)\n- (★★★☆) [全方位木 DP](https://github.com/drken1215/algorithm/blob/master/Tree/rerooting.cpp)\n- (★★★☆) [全方位木 DP (辺に重みがある場合)](https://github.com/drken1215/algorithm/blob/master/Tree/rerooting_with_edge.cpp)\n\n## LCA\n\n- (★★★☆) [LCA (ダブリング)](https://github.com/drken1215/algorithm/blob/master/Tree/lca_by_doubling.cpp)\n- (★★★☆) [LCA (Euler Tour)](https://github.com/drken1215/algorithm/blob/master/Tree/lca_euler_tour.cpp)\n- (★★★☆) [LCA (HL 分解)](https://github.com/drken1215/algorithm/blob/master/Tree/lca_heavy_light_decomposition.cpp)\n\n## 木上のクエリ処理\n\n- (★★★☆) [Euler Tour (頂点上のクエリ)](https://github.com/drken1215/algorithm/blob/master/Tree/euler_tour_on_nodes.cpp)\n- (★★★☆) [Euler Tour (辺上のクエリ)](https://github.com/drken1215/algorithm/blob/master/Tree/euler_tour_on_edges.cpp)\n- (★★★☆) [HL 分解](https://github.com/drken1215/algorithm/blob/master/Tree/heavy_light_decomposition.cpp)\n- (★★★☆) [重心分解](https://github.com/drken1215/algorithm/blob/master/Tree/tree_centroid_decomposition.cpp)\n- (★★★☆) DSU on Tree\n- (★★★★) Link-Cut 木\n- (★★★★) toptree\n\n## その他の問題\n\n- (★★★☆) [強平衡二分木の Distance Frequency Table](https://github.com/drken1215/algorithm/blob/master/Tree/find_various_values_of_binary_tree.cpp)\n- (★★★★) Level Ancester\n\n\n　\n\u003ca name=\"ot\"\u003e\u003c/a\u003e\n# その他 (OTHERS)\nその他のアルゴリズムです\n\n## 入出力\n\n- (★★★★) [Fast IO](https://github.com/drken1215/algorithm/blob/master/Others/fast_io.cpp)\n\n## グリッド\n\n- (★☆☆☆) [グリッドの 4 近傍, 8 近傍](https://github.com/drken1215/algorithm/blob/master/Others/grid_neighbors.cpp)\n- (★☆☆☆) [ハニカムの 6 近傍](https://github.com/drken1215/algorithm/blob/master/Others/honeycomb_neighbors.cpp)\n\n## その他\n\n- (★★★★) [ACL](https://github.com/drken1215/algorithm/blob/master/Others/acl.cpp)\n- (★★☆☆) [XorShift, ランダムシャッフル](https://github.com/drken1215/algorithm/blob/master/Others/xorshift.cpp)\n- (★★☆☆) [タイマー](https://github.com/drken1215/algorithm/blob/master/Others/timer.cpp)\n- (★★☆☆) [サイコロ](https://github.com/drken1215/algorithm/blob/master/Others/dice.cpp)\n- (★★☆☆) [曜日](https://github.com/drken1215/algorithm/blob/master/Others/day_of_the_week.cpp)\n- (★★★☆) 四面体 (AOJ 2060)\n\n\n　\n# License\nThese codes are licensed under CC0.\n[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png \"CC0\")](http://creativecommons.org/publicdomain/zero/1.0/deed.ja)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrken1215%2Falgorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrken1215%2Falgorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrken1215%2Falgorithm/lists"}