From 51c0fa712be416a88fca415bcb2ca2a74aab2041 Mon Sep 17 00:00:00 2001 From: Benjamin Qi Date: Thu, 4 Jun 2020 17:42:30 -0400 Subject: [PATCH 1/2] + descriptions --- content/2_Silver/7_Silver_DFS.md | 43 ++++++-- content/3_Gold/1_Gold_DP.md | 9 +- content/3_Gold/2_Gold_SP.md | 104 ++++++++++++------ content/3_Gold/3_Gold_MST.md | 22 ++-- content/3_Gold/4_Gold_TopoSort.md | 2 + content/3_Gold/5_Gold_BIT.md | 7 +- content/3_Gold/6_Gold_NT.md | 12 +- content/4_Plat/1_Plat_Trees.md | 6 +- content/4_Plat/2_Plat_1DRQ.md | 18 +-- content/4_Plat/3_Plat_2DRQ.md | 4 +- content/4_Plat/5_Plat_Graphs.md | 37 +++++-- content/4_Plat/6_Plat_Strings.md | 30 +++-- content/4_Plat/7_Plat_Bitset.md | 4 +- ...{9_Plat_Fracture.md => 8_Plat_Fracture.md} | 4 +- content/4_Plat/8_Plat_Matrix.md | 17 --- .../{10_Plat_Slope.md => 9_Plat_Slope.md} | 34 +++--- 16 files changed, 221 insertions(+), 132 deletions(-) rename content/4_Plat/{9_Plat_Fracture.md => 8_Plat_Fracture.md} (98%) delete mode 100644 content/4_Plat/8_Plat_Matrix.md rename content/4_Plat/{10_Plat_Slope.md => 9_Plat_Slope.md} (87%) diff --git a/content/2_Silver/7_Silver_DFS.md b/content/2_Silver/7_Silver_DFS.md index b431c72..434fce5 100644 --- a/content/2_Silver/7_Silver_DFS.md +++ b/content/2_Silver/7_Silver_DFS.md @@ -1,12 +1,10 @@ --- slug: /silver/dfs -title: "DFS" +title: "Depth First Search" author: Siyong Huang order: 7 --- -## Overview - - Introduction to Graphs - Depth First Search (DFS) - Flood Fill @@ -17,10 +15,14 @@ order: 7 ## Introduction to Graphs - - [CSAcademy Graph Intro](https://csacademy.com/lesson/introduction_to_graphs) - - [CSAcademy Graph Representations](https://csacademy.com/lesson/graph_representation) - - Note: DFS is most commonly implemented with adjacency lists. - - CPH 11 + - Recommended + - CPH 11 + - [CSAcademy Graph Intro](https://csacademy.com/lesson/introduction_to_graphs) + - [CSAcademy Graph Representations](https://csacademy.com/lesson/graph_representation) + - Usually, adjacency lists are used. + - Additional + - [Topcoder Graphs Pt 1](https://www.topcoder.com/community/data-science/data-science-tutorials/introduction-to-graphs-and-their-data-structures-section-1/) + - [Topcoder Graphs Pt 2](https://www.topcoder.com/community/data-science/data-science-tutorials/introduction-to-graphs-and-their-data-structures-section-2/) ## Depth First Search (DFS) @@ -40,11 +42,23 @@ order: 7 ### Problems - - [Mootube, Silver (Easy)](http://usaco.org/index.php?page=viewproblem2&cpid=788) - - [Closing the Barn, Silver (Easy)](http://usaco.org/index.php?page=viewproblem2&cpid=644) - - [Moocast, Silver (Easy)](http://usaco.org/index.php?page=viewproblem2&cpid=668) - - [Pails (Normal)](http://usaco.org/index.php?page=viewproblem2&cpid=620) - - [Milk Visits (Normal)](http://www.usaco.org/index.php?page=viewproblem2&cpid=968) + - CF + - [PolandBall & Forest](http://codeforces.com/problemset/problem/755/C) [](56) + - [Bear & Friendship](http://codeforces.com/problemset/problem/771/A) + - [Journey](http://codeforces.com/contest/839/problem/C) [](54) + - DFS on Tree + - [Wizard's Tour](http://codeforces.com/contest/860/problem/D) [](59) + - USACO + - [Mootube, Silver (Easy)](http://usaco.org/index.php?page=viewproblem2&cpid=788) + - [Closing the Barn, Silver (Easy)](http://usaco.org/index.php?page=viewproblem2&cpid=644) + - [Moocast, Silver (Easy)](http://usaco.org/index.php?page=viewproblem2&cpid=668) + - [Pails (Normal)](http://usaco.org/index.php?page=viewproblem2&cpid=620) + - [Milk Visits (Normal)](http://www.usaco.org/index.php?page=viewproblem2&cpid=968) + - Other + - [POI Hotels](https://szkopul.edu.pl/problemset/problem/gDw3iFkeVm7ZA3j_16-XR7jI/site/?key=statement) [](61) + - [Kattis Birthday Party (Easy)](https://open.kattis.com/problems/birthday) + - DFS with each edge removed + ## Flood Fill @@ -104,6 +118,7 @@ void dfs(int node) ### Problems + - [CF Bipartiteness](http://codeforces.com/contest/862/problem/B) [](49) - [The Great Revegetation (Normal)](http://usaco.org/index.php?page=viewproblem2&cpid=920) ## Cycle Detection @@ -203,4 +218,8 @@ int main() - [Swapity Swapity Swap (Very Hard)](http://www.usaco.org/index.php?page=viewproblem2&cpid=1014) - [CSES Round Trip (undirected)](https://cses.fi/problemset/task/1669) - [CSES Round Trip II (directed)](https://cses.fi/problemset/task/1678) + - POI + - [Mafia](https://szkopul.edu.pl/problemset/problem/w3YAoAT3ej27YeiaNWjK57_G/site/?key=statement) + - [Spies](https://szkopul.edu.pl/problemset/problem/r6tMTfvQFPAEfQioYMCQndQe/site/?key=statement) + - [Frog](https://szkopul.edu.pl/problemset/problem/qDH9CkBHZKHY4vbKRBlXPrA7/site/?key=statement) diff --git a/content/3_Gold/1_Gold_DP.md b/content/3_Gold/1_Gold_DP.md index 431965e..05562a0 100644 --- a/content/3_Gold/1_Gold_DP.md +++ b/content/3_Gold/1_Gold_DP.md @@ -17,9 +17,10 @@ Assumes familiarity with prefix sums, recursion, bit operations (for Bitmask DP) ## Introduction to DP - * CPH 7 - * [HackerRank DP](https://www.hackerrank.com/topics/dynamic-programming) - * [Topcoder DP](https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/) + - CPH 7 + - [HackerRank DP](https://www.hackerrank.com/topics/dynamic-programming) + - [Topcoder DP](https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/) + - [CPC.6](https://github.com/SuprDewd/T-414-AFLV/tree/master/06_dynamic_programming) ## Classical DP Problems @@ -74,7 +75,7 @@ Note: Has not appeared on recent USACO. ## Practice Problems - * [Atcoder DP Contest (Extremely Good)](https://atcoder.jp/contests/dp/tasks) + * **[Atcoder DP Contest (Extremely Good)](https://atcoder.jp/contests/dp/tasks)** * [CSES DP Section](https://cses.fi/problemset/list/) * [Codeforces DP Problem List](http://codeforces.com/blog/entry/325) * USACO (Not Ordered By Difficulty) diff --git a/content/3_Gold/2_Gold_SP.md b/content/3_Gold/2_Gold_SP.md index 87a5a58..641a2c5 100644 --- a/content/3_Gold/2_Gold_SP.md +++ b/content/3_Gold/2_Gold_SP.md @@ -1,84 +1,116 @@ --- slug: /gold/sp -title: "Shortest Path" +title: "Shortest Paths" author: Benjamin Qi order: 2 --- -
- Description: Todo -
+Assumes familiarity with "Silver - Depth First Search." + + - Breadth First Search + - Shortest Path With and Without Negative Edge Weights + - All Pairs Shortest Path -[CPC.7](https://github.com/SuprDewd/T-414-AFLV/tree/master/07_graphs_1) - ## Breadth First Search Find the shortest path where all edge weights are 1. - * [CSES Message Route](https://cses.fi/problemset/task/1667) + - [CSES Message Route](https://cses.fi/problemset/task/1667) ### Tutorial + - CSES 12.2 - [CSAcademy BFS](https://csacademy.com/lesson/breadth_first_search) - [cp-algo BFS](https://cp-algorithms.com/graph/breadth-first-search.html) - [cp-algo 0/1 BFS](https://cp-algorithms.com/graph/01_bfs.html) + - [KhanAcademy BFS](https://www.khanacademy.org/computing/computer-science/algorithms/breadth-first-search/a/breadth-first-search-and-its-uses) ### Problems + - [CSAcademy BFS-DFS](https://csacademy.com/contest/round-41/task/bfs-dfs/) [](50) - [Cow Navigation](http://www.usaco.org/index.php?page=viewproblem2&cpid=695) - [Dream](http://www.usaco.org/index.php?page=viewproblem2&cpid=575) - [Lasers](http://www.usaco.org/index.php?page=viewproblem2&cpid=671) - * [Monsters](https://cses.fi/problemset/task/1194) + - [Monsters](https://cses.fi/problemset/task/1194) ## Non-Negative Edge Weights - * [Kattis SSSP Non-Negative](https://open.kattis.com/problems/shortestpath1) - * [CSES Shortest Routes I](https://cses.fi/problemset/task/1671) - * [CSES Flight Discount](https://cses.fi/problemset/task/1195) - * [CSES Flight Routes](https://cses.fi/problemset/task/1196) - * [CSES Investigation](https://cses.fi/problemset/task/1202) - Use *Dijkstra's Algorithm*. +### Standard + + - [Kattis SSSP Non-Negative](https://open.kattis.com/problems/shortestpath1) + - [CSES Shortest Routes I](https://cses.fi/problemset/task/1671) + ### Tutorial - * CSES 13.2 - * [cp-algo Dijkstra (Dense Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html) - * [cp-algo Dijkstra (Sparse Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html) - * Usually, it's this one that's applicable. + - CSES 13.2 + - [cp-algo Dijkstra (Dense Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html) + - [cp-algo Dijkstra (Sparse Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html) + - Usually, it's this one that's applicable. + - [CPC.8](https://github.com/SuprDewd/T-414-AFLV/tree/master/08_graphs_2) -### USACO Gold Problems +### Problems - * [Milk Pumping](http://www.usaco.org/index.php?page=viewproblem2&cpid=969) - * fairly standard application - * [Shortcut](http://usaco.org/index.php?page=viewproblem2&cpid=899) - * [Fine Dining](http://usaco.org/index.php?page=viewproblem2&cpid=861) + - CSES + - [CSES Flight Discount](https://cses.fi/problemset/task/1195) + - [CSES Flight Routes](https://cses.fi/problemset/task/1196) + - [CSES Investigation](https://cses.fi/problemset/task/1202) + - USACO + - [Milk Pumping](http://www.usaco.org/index.php?page=viewproblem2&cpid=969) + - fairly standard application + - [Shortcut](http://usaco.org/index.php?page=viewproblem2&cpid=899) + - [Fine Dining](http://usaco.org/index.php?page=viewproblem2&cpid=861) + - Other + - [Lane Switching](https://open.kattis.com/contests/acpc17open/problems/laneswitching) + - [Robot Turtles](https://open.kattis.com/problems/robotturtles) [](100) ## All Pairs Shortest Path (APSP) - * [CSES Shortest Routes II](https://cses.fi/problemset/task/1672) - * [Kattis APSP (with negative weights)](https://open.kattis.com/problems/allpairspath) - Use the *Floyd-Warshall* algorithm. +### Standard + + - [CSES Shortest Routes II](https://cses.fi/problemset/task/1672) + - [Kattis APSP (with negative weights)](https://open.kattis.com/problems/allpairspath) + ### Tutorial - * CSES 13.3 - * [cp-algo Floyd-Warshall](https://cp-algorithms.com/graph/all-pair-shortest-path-floyd-warshall.html) + - CPH 13.3 + - [cp-algo Floyd-Warshall](https://cp-algorithms.com/graph/all-pair-shortest-path-floyd-warshall.html) -### USACO Gold Problems +### Problems - * [Moortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971) - * Use APSP before running DP. + - [USACO Moortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971) + - Use APSP before running DP. + - [SPOJ Arbitrage](https://www.spoj.com/problems/ARBITRAG/) ## Negative Edge Weights -Hasn't appeared in recent USACO Gold as far as I know. +Hasn't appeared in recent USACO Gold as far as I know. Usually Bellman-Ford is used. If no negative cycles, can use [Shortest Path Faster Algorithm](https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm) or modify Dijkstra slightly (though the same running time bound no longer applies). - * [CSES High Score](https://cses.fi/problemset/task/1673) - * [Kattis SSSP Negative](https://open.kattis.com/problems/shortestpath3) - * [CSES Cycle Finding](https://cses.fi/problemset/task/1197) +### Tutorial + + * [cp-algo Bellman Ford](https://cp-algorithms.com/graph/bellman_ford.html) + * [Topcoder Graphs Pt 3](https://www.topcoder.com/community/data-science/data-science-tutorials/introduction-to-graphs-and-their-data-structures-section-3/) -Can also modify Dijkstra's so it works with negative edge weights (but not negative cycles). The same running time bound no longer applies. +You can also use shortest path algorithms to solve the following problem (a very simple [linear program](https://en.wikipedia.org/wiki/Linear_programming)). + +> Given variables $x_1,x_2,\ldots,x_N$ with constraints in the form $x_i-x_j\ge c$, compute a feasible solution. + + * [Linear Programming Trick](https://www.cs.rit.edu/~spr/COURSES/ALG/MIT/lec18.pdf) + +### Problems + + - General + - [CSES High Score](https://cses.fi/problemset/task/1673) + - [Kattis SSSP Negative](https://open.kattis.com/problems/shortestpath3) + - [CSES (Negative) Cycle Finding](https://cses.fi/problemset/task/1197) + - Simple Linear Programming + - [Restore Array](https://oj.uz/problem/view/RMI19_restore) + - [Art](https://codeforces.com/gym/102394/problem/A) (basically same as above) + - [Timeline (Camp)](https://probgate.org/viewproblem.php?pid=524&cid=80) + - equivalent to [Timeline (Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017) except negative values of $x$ are possible. + - [Truth Telling (Camp)](https://probgate.org/viewproblem.php?pid=378) \ No newline at end of file diff --git a/content/3_Gold/3_Gold_MST.md b/content/3_Gold/3_Gold_MST.md index 0ef4d6d..4b58480 100644 --- a/content/3_Gold/3_Gold_MST.md +++ b/content/3_Gold/3_Gold_MST.md @@ -5,21 +5,20 @@ author: Benjamin Qi order: 3 --- -
- Description: Todo -
+Assumes familiarity with "Gold - Shortest Paths." + +Disjoint Set Union and Minimum Spanning Tree -Standard Problems: +## Standard - [Kattis Minimum Spanning Tree](https://open.kattis.com/problems/minspantree) - - [CSES Road Reparation](https://cses.fi/problemset/task/1675) - - equivalent to above + - same as [CSES Road Reparation](https://cses.fi/problemset/task/1675) ## Tutorial - - CPH 15 + - CPH 15 (Spanning Trees) - Prim's Algorithm - [cp-algo](https://cp-algorithms.com/graph/mst_prim.html) - Similar to Dijkstra @@ -28,6 +27,8 @@ Standard Problems: - [cp-algo 2](https://cp-algorithms.com/graph/mst_kruskal_with_dsu.html) - Requires "Disjoint Set Union" (DSU) data structure - [CSAcademy Disjoint-Set](https://csacademy.com/lesson/disjoint_data_sets) + - [Topcoder Union Find](https://www.topcoder.com/community/data-science/data-science-tutorials/disjoint-set-data-structures/) + - [CPC.3](https://github.com/SuprDewd/T-414-AFLV/tree/master/03_data_structures) - DSU Complexity Proofs (optional of course) - [log\*n](https://en.wikipedia.org/wiki/Proof_of_O(log*n)\_time_complexity\_of_union%E2%80%93find) - [a(m,n)](https://dl.acm.org/doi/pdf/10.1145/321879.321884) @@ -44,4 +45,9 @@ Standard Problems: - same as [CSES Road Construction](https://cses.fi/problemset/task/1676) - [Closing the Farm](http://www.usaco.org/index.php?page=viewproblem2&cpid=646) - [Favorite Colors](http://www.usaco.org/index.php?page=viewproblem2&cpid=1042) - - fairly tricky \ No newline at end of file + - fairly tricky + +## Other Problems + + - [Birthday Gifts](https://www.hackerearth.com/practice/math/combinatorics/inclusion-exclusion/practice-problems/algorithm/mancunian-and-birthday-gifts-d44faa15/) [](73) + - [Spanning Tree Fraction](https://www.hackerrank.com/contests/w31/challenges/spanning-tree-fraction) [](78) \ No newline at end of file diff --git a/content/3_Gold/4_Gold_TopoSort.md b/content/3_Gold/4_Gold_TopoSort.md index d305b3a..3dc9c8e 100644 --- a/content/3_Gold/4_Gold_TopoSort.md +++ b/content/3_Gold/4_Gold_TopoSort.md @@ -5,6 +5,8 @@ author: Benjamin Qi order: 4 --- +Assumes familiarity with "Silver - Depth First Search." + A [topological sort](https://en.wikipedia.org/wiki/Topological_sorting) of a directed graph is a linear ordering of its vertices such that for every directed edge $u\to v$ from vertex $u$ to vertex $v$, $u$ comes before $v$ in the ordering. diff --git a/content/3_Gold/5_Gold_BIT.md b/content/3_Gold/5_Gold_BIT.md index dc22e9b..d01efa1 100644 --- a/content/3_Gold/5_Gold_BIT.md +++ b/content/3_Gold/5_Gold_BIT.md @@ -5,19 +5,18 @@ author: Benjamin Qi order: 5 --- -Assumes that you are familiar with prefix sum queries (CPH 9.1). +Assumes familiarity with "Silver - Prefix Sums." -Given an array of size $N$, perform the following tasks in $O(\log N)$ time each: +A **Binary Indexed Tree** allows you to perform the following tasks in $O(\log N)$ time each on an array of size $N$: - Update the element at a single position (point). - Querying the sum of a prefix of the array. -The easiest way to do this is with a **Binary Indexed Tree.** ## Binary Indexed Tree -Probably the easiest way to do all of these tasks (aka **Fenwick Tree**). +Aka **Fenwick Tree**. ### Sample Problems diff --git a/content/3_Gold/6_Gold_NT.md b/content/3_Gold/6_Gold_NT.md index e740301..e6a8d02 100644 --- a/content/3_Gold/6_Gold_NT.md +++ b/content/3_Gold/6_Gold_NT.md @@ -15,4 +15,14 @@ See 13 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a - Prime factorization, GCD, LCM - Modular Arithmetic -- Fast Exponentiation \ No newline at end of file + +# Binary Exponentiation + + + + * Tutorial + * CPH (23, Matrices) + * Problems + * [Currencies](https://www.hackerrank.com/contests/gs-codesprint/challenges/currencies) [](107) + +COWBASIC \ No newline at end of file diff --git a/content/4_Plat/1_Plat_Trees.md b/content/4_Plat/1_Plat_Trees.md index d4bf4d4..2296da5 100644 --- a/content/4_Plat/1_Plat_Trees.md +++ b/content/4_Plat/1_Plat_Trees.md @@ -5,7 +5,7 @@ author: Benjamin Qi order: 1 --- -Lowest Common Ancestor and other common tree topics. +Lowest Common Ancestor and other tree topics. @@ -74,6 +74,10 @@ Other: - [AI-Cash](http://codeforces.com/blog/entry/22072) - [adamant](https://codeforces.com/blog/entry/53170) +### Problems + +?? + ## Small to Large (Offline) ?? \ No newline at end of file diff --git a/content/4_Plat/2_Plat_1DRQ.md b/content/4_Plat/2_Plat_1DRQ.md index 8f506c4..19bfdad 100644 --- a/content/4_Plat/2_Plat_1DRQ.md +++ b/content/4_Plat/2_Plat_1DRQ.md @@ -5,6 +5,8 @@ author: Benjamin Qi order: 2 --- +Assumes familiarity with "Gold - Binary Indexed Trees." + General range queries for associative operations, including segment tree. @@ -33,13 +35,13 @@ Author: Benjamin Qi This data structure allows you to do point update and range query in $O(\log N)$ time each for any associative operation. In particular, note that **lazy** updates allow you to range updates as well. - - Tutorial - - CPH 9.3, 28.1 (Segment Trees Revisited) - - [Codeforces Tutorial](http://codeforces.com/blog/entry/18051) - - [CSAcademy Tutorial](https://csacademy.com/lesson/segment_trees/) - - [cp-algorithms](https://cp-algorithms.com/data_structures/segment_tree.html) - - [Slides from CPC.3](https://github.com/SuprDewd/T-414-AFLV/tree/master/03_data_structures) - - Special: Minimum Query w/ Number of Minimums +### Tutorials + + - CPH 9.3, 28.1 (Segment Trees Revisited) + - [Codeforces Tutorial](http://codeforces.com/blog/entry/18051) + - [CSAcademy Tutorial](https://csacademy.com/lesson/segment_trees/) + - [cp-algorithms](https://cp-algorithms.com/data_structures/segment_tree.html) + - [Slides from CPC.3](https://github.com/SuprDewd/T-414-AFLV/tree/master/03_data_structures) ### Problems @@ -52,6 +54,8 @@ This data structure allows you to do point update and range query in $O(\log N)$ - [USACO Gold Springboards](http://www.usaco.org/index.php?page=viewproblem2&cpid=995) - can use segment tree with min query in place of the map mentioned in analysis - [POI Cards](https://szkopul.edu.pl/problemset/problem/qpsk3ygf8MU7D_1Es0oc_xd8/site/?key=statement) [](81) + - [CSES Area of Rectangles](https://cses.fi/problemset/task/1741) + - use segment tree that keeps track of minimum and # of minimums - Lazy Updates - [USACO Old Gold The Lazy Cow](http://www.usaco.org/index.php?page=viewproblem2&cpid=418) (check ...) - [USACO Plat Counting Haybales](http://www.usaco.org/index.php?page=viewproblem2&cpid=578) diff --git a/content/4_Plat/3_Plat_2DRQ.md b/content/4_Plat/3_Plat_2DRQ.md index 116c7ef..fad3fc5 100644 --- a/content/4_Plat/3_Plat_2DRQ.md +++ b/content/4_Plat/3_Plat_2DRQ.md @@ -5,7 +5,9 @@ author: Benjamin Qi order: 3 --- -Extend 1D Range Queries to 2D (and beyond). +Assumes familiarity with "Platinum - 1D Range Queries." + +Extending 1D Range Queries to 2D (and beyond). diff --git a/content/4_Plat/5_Plat_Graphs.md b/content/4_Plat/5_Plat_Graphs.md index 2db1240..8fef6f6 100644 --- a/content/4_Plat/5_Plat_Graphs.md +++ b/content/4_Plat/5_Plat_Graphs.md @@ -5,43 +5,62 @@ author: Benjamin Qi order: 5 --- -Eulerian Tours, SCCs, and BCCs. + - Eulerian Tours + - SCCs + - BCCs + Note: all except the third have not appeared on a recent USACO contest. *Some problems sourced from [here](http://codeforces.com/blog/entry/54526?#comment-385354).* -[CPC.10](https://github.com/SuprDewd/T-414-AFLV/tree/master/10_graphs_3_network_flow) ## Eulerian Tours Has not appeared on a recent USACO contest. +### Standard + + - [Mail Delivery](https://cses.fi/problemset/task/1691) + - Undirected Euler Tour + - [Teleporters](https://cses.fi/problemset/task/1693) + - Directed Euler Tour + ### Tutorial - - CPH (19, Path & Circuits) + - CPH (19, Path & Circuits) ### Problems - - [Matching Substrings](https://csacademy.com/contest/archive/task/matching-substrings/) [](87) + - [Matching Substrings](https://csacademy.com/contest/archive/task/matching-substrings/) [](87) ## Strongly Connected Components - - Tarjan - - [Kosaraju](https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm) - - [2-SAT](http://codeforces.com/blog/entry/16205) +### Standard + + - [CSES Planets & Kingdoms](https://cses.fi/problemset/task/1683) + - find SCCs + - [Giant Pizza](https://cses.fi/problemset/task/1684) + - 2SAT ### Tutorial + - Wikipedia + - [Tarjan](https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm) + - [Kosaraju](https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm) - CPH (17, Strong Connectivity) + - [CPC.7](https://github.com/SuprDewd/T-414-AFLV/tree/master/07_graphs_1) + - [CF 2-SAT](http://codeforces.com/blog/entry/16205) + ### Problems + - [Coin Collector](https://cses.fi/problemset/task/1686) + - DP on SCCs - [USACO Old Gold: Grass](http://www.usaco.org/index.php?page=viewproblem2&cpid=516) - [Proving Equivalences](https://open.kattis.com/problems/equivalences) [](78) - [Festival](https://szkopul.edu.pl/problemset/problem/p9uJo01RR9ouMLLAYroFuQ-7/site/?key=statement) [](173) - - [Linear Programming Trick](https://www.cs.rit.edu/~spr/COURSES/ALG/MIT/lec18.pdf) ## Biconnected Components @@ -59,6 +78,8 @@ Related topics include ### Problems + - [CSES Forbidden Cities](https://cses.fi/problemset/task/1705) + - compute block-cut tree - [USACO Plat: Push a Box](http://www.usaco.org/index.php?page=viewproblem2&cpid=769) - [Blockade](https://szkopul.edu.pl/problemset/problem/eDt8w290owtatmCjad0O0ywk/site/?key=statement) - [POLICIJA](http://wcipeg.com/problem/coi06p2) diff --git a/content/4_Plat/6_Plat_Strings.md b/content/4_Plat/6_Plat_Strings.md index 45ee64e..24902af 100644 --- a/content/4_Plat/6_Plat_Strings.md +++ b/content/4_Plat/6_Plat_Strings.md @@ -5,7 +5,13 @@ author: Benjamin Qi order: 6 --- -Hashing, Tries, Z, KMP, Aho-Corasick, Suffix Array, Manacher + - Tries + - Hashing + - Z + - KMP + - Manacher + - Aho-Corasick + - Suffix Array @@ -17,6 +23,10 @@ Note: String algorithms do not appear very frequently. Hashing has appeared on g - [CP-Algorithms String Processing: Fundamentals](https://cp-algorithms.com/) - CPH (26, String Algorithms) +## Tries + + - [Algorithm Gym](http://codeforces.com/blog/entry/15729) + ## Hashing Use to quickly test whether two substrings are equal. @@ -44,10 +54,6 @@ My implementation can be found [here](https://github.com/bqi343/USACO/blob/maste - [Palindromic Characteristics](http://codeforces.com/problemset/problem/835/D) [](100) - [Berland SU Computer Network](http://codeforces.com/contest/847/problem/L) [](142) -## Tries - - - [Algorithm Gym](http://codeforces.com/blog/entry/15729) - ## Z, KMP - Tutorial @@ -55,6 +61,13 @@ My implementation can be found [here](https://github.com/bqi343/USACO/blob/maste - [GeeksForGeeks](http://www.geeksforgeeks.org/searching-for-patterns-set-2-kmp-algorithm/) - [TopCoder](https://www.topcoder.com/community/data-science/data-science-tutorials/introduction-to-string-searching-algorithms/) +## Manacher + + - Has appeared at camp but not in platinum. + - [HackerRank](https://www.hackerrank.com/topics/manachers-algorithm) + - [adamant](http://codeforces.com/blog/entry/12143) + - [cp-algorithms](https://cp-algorithms.com/string/manacher.html) + ## Aho-Corasick - Has appeared in old gold. @@ -65,10 +78,3 @@ My implementation can be found [here](https://github.com/bqi343/USACO/blob/maste ## Suffix Array - [USACO Plat - Standing Out from the Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=768) - -## Manacher - - - Has appeared at camp but not in platinum. - - [HackerRank](https://www.hackerrank.com/topics/manachers-algorithm) - - [adamant](http://codeforces.com/blog/entry/12143) - - [cp-algorithms](https://cp-algorithms.com/string/manacher.html) \ No newline at end of file diff --git a/content/4_Plat/7_Plat_Bitset.md b/content/4_Plat/7_Plat_Bitset.md index f54e953..3728863 100644 --- a/content/4_Plat/7_Plat_Bitset.md +++ b/content/4_Plat/7_Plat_Bitset.md @@ -5,7 +5,7 @@ author: Benjamin Qi order: 7 --- -Bitset leads to some unintended solutions. +Three examples of how bitset leads to some unintended solutions on recent USACO problems. @@ -181,4 +181,4 @@ Again, the intended solution runs in $O(N^3)$. Of course, it is still possible t Using operations such as `_Find_first()` and `_Find_next()` mentioned in Errichto's blog above, you can speed up the following: * BFSing through a dense graph with $N$ vertices in $O(N^2)$ - * bipartite matching in $O(N^3)$ + * bipartite matching in $O(N^3)$ \ No newline at end of file diff --git a/content/4_Plat/9_Plat_Fracture.md b/content/4_Plat/8_Plat_Fracture.md similarity index 98% rename from content/4_Plat/9_Plat_Fracture.md rename to content/4_Plat/8_Plat_Fracture.md index 3eb68ac..afc0dd0 100644 --- a/content/4_Plat/9_Plat_Fracture.md +++ b/content/4_Plat/8_Plat_Fracture.md @@ -2,10 +2,10 @@ slug: /plat/fracture title: "Fracturing Search" author: Benjamin Qi -order: 9 +order: 8 --- -A simpler solution to robotic cow herd that generalizes. +A simple solution to [Robotic Cow Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=674) that generalizes. diff --git a/content/4_Plat/8_Plat_Matrix.md b/content/4_Plat/8_Plat_Matrix.md deleted file mode 100644 index 6a66c41..0000000 --- a/content/4_Plat/8_Plat_Matrix.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -slug: /plat/matrix -title: "Platinum - Matrix Exponentiation" -author: ? -order: 8 ---- - -Matrix Exponentiation - - - - * Tutorial - * CPH (23, Matrices) - * Problems - * [Currencies](https://www.hackerrank.com/contests/gs-codesprint/challenges/currencies) [](107) - -COWBASIC \ No newline at end of file diff --git a/content/4_Plat/10_Plat_Slope.md b/content/4_Plat/9_Plat_Slope.md similarity index 87% rename from content/4_Plat/10_Plat_Slope.md rename to content/4_Plat/9_Plat_Slope.md index bf6f26e..516aded 100644 --- a/content/4_Plat/10_Plat_Slope.md +++ b/content/4_Plat/9_Plat_Slope.md @@ -2,12 +2,12 @@ slug: /plat/slope title: "Slope Trick" author: Benjamin Qi -order: 10 +order: 9 --- -**Slope trick** refers to manipulating piecewise linear convex functions. Includes a simple solution to "Landscaping." +**Slope trick** refers to manipulating piecewise linear convex functions. Includes a simple solution to [Landscaping](http://www.usaco.org/index.php?page=viewproblem2&cpid=650). - + ## Tutorials @@ -123,7 +123,7 @@ int main() { ``` -## Landscaping +## [Landscaping](http://www.usaco.org/index.php?page=viewproblem2&cpid=650) This is quite similar to the previous task, so it's easy to guess that slope trick is applicable. @@ -190,16 +190,16 @@ int main() { ## Problems - * [Moving Haybales (USACO Camp)](https://probgate.org/viewproblem.php?pid=247) - * [Wall](https://atcoder.jp/contests/kupc2016/tasks/kupc2016_h) - * same as "Potatoes" - * [Stock Trading (USACO Camp)](https://probgate.org/viewproblem.php?pid=531&cid=81) - * extension of "Buy Low Sell High" - * [Bookface](https://codeforces.com/group/ZFgXbZSjvp/contest/274852/problem/C) - * [CCDSAP Exam](https://www.codechef.com/problems/CCDSAP) - * [Farm of Monsters](https://codeforces.com/gym/102538/problem/F) - * [Moving Walkways](https://codeforces.com/contest/1209/problem/H) - * [April Fools' Problem](https://codeforces.com/contest/802/problem/O) - * [Conquer the World](https://icpc.kattis.com/problems/conquertheworld) - * note: ICPC world finals, 0 solves in contest - * "Potatoes" on tree!! \ No newline at end of file + - [Moving Haybales (USACO Camp)](https://probgate.org/viewproblem.php?pid=247) + - [Wall](https://atcoder.jp/contests/kupc2016/tasks/kupc2016_h) + - same as "Potatoes" + - [Stock Trading (USACO Camp)](https://probgate.org/viewproblem.php?pid=531&cid=81) + - extension of "Buy Low Sell High" + - [Bookface](https://codeforces.com/group/ZFgXbZSjvp/contest/274852/problem/C) + - [CCDSAP Exam](https://www.codechef.com/problems/CCDSAP) + - [Farm of Monsters](https://codeforces.com/gym/102538/problem/F) + - [Moving Walkways](https://codeforces.com/contest/1209/problem/H) + - [April Fools' Problem](https://codeforces.com/contest/802/problem/O) + - [Conquer the World](https://icpc.kattis.com/problems/conquertheworld) + - note: ICPC world finals, 0 solves in contest + - "Potatoes" on tree!! \ No newline at end of file From 1bdf4b0dce70dcc8b9e0055e6c612a8386d602e8 Mon Sep 17 00:00:00 2001 From: Benjamin Qi Date: Thu, 4 Jun 2020 17:58:53 -0400 Subject: [PATCH 2/2] minor --- content/0_Intro/Intro.md | 6 +++--- content/2_Silver/2_Silver_Containers.md | 8 +++++--- content/2_Silver/3_Silver_Sorting.md | 4 ++++ content/3_Gold/2_Gold_SP.md | 3 +-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/content/0_Intro/Intro.md b/content/0_Intro/Intro.md index 72d50f9..5aa6e26 100644 --- a/content/0_Intro/Intro.md +++ b/content/0_Intro/Intro.md @@ -28,10 +28,10 @@ In general, we recommend the following: - For Bronze contestants, any of C++/Java/Python will do. - If you know multiple languages, we recommend you pick C++ over Java, and Java over Python. - For Silver, Gold, and Platinum, we recommend C++/Java. - - If you know multiple languages, we recommend you pick C++ over Java since C++ is faster. - - It's not guaranteed that you can receive full points for every problem using Python (even for Silver). + - If you know multiple languages, we recommend you pick C++ over Java. + - Python and Java have trouble passing time limits even for Silver despite the x2 multiplier. - Rewriting the C++ solution for [Wormsort](http://www.usaco.org/index.php?page=viewproblem2&cpid=992) in Python gets TLE on 2/10 cases. - - A similar solution in Java requires almost 3s (for a time limit of 4s) + - A similar solution in Java requires almost 3s, which is fairly close to the time limit of 4s. Note: A majority of high level contestants use C++ and Java. Between those, C++ is more popular. diff --git a/content/2_Silver/2_Silver_Containers.md b/content/2_Silver/2_Silver_Containers.md index 078744c..63856b8 100644 --- a/content/2_Silver/2_Silver_Containers.md +++ b/content/2_Silver/2_Silver_Containers.md @@ -23,7 +23,7 @@ order: 2 -(from github) +(from my github) * Types * Set, Multiset, Unordered Set @@ -33,7 +33,6 @@ order: 2 * Priority Queue (Heap) * Vector * Stack - * Bitset * Tutorial * CPH (4, Data Structures) * [C++ Reference](http://www.cplusplus.com/reference/stl/) @@ -44,4 +43,7 @@ order: 2 * [Jury Marks](http://codeforces.com/contest/831/problem/C) [](67) * [Mahmoud & Ehab & Function](http://codeforces.com/contest/862/problem/E) [](74) * [Karen & Cards](http://codeforces.com/contest/815/problem/D) [](86) - * [Tournament](http://codeforces.com/contest/878/problem/C) [](106) \ No newline at end of file + * [Tournament](http://codeforces.com/contest/878/problem/C) [](106) + + +[Blowing up Unordered Map](https://codeforces.com/blog/entry/62393) \ No newline at end of file diff --git a/content/2_Silver/3_Silver_Sorting.md b/content/2_Silver/3_Silver_Sorting.md index 74e52e6..89c1d2a 100644 --- a/content/2_Silver/3_Silver_Sorting.md +++ b/content/2_Silver/3_Silver_Sorting.md @@ -19,3 +19,7 @@ order: 3 See 8 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a See 12 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a + + + - [Breaking Java Arrays.sort()](https://codeforces.com/blog/entry/4827) + - no longer works, see [this one](https://codeforces.com/contest/1324/submission/73058869) instead \ No newline at end of file diff --git a/content/3_Gold/2_Gold_SP.md b/content/3_Gold/2_Gold_SP.md index 641a2c5..2dfdc78 100644 --- a/content/3_Gold/2_Gold_SP.md +++ b/content/3_Gold/2_Gold_SP.md @@ -112,5 +112,4 @@ You can also use shortest path algorithms to solve the following problem (a very - [Restore Array](https://oj.uz/problem/view/RMI19_restore) - [Art](https://codeforces.com/gym/102394/problem/A) (basically same as above) - [Timeline (Camp)](https://probgate.org/viewproblem.php?pid=524&cid=80) - - equivalent to [Timeline (Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017) except negative values of $x$ are possible. - - [Truth Telling (Camp)](https://probgate.org/viewproblem.php?pid=378) \ No newline at end of file + - equivalent to [Timeline (Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017) except negative values of $x$ are possible. \ No newline at end of file