Python bindings for the AtCoder Library
Project description
acl-cpp-python
acl-cpp-python is a Python binding for the AtCoder Library (ACL) implemented in C++, using nanobind.
Installation
pip install acl-cpp-python
Usage
from acl_cpp.convolution import convolution998244353
a = [1, 1]
b = convolution998244353(a, a)
print(*b) # 1 2 1
Notes
segtree,lazysegtree, andmodintare not implemented as they are unlikely to offer performance improvements.- Be mindful of integer size. Functions requiring
intmust receive values within the range of 32-bit signed integers, and functions requiringlong longmust receive values within the range of 64-bit signed integers. Passing values outside these ranges will raise aTypeError. - Watch out for overflow. Many integers are implemented as 64-bit signed integers. Calculations exceeding this range will result in overflow and produce incorrect results.
Documentation
Refer to the AC Library documentation.
The differences from the C++ version are outlined below.
Data Structures
acl_cpp.fenwicktree
Contains a class fenwicktree.fenwick_tree where T = long long.
acl_cpp.segtree
Not available.
acl_cpp.lazysegtree
Not available.
acl_cpp.string
Includes implementations for str and T = long long.
Mathematics
acl_cpp.math
pow_modis not available. Usepow(x, n, m)instead.inv_modis not available. Usepow(x, -1, m)instead.crt(r: list[long long], m: list[long long]) -> (long long, long long)is available.floor_sum(n: long long, m: long long, a: long long, b: long long) -> long longis available.
acl_cpp.math.internal
The following functions are available:
math.internal.is_prime(n: int) -> boolmath.internal.primitive_root(m: int) -> intmmust be a prime number.
acl_cpp.convolution
The following functions are available:
convolution.convolution998244353(a: list[int], b: list[int]) -> list[int]- Each element of
aandbmust be in the range [0, 998244353). len(a) + len(b) - 1 <= 2 ** 23.
- Each element of
convolution.convolution(a: list[int], b: list[int], mod: int) -> list[int]- Implements convolution for dynamic_modint, which is not available in the C++ version.
- Each element of
aandbmust be in the range [0, mod). modmust be a prime number.- There must exist an integer
csuch that(mod - 1) % (2 ** c) == 0andlen(a) + len(b) - 1 <= 2 ** c.
convolution.convolution_ll(a: list[long long], b: list[long long]) -> list[long long]len(a) + len(b) - 1 <= 2 ** 23.- All elements of the resulting array fit within
long long.
acl_cpp.convolution.internal
These functions are useful for optimizing formal power series (FPS). Unlike the C++ version, they return new arrays instead of modifying arguments.
convolution.internal.butterfly998244353(a: list[int]) -> list[int]- Each element of
amust be in the range [0, 998244353). len(a).bit_count() == 1.len(a) <= 2 ** 23.
- Each element of
convolution.internal.butterfly(a: list[int], mod: int) -> list[int]- Each element of
amust be in the range [0, mod). modmust be a prime number.len(a).bit_count() == 1.(mod - 1) % len(a) == 0.
- Each element of
convolution.internal.butterfly_inv998244353(a: list[int]) -> list[int]- Each element of
amust be in the range [0, 998244353). len(a).bit_count() == 1.len(a) <= 2 ** 23.
- Each element of
convolution.internal.butterfly_inv(a: list[int], mod: int) -> list[int]- Each element of
amust be in the range [0, mod). modmust be a prime number.len(a).bit_count() == 1.- There must exist an integer
csuch that(mod - 1) % len(a) == 0andlen(a) <= 2 ** c.
- Each element of
acl_cpp.modint
Not available.
Graphs
acl_cpp.dsu
dsu.dsu is available.
acl_cpp.maxflow
Implemented with Cap = long long.
maxflow.mf_graph and maxflow.mf_graph.edge are available.
acl_cpp.mincostflow
Implemented with Cap = Cost = long long.
mincostflow.mcf_graph and mincostflow.mcf_graph.edge are available.
acl_cpp.scc
scc.scc_graph is available.
acl_cpp.twosat
twosat.two_sat is available.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file acl-cpp-python-0.3.0.tar.gz.
File metadata
- Download URL: acl-cpp-python-0.3.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
945d1646386849ecf6e14064091807eec5b5a47f96e1efdc1e32f1326c71a468
|
|
| MD5 |
61e21a19a2a5f2107770cc261b1e80a5
|
|
| BLAKE2b-256 |
e5769deecf85ae70cadcc755e5f1abf0ec15f3882bd8564814477e7a33c31962
|