diff --git a/content/1_Intro/Example_Problem.md b/content/1_Intro/Example_Problem.md index 7332f6e..fe0e4cf 100644 --- a/content/1_Intro/Example_Problem.md +++ b/content/1_Intro/Example_Problem.md @@ -180,8 +180,15 @@ fout.write(str(ans)) The following require relatively little programming experience and no algorithmic knowledge. Do as many as you want, then move on! You do not have to do all of them. - - [Promotion Counting](http://usaco.org/index.php?page=viewproblem2&cpid=591) - - [Word Processor](http://usaco.org/index.php?page=viewproblem2&cpid=987) - - [Square Pasture](http://usaco.org/index.php?page=viewproblem2&cpid=663) - - [CSES Introductory Problems](https://cses.fi/problemset/list/) - - up to and including "Palindrome Reorder" \ No newline at end of file + + + + Can also do range XOR queries w/ update. + + + + + + + +Also check the [CSES Introductory Problems](https://cses.fi/problemset/list/) up to and including "Palindrome Reorder." \ No newline at end of file diff --git a/content/3_Bronze/Complete_Search.md b/content/3_Bronze/Complete_Search.mdx similarity index 54% rename from content/3_Bronze/Complete_Search.md rename to content/3_Bronze/Complete_Search.mdx index b7aa884..5d659d2 100644 --- a/content/3_Bronze/Complete_Search.md +++ b/content/3_Bronze/Complete_Search.mdx @@ -33,7 +33,7 @@ Print one integer, the square of the maximum Euclidean distance between any two ### Solution -We can brute-force every pair of points and find the square of the distance between them, by squaring the formula for Euclidean distance: $\text{distance}^2 = (x_2-x_1)^2 + (y_2-y_1)^2$. Thus, we store the coordinates in arrays \mintinline{java}{X[]} and \mintinline{java}{Y[]}, such that \mintinline{java}{X[i]} and \mintinline{java}{Y[i]} are the $x$- and $y$-coordinates of the $i_{th}$ point, respectively. Then, we iterate through all possible pairs of points, using a variable max to store the maximum square of distance between any pair seen so far, and if the square of the distance between a pair is greater than our current maximum, we set our current maximum to it. +We can brute-force every pair of points and find the square of the distance between them, by squaring the formula for Euclidean distance: $\text{distance}^2 = (x_2-x_1)^2 + (y_2-y_1)^2$. Thus, we store the coordinates in arrays `X[]` and `Y[]`, such that `X[i]` and `Y[i]` are the $x$- and $y$-coordinates of the $i_{th}$ point, respectively. Then, we iterate through all possible pairs of points, using a variable max to store the maximum square of distance between any pair seen so far, and if the square of the distance between a pair is greater than our current maximum, we set our current maximum to it. Java: @@ -67,7 +67,10 @@ for(int i = 0; i < n; i++){ // for each first point cout << high << endl; ``` -A couple notes: first, since we're iterating through all pairs of points, we start the $j$ loop from $j = i+1$ so that point $i$ and point $j$ are never the same point. Furthermore, it makes it so that each pair is only counted once. In this problem, it doesn't matter whether we double-count pairs or whether we allow $i$ and $j$ to be the same point, but in other problems where we're counting something rather than looking at the maximum, it's important to be careful that we don't overcount. Secondly, the problem asks for the square of the maximum Euclidean distance between any two points. Some students may be tempted to maintain the maximum distance in a variable, and then square it at the end when outputting. However, the problem here is that while the square of the distance between two integer points is always an integer, the distance itself isn't guaranteed to be an integer. Thus, we'll end up shoving a non-integer value into an integer variable, which truncates the decimal part. Using a floating point variable isn't likely to work either, due to precision errors (use of floating point decimals should generally be avoided when possible). +A couple notes: + + - First, since we're iterating through all pairs of points, we start the $j$ loop from $j = i+1$ so that point $i$ and point $j$ are never the same point. Furthermore, it makes it so that each pair is only counted once. In this problem, it doesn't matter whether we double-count pairs or whether we allow $i$ and $j$ to be the same point, but in other problems where we're counting something rather than looking at the maximum, it's important to be careful that we don't overcount. + - Secondly, the problem asks for the square of the maximum Euclidean distance between any two points. Some students may be tempted to maintain the maximum distance in a variable, and then square it at the end when outputting. However, the problem here is that while the square of the distance between two integer points is always an integer, the distance itself isn't guaranteed to be an integer. Thus, we'll end up shoving a non-integer value into an integer variable, which truncates the decimal part. Using a floating point variable isn't likely to work either, due to precision errors (use of floating point decimals should generally be avoided when possible). (Ben - have you verified this claim?) @@ -79,7 +82,9 @@ In Java, we'll have to implement this ourselves, which is called [Heap's Algorit As an example, here are the permutations generated by Heap's Algorithm for \([1, 2, 3]\): -$$[1, 2, 3], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [3, 2, 1]$$ +$$ +[1, 2, 3], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [3, 2, 1] +$$ Code for iterating over all permutations is as follows: @@ -110,33 +115,57 @@ do { } while(next_permutation(v.begin(), v.end())); ``` +Note that this generates the permutations in **lexicographical order** (explanation) + ## Problems - - CSES - - [Creating Strings I](https://cses.fi/problemset/task/1622) - - [Apple Division](https://cses.fi/problemset/task/1623) - - [Chessboard and Queens](https://cses.fi/problemset/task/1624) + + + + + + - go through all permutations + + + - USACO Bronze - - [Triangles](http://usaco.org/index.php?page=viewproblem2&cpid=1011) - - [Photoshoot](http://www.usaco.org/index.php?page=viewproblem2&cpid=988) - - Hint: Figure out what exactly you're complete searching - - [Cow Gymnastics](http://usaco.org/index.php?page=viewproblem2&cpid=963) - - Hint: Brute force over all possible pairs - - [Milk Pails](http://usaco.org/index.php?page=viewproblem2&cpid=615) - - [Lifeguards](http://usaco.org/index.php?page=viewproblem2&cpid=784) - - Hint: Try removing each lifeguard one at a time. - - [Where Am I?](http://usaco.org/index.php?page=viewproblem2&cpid=964) - - Hint: Brute force over all possible substrings. - - (Permutations) [Livestock Lineup](http://usaco.org/index.php?page=viewproblem2&cpid=965) - - [Field Reduction](http://www.usaco.org/index.php?page=viewproblem2&cpid=641) - - Hint: For this problem, you can't do a full complete search; you have to do a reduced search) - - [Back and Forth](http://www.usaco.org/index.php?page=viewproblem2&cpid=857) - - Somewhat harder + + + + Hint: Fix the number of first-type operations you perform. + + + + + Hint: Brute force over all possible pairs. + + + Hint: Try removing each lifeguard one at a time. + + + Hint: Brute force over all possible substrings. + + + Hint: Figure out what exactly you're complete searching. + + + Hint: For this problem, you can't do a full complete search; you have to do a reduced search. + + + + + + + - USACO Silver - - [Bovine Genomics](http://usaco.org/index.php?page=viewproblem2&cpid=739) - - [Field Reduction](http://usaco.org/index.php?page=viewproblem2&cpid=642) - + + + + + + + diff --git a/content/3_Bronze/DS.mdx b/content/3_Bronze/DS.mdx index 7f6de5d..1abea17 100644 --- a/content/3_Bronze/DS.mdx +++ b/content/3_Bronze/DS.mdx @@ -9,29 +9,30 @@ prerequisites: ## Standard - - [yosupo - Associative Array](https://judge.yosupo.jp/problem/associative_array) - - CSES - - Do roughly the first half of the Sorting and Searching section in the [CSES Problem Set](https://cses.fi/problemset/) - - [Distinct Numbers](https://cses.fi/problemset/task/1621) - - [Concert Tickets](https://cses.fi/problemset/task/1091) - - Uses iterators - - [Sum of Two Values](https://cses.fi/problemset/task/1640) - - Uses iterators - - Can be solved without sets +Do roughly the first half of the Sorting and Searching section in the [CSES Problem Set](https://cses.fi/problemset/). + + + + + + - Can be solved without sets + + + diff --git a/content/3_Bronze/Intro_Graphs.md b/content/3_Bronze/Intro_Graphs.md index 82f754f..520accc 100644 --- a/content/3_Bronze/Intro_Graphs.md +++ b/content/3_Bronze/Intro_Graphs.md @@ -26,18 +26,22 @@ Both of these will be covered in Silver. For now, it suffices to learn how graph ## Trees? - ## USACO Bronze Problems -(what are you expected to now?) +(what are you expected to know?) (add some more) - - Tree - - [Factory](http://usaco.org/index.php?page=viewproblem2&cpid=940) - - [Family Tree](http://usaco.org/index.php?page=viewproblem2&cpid=833) - - [Grass Planting (Silver)](http://usaco.org/index.php?page=viewproblem2&cpid=894) - - Permutation - - [Swapity Swap](http://usaco.org/index.php?page=viewproblem2&cpid=1013) - - General Graph - - [The Great Revegetation](http://usaco.org/index.php?page=viewproblem2&cpid=916) \ No newline at end of file + + + + + + + + + Hint: One option is to keep swapping until the permutation returns to its original state (but can you do better?). + + + + \ No newline at end of file diff --git a/content/3_Bronze/Rect_Geo.md b/content/3_Bronze/Rect_Geo.mdx similarity index 87% rename from content/3_Bronze/Rect_Geo.md rename to content/3_Bronze/Rect_Geo.mdx index b3bdfe4..9e085ac 100644 --- a/content/3_Bronze/Rect_Geo.md +++ b/content/3_Bronze/Rect_Geo.mdx @@ -2,9 +2,13 @@ id: rect-geo title: "Rectangle Geometry" author: Darren Yao, Michael Cao, Benjamin Qi -description: "\"Geometry\" problems on USACO Bronze are usually quite simple and limited to intersections and unions of squares or rectangles." +description: "Problems on 2D grids" --- +# Geometry + +\"Geometry\" problems on USACO Bronze are usually quite simple and limited to intersections and unions of squares or rectangles. + Most only include two or three squares or rectangles, in which case you can simply draw out cases on paper. This should logically lead to a solution. ## Example: [Blocked Billboard](http://usaco.org/index.php?page=viewproblem2&cpid=759) @@ -152,13 +156,14 @@ int main(){ ## Problems - - USACO Bronze - - [Fence Painting](http://usaco.org/index.php?page=viewproblem2&cpid=567) - - 1D geometry!! - - [Square Pasture](http://usaco.org/index.php?page=viewproblem2&cpid=663) - - [Blocked Billboard II](http://usaco.org/index.php?page=viewproblem2&cpid=783) - - Also rectangles - - Other - - [CF 587 (Div. 3) C: White Sheet](https://codeforces.com/contest/1216/problem/C) - - See this code (TODO; codeforces is down) for a nice implementation using the Java Rectangle class. + + + + + also rectangles + + + See this code (TODO; codeforces is down) for a nice implementation using the Java Rectangle class. + + diff --git a/content/4_Silver/2P.mdx b/content/4_Silver/Amortized.mdx similarity index 100% rename from content/4_Silver/2P.mdx rename to content/4_Silver/Amortized.mdx diff --git a/content/5_Gold/Bin_Jump.md b/content/5_Gold/Bin_Jump.md index 6fcdbac..483db62 100644 --- a/content/5_Gold/Bin_Jump.md +++ b/content/5_Gold/Bin_Jump.md @@ -5,20 +5,23 @@ author: Benjamin Qi description: Introduces the problems of finding level ancestors in a tree and computing the lowest common ancestors. --- + + + + + + + + + ## Binary Jumping - - CSES - - [Planet Queries I](https://cses.fi/problemset/task/1750) - - [Company Queries I](https://cses.fi/problemset/task/1687) - ## Lowest Common Ancestor - - [CSES Company Queries II](https://cses.fi/problemset/task/1688) - ### Tutorial - CPH 18.1, 18.3 - - [cp-algorithms: Lowest Common Ancestor](https://cp-algorithms.com/) + - [cp-algorithms](https://cp-algorithms.com/) @@ -30,25 +33,28 @@ description: Introduces the problems of finding level ancestors in a tree and co ### Problems - - CSES - - [Distance Queries](https://cses.fi/problemset/task/1135/) - - [Planets Queries II](https://cses.fi/problemset/task/1160) - - USACO - - Gold - - [Cow Land](http://www.usaco.org/index.php?page=viewproblem2&cpid=921) - - LCA + BIT - - Plat - - [Max Flow](http://www.usaco.org/index.php?page=viewproblem2&cpid=576) - - [Disruption](http://www.usaco.org/index.php?page=viewproblem2&cpid=842) - - [Newbarns](http://www.usaco.org/index.php?page=viewproblem2&cpid=817) - - online tree diameter - - Copy of [CF Brain Network "Hard"](https://codeforces.com/contest/690/problem/C3) - - [Tree Boxes](http://www.usaco.org/index.php?page=viewproblem2&cpid=948) - - interactive!! - - [Gathering](http://www.usaco.org/index.php?page=viewproblem2&cpid=866) - - test cases added after contest ... - - [Exercise](http://www.usaco.org/index.php?page=viewproblem2&cpid=901) - - tricky - - Other - - [Hot & Cold](https://dmoj.ca/problem/bts17p7) [](105) - - [Root LCA Queries](https://csacademy.com/contest/archive/task/root-lca-queries/) [](107) + + + + + + + + + + + + + + + - interactive!! + + + Copy of [CF Brain Network "Hard"](https://codeforces.com/contest/690/problem/C3) + + + - interactive!! + + + + \ No newline at end of file diff --git a/content/5_Gold/DS.md b/content/5_Gold/DS.md deleted file mode 100644 index 5416d3c..0000000 --- a/content/5_Gold/DS.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -id: ds-gold -title: "Data Structures" -author: Michael Cao -prerequisites: - - Silver - Data Structures -description: "Monotonic stack and sliding window." ---- - -# Springboards DS - - - [Karen & Cards](http://codeforces.com/contest/815/problem/D) [](86) - - Extremely hard, do not attempt (2800 on CF) -(add more once codeforces comes up) \ No newline at end of file diff --git a/content/5_Gold/MST.md b/content/5_Gold/MST.md index 8b9e204..9e85577 100644 --- a/content/5_Gold/MST.md +++ b/content/5_Gold/MST.md @@ -8,10 +8,14 @@ prerequisites: description: A subset of the edges of a connected, undirected, edge-weighted graph that connects all the vertices to each other of minimum total weight, where no cycles are allowed. --- -## Standard +## Sample - - [Kattis Minimum Spanning Tree](https://open.kattis.com/problems/minspantree) - - same as [CSES Road Reparation](https://cses.fi/problemset/task/1675) + + + + + + ## Tutorial @@ -26,11 +30,16 @@ description: A subset of the edges of a connected, undirected, edge-weighted gra ## USACO Gold Problems - - [Old Silver - SuperBull](http://www.usaco.org/index.php?page=viewproblem2&cpid=531) - - [Walk](http://usaco.org/index.php?page=viewproblem2&cpid=946) - - Prim's is applicable, but the edge weights are special so you don't actually need to use an MST algo ... - - [Fencedin](http://www.usaco.org/index.php?page=viewproblem2&cpid=623) - - also special ... + + + + + + + + + + ## Other Problems diff --git a/content/5_Gold/Merging.md b/content/5_Gold/Merging.md index ebb2db4..874caf1 100644 --- a/content/5_Gold/Merging.md +++ b/content/5_Gold/Merging.md @@ -46,13 +46,16 @@ Prove that if you instead merge sets that have size equal to the depths of the s ## Problems - - USACO - - [Gold - Favorite Colors](http://www.usaco.org/index.php?page=viewproblem2&cpid=1042) - - merge adjacency lists - - not required to get AC - - [Plat - Disruption](http://www.usaco.org/index.php?page=viewproblem2&cpid=842) - - [Plat - Promotion Counting](http://www.usaco.org/index.php?page=viewproblem2&cpid=696) +(note about indexed set swap) + + + + + + + + + - merge indexed sets - - Other - - [CSES Distinct Colors](https://cses.fi/problemset/task/1139) - - [CF Lomsat gelral](https://codeforces.com/contest/600/problem/E) + + \ No newline at end of file diff --git a/content/5_Gold/PURQ.md b/content/5_Gold/PURQ.md index 9963c8e..d578811 100644 --- a/content/5_Gold/PURQ.md +++ b/content/5_Gold/PURQ.md @@ -35,6 +35,4 @@ Can try solving some of the BIT questions w/ segtree. - [USACO Old Gold Marathon](http://www.usaco.org/index.php?page=viewproblem2&cpid=495) (check ...) - [USACO Plat Balancing](http://www.usaco.org/index.php?page=viewproblem2&cpid=624) (check ...) - [USACO Plat Nocross](http://www.usaco.org/index.php?page=viewproblem2&cpid=721) - - [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 + - [POI Cards](https://szkopul.edu.pl/problemset/problem/qpsk3ygf8MU7D_1Es0oc_xd8/site/?key=statement) [](81) \ No newline at end of file diff --git a/content/5_Gold/PURS.md b/content/5_Gold/PURS.md index a543e55..18bc6c3 100644 --- a/content/5_Gold/PURS.md +++ b/content/5_Gold/PURS.md @@ -4,10 +4,21 @@ title: "Point Update Range Sum" author: Benjamin Qi prerequisites: - Silver - Prefix Sums -description: Binary Indexed Trees & Indexed Sets +description: Introducing Binary Indexed Trees & Indexed Sets (C++ only). --- - - [yosupo - Point Add Range Sum](https://judge.yosupo.jp/problem/point_add_range_sum) +## Sample Problems + + + + + + Can also do range XOR queries w/ update. + + + Solution notes go here. **Markdown suppported maybe?** + + ## Binary Indexed Tree @@ -18,18 +29,6 @@ A *Binary Indexed Tree* allows you to perform the following tasks in $O(\log N)$ Aka *Fenwick Tree*. - -### Sample Problems - - - - Can also do range XOR queries w/ update. - - - Solution notes go here. **Markdown suppported maybe?** - - - ### Tutorials * CPH 9.2, 9.4 @@ -53,6 +52,8 @@ In the special case where all elements of the array are either zero or one (whic See the link for more examples of usage. + + ```cpp #include using namespace std; @@ -78,12 +79,12 @@ int main() { } ``` + + Note that if it were not the case that all elements of the input array were distinct, then this code would be incorrect since `Tree` would remove duplicates. Instead, we would use an indexed set of pairs (`Tree>`), where the first element of each pair would denote the value while the second would denote the array position. ## Practice Problems - - CSES - easy with indexed set @@ -98,44 +99,39 @@ Note that if it were not the case that all elements of the input array were dist + + also just inversion counting + + + Offline 2D queries can be done with a 1D data structure + + Do queries in increasing order of $a$. - - USACO Gold - - The first three problems are just variations on inversion counting. +USACO Gold: + - The first three problems are just variations on inversion counting. - + - + - + - + All USACO problems (aside from some special exceptions) have only one possible output. - - - - -* Other Problems: - - - - - also just inversion counting - - aka [Sorting Steps](https://csacademy.com/contest/round-42/task/sorting-steps/) [](42) - Of course, this doesn't require anything other than sorting but fast range sum queries may make this easier. - - Offline 2D queries can be done with a 1D data structure + diff --git a/content/5_Gold/Springboards.md b/content/5_Gold/Springboards.md index 8808dbc..60662b1 100644 --- a/content/5_Gold/Springboards.md +++ b/content/5_Gold/Springboards.md @@ -5,7 +5,7 @@ author: Benjamin Qi prerequisites: - Silver - More with Maps & Sets - Silver - Amortized Analysis -description: "Solving USACO Gold - Springboards" +description: "Solving USACO Gold - Springboards." --- To solve USACO Gold [Springboards](http://www.usaco.org/index.php?page=viewproblem2&cpid=995), we need a data structure that supports operations similar to the following: @@ -43,6 +43,11 @@ ll query(int x) { auto it = m.lb(x); (easier examples?) - - [CF: Karen & Cards](https://codeforces.com/contest/815/problem/D) - - For each $a$ from $p\to 1$, calculate the number of possible cards with that value of $a$. - - [GP of Korea 19 - Interesting Drug](https://codeforces.com/gym/102059/problem/K) + + + - For each $a$ from $p\to 1$, calculate the number of possible cards with that value of $a$. + + + - Genfuncs not required but possibly helpful + + diff --git a/content/5_Gold/Tree_Euler.md b/content/5_Gold/Tree_Euler.md index 91c8fa1..6304cb1 100644 --- a/content/5_Gold/Tree_Euler.md +++ b/content/5_Gold/Tree_Euler.md @@ -5,10 +5,18 @@ author: ? prerequisites: - Silver - Depth First Search - Gold - Static Range Queries + - Gold - Point Update Range Sum description: Subtree updates and queries and another way to compute lowest common ancestors. --- - - [CSES: Subtree Queries](https://cses.fi/problemset/task/1137) +## Sample Problems + + + + + + + ## Tutorial @@ -17,8 +25,15 @@ description: Subtree updates and queries and another way to compute lowest commo ## Problems - - [CSES: Path Queries](https://cses.fi/problemset/task/1138) - - USACO - - [Gold - Milk Visits](http://www.usaco.org/index.php?page=viewproblem2&cpid=970) - - [Plat - Promotion Counting](http://www.usaco.org/index.php?page=viewproblem2&cpid=696) - - [Plat - Snow-Cow](http://www.usaco.org/index.php?page=viewproblem2&cpid=973) \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/content/6_Plat/2DRQ.md b/content/6_Plat/2DRQ.md index 44c890c..2d495a7 100644 --- a/content/6_Plat/2DRQ.md +++ b/content/6_Plat/2DRQ.md @@ -67,4 +67,5 @@ Note: no lazy propagation in 2D. ### Problems - [POI Tetris 3D](https://szkopul.edu.pl/problemset/problem/OQjANSOOD_-c38gh8p6g3Gxp/site/?key=statement) - - [IOI 2013 Game](http://wcipeg.com/problem/ioi1323) \ No newline at end of file + - [IOI 2013 Game](http://wcipeg.com/problem/ioi1323) + - good implementation? \ No newline at end of file diff --git a/content/6_Plat/Centroid.md b/content/6_Plat/Centroid.md index e9e02c7..7b6a699 100644 --- a/content/6_Plat/Centroid.md +++ b/content/6_Plat/Centroid.md @@ -14,8 +14,13 @@ description: ? ### Problems - - [Ciel the Commander](https://codeforces.com/problemset/problem/321/C) - - [DMOJ Bob Equilibrium](https://dmoj.ca/problem/dmopc19c7p6) - - tight time limit - - [USACO Plat - At Large](http://www.usaco.org/index.php?page=viewproblem2&cpid=793) - - *very* tricky, requires several observations + + + + + - tight time limit + + + - tight time limit + + \ No newline at end of file diff --git a/content/6_Plat/DP_Bitmasks.md b/content/6_Plat/DP_Bitmasks.md index f2ae0e6..9ffff9f 100644 --- a/content/6_Plat/DP_Bitmasks.md +++ b/content/6_Plat/DP_Bitmasks.md @@ -19,8 +19,13 @@ Has not been the solution to any platinum problem, but appeared in old gold and ## Problems - - [CSES Hamiltonian Flights](https://cses.fi/problemset/task/1690) - - [CSES Elevator Rides](https://cses.fi/problemset/task/1653) + + + + + + + - [Old Gold - Moovie Moving](http://www.usaco.org/index.php?page=viewproblem2&cpid=515) - [AC Matching](https://atcoder.jp/contests/dp/tasks/dp_o) - [CF Square Subsets](https://codeforces.com/contest/895/problem/C) diff --git a/content/6_Plat/DP_Ranges.md b/content/6_Plat/DP_Ranges.md index 9dd6765..77667a4 100644 --- a/content/6_Plat/DP_Ranges.md +++ b/content/6_Plat/DP_Ranges.md @@ -9,10 +9,17 @@ description: Solving the problem on every contiguous subarray of the original ar ## Problems - * [Gold - 248](http://www.usaco.org/index.php?page=viewproblem2&cpid=647) - * more straightforward - * TC SRM 787 500 - * [CSES Empty String](https://cses.fi/problemset/task/1080) - * [CF Zuma](https://codeforces.com/problemset/problem/607/B) - * [Plat - Greedy Pie Eaters](http://www.usaco.org/index.php?page=viewproblem2&cpid=972) - * [Plat - Subsequence Reversal](http://www.usaco.org/index.php?page=viewproblem2&cpid=698) \ No newline at end of file + + + + + + + + + + + + + + * TC SRM 787 500 \ No newline at end of file diff --git a/content/6_Plat/FFT.md b/content/6_Plat/FFT.md index 0b62eb2..19aaf63 100644 --- a/content/6_Plat/FFT.md +++ b/content/6_Plat/FFT.md @@ -32,9 +32,14 @@ description: "?" ## Counting - - USACO Plat - - [Tree Depth](http://www.usaco.org/index.php?page=viewproblem2&cpid=974) - - [Exercise](http://www.usaco.org/index.php?page=viewproblem2&cpid=1045) + + + + + - genfuncs not required but possibly helpful + + + - [zscoder GenFunc Pt 1](https://codeforces.com/blog/entry/77468) - [zscoder GenFunc Pt 2](https://codeforces.com/blog/entry/77551) diff --git a/content/6_Plat/HLD.md b/content/6_Plat/HLD.md index 0fc3a46..f6e69be 100644 --- a/content/6_Plat/HLD.md +++ b/content/6_Plat/HLD.md @@ -4,6 +4,7 @@ title: "Heavy-Light Decomposition" author: Benjamin Qi prerequisites: - Gold - Euler Tour on Tree + - Platinum - Range Update Range Query description: Path and subtree updates and queries. --- @@ -17,4 +18,8 @@ description: Path and subtree updates and queries. ### Problems - - [Disrupt](http://www.usaco.org/index.php?page=viewproblem2&cpid=842) \ No newline at end of file + + + + + \ No newline at end of file diff --git a/content/6_Plat/RURQ.md b/content/6_Plat/RURQ.md index d5839b9..cb645ee 100644 --- a/content/6_Plat/RURQ.md +++ b/content/6_Plat/RURQ.md @@ -11,9 +11,19 @@ CPH 28.1 (Segment Trees Revisited) ## Lazy Segment Tree - - [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) - - [CSES Area of Rectangles](https://cses.fi/problemset/task/1741) +(problem that's only increment with no sets?) + + + + + + + + + + - use segment tree that keeps track of minimum and # of minimums + + ## BIT Revisited @@ -23,7 +33,9 @@ Binary Indexed Trees can support range increments in addition to range sum queri - [GFG Range Update Range Query](https://www.geeksforgeeks.org/binary-indexed-tree-range-update-range-queries/) - [My Implementation](https://github.com/bqi343/USACO/blob/master/Implementations/content/data-structures/1D%20Range%20Queries%20(9.2)/BITrange.h) -Example problem: - - - [DMOJ Range Update Range Query](https://dmoj.ca/problem/acc3p4) - - [CSES Polynomial Queries](https://cses.fi/problemset/task/1736) + + + + + + \ No newline at end of file diff --git a/content/6_Plat/Slope.md b/content/6_Plat/Slope.md index 91161ce..108e1be 100644 --- a/content/6_Plat/Slope.md +++ b/content/6_Plat/Slope.md @@ -64,8 +64,14 @@ int main() { ``` +### Extension + +*Stock Trading (USACO Camp)*: What if your amount of shares can go negative, but you can never have more than $L$ shares or less than $-L$? + ## [Potatoes](https://oj.uz/problem/view/LMIO19_bulves) +[Equivalent Problem](https://atcoder.jp/contests/kupc2016/tasks/kupc2016_h) + Let $dif_i=a_i-b_i$. Defining $d_j=\sum_{i=1}^jdif_i$, our goal is to move around the potatoes such that $d_0,d_1,\ldots,d_N$ is a non-decreasing sequence. Moving a potato is equivalent to changing exactly one of the $d_i$ (aside from $d_0,d_N$) by one. **Slow Solution:** Let $dp[i][j]$ be the minimum cost to determine $d_0,d_1,\ldots,d_i$ such that $d_i\le j$ for each $0\le j\le d_N$. This gives a $O(N\cdot d_N)$ solution. @@ -178,18 +184,20 @@ int main() { ## Problems - - [Wall](https://atcoder.jp/contests/kupc2016/tasks/kupc2016_h) - - same as "Potatoes" - - Stock Trading (Camp) - - extension of "Buy Low Sell High" - - Amount of shares can go negative, but you can never have more than $L$ shares or less than $-L$. - - [Bookface](https://codeforces.com/gym/102576/problem/C) - - [CCDSAP Exam](https://www.codechef.com/problems/CCDSAP) - - basically same as Bookface - - [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) + + + + + + + + + + - binary search on top of slope trick - - [Conquer the World](https://icpc.kattis.com/problems/conquertheworld) + + - ICPC world finals, 0 solves in contest - - "Potatoes" on tree!! \ No newline at end of file + - "Potatoes" on tree!! + + \ No newline at end of file diff --git a/content/models.ts b/content/models.ts index d87c7f6..ea32a26 100644 --- a/content/models.ts +++ b/content/models.ts @@ -1,40 +1,34 @@ -import * as React from "react"; +const sources = { + "CC": "https://www.codechef.com/problems/", + "CSA": "https://csacademy.com/contest/archive/task/", + "DMOJ": "https://dmoj.ca/problem/", + "SPOJ": "https://www.spoj.com/problems/", + "YS": "https://judge.yosupo.jp/problem/", + "CF": "https://codeforces.com/", + "USACO": "http://www.usaco.org/index.php?page=viewproblem2&cpid=", + "Kattis": "https://open.kattis.com/problems/", + "CSES": "https://cses.fi/problemset/task/", +}; export class Problem { + public url: string; + constructor( + public source: string, public name: string, - public url: string, + public id: string, public starred?: boolean, public difficulty?: 'Intro' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard', - public source?: string, public tags?: string[], - public sketch?: string - ) {} + public sketch?: string, + ) { + if (source in sources) { + this.url = sources[source] + id; + } else { + if (!id.startsWith("http")) { + throw "URL of problem not valid. Did you make a typo in the problem source, or in the URL?" + } + this.url = id; + } + } } - -export namespace Problem { - export class CSES extends Problem { - constructor( - public name: string, - public id: string, - public starred?: boolean, - public difficulty?: 'Intro' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard', - public tags?: string[], - public sketch?: string - ) { - super(name, `https://cses.fi/problemset/task/${id}`, starred, difficulty, "CSES", tags, sketch); - } - } - export class USACO extends Problem { - constructor( - public name: string, - public id: string, - public starred?: boolean, - public difficulty?: 'Intro' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard', - public tags?: string[], - public sketch?: string - ) { - super(name, `http://www.usaco.org/index.php?page=viewproblem2&cpid=${id}`, starred, difficulty, "USACO", tags, sketch); - } - } -} \ No newline at end of file diff --git a/content/ordering.ts b/content/ordering.ts index 7fd056e..7635c8c 100644 --- a/content/ordering.ts +++ b/content/ordering.ts @@ -69,7 +69,6 @@ const ModuleOrdering = { }, ], "gold": [ - "ds-gold", "dp", "intro-nt", { diff --git a/src/components/markdown/Problems.tsx b/src/components/markdown/Problems.tsx index c12b73f..510ec90 100644 --- a/src/components/markdown/Problems.tsx +++ b/src/components/markdown/Problems.tsx @@ -16,6 +16,9 @@ export function ProblemsListComponent(props: ProblemsListComponentProps) { + - @@ -59,6 +59,9 @@ export function ProblemComponent(props: ProblemComponentProps) { return ( + -
+ Source + Problem Name @@ -23,9 +26,6 @@ export function ProblemsListComponent(props: ProblemsListComponentProps) { Difficulty - Source -
+ {problem.source} + {problem.starred && ( )} - {problem.source} - {!showTags && (