ac-library-rb 0.6.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.github/workflows/unittest.yml +16 -3
 - data/.rubocop.yml +61 -45
 - data/README.ja.md +36 -8
 - data/README.md +7 -4
 - data/Rakefile +7 -3
 - data/ac-library-rb.gemspec +11 -4
 - data/ac-library-rb_header.jpg +0 -0
 - data/bin/console +1 -1
 - data/document_en/dsu.md +1 -1
 - data/document_en/fenwick_tree.md +2 -2
 - data/document_en/lazy_segtree.md +4 -4
 - data/document_en/math.md +3 -3
 - data/document_en/max_flow.md +3 -3
 - data/document_en/min_cost_flow.md +4 -4
 - data/document_en/modint.md +4 -4
 - data/document_en/scc.md +67 -0
 - data/document_en/segtree.md +2 -2
 - data/document_ja/dsu.md +1 -1
 - data/document_ja/fenwick_tree.md +2 -2
 - data/document_ja/lazy_segtree.md +2 -2
 - data/document_ja/math.md +3 -3
 - data/document_ja/max_flow.md +4 -7
 - data/document_ja/min_cost_flow.md +5 -4
 - data/document_ja/modint.md +4 -4
 - data/document_ja/scc.md +9 -8
 - data/document_ja/segtree.md +2 -2
 - data/lib/ac-library-rb/version.rb +1 -1
 - data/lib/convolution.rb +1 -1
 - data/lib/dsu.rb +14 -1
 - data/lib/fenwick_tree.rb +4 -0
 - data/lib/lazy_segtree.rb +2 -6
 - data/lib/max_flow.rb +27 -26
 - data/lib/modint.rb +4 -4
 - data/lib/priority_queue.rb +14 -0
 - data/lib/scc.rb +43 -41
 - data/lib/two_sat.rb +1 -1
 - data/lib_lock/ac-library-rb/convolution.rb +1 -1
 - data/lib_lock/ac-library-rb/dsu.rb +14 -1
 - data/lib_lock/ac-library-rb/fenwick_tree.rb +4 -0
 - data/lib_lock/ac-library-rb/lazy_segtree.rb +2 -6
 - data/lib_lock/ac-library-rb/max_flow.rb +27 -26
 - data/lib_lock/ac-library-rb/modint.rb +4 -4
 - data/lib_lock/ac-library-rb/priority_queue.rb +14 -0
 - data/lib_lock/ac-library-rb/scc.rb +43 -41
 - data/lib_lock/ac-library-rb/two_sat.rb +1 -1
 - metadata +39 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 22006092d0cd212252ead6bc78fa5e37c6561f2fc9117d2bb92c9bc35d9652b2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8ffdfae56a8b4065ae0698d1a99082554cddc63793847f526ce1b97b56dce7e5
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7786082b3706d8f4381e544d506e55fbc846621c34c91342b6248110a9d6310eff38e6f2d5d2d3230d10580a331439a4e027af2b43e0bdb38f9f150695df759f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3dfc4a42e293c08699c9e8926114ee757f1b501988672a862760545d155d91632985d36a10e0b0fd8a3aa654f68fb975baccccb37cb09d0c6313e82748ee6898
         
     | 
| 
         @@ -1,16 +1,29 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            name: Unittest
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            on: 
     | 
| 
      
 3 
     | 
    
         
            +
            on:
         
     | 
| 
      
 4 
     | 
    
         
            +
              push:
         
     | 
| 
      
 5 
     | 
    
         
            +
                paths-ignore:
         
     | 
| 
      
 6 
     | 
    
         
            +
                  - 'document_*/**/*'
         
     | 
| 
      
 7 
     | 
    
         
            +
                  - 'README.*'
         
     | 
| 
      
 8 
     | 
    
         
            +
              pull_request:
         
     | 
| 
      
 9 
     | 
    
         
            +
                paths-ignore:
         
     | 
| 
      
 10 
     | 
    
         
            +
                  - 'document_*/**/*'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  - 'README.*'
         
     | 
| 
       4 
12 
     | 
    
         
             
            jobs:
         
     | 
| 
       5 
13 
     | 
    
         
             
              unittest:
         
     | 
| 
       6 
14 
     | 
    
         
             
                runs-on: ${{ matrix.os }}
         
     | 
| 
       7 
15 
     | 
    
         
             
                strategy:
         
     | 
| 
       8 
16 
     | 
    
         
             
                  matrix:
         
     | 
| 
       9 
17 
     | 
    
         
             
                    os: [macos-latest, ubuntu-latest, windows-latest]
         
     | 
| 
      
 18 
     | 
    
         
            +
                    ruby: [2.7, 3.1]
         
     | 
| 
       10 
19 
     | 
    
         
             
                steps:
         
     | 
| 
       11 
20 
     | 
    
         
             
                  - uses: actions/checkout@v2
         
     | 
| 
       12 
21 
     | 
    
         
             
                  - uses: ruby/setup-ruby@v1
         
     | 
| 
       13 
22 
     | 
    
         
             
                    with:
         
     | 
| 
       14 
     | 
    
         
            -
                      ruby-version:  
     | 
| 
      
 23 
     | 
    
         
            +
                      ruby-version: ${{ matrix.ruby }}
         
     | 
| 
      
 24 
     | 
    
         
            +
                  - name: insall by bundler
         
     | 
| 
      
 25 
     | 
    
         
            +
                    run: bundle install
         
     | 
| 
       15 
26 
     | 
    
         
             
                  - name: run unittests
         
     | 
