ac-library-rb 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f191f90563fea038c7181e2bf9d13e1dc8caa0e816a364176e46b67c8d63f471
4
- data.tar.gz: c89db082816046146cb60faa3747e046877394bfff776a3defe8063fb2d1c390
3
+ metadata.gz: 7f7674ea5a0a95f6cad7945415632a06bf91a515cde31d1c08320d5e9561fc0e
4
+ data.tar.gz: d6bb650ec23b99f6180f5e8413644863dae78c7923d79249bcadcb9a8a1fcaa0
5
5
  SHA512:
6
- metadata.gz: '0114099d09f9566741d84ed2b5e43427b62592bb8b2a6b90d25b9f68288d2a387f34899351d18a7b3e0c93ec72af9cae4aac2f1d38f5fe517e30ec850e33429e'
7
- data.tar.gz: cdb1eac1808855f86c00c991b4c66ae3489035420ef0fdb8c88915712ace8faa5db02da074a78734e0c4235058ac1e2a62a0fc9cc0523e6c85aff4617b47ae39
6
+ metadata.gz: d549b2be1fa15a519b8e1d692bbbd03ccd6c0f0b2d94787dbdc48c44ce9274c92ed5e7d6148c195ef73a545ba9951a64f74e84f39eed62e6c12a2eaaf386fcb9
7
+ data.tar.gz: 5f2b39beb3aacb21ac0fec142b550baf20b6343ed4fabce3ca303d8466bd632af71ce33d911b6a0494425234afa928949d33a670d490a91f9f5441c535586ae4
@@ -1,3 +1,3 @@
1
1
  module AcLibraryRb
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.6.1".freeze
3
3
  end
data/lib/crt.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # return [rem, mod] or [0, 0] (if no solution)
2
2
  def crt(r, m)
3
- raise ArgumentError if r.size != m.size
3
+ unless r.size == m.size
4
+ raise ArgumentError.new("size of r and m must be equal for crt(r, m)")
5
+ end
4
6
 
5
7
  n = r.size
6
8
  r0, m0 = 0, 1
data/lib/dsu.rb CHANGED
@@ -20,10 +20,10 @@ class DSU
20
20
  end
21
21
  alias unite merge
22
22
 
23
- def same(a, b)
23
+ def same?(a, b)
24
24
  leader(a) == leader(b)
25
25
  end
26
- alias same? same
26
+ alias same same?
27
27
 
28
28
  def leader(a)
29
29
  unless 0 <= a && a < @n
data/lib/fenwick_tree.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  class FenwickTree
3
3
  attr_reader :data, :size
4
4
 
5
- def initialize(arg = nil)
5
+ def initialize(arg)
6
6
  case arg
7
7
  when Array
8
8
  @size = arg.size
data/lib/two_sat.rb CHANGED
@@ -13,7 +13,7 @@ class TwoSAT
13
13
 
14
14
  def add_clause(i, f, j, g)
15
15
  unless 0 <= i && i < @n and 0 <= j && j < @n
16
- raise RangeError.new
16
+ raise ArgumentError.new("i:#{i} and j:#{j} must be in (0...#{@n})")
17
17
  end
18
18
 
19
19
  @scc.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0))
@@ -21,7 +21,7 @@ class TwoSAT
21
21
  nil
22
22
  end
23
23
 
24
- def satisfiable
24
+ def satisfiable?
25
25
  id = @scc.send(:scc_ids)[1]
26
26
  @n.times do |i|
27
27
  return false if id[2 * i] == id[2 * i + 1]
@@ -30,7 +30,7 @@ class TwoSAT
30
30
  end
31
31
  true
32
32
  end
33
- alias satisfiable? satisfiable
33
+ alias satisfiable satisfiable?
34
34
  end
35
35
 
36
36
  TwoSat = TwoSAT
@@ -0,0 +1,24 @@
1
+ module AcLibraryRb
2
+ end
3
+ include AcLibraryRb
4
+
5
+ require_relative '../lib_lock/ac-library-rb/core_ext/all.rb'
6
+
7
+ require_relative '../lib_lock/ac-library-rb/convolution'
8
+ require_relative '../lib_lock/ac-library-rb/crt'
9
+ require_relative '../lib_lock/ac-library-rb/dsu'
10
+ require_relative '../lib_lock/ac-library-rb/fenwick_tree'
11
+ require_relative '../lib_lock/ac-library-rb/floor_sum'
12
+ require_relative '../lib_lock/ac-library-rb/inv_mod'
13
+ require_relative '../lib_lock/ac-library-rb/lazy_segtree'
14
+ require_relative '../lib_lock/ac-library-rb/lcp_array'
15
+ require_relative '../lib_lock/ac-library-rb/max_flow'
16
+ require_relative '../lib_lock/ac-library-rb/min_cost_flow'
17
+ require_relative '../lib_lock/ac-library-rb/modint'
18
+ require_relative '../lib_lock/ac-library-rb/pow_mod'
19
+ require_relative '../lib_lock/ac-library-rb/priority_queue'
20
+ require_relative '../lib_lock/ac-library-rb/scc'
21
+ require_relative '../lib_lock/ac-library-rb/segtree'
22
+ require_relative '../lib_lock/ac-library-rb/suffix_array'
23
+ require_relative '../lib_lock/ac-library-rb/two_sat'
24
+ require_relative '../lib_lock/ac-library-rb/z_algorithm'
@@ -1,7 +1,9 @@
1
1
  module AcLibraryRb
