AC(AtCoder) Library Document
Library map
Nim-ACL provides AtCoder Library-compatible APIs together with additional competitive-programming algorithms, data structures, and Japanese/English documentation.
Start with the standard APIs
| Purpose | Documentation | Main APIs |
|---|---|---|
| Range products | Segment Tree | SegTree, prod, set |
| Lazy propagation | Lazy Segment Tree | LazySegTree, apply, prod |
| Prefix sums | Fenwick Tree | FenwickTree, add, sum |
| Convolution | Convolution | convolution |
| Maximum flow | Max Flow | MFGraph, flow |
| Minimum-cost flow | Min-Cost Flow | MCFGraph, flow, slope |
| Disjoint sets | DSU | DSU, merge, leader |
| Strongly connected components | SCC | SCCGraph, scc |
| Strings | String Algorithms | suffix array, LCP, Z algorithm |
| Modular arithmetic | ModInt | static and dynamic modint |
Recently added or substantially improved
| Area | API | Purpose |
|---|---|---|
| Multidimensional search | KD-tree | nearest neighbor and half-open orthogonal ranges |
| Computational geometry | Minkowski Sum | Minkowski sum of arbitrary point-set hulls |
| Set power series | Set Power Series Exp / Log | exponential and logarithm |
| Flow | Minimum-Cost B-Flow | lower/upper bounds, supplies, demands, and costs |
| Persistent structures | Persistent Segment Tree | versioned updates and range products |
| Sequence structures | Implicit Treap | split/merge and sequence operations |
| Trie | Binary Trie | XOR minimum/maximum and multiset operations |
| FPS | Formal Power Series facade | a unified entry point for FPS APIs |
Additional libraries by category
| Category | Documentation |
|---|---|
| DP optimization | Monotone Minima · Divide and Conquer Optimization · SMAWK |
| Mathematics and polynomials | Berlekamp–Massey · Polynomial Interpolation · Subset Convolution · FPS |
| Data structures | Persistent Segment Tree · Implicit Treap · KD-tree · Binary Trie |
| Graphs | Bipartite Edge Coloring · Minimum-Cost B-Flow |
| Computational geometry | Minkowski Sum |
Guides
Documentation structure
Additional-library pages generally follow this order: general form, parameters and types, preconditions, return values and side effects, example, related APIs, and complexity and implementation.
Guides
How to Install
- There is
atcoderfolder in theac-libraryfolder, after extracting the zip file. - With g++, you can compile by
g++ main.cpp -std=c++14 -I .with puttingatcoderfolder on the same place asmain.cpp. - You should compile with
-std=c++14or-std=c++17. - See Appendix for further details.
Note
- The behavior is undefined if the input does not match the constraints.
- For simplicity, we abbreviate the types as follows.
unsigned int→uintlong long→llunsigned long long→ull- $0^0=1$.
- Multiple edges and self-loops are allowed unless specified.
List
#include <atcoder/all> : include everything
Data Structures
#include <atcoder/fenwicktree>#include <atcoder/segtree>#include <atcoder/lazysegtree>#include <atcoder/string>
Math
Graphs
#include <atcoder/dsu>#include <atcoder/maxflow>#include <atcoder/mincostflow>#include <atcoder/scc>#include <atcoder/twosat>
Appendix
Test
- You can test this Library here.
License
The header files in atcoder folder are licensed under a CC0 license. See atcoder/LICENSE for further details.
Extra / Math
extra/dp
import atcoder/extra/dp/cumulative_sumimport atcoder/extra/dp/cumulative_sum_2dimport atcoder/extra/dp/dual_cumulative_sum_2dimport atcoder/extra/dp/edit_distanceimport atcoder/extra/dp/largest_rectangleimport atcoder/extra/dp/dual_cumulative_sumimport atcoder/extra/dp/longest_increasing_subsequenceimport atcoder/extra/dp/slide_min
extra/math
import atcoder/extra/math/xor_basisimport atcoder/extra/math/convert_baseimport atcoder/extra/math/mod_sqrtimport atcoder/extra/math/combination_tableimport atcoder/extra/math/arbitrary_mod_combinationimport atcoder/extra/math/floor_sum_squareimport atcoder/extra/math/factorial
extra/geometry
import atcoder/extra/geometry/geometryimport atcoder/extra/geometry/closest_pairimport atcoder/extra/geometry/polygonimport atcoder/extra/geometry/triangleimport atcoder/extra/geometry/tangent
extra/structure
import atcoder/extra/structure/persistent_segment_treeimport atcoder/extra/structure/sqrt_treeimport atcoder/extra/structure/mex_setimport atcoder/extra/structure/fast_setimport atcoder/extra/structure/disjoint_sparse_tableimport atcoder/extra/structure/cartesian_treeimport atcoder/extra/structure/rollback_dsuimport atcoder/extra/structure/binary_trieimport atcoder/extra/structure/sorted_set_mapimport atcoder/extra/structure/set_mapimport atcoder/extra/structure/tree_backendsimport atcoder/extra/structure/partially_persistent_dsuimport atcoder/extra/structure/succinct_indexable_dictionaryimport atcoder/extra/structure/convex_hull_trick_add_monotoneimport atcoder/extra/structure/li_chao_treeimport atcoder/extra/structure/segtree_2dimport atcoder/extra/structure/wavelet_matriximport atcoder/extra/structure/radix_heapimport atcoder/extra/structure/sparse_tableimport atcoder/extra/structure/dual_fenwicktreeimport atcoder/extra/structure/weighted_union_find
extra/graph
import atcoder/extra/graph/euler_tourimport atcoder/extra/graph/undirected_decompositionimport atcoder/extra/graph/biconnected_componentsimport atcoder/extra/graph/two_edge_connected_componentsimport atcoder/extra/graph/block_cut_treeimport atcoder/extra/graph/rerooting_dpimport atcoder/extra/graph/dsu_on_treeimport atcoder/extra/graph/offline_dynamic_connectivityimport atcoder/extra/graph/functional_graph
extra/string
import atcoder/extra/string/kmpimport atcoder/extra/string/rolling_hashimport atcoder/extra/string/minimum_rotationimport atcoder/extra/string/suffix_automatonimport atcoder/extra/string/palindromic_treeimport atcoder/extra/string/aho_corasickimport atcoder/extra/string/manacher
extra/algorithm
import atcoder/extra/algorithm/coordinate_compressionimport atcoder/extra/algorithm/run_length_encodingimport atcoder/extra/algorithm/mo
Japanese API facades (experimental)
Canonical Nim-ACL implementations can also be reached through Japanese import paths and API names.
Tree algorithms
DP optimization
Curated graph facade
| Description | Documentation | Import |
|---|---|---|
| Curated graph representation, shortest-path, connectivity, spanning-tree, functional-graph and offline-connectivity modules. Existing direct imports remain supported. | Graph facade | import atcoder/extra/graph/graph |