| 
       16 
     | 
    
         
            -
                    run: ruby test/*.rb
         
     | 
| 
      
 27 
     | 
    
         
            +
                    run: bundle exec ruby test/*.rb
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - name: Upload coverage to Codecov
         
     | 
| 
      
 29 
     | 
    
         
            +
                    uses: codecov/codecov-action@v3
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    | 
         @@ -1,15 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            AllCops:
         
     | 
| 
       2 
2 
     | 
    
         
             
              NewCops: enable
         
     | 
| 
      
 3 
     | 
    
         
            +
              TargetRubyVersion: 2.7
         
     | 
| 
       3 
4 
     | 
    
         
             
              Exclude:
         
     | 
| 
       4 
5 
     | 
    
         
             
                - 'lib_lock/ac-library-rb/*.rb'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Layout
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       5 
9 
     | 
    
         
             
            Layout/ExtraSpacing:
         
     | 
| 
       6 
10 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       7 
11 
     | 
    
         
             
              Exclude:
         
     | 
| 
       8 
12 
     | 
    
         
             
                - 'ac-library-rb.gemspec'
         
     | 
| 
       9 
13 
     | 
    
         
             
                - 'test/convolution_test.rb'
         
     | 
| 
       10 
     | 
    
         
            -
            Layout/LineLength:
         
     | 
| 
       11 
     | 
    
         
            -
              Exclude:
         
     | 
| 
       12 
     | 
    
         
            -
                - 'ac-library-rb.gemspec'
         
     | 
| 
       13 
14 
     | 
    
         
             
            Layout/SpaceAroundOperators:
         
     | 
| 
       14 
15 
     | 
    
         
             
              Exclude:
         
     | 
| 
       15 
16 
     | 
    
         
             
                - 'ac-library-rb.gemspec'
         
     | 
| 
         @@ -21,6 +22,9 @@ Layout/SpaceInsideArrayLiteralBrackets: 
     | 
|
| 
       21 
22 
     | 
    
         
             
                - 'test/convolution_test.rb'
         
     | 
| 
       22 
23 
     | 
    
         
             
            Layout/SpaceInsideRangeLiteral:
         
     | 
| 
       23 
24 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ## Lint
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       24 
28 
     | 
    
         
             
            Lint/AmbiguousOperator:
         
     | 
| 
       25 
29 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       26 
30 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -29,8 +33,27 @@ Lint/AmbiguousOperator: 
     | 
|
| 
       29 
33 
     | 
    
         
             
            Lint/AmbiguousBlockAssociation:
         
     | 
| 
       30 
34 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       31 
35 
     | 
    
         
             
              Exclude:
         
     | 
| 
      
 36 
     | 
    
         
            +
                - 'bin/lock_lib.rb'
         
     | 
| 
       32 
37 
     | 
    
         
             
                - 'test/convolution_test.rb'
         
     | 
| 
       33 
38 
     | 
    
         
             
                - 'test/crt_test.rb'
         
     | 
| 
      
 39 
     | 
    
         
            +
            Lint/AmbiguousOperatorPrecedence:
         
     | 
| 
      
 40 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 41 
     | 
    
         
            +
            Lint/AmbiguousRegexpLiteral:
         
     | 
| 
      
 42 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 43 
     | 
    
         
            +
                - 'test/priority_queue_test.rb'
         
     | 
| 
      
 44 
     | 
    
         
            +
            Lint/AmbiguousRange:
         
     | 
| 
      
 45 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 46 
     | 
    
         
            +
                - 'lib/convolution.rb'
         
     | 
| 
      
 47 
     | 
    
         
            +
                - 'test/convolution_test.rb'
         
     | 
| 
      
 48 
     | 
    
         
            +
                - 'test/crt_test.rb'
         
     | 
| 
      
 49 
     | 
    
         
            +
                - 'test/lcp_array_test.rb'
         
     | 
| 
      
 50 
     | 
    
         
            +
                - 'test/suffix_array_test.rb'
         
     | 
| 
      
 51 
     | 
    
         
            +
                - 'test/z_algorithm_test.rb'
         
     | 
| 
      
 52 
     | 
    
         
            +
            Lint/AssignmentInCondition:
         
     | 
| 
      
 53 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 54 
     | 
    
         
            +
                - 'lib/fenwick_tree.rb'
         
     | 
| 
      
 55 
     | 
    
         
            +
                - 'lib/lazy_segtree.rb'
         
     | 
| 
      
 56 
     | 
    
         
            +
                - 'lib/segtree.rb'
         
     | 
| 
       34 
57 
     | 
    
         
             
            Lint/BinaryOperatorWithIdenticalOperands:
         
     | 
| 
       35 
58 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       36 
59 
     | 
    
         
             
            Lint/MissingSuper:
         
     | 
| 
         @@ -52,42 +75,23 @@ Lint/ShadowingOuterLocalVariable: 
     | 
|
| 
       52 
75 
     | 
    
         
             
                - 'test/crt_test.rb'
         
     | 
| 
       53 
76 
     | 
    
         
             
                - 'test/lcp_array_test.rb'
         
     | 
| 
       54 
77 
     | 
    
         
             
                - 'test/example/suffix_array_and_lcp_array_practice.rb'
         
     | 
| 
       55 
     | 
    
         
            -
            Lint/UnderscorePrefixedVariableName:
         
     | 
| 
       56 
     | 
    
         
            -
              AutoCorrect: false
         
     | 
| 
       57 
     | 
    
         
            -
              Exclude:
         
     | 
| 
       58 
     | 
    
         
            -
                - 'lib/max_flow.rb'
         
     | 
| 
       59 
78 
     | 
    
         
             
            Lint/Void:
         
     | 
| 
       60 
79 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       61 
80 
     | 
    
         
             
              Exclude:
         
     | 
| 
       62 
81 
     | 
    
         
             
                - 'test/example/*'
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                - 'lib/max_flow.rb'
         
     | 
| 
       74 
     | 
    
         
            -
            Metrics/ClassLength:
         
     | 
| 
       75 
     | 
    
         
            -
              Max: 334
         
     | 
| 
       76 
     | 
    
         
            -
            Metrics/CyclomaticComplexity:
         
     | 
| 
       77 
     | 
    
         
            -
              Max: 13
         
     | 
| 
       78 
     | 
    
         
            -
              Exclude:
         
     | 
| 
       79 
     | 
    
         
            -
                - 'lib/suffix_array.rb'
         
     | 
| 
       80 
     | 
    
         
            -
            Metrics/MethodLength:
         
     | 
| 
       81 
     | 
    
         
            -
              Max: 120
         
     | 
| 
       82 
     | 
    
         
            -
            Metrics/ParameterLists:
         
     | 
| 
       83 
     | 
    
         
            -
              Exclude:
         
     | 
| 
       84 
     | 
    
         
            -
                - 'lib/lazy_segtree.rb'
         
     | 
| 
       85 
     | 
    
         
            -
            Metrics/PerceivedComplexity:
         
     | 
| 
       86 
     | 
    
         
            -
              Max: 13
         
     | 
| 
       87 
     | 
    
         
            -
              Exclude:
         
     | 
| 
       88 
     | 
    
         
            -
                - 'lib/suffix_array.rb'
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            ## Metrics
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            Metrics:
         
     | 
| 
      
 87 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            ## Naming
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
       89 
92 
     | 
    
         
             
            Naming/FileName:
         
     | 
| 
       90 
93 
     | 
    
         
             
              Exclude:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - 'lib_helpers/ac-library-rb.rb'
         
     | 
| 
       91 
95 
     | 
    
         
             
                - 'lib_lock/ac-library-rb.rb'
         
     | 
| 
       92 
96 
     | 
    
         
             
            Naming/AccessorMethodName:
         
     | 
| 
       93 
97 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -104,10 +108,11 @@ Naming/MethodParameterName: 
     | 
|
| 
       104 
108 
     | 
    
         
             
            Naming/VariableNumber:
         
     | 
| 
       105 
109 
     | 
    
         
             
              Exclude:
         
     | 
| 
       106 
110 
     | 
    
         
             
                - 'test/max_flow_test.rb'
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
                - 'test/scc_test.rb'
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            ## Style
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
       111 
116 
     | 
    
         
             
            Style/BlockDelimiters:
         
     | 
| 
       112 
117 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       113 
118 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -121,9 +126,14 @@ Style/BlockDelimiters: 
     | 
|
| 
       121 
126 
     | 
    
         
             
                - 'test/z_algorithm_test.rb'
         
     | 
| 
       122 
127 
     | 
    
         
             
            Style/Documentation:
         
     | 
| 
       123 
128 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
      
 129 
     | 
    
         
            +
            Style/EachForSimpleLoop:
         
     | 
| 
      
 130 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 131 
     | 
    
         
            +
            Style/EmptyElse:
         
     | 
| 
       125 
132 
     | 
    
         
             
              Exclude:
         
     | 
| 
       126 
133 
     | 
    
         
             
                - 'test/segtree_test.rb'
         
     | 
| 
      
 134 
     | 
    
         
            +
            Style/FormatString:
         
     | 
| 
      
 135 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 136 
     | 
    
         
            +
                - 'lib/convolution.rb'
         
     | 
| 
       127 
137 
     | 
    
         
             
            Style/GlobalVars:
         
     | 
| 
       128 
138 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       129 
139 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -131,6 +141,16 @@ Style/GlobalVars: 
     | 
|
| 
       131 
141 
     | 
    
         
             
                - 'test/lazy_segtree_test.rb'
         
     | 
| 
       132 
142 
     | 
    
         
             
            Style/FrozenStringLiteralComment:
         
     | 
| 
       133 
143 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 144 
     | 
    
         
            +
            Style/GuardClause:
         
     | 
| 
      
 145 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 146 
     | 
    
         
            +
                - 'lib/lazy_segtree.rb'
         
     | 
| 
      
 147 
     | 
    
         
            +
            Style/IdenticalConditionalBranches:
         
     | 
| 
      
 148 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 149 
     | 
    
         
            +
            Style/IfUnlessModifier:
         
     | 
| 
      
 150 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 151 
     | 
    
         
            +
                - 'lib/crt.rb'
         
     | 
| 
      
 152 
     | 
    
         
            +
                - 'lib/dsu.rb'
         
     | 
| 
      
 153 
     | 
    
         
            +
                - 'lib/two_sat.rb'
         
     | 
| 
       134 
154 
     | 
    
         
             
            Style/InfiniteLoop:
         
     | 
| 
       135 
155 
     | 
    
         
             
              Exclude:
         
     | 
| 
       136 
156 
     | 
    
         
             
                - 'lib/floor_sum.rb'
         
     | 
| 
         @@ -147,7 +167,7 @@ Style/HashSyntax: 
     | 
|
| 
       147 
167 
     | 
    
         
             
                - 'Rakefile'
         
     | 
| 
       148 
168 
     | 
    
         
             
            Style/MixinUsage:
         
     | 
| 
       149 
169 
     | 
    
         
             
              Exclude:
         
     | 
| 
       150 
     | 
    
         
            -
                - ' 
     | 
| 
      
 170 
     | 
    
         
            +
                - 'lib_helpers/ac-library-rb.rb'
         
     | 
| 
       151 
171 
     | 
    
         
             
            Style/MultipleComparison:
         
     | 
| 
       152 
172 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       153 
173 
     | 
    
         
             
            Style/NegatedIf:
         
     | 
| 
         @@ -168,6 +188,8 @@ Style/ParallelAssignment: 
     | 
|
| 
       168 
188 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       169 
189 
     | 
    
         
             
            Style/RedundantFileExtensionInRequire:
         
     | 
| 
       170 
190 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 191 
     | 
    
         
            +
            Style/RaiseArgs:
         
     | 
| 
      
 192 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
       171 
193 
     | 
    
         
             
            Style/RedundantReturn:
         
     | 
| 
       172 
194 
     | 
    
         
             
              AutoCorrect: false
         
     | 
| 
       173 
195 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -200,11 +222,5 @@ Style/StringConcatenation: 
     | 
|
| 
       200 
222 
     | 
    
         
             
                - 'bin/lock_lib.rb'
         
     | 
| 
       201 
223 
     | 
    
         
             
            Style/StringLiterals:
         
     | 
| 
       202 
224 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       203 
     | 
    
         
            -
            Style/TrailingCommaInArrayLiteral:
         
     | 
| 
       204 
     | 
    
         
            -
              Enabled: false
         
     | 
| 
       205 
     | 
    
         
            -
            Style/WordArray:
         
     | 
| 
       206 
     | 
    
         
            -
              Enabled: false
         
     | 
| 
       207 
     | 
    
         
            -
            Style/WhileUntilModifier:
         
     | 
| 
       208 
     | 
    
         
            -
              Enabled: false
         
     | 
| 
       209 
225 
     | 
    
         
             
            Style/YodaCondition:
         
     | 
| 
       210 
226 
     | 
    
         
             
              Enabled: false
         
     | 
    
        data/README.ja.md
    CHANGED
    
    | 
         @@ -1,6 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ### Other language English version(英語バージョン)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            This file is for Japanese to read.  
         
     | 
| 
      
 4 
     | 
    
         
            +
            The following files are written in English: (英語で読みたい方は次のファイルを)
         
     | 
| 
      
 5 
     | 
    
         
            +
            - [README.md (ver. English)](README.md)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       1 
7 
     | 
    
         
             
            # ac-library-rb
         
     | 
| 
       2 
8 
     | 
    
         | 
| 
       3 
9 
     | 
    
         
             
            [](https://badge.fury.io/rb/ac-library-rb)
         
     | 
| 
      
 10 
     | 
    
         
            +
            [](https://codecov.io/gh/universato/ac-library-rb)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            <img width="560" src="ac-library-rb_header.jpg" alt="ac-library-rb Logo">
         
     | 
| 
       4 
13 
     | 
    
         | 
| 
       5 
14 
     | 
    
         
             
            ac-library-rbは、AtCoder Library (ACL)のRuby版です。
         
     | 
| 
       6 
15 
     | 
    
         | 
| 
         @@ -50,7 +59,7 @@ bundlerをインストールしてない場合は、`gem install bundler`とい 
     | 
|
| 
       50 
59 
     | 
    
         | 
| 
       51 
60 
     | 
    
         
             
            次に、ac-library-rbを使いたいディレクトリ配下にGemfileを置きます。Gemfileという名称のファイルです。  
         
     | 
| 
       52 
61 
     | 
    
         
             
            このGemfileの中で、次のように書きます。
         
     | 
| 
       53 
     | 
    
         
            -
            ```
         
     | 
| 
      
 62 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       54 
63 
     | 
    
         
             
            gem "ac-library-rb"
         
     | 
| 
       55 
64 
     | 
    
         
             
            ```
         
     | 
| 
       56 
65 
     | 
    
         
             
            そして、`budnle install`というコマンドにより、Gemfileに書かれたac-library-rbをインストールします。
         
     | 
| 
         @@ -104,7 +113,7 @@ ACL本家のレポジトリ名がac-libraryとハイフン区切りで、それ 
     | 
|
| 
       104 
113 
     | 
    
         | 
| 
       105 
114 
     | 
    
         
             
            現在、AtCoderのRubyバージョンは、2.7.1です。
         
     | 
| 
       106 
115 
     | 
    
         | 
| 
       107 
     | 
    
         
            -
            そのため、2.7.1 
     | 
| 
      
 116 
     | 
    
         
            +
            そのため、2.7と最新の3.1でテストをしています。
         
     | 
| 
       108 
117 
     | 
    
         | 
| 
       109 
118 
     | 
    
         
             
            ただ、開発される方は2.7より古くても動かせるようNumbered parametersなどの使用は控えてもらえると嬉しいです。
         
     | 
| 
       110 
119 
     | 
    
         | 
| 
         @@ -116,25 +125,44 @@ ACL本家のレポジトリ名がac-libraryとハイフン区切りで、それ 
     | 
|
| 
       116 
125 
     | 
    
         | 
| 
       117 
126 
     | 
    
         
             
            宣伝・バグ報告などしてもらえると嬉しいです。
         
     | 
| 
       118 
127 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
            ## ac-library-rbを開発したい方向けの情報
         
     | 
| 
      
 128 
     | 
    
         
            +
            ## ac-library-rbを開発したい方向けの情報(CONTRIBUTEING)
         
     | 
| 
       120 
129 
     | 
    
         | 
| 
       121 
130 
     | 
    
         
             
            ### コーディングスタイル
         
     | 
| 
       122 
131 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
            Rubocop(Rubyのlintツール)の設定ファイル`.rubocop.yml`は、参考に置いています。  
         
     | 
| 
       124 
     | 
    
         
            -
            Rubocopのルールを守ることが必ずしもよくなかったり、ルールを守ることが難しかったりもするので、Rubocopの適用は必須ではないです。  
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
132 
     | 
    
         
             
            推奨スタイル
         
     | 
| 
       127 
133 
     | 
    
         
             
            - インデントは、半角スペース2文字
         
     | 
| 
       128 
134 
     | 
    
         
             
            - 行末の余計なスペースは削除
         
     | 
| 
       129 
135 
     | 
    
         | 
| 
      
 136 
     | 
    
         
            +
            RuboCopを使用できる方は、使用してもらえるとありがたいです。  
         
     | 
| 
      
 137 
     | 
    
         
            +
            使い方のわからない方は、使う必要がないです。  
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            ```console
         
     | 
| 
      
 140 
     | 
    
         
            +
            $gem install rubocop
         
     | 
| 
      
 141 
     | 
    
         
            +
            ```
         
     | 
| 
      
 142 
     | 
    
         
            +
            上記の方法でrubocopをインストールします。
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
            ```console
         
     | 
| 
      
 145 
     | 
    
         
            +
            $rubocop    <- チェック
         
     | 
| 
      
 146 
     | 
    
         
            +
            $rubocop -a <- 安全に直せるところは自動で修正
         
     | 
| 
      
 147 
     | 
    
         
            +
            $rubocop -A <- 安全でない可能性のところも自動で修正
         
     | 
| 
      
 148 
     | 
    
         
            +
            ```
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
       130 
150 
     | 
    
         
             
            ### ディレクトリの説明
         
     | 
| 
       131 
151 
     | 
    
         | 
| 
       132 
152 
     | 
    
         
             
            `lib`ディレクトリ内に各種のデータ構造などのライブラリがあります。  
         
     | 
| 
       133 
153 
     | 
    
         
             
            `lib_lock`は、Gem用にモジュール化させるため`lib`の内容をコピーする形でモジュール化させています。  
         
     | 
| 
       134 
     | 
    
         
            -
            `bin/lock_lib.rb 
     | 
| 
      
 154 
     | 
    
         
            +
            [`bin/lock_lib.rb`](./bin/lock_lib.rb)を実行することで、`lib`から`lib_lock`にモジュール化させる形でコピーします。  
         
     | 
| 
      
 155 
     | 
    
         
            +
            `rake copy`コマンドを実行すると、[`bin/lock_lib.rb`](./bin/lock_lib.rb)が実行されるため、この2つは同等です。
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
       135 
157 
     | 
    
         
             
            なお、`rake`コマンドでテストを実行させると、自動的に`require_relative "./bin/lock_lib.rb"`により、コピーが行われます。  
         
     | 
| 
       136 
158 
     | 
    
         
             
            このあたりはトリッキーで、予定は未定ですが、今後全てモジュール化される等に統一される可能性があります。  
         
     | 
| 
       137 
159 
     | 
    
         | 
| 
      
 160 
     | 
    
         
            +
            ```
         
     | 
| 
      
 161 
     | 
    
         
            +
            $ rake copy <- `lib`に変更があれば、`./lib_lokc`を更新する。
         
     | 
| 
      
 162 
     | 
    
         
            +
            $ rake test <- 全てのテストを実行
         
     | 
| 
      
 163 
     | 
    
         
            +
            $ rake      <- 上2つのcopy & testを実行
         
     | 
| 
      
 164 
     | 
    
         
            +
            ```
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
       138 
166 
     | 
    
         
             
            ## その他の情報
         
     | 
| 
       139 
167 
     | 
    
         | 
| 
       140 
168 
     | 
    
         
             
            ### RubyのSlackのAtCoderチャンネル
         
     | 
| 
         @@ -143,7 +171,7 @@ Rubocopのルールを守ることが必ずしもよくなかったり、ルー 
     | 
|
| 
       143 
171 
     | 
    
         | 
| 
       144 
172 
     | 
    
         
             
            ここで、バグ報告などすると、競プロ詳しい人などが反応しやすいかもしれません。
         
     | 
| 
       145 
173 
     | 
    
         | 
| 
       146 
     | 
    
         
            -
            Slackに 
     | 
| 
      
 174 
     | 
    
         
            +
            Slackに4000人近く、atcoderチャンネルに350人ほどの登録者がいるので、お気軽に参加してください。
         
     | 
| 
       147 
175 
     | 
    
         | 
| 
       148 
176 
     | 
    
         
             
            ### 他言語のライブラリ
         
     | 
| 
       149 
177 
     | 
    
         | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,13 +1,16 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            ### Other language Japanese version(ver. 日本語)
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            [README 日本語バージョン(ver. Japanese)](README.ja.md)
         
     | 
| 
       4 
4 
     | 
    
         
             
            - [ライブラリ目次: index.md](https://github.com/universato/ac-library-rb/blob/master/document_ja/index.md)
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            <hr>
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            # ac-library-rb
         
     | 
| 
      
 8 
     | 
    
         
            +
            # ac-library-rb  
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            [](https://badge.fury.io/rb/ac-library-rb)
         
     | 
| 
      
 11 
     | 
    
         
            +
            [](https://codecov.io/gh/universato/ac-library-rb)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            <img width="560" src="ac-library-rb_header.jpg" alt="ac-library-rb Logo">
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
15 
     | 
    
         
             
            ac-library-rb is a ruby port of AtCoder Library (ACL).
         
     | 
| 
       13 
16 
     | 
    
         | 
| 
         @@ -21,7 +24,7 @@ See below for ACL. 
     | 
|
| 
       21 
24 
     | 
    
         | 
| 
       22 
25 
     | 
    
         
             
            Currently, the Ruby version in AtCoder is 2.7.1.
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            Therefore, 2.7 
     | 
| 
      
 27 
     | 
    
         
            +
            Therefore, 2.7 and the latest 3.1 are tested.
         
     | 
| 
       25 
28 
     | 
    
         | 
| 
       26 
29 
     | 
    
         
             
            # Document
         
     | 
| 
       27 
30 
     | 
    
         | 
| 
         @@ -90,7 +93,7 @@ Note that the gem names are separated by hyphens, but the library names in ac-li 
     | 
|
| 
       90 
93 
     | 
    
         
             
            In general, underscores are recommended for Ruby library names.
         
     | 
| 
       91 
94 
     | 
    
         
             
            However, the repository names in the original ACL are separated by a hyphen, ac-library, so ac-library-rb is also separated by a hyphen.
         
     | 
| 
       92 
95 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
            ## Development
         
     | 
| 
      
 96 
     | 
    
         
            +
            ## Development: How to Contirubute
         
     | 
| 
       94 
97 
     | 
    
         | 
| 
       95 
98 
     | 
    
         
             
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         
     | 
| 
       96 
99 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,12 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "bundler/gem_tasks"
         
     | 
| 
       2 
2 
     | 
    
         
             
            require "rake/testtask"
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            Rake::TestTask.new 
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
            Rake::TestTask.new :copy do
         
     | 
| 
      
 5 
     | 
    
         
            +
              # for make ./lib_lock to use ./lib
         
     | 
| 
      
 6 
     | 
    
         
            +
              require_relative "./bin/lock_lib.rb"
         
     | 
| 
      
 7 
     | 
    
         
            +
            end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Rake::TestTask.new :test do |t|
         
     | 
| 
       6 
10 
     | 
    
         
             
              t.warning = false
         
     | 
| 
       7 
11 
     | 
    
         
             
              t.libs << "test"
         
     | 
| 
       8 
12 
     | 
    
         
             
              t.libs << "lib"
         
     | 
| 
       9 
13 
     | 
    
         
             
              t.test_files = FileList["test/**/*_test.rb"]
         
     | 
