ac-library-rb 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/unittest.yml +16 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +198 -0
- data/Gemfile +3 -0
- data/LICENSE +116 -0
- data/README.ja.md +56 -0
- data/README.md +41 -0
- data/Rakefile +11 -0
- data/ac-library-rb.gemspec +32 -0
- data/bin/console +8 -0
- data/bin/lock_lib.rb +27 -0
- data/bin/setup +8 -0
- data/document_en/binary_index_tree.md +3 -0
- data/document_en/convolution.md +67 -0
- data/document_en/dsu.md +132 -0
- data/document_en/fenwick_tree.md +99 -0
- data/document_en/index.md +79 -0
- data/document_en/lazy_segtree.md +141 -0
- data/document_en/math.md +104 -0
- data/document_en/max_flow.md +165 -0
- data/document_en/min_cost_flow.md +132 -0
- data/document_en/modint.md +263 -0
- data/document_en/priority_queue.md +119 -0
- data/document_en/segtree.md +134 -0
- data/document_en/string.md +106 -0
- data/document_en/two_sat.md +91 -0
- data/document_en/union_find.md +3 -0
- data/document_ja/convolution.md +64 -0
- data/document_ja/dsu.md +183 -0
- data/document_ja/fenwick_tree.md +83 -0
- data/document_ja/index.md +89 -0
- data/document_ja/lazy_segtree.md +135 -0
- data/document_ja/math.md +116 -0
- data/document_ja/max_flow.md +129 -0
- data/document_ja/min_cost_flow.md +105 -0
- data/document_ja/modint.md +349 -0
- data/document_ja/priority_queue.md +103 -0
- data/document_ja/scc.md +65 -0
- data/document_ja/segtree.md +145 -0
- data/document_ja/string.md +105 -0
- data/document_ja/two_sat.md +87 -0
- data/lib/ac-library-rb/version.rb +3 -0
- data/lib/convolution.rb +124 -0
- data/lib/core_ext/modint.rb +19 -0
- data/lib/crt.rb +52 -0
- data/lib/dsu.rb +44 -0
- data/lib/fenwick_tree.rb +48 -0
- data/lib/floor_sum.rb +21 -0
- data/lib/inv_mod.rb +26 -0
- data/lib/lazy_segtree.rb +149 -0
- data/lib/lcp_array.rb +23 -0
- data/lib/max_flow.rb +137 -0
- data/lib/min_cost_flow.rb +143 -0
- data/lib/modint.rb +170 -0
- data/lib/pow_mod.rb +13 -0
- data/lib/priority_queue.rb +89 -0
- data/lib/scc.rb +77 -0
- data/lib/segtree.rb +140 -0
- data/lib/suffix_array.rb +128 -0
- data/lib/two_sat.rb +34 -0
- data/lib/z_algorithm.rb +32 -0
- data/lib_helpers/ac-library-rb/all.rb +22 -0
- data/lib_lock/ac-library-rb.rb +22 -0
- data/lib_lock/ac-library-rb/convolution.rb +126 -0
- data/lib_lock/ac-library-rb/core_ext/modint.rb +19 -0
- data/lib_lock/ac-library-rb/crt.rb +54 -0
- data/lib_lock/ac-library-rb/dsu.rb +46 -0
- data/lib_lock/ac-library-rb/fenwick_tree.rb +50 -0
- data/lib_lock/ac-library-rb/floor_sum.rb +23 -0
- data/lib_lock/ac-library-rb/inv_mod.rb +28 -0
- data/lib_lock/ac-library-rb/lazy_segtree.rb +151 -0
- data/lib_lock/ac-library-rb/lcp_array.rb +25 -0
- data/lib_lock/ac-library-rb/max_flow.rb +139 -0
- data/lib_lock/ac-library-rb/min_cost_flow.rb +145 -0
- data/lib_lock/ac-library-rb/modint.rb +172 -0
- data/lib_lock/ac-library-rb/pow_mod.rb +15 -0
- data/lib_lock/ac-library-rb/priority_queue.rb +91 -0
- data/lib_lock/ac-library-rb/scc.rb +79 -0
- data/lib_lock/ac-library-rb/segtree.rb +142 -0
- data/lib_lock/ac-library-rb/suffix_array.rb +130 -0
- data/lib_lock/ac-library-rb/two_sat.rb +36 -0
- data/lib_lock/ac-library-rb/z_algorithm.rb +34 -0
- metadata +158 -0
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'lib/ac-library-rb/version'
|
2
|
+
|
3
|
+
gem_description = "ac-library-rb is a ruby port of AtCoder Library (ACL).
|
4
|
+
DSU(UnionFind), FenwickTree, PriorityQueue, Segtree, SCC, 2-SAT, suffix_array, lcp_array, z_algorithm, crt, inv_mod, floor_sum, max_flow, min_cost_flow......"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ac-library-rb"
|
8
|
+
spec.version = AcLibraryRb::VERSION
|
9
|
+
spec.authors = ["universato"]
|
10
|
+
spec.email = ["universato@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "ac-library-rb is a ruby port of AtCoder Library (ACL)."
|
13
|
+
spec.description = gem_description
|
14
|
+
spec.homepage = "https://github.com/universato/ac-library-rb"
|
15
|
+
spec.license = "CC0"
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/universato/ac-library-rb"
|
20
|
+
|
21
|
+
spec.add_development_dependency "minitest"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib_lock", "lib_helpers"]
|
32
|
+
end
|
data/bin/console
ADDED
data/bin/lock_lib.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# copy libraries from `lib` to `lib_lock/ac-library` and add `module AcLibraryRb`
|
4
|
+
lib_path = File.expand_path('../../lib/**', __FILE__)
|
5
|
+
lock_dir = File.expand_path('../../lib_lock/ac-library-rb', __FILE__)
|
6
|
+
Dir.glob(lib_path) do |file|
|
7
|
+
next unless FileTest.file?(file)
|
8
|
+
|
9
|
+
path = Pathname.new(lock_dir) + Pathname.new(file).basename
|
10
|
+
File.open(path, "w") do |f|
|
11
|
+
f.puts "module AcLibraryRb"
|
12
|
+
f.puts File.readlines(file).map{ |line| line == "\n" ? "\n" : ' ' + line }
|
13
|
+
f.puts "end"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# cope library from `lib/core_ext` to `lib_lock/ac-library-rb/core_ext`
|
18
|
+
lib_path = File.expand_path('../../lib/core_ext/**', __FILE__)
|
19
|
+
lock_dir = File.expand_path('../../lib_lock/ac-library-rb/core_ext', __FILE__)
|
20
|
+
Dir.glob(lib_path) do |file|
|
21
|
+
next unless FileTest.file?(file)
|
22
|
+
|
23
|
+
path = Pathname.new(lock_dir) + Pathname.new(file).basename
|
24
|
+
File.open(path, "w") do |f|
|
25
|
+
f.puts File.readlines(file)
|
26
|
+
end
|
27
|
+
end
|
data/bin/setup
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Convolution
|
2
|
+
|
3
|
+
Performs convolution. An array of `Integer` of length `N`, `a[0],a[1],... ,a[N - 1]` and an array of `Integer` of length `M`, `b[0],b[1],... ,b[M - 1]`, and returns it as `c`, an array of `Integer` of length `N + M - 1`.
|
4
|
+
|
5
|
+
## convolution
|
6
|
+
|
7
|
+
``ruby
|
8
|
+
(1) conv = Convolution.new(m = 998244353)
|
9
|
+
(2) conv = Convolution.new(m, primitive_root)
|
10
|
+
``
|
11
|
+
|
12
|
+
It creates an object to compute the convolution with `mod m`.
|
13
|
+
|
14
|
+
The `primitive_root` must be a primitive root for the method `m`. If it is not given, the minimal primitive root is computed internally.
|
15
|
+
|
16
|
+
**constraints**.
|
17
|
+
|
18
|
+
- `2 ≤ m`.
|
19
|
+
|
20
|
+
- `m` is a prime number
|
21
|
+
|
22
|
+
- ((2) only) `primitive_root` is the primitive root for law `m`.
|
23
|
+
|
24
|
+
**computational complexity** 1.
|
25
|
+
|
26
|
+
1.`O(sqrt m)` 2.
|
27
|
+
|
28
|
+
2.`O(log m)`.
|
29
|
+
|
30
|
+
### Usage
|
31
|
+
|
32
|
+
The actual computation is done as follows, using the object `conv` created above.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
c = conv.convolution(a, b)
|
36
|
+
```
|
37
|
+
|
38
|
+
If at least one of `a` and `b` is an empty array, it returns an empty array.
|
39
|
+
|
40
|
+
**constraints**.
|
41
|
+
|
42
|
+
- There exists a `c` such that `2^c|(m-1)` and `|a|+|b|-1<=2^c`.
|
43
|
+
|
44
|
+
**computational complexity**.
|
45
|
+
|
46
|
+
- `O((|a|+|b|) log (|a|+|b|))`
|
47
|
+
|
48
|
+
## convolution_ll
|
49
|
+
|
50
|
+
This can be handled by using a sufficiently large prime number as `m` in `convolution`.
|
51
|
+
|
52
|
+
An example of an `NTT-Friendly` prime over `1e15` is `1125900443713537 = 2^29×2097153+1`.
|
53
|
+
|
54
|
+
# Verified
|
55
|
+
|
56
|
+
- [C - Fast Fourier Transform](https://atcoder.jp/contests/atc001/tasks/fft_c)
|
57
|
+
- `m = 1012924417`
|
58
|
+
[1272ms](https://atcoder.jp/contests/atc001/submissions/17193829)
|
59
|
+
- `m = 1125900443713537`
|
60
|
+
[2448 ms](https://atcoder.jp/contests/atc001/submissions/17193739)
|
61
|
+
|
62
|
+
# Reference.
|
63
|
+
|
64
|
+
- [Main ACL documentation Convolution](https://atcoder.github.io/ac-library/master/document_ja/convolution.html)
|
65
|
+
|
66
|
+
|
67
|
+
Translated with www.DeepL.com/Translator (free version)
|
data/document_en/dsu.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# DSU - Disjoint Set Union
|
2
|
+
|
3
|
+
**alias: Union Find**
|
4
|
+
|
5
|
+
Given an undirected graph, it processes the following queries in `O(α(n))` time (amortized).
|
6
|
+
|
7
|
+
- Edge addition
|
8
|
+
- Deciding whether given two vertices are in the same connected component
|
9
|
+
|
10
|
+
Each connected component internally has a representative vertex.
|
11
|
+
|
12
|
+
When two connected components are merged by edge addition, one of the two representatives of these connected components becomes the representative of the new connected component.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```rb
|
17
|
+
d = DSU.new(5)
|
18
|
+
p d.groups # => [[0], [1], [2], [3], [4]]
|
19
|
+
p d.same?(2, 3) # => false
|
20
|
+
p d.size(2) # => 1
|
21
|
+
|
22
|
+
d.merge(2, 3)
|
23
|
+
p d.groups # => [[0], [1], [2, 3], [4]]
|
24
|
+
p d.same?(2, 3) # => true
|
25
|
+
p d.size(2) # => 2
|
26
|
+
```
|
27
|
+
|
28
|
+
## Class Method
|
29
|
+
|
30
|
+
### new(n = 0) -> DSU
|
31
|
+
|
32
|
+
```rb
|
33
|
+
d = DSU.new(n)
|
34
|
+
```
|
35
|
+
|
36
|
+
It creates an undirected graph with `n` vertices and `0` edges.
|
37
|
+
|
38
|
+
**complexity**
|
39
|
+
|
40
|
+
- `O(n)`
|
41
|
+
|
42
|
+
**alias**
|
43
|
+
|
44
|
+
- `DSU`, `DisjointSetUnion`, `UnionFind`, `UnionFindTree`
|
45
|
+
|
46
|
+
## Instance Methods
|
47
|
+
|
48
|
+
### merge(a, b) -> Integer
|
49
|
+
|
50
|
+
```rb
|
51
|
+
d.merge(a, b)
|
52
|
+
```
|
53
|
+
|
54
|
+
It adds an edge $(a, b)$.
|
55
|
+
|
56
|
+
If the vertices $a$ and $b$ were in the same connected component, it returns the representative of this connected component. Otherwise, it returns the representative of the new connected component.
|
57
|
+
|
58
|
+
**complexity**
|
59
|
+
|
60
|
+
- `O(α(n))` amortized
|
61
|
+
|
62
|
+
**alias**
|
63
|
+
|
64
|
+
- `merge`, `unite`
|
65
|
+
|
66
|
+
### same?(a, b) -> bool
|
67
|
+
|
68
|
+
```rb
|
69
|
+
d.same?(a, b)
|
70
|
+
```
|
71
|
+
|
72
|
+
It returns whether the vertices `a` and `b` are in the same connected component.
|
73
|
+
|
74
|
+
**complexity**
|
75
|
+
|
76
|
+
- `O(α(n))` amortized
|
77
|
+
|
78
|
+
**alias**
|
79
|
+
|
80
|
+
- `same?`, `same`
|
81
|
+
|
82
|
+
### leader(a) -> Integer
|
83
|
+
|
84
|
+
```rb
|
85
|
+
d.leader(a)
|
86
|
+
```
|
87
|
+
|
88
|
+
It returns the representative of the connected component that contains the vertex `a`.
|
89
|
+
|
90
|
+
**complexity**
|
91
|
+
|
92
|
+
- `O(α(n))` amortized
|
93
|
+
|
94
|
+
**alias**
|
95
|
+
|
96
|
+
- `leader`, `root`, `find`
|
97
|
+
|
98
|
+
### size(a) -> Integer
|
99
|
+
|
100
|
+
It returns the size of the connected component that contains the vertex `a`.
|
101
|
+
|
102
|
+
**complexity**
|
103
|
+
|
104
|
+
- `O(α(n))` amortized
|
105
|
+
|
106
|
+
### groups -> Array(Array(Integer))
|
107
|
+
|
108
|
+
```rb
|
109
|
+
d.groups
|
110
|
+
```
|
111
|
+
|
112
|
+
It divides the graph into connected components and returns the list of them.
|
113
|
+
|
114
|
+
More precisely, it returns the list of the "list of the vertices in a connected component". Both of the orders of the connected components and the vertices are undefined.
|
115
|
+
|
116
|
+
|
117
|
+
**complexity**
|
118
|
+
|
119
|
+
- `O(α(n))` amortized
|
120
|
+
|
121
|
+
## Verified
|
122
|
+
|
123
|
+
[A \- Disjoint Set Union](https://atcoder.jp/contests/practice2/tasks/practice2_a)
|
124
|
+
|
125
|
+
## Links & Reference
|
126
|
+
|
127
|
+
- ac-library-rb
|
128
|
+
- [Code dsu.rb](https://github.com/universato/ac-library-rb/blob/master/lib/dsu.rb)
|
129
|
+
- [Test dsu_test.rb](https://github.com/universato/ac-library-rb/blob/master/test/dsu_test.rb)
|
130
|
+
- AtCoder Library
|
131
|
+
- [Document](https://github.com/atcoder/ac-library/blob/master/document_en/dsu.md)
|
132
|
+
- [Code dsu.hpp](https://github.com/atcoder/ac-library/blob/master/atcoder/dsu.hpp)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Fenwick Tree
|
2
|
+
|
3
|
+
**alias: BIT (Binary Indexed Tree)**
|
4
|
+
|
5
|
+
Given an array of length `N`, it processes the following queries in `O(log N)` time.
|
6
|
+
|
7
|
+
- Updating an element
|
8
|
+
- Calculating the sum of the elements of an interval
|
9
|
+
|
10
|
+
## Class Method
|
11
|
+
|
12
|
+
### new(n) -> FenwickTree
|
13
|
+
|
14
|
+
```rb
|
15
|
+
fw = FenwickTree.new(5)
|
16
|
+
```
|
17
|
+
|
18
|
+
It creates an array `a_0, a_1, ...... a_{n-1}` of length `n`. All the elements are initialized to `0`.
|
19
|
+
|
20
|
+
**complexity**
|
21
|
+
|
22
|
+
- `O(n)`
|
23
|
+
|
24
|
+
### new(ary) -> FenwickTree
|
25
|
+
|
26
|
+
```rb
|
27
|
+
fw = FenwickTree.new([1, 3, 2])
|
28
|
+
```
|
29
|
+
|
30
|
+
It creates an array `ary`.
|
31
|
+
|
32
|
+
**complexity**
|
33
|
+
|
34
|
+
- `O(n)`
|
35
|
+
|
36
|
+
## add(pos, x)
|
37
|
+
|
38
|
+
```rb
|
39
|
+
fw.add(pos, x)
|
40
|
+
```
|
41
|
+
|
42
|
+
It processes `a[p] += x`.
|
43
|
+
|
44
|
+
`pos` is zero-based index.
|
45
|
+
|
46
|
+
**constraints**
|
47
|
+
|
48
|
+
- `0 ≦ pos < n`
|
49
|
+
|
50
|
+
**complexity**
|
51
|
+
|
52
|
+
- `O(log n)`
|
53
|
+
|
54
|
+
## sum(l, r) ->Integer
|
55
|
+
|
56
|
+
```rb
|
57
|
+
fw.sum(l, r)
|
58
|
+
```
|
59
|
+
|
60
|
+
It returns `a[l] + a[l + 1] + ... + a[r - 1]`.
|
61
|
+
|
62
|
+
It equals `fw._sum(r) - fw._sum(l)`
|
63
|
+
|
64
|
+
**constraints**
|
65
|
+
|
66
|
+
- `0 ≦ l ≦ r ≦ n`
|
67
|
+
|
68
|
+
**complexity**
|
69
|
+
|
70
|
+
- `O(log n)`
|
71
|
+
|
72
|
+
## _sum(pos) -> Integer
|
73
|
+
|
74
|
+
```rb
|
75
|
+
fw._sum(pos)
|
76
|
+
```
|
77
|
+
|
78
|
+
It returns `a[0] + a[1] + ... + a[pos - 1]`.
|
79
|
+
|
80
|
+
**complexity**
|
81
|
+
|
82
|
+
- `O(logn)`
|
83
|
+
|
84
|
+
## Verified
|
85
|
+
|
86
|
+
- [AtCoder ALPC B \- Fenwick Tree](https://atcoder.jp/contests/practice2/tasks/practice2_b)
|
87
|
+
- [AC Code(1272ms)](https://atcoder.jp/contests/practice2/submissions/17074108)
|
88
|
+
- [F \- Range Xor Query](https://atcoder.jp/contests/abc185/tasks/abc185_f)
|
89
|
+
- [AC Code(821ms)](https://atcoder.jp/contests/abc185/submissions/18769200)
|
90
|
+
|
91
|
+
|
92
|
+
## Link
|
93
|
+
|
94
|
+
- ac-library-rb
|
95
|
+
- [Code dsu.rb](https://github.com/universato/ac-library-rb/blob/master/lib/dsu.rb)
|
96
|
+
- [Test dsu_test.rb](https://github.com/universato/ac-library-rb/blob/master/test/dsu_test.rb)
|
97
|
+
- AtCoder
|
98
|
+
- [fenwicktree.html](https://atcoder.github.io/ac-library/document_en/fenwicktree.html)
|
99
|
+
- [Code fenwick.hpp](https://github.com/atcoder/ac-library/blob/master/atcoder/fenwick.hpp)
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# index
|
2
|
+
|
3
|
+
| C | D | |
|
4
|
+
| :--- | :--- | --- |
|
5
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/fenwick_tree.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/fenwick_tree.md) |FenwickTree(BIT)|
|
6
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/segtree.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/segtree.md) |Segtree|
|
7
|
+
| [○](https://github.com/universato/ac-library-rb/blob/master/lib/lazy_segtree.rb) | [○G](https://github.com/universato/ac-library-rb/blob/master/document_ja/lazy_segtree.md) |LazySegtree|
|
8
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/priority_queue.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/priority_queue.md) |PriorityQueue|
|
9
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/suffix_array.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/string.md) |suffix_array|
|
10
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/lcp_array.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/string.md) |lcp_array|
|
11
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/z_algorithm.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/string.md) |z_algorithm|
|
12
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/pow_mod.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/math.md) |pow_mod|
|
13
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/inv_mod.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/math.md) |inv_mod|
|
14
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/crt.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/math.md) |crt(Chinese remainder theorem)|
|
15
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/floor_sum.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/math.md) |floor_sum|
|
16
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/convolution.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/convolution.md) |convolution|
|
17
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/modint.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/modint.md) |ModInt|
|
18
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/dsu.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/dsu.md) |DSU(UnionFind)|
|
19
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/max_flow.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/max_flow.md) |MaxFlow|
|
20
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/min_cost_flow.rb) |[◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/min_cost_flow.md) |MinCostFlow|
|
21
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/scc.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/scc.md) |SCC (Strongly Connected Component)|
|
22
|
+
| [◎](https://github.com/universato/ac-library-rb/blob/master/lib/two_sat.rb) | [◎G](https://github.com/universato/ac-library-rb/blob/master/document_ja/two_sat.md) |TwoSat|
|
23
|
+
|
24
|
+
## Link to Code on GitHub
|
25
|
+
|
26
|
+
### Data structure
|
27
|
+
|
28
|
+
- [fenwick_tree.rb](https://github.com/universato/ac-library-rb/blob/master/lib/fenwick_tree.rb)
|
29
|
+
- [segtree.rb](https://github.com/universato/ac-library-rb/blob/master/lib/segtree.rb)
|
30
|
+
- [lazy_segtree.rb](https://github.com/universato/ac-library-rb/blob/master/lib/lazy_segtree.rb)
|
31
|
+
- [priority_queue.rb](https://github.com/universato/ac-library-rb/blob/master/lib/priority_queue.rb)
|
32
|
+
- String
|
33
|
+
- [suffix_array.rb](https://github.com/universato/ac-library-rb/blob/master/lib/suffix_array.rb)
|
34
|
+
- [lcp_array.rb](https://github.com/universato/ac-library-rb/blob/master/lib/lcp_array.rb)
|
35
|
+
- [z_algorithm.rb](https://github.com/universato/ac-library-rb/blob/master/lib/z_algorithm.rb)
|
36
|
+
|
37
|
+
### Math
|
38
|
+
|
39
|
+
- math
|
40
|
+
- [pow_mod.rb](https://github.com/universato/ac-library-rb/blob/master/lib/pow_mod.rb)
|
41
|
+
- [inv_mod.rb](https://github.com/universato/ac-library-rb/blob/master/lib/inv_mod.rb)
|
42
|
+
- [crt.rb](https://github.com/universato/ac-library-rb/blob/master/lib/crt.rb)
|
43
|
+
- [floor_sum.rb](https://github.com/universato/ac-library-rb/blob/master/lib/floor_sum.rb)
|
44
|
+
- [convolution.rb](https://github.com/universato/ac-library-rb/blob/master/lib/convolution.rb)
|
45
|
+
- [modint.rb](https://github.com/universato/ac-library-rb/blob/master/lib/modint.rb)
|
46
|
+
|
47
|
+
### Graph
|
48
|
+
|
49
|
+
- [dsu.rb](https://github.com/universato/ac-library-rb/blob/master/lib/dsu.rb)
|
50
|
+
- [max_flow.rb](https://github.com/universato/ac-library-rb/blob/master/lib/max_flow.rb)
|
51
|
+
- [min_cost_flow.rb](https://github.com/universato/ac-library-rb/blob/master/lib/min_cost_flow.rb)
|
52
|
+
- [scc.rb](https://github.com/universato/ac-library-rb/blob/master/lib/scc.rb)
|
53
|
+
- [two_sat.rb](https://github.com/universato/ac-library-rb/blob/master/lib/two_sat.rb)
|
54
|
+
|
55
|
+
## Alphabet Order Index
|
56
|
+
|
57
|
+
<details>
|
58
|
+
<summary>Alphabet Order Index</summary>
|
59
|
+
|
60
|
+
[convolution.rb](https://github.com/universato/ac-library-rb/blob/master/lib/convolution.rb)
|
61
|
+
[crt.rb](https://github.com/universato/ac-library-rb/blob/master/lib/crt.rb)
|
62
|
+
[dsu.rb](https://github.com/universato/ac-library-rb/blob/master/lib/dsu.rb)
|
63
|
+
[fenwick_tree.rb](https://github.com/universato/ac-library-rb/blob/master/lib/fenwick_tree.rb)
|
64
|
+
[floor_sum.rb](https://github.com/universato/ac-library-rb/blob/master/lib/floor_sum..rb)
|
65
|
+
[inv_mod.rb](https://github.com/universato/ac-library-rb/blob/master/lib/inv_mod.rb)
|
66
|
+
[lazy_segtree.rb](https://github.com/universato/ac-library-rb/blob/master/lib/lazy_segtree.rb)
|
67
|
+
[lcp_array.rb](https://github.com/universato/ac-library-rb/blob/master/lib/lcp_array.rb)
|
68
|
+
[max_flow.rb](https://github.com/universato/ac-library-rb/blob/master/lib/max_flow.rb)
|
69
|
+
[min_cost_flow.rb](https://github.com/universato/ac-library-rb/blob/master/lib/min_cost_flow.rb)
|
70
|
+
[modint.rb](https://github.com/universato/ac-library-rb/blob/master/lib/modint.rb)
|
71
|
+
[pow_mod.rb](https://github.com/universato/ac-library-rb/blob/master/lib/pow_mod.rb)
|
72
|
+
[priority_queue.rb](https://github.com/universato/ac-library-rb/blob/master/lib/priority_queue.rb)
|
73
|
+
[scc.rb](https://github.com/universato/ac-library-rb/blob/master/lib/scc.rb)
|
74
|
+
[segtree.rb](https://github.com/universato/ac-library-rb/blob/master/lib/segtree.rb)
|
75
|
+
[suffix_array.rb](https://github.com/universato/ac-library-rb/blob/master/lib/suffix_array.rb)
|
76
|
+
[two_sat.rb](https://github.com/universato/ac-library-rb/blob/master/lib/two_sat.rb)
|
77
|
+
[z_algorithm.rb](https://github.com/universato/ac-library-rb/blob/master/lib/z_algorithm.rb)
|
78
|
+
|
79
|
+
</details>
|