2
2
  # return [rem, mod] or [0, 0] (if no solution)
3
3
  def crt(r, m)
4
- raise ArgumentError if r.size != m.size
4
+ unless r.size == m.size
5
+ raise ArgumentError.new("size of r and m must be equal for crt(r, m)")
6
+ end
5
7
 
6
8
  n = r.size
7
9
  r0, m0 = 0, 1
@@ -21,10 +21,10 @@ module AcLibraryRb
21
21
  end
22
22
  alias unite merge
23
23
 
24
- def same(a, b)
24
+ def same?(a, b)
25
25
  leader(a) == leader(b)
26
26
  end
27
- alias same? same
27
+ alias same same?
28
28
 
29
29
  def leader(a)
30
30
  unless 0 <= a && a < @n
@@ -3,7 +3,7 @@ module AcLibraryRb
3
3
  class FenwickTree
4
4
  attr_reader :data, :size
5
5
 
6
- def initialize(arg = nil)
6
+ def initialize(arg)
7
7
  case arg
8
8
  when Array
9
9
  @size = arg.size
@@ -14,7 +14,7 @@ module AcLibraryRb
14
14
 
15
15
  def add_clause(i, f, j, g)
16
16
  unless 0 <= i && i < @n and 0 <= j && j < @n
17
- raise RangeError.new
17
+ raise ArgumentError.new("i:#{i} and j:#{j} must be in (0...#{@n})")
18
18
  end
19
19
 
20
20
  @scc.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0))
@@ -22,7 +22,7 @@ module AcLibraryRb
22
22
  nil
23
23
  end
24
24
 
25
- def satisfiable
25
+ def satisfiable?
26
26
  id = @scc.send(:scc_ids)[1]
27
27
  @n.times do |i|
28
28
  return false if id[2 * i] == id[2 * i + 1]
@@ -31,7 +31,7 @@ module AcLibraryRb
31
31
  end
32
32
  true
33
33
  end
34
- alias satisfiable? satisfiable
34
+ alias satisfiable satisfiable?
35
35
  end
36
36
 
37
37
  TwoSat = TwoSAT
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ac-library-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - universato
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -123,8 +123,8 @@ files:
123
123
  - lib/suffix_array.rb
124
124
  - lib/two_sat.rb
125
125
  - lib/z_algorithm.rb
126
+ - lib_helpers/ac-library-rb.rb
126
127
  - lib_helpers/ac-library-rb/all.rb
127
- - lib_lock/ac-library-rb.rb
128
128
  - lib_lock/ac-library-rb/convolution.rb
129
129
  - lib_lock/ac-library-rb/core_ext/all.rb
130
130
  - lib_lock/ac-library-rb/core_ext/modint.rb
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.2.15
170
+ rubygems_version: 3.2.22
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: ac-library-rb is a ruby port of AtCoder Library (ACL).
@@ -1,24 +0,0 @@
1
- module AcLibraryRb
2
- end
3
- include AcLibraryRb
4
-
5
- require_relative './lib_lock/ac-library-rb/all.rb'
6
-
7
- require_relative './ac-library-rb/convolution'
8
- require_relative './ac-library-rb/crt'
9
- require_relative './ac-library-rb/dsu'
10
- require_relative './ac-library-rb/fenwick_tree'
11
- require_relative './ac-library-rb/floor_sum'
12
- require_relative './ac-library-rb/inv_mod'
13
- require_relative './ac-library-rb/lazy_segtree'
14
- require_relative './ac-library-rb/lcp_array'
15
- require_relative './ac-library-rb/max_flow'
16
- require_relative './ac-library-rb/min_cost_flow'
17
- require_relative './ac-library-rb/modint'
18
- require_relative './ac-library-rb/pow_mod'
19
- require_relative './ac-library-rb/priority_queue'
20
- require_relative './ac-library-rb/scc'
21
- require_relative './ac-library-rb/segtree'
22
- require_relative './ac-library-rb/suffix_array'
23
- require_relative './ac-library-rb/two_sat'
24
- require_relative './ac-library-rb/z_algorithm'