cpp-algorithm-snippets
cpp-algorithm-snippets copied to clipboard
♾️ In this repository there is a collection of useful algorithms to use in competitive programming.
![Screenshot 2024-05-13 at 2 25 20 PM](https://github.com/LuchoBazz/cpp-algorithm-snippets/assets/22530481/a203e5fd-21f1-4093-b757-359fa08211fb) ![Screenshot 2024-05-13 at 2 24 32 PM](https://github.com/LuchoBazz/cpp-algorithm-snippets/assets/22530481/9cf46e3f-e0a3-4034-aa42-041cbf059938)
```cpp // Reference: https://codeforces.com/contest/1782/submission/230743928 int floordiv(int a, int b) { return a > 0 ? a / b : -((-a + b - 1) / b); } int ceildiv(int a,...
### Variables Naming #### Prefix ```text do_ has_ can_ compute_ build_ make_ ``` #### Verbs ```text best item quantity unknown_process works have need previous nxt current buckets turn half split...
https://codeforces.com/contest/159/submission/213953589 ```cpp template struct FenwickTree { using G = Monoid; using E = typename G::value_type; int n; vector dat; E total; FenwickTree() {} FenwickTree(int n) { build(n); } template FenwickTree(int...
[Tourist Code](https://codeforces.com/contest/1889/submission/230219842) ```cpp struct SegmTree { vector T; int n; SegmTree(int n) : T(2 * n, (int)-2e9), n(n) {} void Update(int pos, int val) { for (T[pos += n] =...
https://codeforces.com/contest/1/submission/246338459
```cpp const string ALPHA = "abcdefghijklmnopqrstuvwxyz"; ```
[Reference](https://codeforces.com/contest/1731/submission/187482008)
[Ternary Search on Integers!](https://codeforces.com/blog/entry/43440) [tourist implementation](https://codeforces.com/contest/626/submission/15999995) [Errichto Implementation](https://codeforces.com/contest/626/submission/16002332)
```c++ const char SPECIAL_CH = '$'; const string FIRST_ALPHA = "0"; const string SECOND_ALPHA = "1"; struct HffTreeNode { // One of the input characters char ch; // Frequency of...