| 
       10 
14 
     | 
    
         
             
            end
         
     | 
| 
       11 
15 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            task :default =>  
     | 
| 
      
 16 
     | 
    
         
            +
            task :default => %i[copy test]
         
     | 
    
        data/ac-library-rb.gemspec
    CHANGED
    
    | 
         @@ -1,7 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative 'lib/ac-library-rb/version'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            gem_description =  
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem_description = <<~DESCRIPTION
         
     | 
| 
      
 4 
     | 
    
         
            +
              ac-library-rb is a ruby port of AtCoder Library (ACL).
         
     | 
| 
      
 5 
     | 
    
         
            +
              DSU(UnionFind), FenwickTree, PriorityQueue, Segtree, SCC, 2-SAT,
         
     | 
| 
      
 6 
     | 
    
         
            +
              suffix_array, lcp_array, z_algorithm, crt, inv_mod, floor_sum, max_flow, min_cost_flow......
         
     | 
| 
      
 7 
     | 
    
         
            +
            DESCRIPTION
         
     | 
| 
       5 
8 
     | 
    
         | 
| 
       6 
9 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       7 
10 
     | 
    
         
             
              spec.name          = "ac-library-rb"
         
     | 
| 
         @@ -13,14 +16,18 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       13 
16 
     | 
    
         
             
              spec.description   = gem_description
         
     | 
