Skip to content

Commit

Permalink
refactor: update fenwick trees
Browse files Browse the repository at this point in the history
  • Loading branch information
7oSkaaa committed Jun 25, 2023
1 parent c98c689 commit 84340dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions CP.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@
" int n;",
" T DEFAULT;",
"",
" Fenwick_Tree(int N = 0){",
" n = N + 1, DEFAULT = 0;",
" Fenwick_Tree(int sz = 0){",
" n = sz + 1, DEFAULT = 0;",
" Tree = vector < T > (n + 10, DEFAULT);",
" }",
"",
Expand Down Expand Up @@ -655,8 +655,8 @@
" int n, m;",
" T DEFAULT;",
"",
" Fenwick_Tree(int N, int M){",
" n = N + 1, m = M + 1, DEFAULT = 0;",
" Fenwick_Tree(int rows = 0, int cols = 0){",
" n = rows + 1, m = cols + 1, DEFAULT = 0;",
" Tree.assign(n + 10, vector < ll > (m + 10, DEFAULT));",
" }",
"",
Expand Down Expand Up @@ -3687,9 +3687,9 @@
" T DEFAULT;",
" vector < T > M, C;",
"",
" Fenwick_Range(int n){",
" N = n + 1, DEFAULT = 0;",
" M = C = vector < T > (n + 10);",
" Fenwick_Tree_Range(int sz = 0){",
" N = sz + 1, DEFAULT = 0;",
" M = C = vector < T > (N + 10);",
" }",
"",
" int lowest_bit(int idx){",
Expand Down
4 changes: 2 additions & 2 deletions Fenwick_Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ template < typename T = int > struct Fenwick_Tree {
int n;
T DEFAULT;

Fenwick_Tree(int N = 0){
n = N + 1, DEFAULT = 0;
Fenwick_Tree(int sz = 0){
n = sz + 1, DEFAULT = 0;
Tree = vector < T > (n + 10, DEFAULT);
}

Expand Down
4 changes: 2 additions & 2 deletions Fenwick_Tree_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ template < typename T = int > struct Fenwick_Tree {
int n, m;
T DEFAULT;

Fenwick_Tree(int N, int M){
n = N + 1, m = M + 1, DEFAULT = 0;
Fenwick_Tree(int rows = 0, int cols = 0){
n = rows + 1, m = cols + 1, DEFAULT = 0;
Tree.assign(n + 10, vector < ll > (m + 10, DEFAULT));
}

Expand Down
6 changes: 3 additions & 3 deletions Fenwick_Tree_Range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ template < typename T = int > struct Fenwick_Tree_Range {
T DEFAULT;
vector < T > M, C;

Fenwick_Range(int n){
N = n + 1, DEFAULT = 0;
M = C = vector < T > (n + 10);
Fenwick_Tree_Range(int sz = 0){
N = sz + 1, DEFAULT = 0;
M = C = vector < T > (N + 10);
}

int lowest_bit(int idx){
Expand Down

0 comments on commit 84340dd

Please sign in to comment.