diff --git a/content/contest/.vimrc b/content/contest/.vimrc index ca52aa1..3c2636f 100644 --- a/content/contest/.vimrc +++ b/content/contest/.vimrc @@ -2,10 +2,8 @@ set cin ar aw ai is ts=4 sw=4 tm=50 nu noeb bg=dark ru cul sm syn on | filetype plugin indent on | colo zaibatsu | no ; : " Select region and then type :Hash to hash your selection. " Useful for verifying that there aren't mistypes. -ca Hash w !cpp -dD -P -fpreprocessed \| tr -d '[:space:]' \ - \| md5sum \| cut -c-6 - -set makeprg=g++\ -Wall\ -Wconversion\ -Wfatal-errors\ -g\ -std=c++17\ -fsanitize=undefined,address\ %\ -o\ %< +command! Hash w !cpp -dD -P -fpreprocessed \| tr -d '[:space:]' \| md5sum \| cut -c-6 +let &makeprg = 'g++ -Wall -Wconversion -Wfatal-errors -g -std=c++17 -fsanitize=undefined,address % -o %<' map :w:make:!./%< < %<.in diff --git a/content/data-structures/FenwickRUPQ.cpp b/content/data-structures/FenwickRUPQ.cpp deleted file mode 100644 index ede7927..0000000 --- a/content/data-structures/FenwickRUPQ.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Author: Ramez Medhat - * Description: Range Update, Point Query - * Time: O(logN) - */ -struct FenwickRUPQ { - int n; - vi f; - FenwickRUPQ(int _n) : n(_n), f(n + 1, 0) {} - - void update(int idx, int val) { - for (; idx <= n; idx += idx & -idx) - f[idx] += val; - } - - void rangeAdd(int l, int r, int val) { - update(l, val); - if (r + 1 <= n) update(r + 1, -val); - } - - int pointQuery(int idx) { - int res = 0; - for (; idx > 0; idx -= idx & -idx) res += f[idx]; - return res; - } -}; \ No newline at end of file diff --git a/content/data-structures/chapter.tex b/content/data-structures/chapter.tex index fe6ac62..7b60817 100644 --- a/content/data-structures/chapter.tex +++ b/content/data-structures/chapter.tex @@ -1,14 +1,14 @@ \chapter{Data structures} \kactlimport{SegmentTree.h} +\kactlimport{LazySegmentTree.h} +\kactlimport{MergeSortTree.h} \kactlimport{FenwickPURQ.cpp} -\kactlimport{FenwickRUPQ.cpp} \kactlimport{FenwickRURQ.cpp} \kactlimport{Fenwick2d.h} \kactlimport{Fenwick2dAdd.h} \kactlimport{Fenwick2dXor.h} \kactlimport{OrderStatisticTree.h} \kactlimport{HashMap.h} -\kactlimport{LazySegmentTree.h} \kactlimport{DSU.h} \kactlimport{DSURollback.h} \kactlimport{SubMatrix.h} @@ -17,4 +17,3 @@ \chapter{Data structures} \kactlimport{Treap.h} \kactlimport{RMQ.h} \kactlimport{MoQueries.h} -\kactlimport{MergeSortTree.h} diff --git a/content/kactl.tex b/content/kactl.tex index 3fd16ff..c0c3b8e 100644 --- a/content/kactl.tex +++ b/content/kactl.tex @@ -21,7 +21,7 @@ \kactlchapter{contest} \kactlchapter{math} \kactlchapter{data-structures} - % \kactlchapter{numerical} + \kactlchapter{numerical} \kactlchapter{number-theory} \kactlchapter{combinatorial} \kactlchapter{graph} diff --git a/content/strings/Hashing.h b/content/strings/Hashing.h index 0f5026d..f73eee5 100644 --- a/content/strings/Hashing.h +++ b/content/strings/Hashing.h @@ -17,6 +17,12 @@ const val M = { val tmp; +val operator+(const val &a, const val &b) { + for (int i = 0; i < H; i++) + tmp[i] = (a[i] + b[i]) % M[i]; + return tmp; +} + val operator*(const val &a, const val &b) { for (int i = 0; i < H; i++) tmp[i] = a[i] * b[i] % M[i]; @@ -29,11 +35,6 @@ val operator-(const val &a, const val &b) { return tmp; } -val operator+(const val &a, const val &b) { - for (int i = 0; i < H; i++) - tmp[i] = (a[i] + b[i]) % M[i]; - return tmp; -} val getval(int x) { // make sure x is always positvie if not handle it