| 
       14 
17 
     | 
    
         
             
              spec.homepage      = "https://github.com/universato/ac-library-rb"
         
     | 
| 
       15 
18 
     | 
    
         
             
              spec.license       = "CC0"
         
     | 
| 
       16 
     | 
    
         
            -
              spec.required_ruby_version = Gem::Requirement.new(">= 2. 
     | 
| 
      
 19 
     | 
    
         
            +
              spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
         
     | 
| 
       17 
20 
     | 
    
         | 
| 
       18 
21 
     | 
    
         
             
              spec.metadata["homepage_uri"] = spec.homepage
         
     | 
| 
       19 
22 
     | 
    
         
             
              spec.metadata["source_code_uri"] = "https://github.com/universato/ac-library-rb"
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.metadata['rubygems_mfa_required'] = 'true'
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_dependency "prime"
         
     | 
| 
       20 
26 
     | 
    
         | 
| 
       21 
27 
     | 
    
         
             
              spec.add_development_dependency "minitest"
         
     | 
| 
       22 
28 
     | 
    
         
             
              spec.add_development_dependency "rake"
         
     | 
| 
       23 
29 
     | 
    
         
             
              spec.add_development_dependency "simplecov"
         
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_development_dependency 'simplecov-cobertura'
         
     | 
| 
       24 
31 
     | 
    
         | 
| 
       25 
32 
     | 
    
         
             
              # Specify which files should be added to the gem when it is released.
         
     | 
| 
       26 
33 
     | 
    
         
             
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         
     | 
| 
         @@ -29,5 +36,5 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       29 
36 
     | 
    
         
             
              end
         
     | 
| 
       30 
37 
     | 
    
         
             
              spec.bindir        = "exe"
         
     | 
| 
       31 
38 
     | 
    
         
             
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
       32 
     | 
    
         
            -
              spec.require_paths = [ 
     | 
| 
      
 39 
     | 
    
         
            +
              spec.require_paths = %w[lib_lock lib_helpers"]
         
     | 
| 
       33 
40 
     | 
    
         
             
            end
         
     | 
| 
         Binary file 
     | 
    
        data/bin/console
    CHANGED
    
    
    
        data/document_en/dsu.md
    CHANGED
    
    | 
         @@ -120,7 +120,7 @@ More precisely, it returns the list of the "list of the vertices in a connected 
     | 
|
| 
       120 
120 
     | 
    
         | 
| 
       121 
121 
     | 
    
         
             
            ## Verified
         
     | 
| 
       122 
122 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
            [A  
     | 
| 
      
 123 
     | 
    
         
            +
            [A - Disjoint Set Union](https://atcoder.jp/contests/practice2/tasks/practice2_a)
         
     | 
| 
       124 
124 
     | 
    
         | 
| 
       125 
125 
     | 
    
         
             
            ## Links & Reference
         
     | 
| 
       126 
126 
     | 
    
         | 
    
        data/document_en/fenwick_tree.md
    CHANGED
    
    | 
         @@ -83,9 +83,9 @@ It returns `a[0] + a[1] + ... + a[pos - 1]`. 
     | 
|
| 
       83 
83 
     | 
    
         | 
| 
       84 
84 
     | 
    
         
             
            ## Verified
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
            - [AtCoder ALPC B  
     | 
| 
      
 86 
     | 
    
         
            +
            - [AtCoder ALPC B - Fenwick Tree](https://atcoder.jp/contests/practice2/tasks/practice2_b)
         
     | 
| 
       87 
87 
     | 
    
         
             
              -  [AC Code(1272ms)](https://atcoder.jp/contests/practice2/submissions/17074108)
         
     | 
| 
       88 
     | 
    
         
            -
            - [F  
     | 
| 
      
 88 
     | 
    
         
            +
            - [F - Range Xor Query](https://atcoder.jp/contests/abc185/tasks/abc185_f)
         
     | 
| 
       89 
89 
     | 
    
         
             
              - [AC Code(821ms)](https://atcoder.jp/contests/abc185/submissions/18769200)
         
     | 
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         | 
    
        data/document_en/lazy_segtree.md
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            This is a lazy evaluation segment tree.
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            ## Class Methods 
     | 
| 
      
 5 
     | 
    
         
            +
            ## Class Methods
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            ### new(v, e, id, op, mapping, composition)
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -21,7 +21,7 @@ The second argument `e` is the unit source. We need to define the monoid by defi 
     | 
|
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            - `O(n)`
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            ## Instance methods 
     | 
| 
      
 24 
     | 
    
         
            +
            ## Instance methods
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
            ## set(pos, x)
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
         @@ -136,8 +136,8 @@ This is the link in question. There is no code, but it has been Verified. 
     | 
|
| 
       136 
136 
     | 
    
         
             
            - [AIZU ONLINE JUDGE DSL\_2\_G RSQ and RAQ](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_G)
         
     | 
| 
       137 
137 
     | 
    
         | 
| 
       138 
138 
     | 
    
         
             
            The following problem is not AC in Ruby because the execution time is strictly TLE.
         
     | 
| 
       139 
     | 
    
         
            -
            - [ALPC: K  
     | 
| 
       140 
     | 
    
         
            -
            - [ALPC: L  
     | 
| 
      
 139 
     | 
    
         
            +
            - [ALPC: K - Range Affine Range Sum](https://atcoder.jp/contests/practice2/tasks/practice2_k)
         
     | 
| 
      
 140 
     | 
    
         
            +
            - [ALPC: L - Lazy Segment Tree](https://atcoder.jp/contests/practice2/tasks/practice2_l)
         
     | 
| 
       141 
141 
     | 
    
         | 
| 
       142 
142 
     | 
    
         
             
            ## Reference links
         
     | 
| 
       143 
143 
     | 
    
         | 
    
        data/document_en/math.md
    CHANGED
    
    | 
         @@ -65,7 +65,7 @@ If there is a solution, all the solutions can be written as the form `x ≡ rem( 
     | 
|
| 
       65 
65 
     | 
    
         
             
            ## Verified
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
67 
     | 
    
         
             
            Problems
         
     | 
| 
       68 
     | 
    
         
            -
            - [No\.187 中華風 \(Hard\)  
     | 
| 
      
 68 
     | 
    
         
            +
            - [No\.187 中華風 \(Hard\) - yukicoder](https://yukicoder.me/problems/no/187)
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
70 
     | 
    
         
             
            ## floor_sum(n, m, a, b)
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
         @@ -79,7 +79,7 @@ It retrurns `Σ[k = 0 → n - 1] floor((a * i + b) / m)` 
     | 
|
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
            ## Verified
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
            [ALPC: C  
     | 
| 
      
 82 
     | 
    
         
            +
            [ALPC: C - Floor Sum](https://atcoder.jp/contests/practice2/tasks/practice2_c)
         
     | 
| 
       83 
83 
     | 
    
         
             
             - [AC Code 426ms 2020/9/14](https://atcoder.jp/contests/practice2/submissions/16735215)
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         
             
            ## 参考リンク
         
     | 
| 
         @@ -101,4 +101,4 @@ It retrurns `Σ[k = 0 → n - 1] floor((a * i + b) / m)` 
     | 
|
| 
       101 
101 
     | 
    
         
             
              - [Test math_test.cpp](https://github.com/atcoder/ac-library/blob/master/test/unittest/math_test.cpp)
         
     | 
| 
       102 
102 
     | 
    
         
             
              - [Document math.md](https://github.com/atcoder/ac-library/blob/master/document_ja/math.md)
         
     | 
| 
       103 
103 
     | 
    
         
             
              - [Document math.html](https://atcoder.github.io/ac-library/document_en/math.html)
         
     | 
| 
       104 
     | 
    
         
            -
              - [Relax the constraints of floor\_sum? · Issue \#33 · atcoder/ac 
     | 
| 
      
 104 
     | 
    
         
            +
              - [Relax the constraints of floor\_sum? · Issue \#33 · atcoder/ac-library](https://github.com/atcoder/ac-library/issues/33)
         
     | 
    
        data/document_en/max_flow.md
    CHANGED
    
    | 
         @@ -3,7 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            Library for solving [Maximum flow problem](https://en.wikipedia.org/wiki/Maximum_flow_problem).
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            ## Class Methods 
     | 
| 
      
 6 
     | 
    
         
            +
            ## Class Methods
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            ### new(n) -> MaxFlow
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
         @@ -17,7 +17,7 @@ It creates a graph of `n` vertices and `0` edges. 
     | 
|
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
            - `O(n)`
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            ## Instance Methods 
     | 
| 
      
 20 
     | 
    
         
            +
            ## Instance Methods
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            ### add_edge(from, to, cap) -> Integer
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
         @@ -122,7 +122,7 @@ Change the capacity and flow rate of the `i`-th changed edge to `new_cap` and `n 
     | 
|
| 
       122 
122 
     | 
    
         | 
| 
       123 
123 
     | 
    
         
             
            ## Verified.
         
     | 
| 
       124 
124 
     | 
    
         | 
| 
       125 
     | 
    
         
            -
            - [ALPC: D  
     | 
| 
      
 125 
     | 
    
         
            +
            - [ALPC: D - Maxflow](https://atcoder.jp/contests/practice2/tasks/practice2_d)
         
     | 
| 
       126 
126 
     | 
    
         
             
              - [AC Code 211ms 2020/9/17](https://atcoder.jp/contests/practice2/submissions/16789801)
         
     | 
| 
       127 
127 
     | 
    
         
             
              - [ALPC: D \fnDroid Sans Fallback - Qiita](https://qiita.com/magurofly/items/bfaf6724418bfde86bd0)
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # MinCostFlow
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            It solves [Minimum 
     | 
| 
      
 3 
     | 
    
         
            +
            It solves [Minimum-cost flow problem](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem).
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            ## Class Methods 
     | 
| 
      
 5 
     | 
    
         
            +
            ## Class Methods
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            ### new(n) -> MinCostFlow
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -23,7 +23,7 @@ Verticle order is the 0-based index. 
     | 
|
| 
       23 
23 
     | 
    
         
             
            - `O(n)`
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            ## Instance Methods 
     | 
| 
      
 26 
     | 
    
         
            +
            ## Instance Methods
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
            ### add_edge(from, to, cap, cost) -> Integer
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
         @@ -100,7 +100,7 @@ It returns an array containing information on all edges. 
     | 
|
| 
       100 
100 
     | 
    
         | 
| 
       101 
101 
     | 
    
         
             
            ## Verified
         
     | 
| 
       102 
102 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
            - [ALPC: E 
     | 
| 
      
 103 
     | 
    
         
            +
            - [ALPC: E- MinCostFlow](https://atcoder.jp/contests/practice2/tasks/practice2_e)
         
     | 
| 
       104 
104 
     | 
    
         
             
              - [1213ms 2020/9/17](https://atcoder.jp/contests/practice2/submissions/16792967)
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
106 
     | 
    
         
             
            ## Reference links
         
     | 
    
        data/document_en/modint.md
    CHANGED
    
    | 
         @@ -127,7 +127,7 @@ This is a constructor for constant-fold speedup. 
     | 
|
| 
       127 
127 
     | 
    
         | 
| 
       128 
128 
     | 
    
         
             
            If `val` is guaranteed to be greater than or equal to `0` and not exceed `mod`, it is faster to generate `ModInt` here.
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
            ## Instance  
     | 
| 
      
 130 
     | 
    
         
            +
            ## Instance Methods
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
            ### val -> Integer
         
     | 
| 
       133 
133 
     | 
    
         | 
| 
         @@ -204,9 +204,9 @@ The `Integer` to be compared returns true or false in the range of [0, mod), but 
     | 
|
| 
       204 
204 
     | 
    
         | 
| 
       205 
205 
     | 
    
         
             
            ## Verified
         
     | 
| 
       206 
206 
     | 
    
         | 
| 
       207 
     | 
    
         
            -
            - [ABC156: D  
     | 
| 
      
 207 
     | 
    
         
            +
            - [ABC156: D - Bouquet](https://atcoder.jp/contests/abc156/tasks/abc156_d) held on 2020/2/22
         
     | 
| 
       208 
208 
     | 
    
         
             
              - [AC Code 138ms 2020/10/5](https://atcoder.jp/contests/abc156/submissions/17205940)
         
     | 
| 
       209 
     | 
    
         
            -
            - [ARC009: C  
     | 
| 
      
 209 
     | 
    
         
            +
            - [ARC009: C - Takahashi, 24 years old](https://atcoder.jp/contests/arc009/tasks/arc009_3) held on 2012/10/20
         
     | 
| 
       210 
210 
     | 
    
         
             
              - [AC Code 1075ms 2020/10/5](https://atcoder.jp/contests/arc009/submissions/17206081)
         
     | 
| 
       211 
211 
     | 
    
         
             
              - [AC code 901ms 2020/10/5](https://atcoder.jp/contests/arc009/submissions/17208378)
         
     | 
| 
       212 
212 
     | 
    
         | 
| 
         @@ -227,7 +227,7 @@ The methods `+`, `-`, `*`, and `/` use the methods `add!`, `sub!`, `mul!`, and ` 
     | 
|
| 
       227 
227 
     | 
    
         
             
              - [class Numeric \(Ruby 2\.7\.0 Reference Manual\)](https://docs.ruby-lang.org/ja/latest/class/Numeric.html)
         
     | 
| 
       228 
228 
     | 
    
         
             
            - Others
         
     | 
| 
       229 
229 
     | 
    
         
             
              - [Why don't you try using the modint struct? \(C\cH000000)}Noshi91's Notes](https://noshi91.hatenablog.com/entry/2019/03/31/174006)(Mar 31, 2019)
         
     | 
| 
       230 
     | 
    
         
            -
              - [Implementing modint in Python  
     | 
| 
      
 230 
     | 
    
         
            +
              - [Implementing modint in Python - Qiita](https://qiita.com/wotsushi/items/c936838df992b706084c)(Apr 1, 2019)
         
     | 
| 
       231 
231 
     | 
    
         
             
              - [Documentation of the C# version of ModInt](https://github.com/key-moon/ac-library-cs/blob/master/document_ja/modint.md)
         
     | 
| 
       232 
232 
     | 
    
         | 
| 
       233 
233 
     | 
    
         | 
    
        data/document_en/scc.md
    ADDED
    
    | 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # SCC
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Strongly Connected Components
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            It calculates the strongly connected components of directed graph.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Class Methods
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ### new(n) -> SCC
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            graph = SCC.new(6)
         
     | 
| 
      
 13 
     | 
    
         
            +
            ```
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            It creates a directed graph of `n` vertices and `0` edges.
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            This `n` is 0-based index.
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            **Constraints** `0 ≦ n`
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            **Complexity** $O(n)$
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Instance Methods
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ### add_edge(from, to)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 28 
     | 
    
         
            +
            graph.add_edge(1, 4)
         
     | 
| 
      
 29 
     | 
    
         
            +
            ```
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            It adds a directed edge from the vertex `from` to the vertex `to`.
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            **Constraints**  `0 ≦ from < n`, `0 ≦ to < n`
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            **Complexity** $O(n)$
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            ### scc -> Array[Array[Integer]]
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 40 
     | 
    
         
            +
            graph.scc
         
     | 
| 
      
 41 
     | 
    
         
            +
            ```
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            It returns the array of the "array of the vertices" that satisfies the following.
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            - Each vertex is in exactly one "array of the vertices".
         
     | 
| 
      
 46 
     | 
    
         
            +
            - Each "array of the vertices" corresponds to the vertex set of a strongly connected component. The order of the vertices in the list is undefined.
         
     | 
| 
      
 47 
     | 
    
         
            +
            - The array of "array of the vertices" are sorted in topological order, i.e., for two vertices $u, v$ in different strongly connected components, if there is a directed path from $u$ to $v$, the list contains uu appears earlier than the list contains $v$.
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            **Complexity**  $O(n + m)$ , where $m$ is the number of added edges.
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            ## Verified
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            - [ALPC: G - SCC](https://atcoder.jp/contests/practice2/tasks/practice2_g)  
         
     | 
| 
      
 56 
     | 
    
         
            +
              - [Ruby 2.7 1848ms 2022/11/22](https://atcoder.jp/contests/practice2/submissions/36708506)
         
     | 
| 
      
 57 
     | 
    
         
            +
            - [typical90: 021 - Come Back in One Piece](https://atcoder.jp/contests/typical90/tasks/typical90_u)
         
     | 
| 
      
 58 
     | 
    
         
            +
              - [Ruby2.7 471ms 2021/6/15](https://atcoder.jp/contests/typical90/submissions/23487102)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            # 参考リンク
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            - ac-library-rb
         
     | 
| 
      
 63 
     | 
    
         
            +
              - [scc.rb](https://github.com/universato/ac-library-rb/blob/master/lib/scc.rb)
         
     | 
| 
      
 64 
     | 
    
         
            +
              - [scc_test.rb](https://github.com/universato/ac-library-rb/blob/master/test/scc_test.rb)
         
     | 
| 
      
 65 
     | 
    
         
            +
            - Original C++
         
     | 
| 
      
 66 
     | 
    
         
            +
              - [Original C++ code scc.hpp](https://github.com/atcoder/ac-library/blob/master/atcoder/scc.hpp)
         
     | 
| 
      
 67 
     | 
    
         
            +
              - [Original document scc.md](https://github.com/atcoder/ac-library/blob/master/document_en/scc.md)
         
     |