Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dragonslayerx/Competitive-Programming-Repository
Competitive Programming templates that I used during the past few years.
https://github.com/dragonslayerx/Competitive-Programming-Repository
algorithms algorithms-implemented bellman-ford-algorithm biginteger bipartite-graphs competitive-programming data-structures dijkstra disjoint-sets dynamic-programming fft floyd-warshall graphs hashing lca matching matrix-exponentiation recurrence segment-tree string
Last synced: 3 months ago
JSON representation
Competitive Programming templates that I used during the past few years.
- Host: GitHub
- URL: https://github.com/dragonslayerx/Competitive-Programming-Repository
- Owner: dragonslayerx
- License: mit
- Created: 2016-12-08T21:16:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T18:54:46.000Z (over 4 years ago)
- Last Synced: 2024-08-01T21:40:39.016Z (6 months ago)
- Topics: algorithms, algorithms-implemented, bellman-ford-algorithm, biginteger, bipartite-graphs, competitive-programming, data-structures, dijkstra, disjoint-sets, dynamic-programming, fft, floyd-warshall, graphs, hashing, lca, matching, matrix-exponentiation, recurrence, segment-tree, string
- Language: C++
- Size: 146 KB
- Stars: 434
- Watchers: 25
- Forks: 154
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Competitive-Programming-Repository
Collection of algorithms and data structures in C++ used widely in Competitive programming contests.### The following topics are covered:
#### Range Updates and Queries
* **Range Aggregate Queries** :
* *Binary Indexed Trees (BIT)* :
* [Point Update Range Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree.cpp)
* [Range Update Range Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree_range_query_range_update.cpp)
* [Order Statistic Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree_order_stat.cpp)
* [2D Binary Indexed Trees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree_2D.cpp)
* *Segment Trees (SegTree)* :
* [Point Update Range Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_range_query_point_update.cpp)
* [Fast Iterative Segtrees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_trees_interative_fast.cpp)
* [Range Update Point Query - Lazy Propogation](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_range_query_range_update_lazy_propogation.cpp)
* [Max subsegment sum in range](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_custom_merge_function.cpp)
* [2D Segment Trees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_2D.cpp)
* [Dynamic Segment Trees - Insertion/Deletion between elements](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_dynamic_using_treaps.cpp)
* [Dynamic Segment Trees - Reverse a segment](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_dynamic_reverse_subarray_using_treap.cpp)
* *Merge Sort Trees* :
* [Merge sort trees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/merge_sort_trees.cpp)
* [Merge sort trees - Order Statistics](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/merge_sort_trees_order_stat_query.cpp)
* *Sparse Table* :
* [Range Minimum Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/range_minimum_query_sparse_table.cpp)
* *Mo Algorithm* :
* [Mo Algorithm - Arrays](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/mo_algorithm_offline_range_query.cpp)
* **Dynamic Programming** :
* *Dynamic Programming Templates* :
* [Digit DP / Bitwise DP](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/dynamic_programming_templates.cpp)
* *Standard DP Problems* :
* [Longest Increasing Subsequence](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/longest_increasing_subsequence_lis_binary_search.cpp)
* [Longest Palindromic Subsequence](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/palindrome_longest_subsequence.cpp)
* [Levenstein Distance / Edit Distance](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/edit_distance_levenstein_dynamic_programming.cpp)
* **Graphs** :
* *Single Source Shortest Path Algorithms* :
* [Dijkstra in dense graphs](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/dijsktra_dense_graphs.cpp)
* [Dijkstra using priority queue](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/dijkstra_using_priority_queue.cpp)
* [Kth Shortest Path between Nodes using Dijkstra](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/kth_shortest_path_between_nodes_graph.cpp)
* [Bellman Ford Negative cycle detection](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/bellman_ford.cpp)
* *All Pair shortest path* :
* [Using Binary exponentiation](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/all_pair_shortest_path_binary_exponentation.cpp)
* [Floyd Warshall](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/all_pair_shortest_path_floyd_warshall.cpp)
* *Cycle Detection* :
* [Cycle detection in Undirected/Directed Graphs](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/cycle_detection_in_graph.cpp)
* *Minimum Spanning tree* :
* [Kruskal Algorithm](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/kruskal_min_spanning_tree.cpp)
* *Topological Sort / Strongly Connected Component* :
* [Topological Sort](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/topological_sort_kosaraju.cpp)
* [Strongly Connected Component](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/strongly_connected_components_kosaraju.cpp)
* *Maxflow/Matching* :
* [Hopkroft Karp Max Matching](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/max_bipartite_matching_hopcroft_karp.cpp)
* [Dinic Max Flow](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/max_flow_network_dinic_algorithm.cpp)
* *Misc* :
* [Bridges in Graph](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/bridges_in_graph.cpp)
* [Connectivity](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/isConnected_using_bfs.cpp)
* [Bipartite Check](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/non_bipartite_check.cpp)
* **Trees** :
* *Ancestor queries* :
* [Lowest Common Ancestor](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/lowest_common_ancestor_lca.cpp)
* [Kth Ancestor](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/kth_ancestor_tree.cpp)
* *Path queries* :
* [Sparse Table *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/trees_path_query_sparse_tables.cpp)
* [Heavy Light Decomposition Weighted Nodes](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/heavy_light_decomposition_wieghted_vertices(hld).cpp)
* [Heavy Light Decomposition Weighted Edges](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/heavy_light_decomposition_weighted_edges%20(hld).cpp)
* *Misc* :
* [Diameter of Tree](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/tree_diameter.cpp)
* [Preorder/Postorder stamps, Is it in Subtree?](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/tree_dfs_preorder_postorder_isInSubtree.cpp)
* **Binary Exponentiation** :
* [Calculate n^m using Binary exponentiation](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/power_binary_exponentiation.cpp)
* [Solving Linear Recurrences](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/linear_recurrence_matrix_exponentiation.cpp)
* **Strings** :
* *String Algorithms* :
* [Z Algorithm](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/Z_algorithm_max_prefix_match.cpp)
* [KMP algorithm](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/KMP.cpp)
* [Rolling String Hashing](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/string_hashing.cpp)
* [Rolling String Hashing for Dynamic Strings](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/string_hashing_dynamic_segment_trees.cpp)
* *String Data Structures* :
* [Suffix Array *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/untested-codes/suffix_array.cpp)
* **Sorting** :
* [Merge Sort](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/merge_sort_count_inversion.cpp)
* [Quick Select](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/quick_select_order_stat_linear.cpp)
* **Fast Input/Output, String/Integer Conversion** :
* [Fast Input/Output](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/fast_readInt_writeInt_function.cpp)
* [String/Integer Conversion](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/int2string_string2int.cpp)
* **Misc. Data Structures** :
* [Disjoint Set](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/disjoint_set.cpp)
* [Disjoint Set (Supports Undo Operation)](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/disjoint_set_with_undo_operation.cpp)
* [Max/Min Priority Queue with update](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/heap_using_multiset_max_min_insert_erase_update.cpp)
* [Binary Trie for xor maximization/minimization](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_trie_max_xor.cpp)
* [Bigint *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/bigint_library.cpp)
* [Augmented Binary Tree for order statistics and rank query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/orderstat_rank_query_augmented_bst.cpp)
* [Monotone Priority Queue](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/monotone_priority_queue.cpp)
* [Trie](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/trie_insertion_deleteion.cpp)
* **Persistent Data Structures** :
* *Persistent Segment Trees (SegTree)* :
* [Persistent Segment Tree](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_persistent.cpp)
* [Persistent Segment Tree - Order Statistics](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_persistent_order_stat.cpp)
* **Number Theory Algorithms** :
* *Primality Check* :
* [Fermat's Primality Check](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/primality_check_fermat.cpp)
* *Sieve* :
* [Sieve of Eratosthenes](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/prime_sieve.cpp)
* [Segmented Sieve for large primes](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segmented_sieve_large_primes.cpp)
* [Counting Prime Factors](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/prime_factor_count.cpp)
* *Polynomial Multiplication* :
* [Fast Fourier Tranform](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/fast_fourier_transform_fft.cpp)
* [Karatsuba](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/karatsuba_polynomial_multiplication.cpp)
* *Misc* :
* [Combinatorial and Catalan - Factorial preprocessing](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/factorial_preprocessing.cpp)
* [Mobeius Function](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/mobeius_function.cpp)
* [Euler Totient Function](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/euler_phi_euler_totient_function.cpp)
* [Lucas Theorm - Combinatorics](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/lucas_combinatorics.cpp)
* **Computational Geometry** :
* [Convex Hull](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/convexhull.cpp)
* **Misc** :
* [Sum of floor(x) with x=1:n](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/aggreate_sqrt_distinct_values.cpp)
* [Sum of cyclic functions *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/aggregate_cyclic_function.cpp)
* [Closest larger element before/after every element](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/closest_max_element_before_after_index_using_stack.cpp)
* [Multiply Long Long Integers](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/multiply_longlong_integers.cpp)
* [Multiply Long Long Integers - Overflow detection](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/multiply_detect_overflow.cpp)
* [Scanline - Merge intersecting intervals](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/scanline_merge_overlapping_intervals.cpp)