This commit is contained in:
Benjamin Qi 2020-06-26 14:00:32 -04:00
parent 0d1c98bd40
commit 569b14ff01
63 changed files with 231 additions and 78 deletions

View file

@ -29,14 +29,14 @@ For those of you with experience in software development, note that competitive
The [USA Computing Olympiad](http://www.usaco.org/index.php?page=contests) is a national programming competition that occurs four times a year, with December, January, February, and US Open (March) contests. The regular contests are four hours long, and the US Open is five hours long. Each contest contains three problems. Solutions are evaluated and scored against a set of predetermined test cases that are not visible to the student. Scoring is out of 1000 points, with each problem being weighted equally (\~333 points). There are four divisions of contests: Bronze, Silver, Gold, and Platinum. After each contest, students who meet the contest-dependent cutoff for promotion will compete in the next division for future contests.
## Guide Languages
## About This Guide
### Languages
- For Bronze and Silver, we will provide code snippets in C++, Java, and Python.
- For Gold, we will provide code snippets in C++ and Java and (sometimes) Python.
- For Platinum, code snippets may only be provided in one language (typically either C++ or Java).
All material in this guide will be grouped into **modules** such as the one you're reading right now.
### Guidelines
- For Bronze, Silver, and Gold contestants, we aim to be a "**one stop shop**," meaning that this is the only site you have to use to be exposed to most (if not all) of the topics required for Bronze - Gold.
@ -46,21 +46,37 @@ All material in this guide will be grouped into **modules** such as the one you'
- There are plenty of resources out there, but we do not expect you to click through all of them to find the information you want.
- This means in addition to the link itself, we will try our best to provide information about what the link is about as well as the quality of the link.
- We won't write something like "learn DP, here are 50 links that can teach you that." Instead, we will write "learn DP by first reading this one article, then reading this other article. For reference, here are some other links you can explore as you wish."
- For Platinum contestants, there are too many topics for us to effectively cover all of them. We'll try our best to cover the main topics, but if you want to do well in Platinum, you will have to find additional resources on your own in addition to this site.
- For Platinum contestants, there are too many topics for us to effectively cover all of them.
- We'll try our best to cover the main topics, but if you want to do well in Platinum, you will have to find additional resources on your own in addition to this site.
- Platinum modules may have more vague explanations compared to earlier divisions. If you're confused, you'll have to research the topic more on your own.
### Lesson
### Modules
The first part of a module is the lesson.
All material in this guide will be grouped into **modules** such as the one you're reading right now.
<info-block title="Pro Tip">
Hopefully these are helpful.
</info-block>
#### Lesson
- Consists of text, videos, and simple problems.
- Goal is to introduce you to the concept.
- Everything should be completed in order.
- Any problems here will generally be pure implementation.
### Practice
<optional-content title="Optional Content">
It's okay to skip over these. Some material might not be useful for competitive programming.
</optional-content>
#### Practice
- Link the relevant past USACO problems (and other recommended problems).
- Problems should be sorted in order of how they are recommended be completed.
- Add comments regarding difficulty and / or solution sketches.
- Possibly include additional problems.
- Add comments regarding solution sketches.
- Possibly include additional problems.
- Difficulty is relative to division. (?)

View file

@ -3,6 +3,7 @@ id: complete-search
title: "Complete Search"
author: Darren Yao
description: In many problems (especially in Bronze) it suffices to check all possible cases in the solution space.
frequency: 4
---
import { Problem } from "../models";

View file

@ -2,7 +2,8 @@
id: intro-graphs
title: Introduction to Graphs
author: Darren Yao, Benjamin Qi
description: "Graph theory is one of the most important topics at the Silver level and above, although some basic problems occasionally appear in Bronze."
description: "?"
frequency: 2
---
import { Problem } from "../models";
@ -19,6 +20,12 @@ export const metadata = {
}
};
<info-block title="Pro Tip">
Very important at the Silver level and above, not very frequent in bronze.
</info-block>
Graphs can be used to represent many things, from images to wireless signals, but one of the simplest analogies is to a map. Consider a map with several cities and highways connecting the cities. Some problems relating to graphsare:
- If we have a map with some cities and roads, what's the shortest distance I have to travel to get from point A to point B?

View file

@ -3,7 +3,7 @@ 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."
frequency: 2
---
import { Problem } from "../models";

View file

@ -3,6 +3,7 @@ id: simulation
title: "Simulation"
author: Darren Yao
description: "In many problems, we can just simulate what we're told to do by the problem statement."
frequency: 4
---
import { Problem } from "../models"

View file

@ -6,6 +6,7 @@ prerequisites:
- Silver - Introduction to Sorting
- Silver - Stacks & Queues
description: "?"
frequency: 2
---
import { Problem } from "../models";

View file

@ -4,7 +4,8 @@ title: "Breadth First Search"
author: Benjamin Qi
prerequisites:
- Silver - Depth First Search
description: Traversing a graph in a way such that vertices closer to the starting vertex are processed first.
description: "Traversing a graph in a way such that vertices closer to the starting vertex are processed first."
frequency: 2
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Darren Yao
prerequisites:
- Silver - Introduction to Sorting
description: You should already be familiar with the concept of binary searching for a number in a sorted array. However, binary search can be extended to binary searching on the answer itself.
frequency: 3
---
import { Problem } from "../models";
@ -28,6 +29,12 @@ export const metadata = {
}
};
<info-block title="Pro Tip">
Quite frequent at the Silver level.
</info-block>
When we binary search on the answer, we start with a search space of size $N$ which we know the answer lies in. Then, each iteration of the binary search cuts the search space in half, so the algorithm tests $O(\log N)$ values. This is efficient and much better than testing each possible value in the search space.
Let's say we have a function `check(x)` that returns true if the answer of $x$ is possible, and false otherwise. Usually, in such problems, we'll want to find the maximum or minimum value of $x$ such that `check(x)` is true. Similarly to how binary search on an array only works on a sorted array, binary search on the answer only works if the answer function is [monotonic](https://en.wikipedia.org/wiki/Monotonic_function), meaning that it is always non-decreasing or always non-increasing.

View file

@ -5,6 +5,7 @@ author: Siyong Huang
prerequisites:
- Bronze - Introduction to Graphs
description: A way to traverse a graph using recursion.
frequency: 4
---
import { Problem } from "../models";
@ -50,6 +51,12 @@ export const metadata = {
<problems-list problems={metadata.problems.sample} />
<info-block title="Pro Tip">
Quite frequent at the Silver level.
</info-block>
## Tutorial
- Recommended:

View file

@ -5,6 +5,7 @@ author: Siyong Huang
prerequisites:
- Silver - Depth First Search
description: Finding connected components in a graph that is respresented by a grid.
frequency: 3
---
import { Problem } from "../models";
@ -30,6 +31,12 @@ export const metadata = {
}
};
<info-block title="Pro Tip">
Quite frequent at the Silver level.
</info-block>
<problems-list problems={metadata.problems.sample} />
## [Flood Fill](https://en.wikipedia.org/wiki/Flood_fill)

View file

@ -5,6 +5,7 @@ author: Siyong Huang
prerequisites:
- Silver - Depth First Search
description: A functional graph is a digraph in which every vertex has exactly one outgoing edge.
frequency: 1
---

View file

@ -5,6 +5,7 @@ author: Darren Yao
prerequisites:
- Silver - Sorting with Custom Comparators
description: Greedy algorithms select the optimal choice at each step instead of looking at the solution space as a whole. This reduces the problem to a smaller problem at each step.
frequency: 3
---
import {Problem} from "../models"

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Bronze - Data Structures
description: "More with iterators?"
frequency: 2
---
(set iterators?)

View file

@ -3,6 +3,7 @@ id: prefix-sums
title: "Prefix Sums"
author: Darren Yao, Eric Wei
description: Computing range sum queries in constant time over a fixed array.
frequency: 3
---
import { Problem } from "../models";
@ -45,6 +46,12 @@ export const metadata = {
}
};
<info-block title="Pro Tip">
Quite frequent at the Silver level.
</info-block>
<problems-list problems={metadata.problems.sample} />
## Additional Resources

View file

@ -21,6 +21,12 @@ export const metadata = {
}
};
<info-block title="Pro Tip">
Especially important for competitors using Java.
</info-block>
## Comparators
Normally, sorting functions rely on moving objects with a lower value in front of objects with a higher value if sorting in ascending order, and vice versa if in descending order. This is done through comparing two objects at a time.

View file

@ -22,7 +22,7 @@ export const metadata = {
## Additional Reading
- CPH 4.5
- [PAPS 3.2 3.3, 3.4, 6.2, 6.3, 6.5](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
- [PAPS 3.2, 3.3, 3.4, 6.2, 6.3, 6.5](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
## [Stacks](http://www.cplusplus.com/reference/stack/stack/)

View file

@ -3,6 +3,7 @@ id: bin-jump
title: "Binary Jumping"
author: Benjamin Qi
description: Introduces the problems of finding level ancestors in a tree and computing the lowest common ancestors.
frequency: 3
---
import { Problem } from "../models";

View file

@ -6,6 +6,7 @@ prerequisites:
- Silver - Functional Graphs
- Gold - Breadth First Search
description: A simple cycle is a non-empty path of distinct edges that start and end at the same vertex such that no vertex appears more than once. Describes how to detect cycles in both directed and undirected graphs.
frequency: 0
---
import { Problem } from "../models";

View file

@ -6,6 +6,7 @@ prerequisites:
- Recursion
- Silver - Prefix Sums
description: Speeding up naive solutions with memoization.
frequency: 4
---
import { Problem } from "../models";

View file

@ -6,6 +6,7 @@ prerequisites:
- Silver - Depth First Search
- Gold - Introduction to Dynamic Programming
description: What it sounds like.
frequency: 1
---

View file

@ -5,6 +5,7 @@ author: Benjamin Qi, Michael Cao
prerequisites:
- Silver - Depth First Search
description: The Disjoint Set Union (DSU) data structure allows you to add edges to an initially empty graph and test whether two vertices of the graph are connected.
frequency: 3
---
import { Problem } from "../models";

View file

@ -3,6 +3,7 @@ id: hashing
title: "Hashing"
author: Benjamin Qi
description: Quickly test equality of substrings with a small probability of failure.
frequency: 1
---
## Tutorial

View file

@ -5,6 +5,7 @@ author: Darren Yao, Michael Cao
prerequisites:
- Gold - Introduction to Dynamic Programming
description: Divisibility and Modular Arithmetic
frequency: 1
---
import { Problem } from "../models";

View file

@ -6,6 +6,7 @@ prerequisites:
- Gold - Shortest Paths
- Gold - Disjoint Set Union
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.
frequency: 2
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Michael Cao
prerequisites:
- Silver - Depth First Search
description: "?"
frequency: 1
---
import { Problem } from "../models";

View file

@ -7,6 +7,7 @@ prerequisites:
- Gold - Static Range Queries
- Gold - Max Suffix Query with Insertions Only
description: Range queries for any associative operation over an array with updates, using segment tree.
frequency: 3
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Silver - Prefix Sums
description: Introducing Binary Indexed Trees & Indexed Sets (C++ only).
frequency: 3
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Gold - Breadth First Search
description: Introduces Dijkstra's Algorithm for a single source as well as Floyd-Warshall for All-Pairs Shortest Path.
frequency: 3
---
import { Problem } from "../models";
@ -40,8 +41,6 @@ export const metadata = {
Use *Dijkstra's Algorithm*.
### Standard
### Tutorial
- CSES 13.2
@ -51,6 +50,18 @@ Use *Dijkstra's Algorithm*.
- Usually, it's this one that's applicable.
- [CPC.8](https://github.com/SuprDewd/T-414-AFLV/tree/master/08_graphs_2)
### $O(M\log N)$ implementation
The USACO training pages present a $O(N^2)$ version, although this is rarely used nowadays.
<optional-content title="Faster Dijkstra">
Can be done in $O(M+N\log N)$ with Fibonacci heap.
(link?)
</optional-content>
### Problems
<problems-list problems={metadata.problems.dijk} />

View file

@ -3,6 +3,7 @@ id: SRQ
title: "Static Range Queries"
author: Benjamin Qi
description: Range queries for any associative operation over a static array.
frequency: 1
---
import { Problem } from "../models";
@ -76,5 +77,4 @@ A data structure known as **sqrt-tree** can speed up preprocessing time to $O(N\
## Problems
<problems-list problems={metadata.problems.general} />

View file

@ -6,6 +6,7 @@ prerequisites:
- Silver - More with Maps & Sets
- Silver - Amortized Analysis
description: "Solving USACO Gold - Springboards."
frequency: 1
---
import { Problem } from "../models";

View file

@ -6,6 +6,7 @@ prerequisites:
- Gold - Breadth First Search
- Gold - Introduction to Dynamic Programming
description: "?"
frequency: 1
---
import { Problem } from "../models";
@ -19,7 +20,7 @@ export const metadata = {
new Problem("CSES", "Game Routes", "1681", "Easy", false, [], "counting paths on DAG"),
new Problem("Kattis", "Quantum", "https://open.kattis.com/contests/acpc17open/problems/quantumsuperposition", "Easy", false, [], "enumerating paths on DAG"),
new Problem("Gold", "Timeline", "1017", "Easy", false, [], "not explicitly given, but graph is a DAG"),
new Problem("Gold", "Milking Order", "838", "Easy", false, ["TopoSort", "Binary Search"]),
new Problem("Gold", "Milking Order", "838", "Normal", false, ["TopoSort", "Binary Search"]),
new Problem("CSES", "Course Schedule II", "1681", "Hard", false, [], "equivalent to [Minimal Labels](https://codeforces.com/contest/825/problem/E)"),
],
}
@ -41,10 +42,8 @@ A [topological sort](https://en.wikipedia.org/wiki/Topological_sorting) of a dir
- DFS
- [CSAcademy](https://csacademy.com/lesson/topological_sorting)
- both BFS, DFS
Consider [Khan's Algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm) for topological sorting.
(note: lex min toposort?)
The BFS version, known as [Kahn's Algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm), makes it obvious how to extract the lexicographically minimum topological sort.
## Dynamic Programming
@ -55,12 +54,20 @@ One useful property of directed acyclic graphs is, as the name suggests, that th
Let's consider the classical problem [CSES Longest Flight Route](https://cses.fi/problemset/task/1680), where we must find the longest path in a DAG.
<spoiler title="Solution">
Let `dp[curr] = longest path ending at the node curr`. Then, if we process states in topological order, the transition is relatively straightforward: `dp[curr] = max of all dp[prev] where prev represents a node with an edge going into the current node` (word better?). To reiterate, since the states a processed in topological order, we can guarantee that all possible `dp[prev]` are computed before we compute `dp[curr]`.
Let $dp[v]$ denote the length of the longest path ending at the node $v$. Clearly
$$
dp[v]=\max_{\text{edge } u\to v \text{ exists}}dp[u]+1,
$$
or zero if $v$ has in-degree $0$. If we process the states in topological order, it is guarangeed that $dp[u]$ will already have been computed before computing $dp[v]$.
</spoiler>
However, not all problems clearly give you directed acyclic graphs (ex. [Plat - Cave Paintings](http://usaco.org/index.php?page=viewproblem2&cpid=996)). An important step in many problems is to reduce the statement into a directed acyclic graph. See the editorial of the linked problem for more information.
<!-- However, not all problems clearly give you directed acyclic graphs (ex. [Plat - Cave Paintings](http://usaco.org/index.php?page=viewproblem2&cpid=996)). An important step in many problems is to reduce the statement into a directed acyclic graph. See the editorial of the linked problem for more information.
(Ben - this last paragraph doesn't seem very helpful.)
(Ben - this last paragraph doesn't seem very helpful.) -->
## Problems

View file

@ -7,7 +7,7 @@ prerequisites:
- Gold - Static Range Queries
- Gold - Point Update Range Sum
description: Subtree updates and queries and another way to compute lowest common ancestors.
frequency: 3
frequency: 2
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Platinum - Range Update Range Query
description: "Extending Range Queries to 2D (and beyond)."
frequency: 1
---
See [my implementations](https://github.com/bqi343/USACO/tree/master/Implementations/content/data-structures/2D%20Range%20Queries%20(15.2)).

View file

@ -182,6 +182,8 @@ int main() {
</spoiler>
Apparently no test case contains more than $25000$ distinct colors, so we don't actually need to split the calculation into two halves.
## Lots of Triangles
<problems-list problems={metadata.problems.lots} />

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Silver - Depth First Search
description: "?"
frequency: 1
---
import { Problem } from "../models";

View file

@ -6,6 +6,7 @@ prerequisites:
- Bit Operations
- Gold - Introduction to Dynamic Programming
description: DP problems that require iterating over subsets.
frequency: 1
---
import { Problem } from "../models";
@ -15,6 +16,7 @@ export const metadata = {
general: [
new Problem("CSES", "Hamiltonian Flights", "1690", "Easy", false, ["Bitmasks"], ""),
new Problem("CSES", "Elevator Rides", "1653", "Normal", false, ["Bitmasks"], ""),
new Problem("ojuz", "IZhO Bank", "IZhO14_bank", "Normal", false, ["Bitmasks"], ""),
new Problem("YS", "Max Indep Set", "maximum_independent_set", "Hard", false, ["Bitmasks", "Meet in Middle"], ""),
],
}
@ -33,7 +35,7 @@ Has not been the solution to any platinum problem, but appeared in old gold and
<problems-list problems={metadata.problems.general} />
- [Old Gold - Moovie Moving](http://www.usaco.org/index.php?page=viewproblem2&cpid=515)
- [Old Gold - Moovie Mooving](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)
- [CF Guards in the Storehouse](https://codeforces.com/problemset/problem/845/F)

View file

@ -5,6 +5,7 @@ author: Michael Cao
prerequisites:
- Gold - Introduction to Dynamic Programming
description: Solving the problem on every contiguous subarray of the original array.
frequency: 2
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Silver - Depth First Search
description: Visiting all edges of a graph exactly once.
frequency: 0
---
Has not appeared on a recent USACO contest.

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: "?"
prerequisites:
- "?"
frequency: 1
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Gold - Breadth First Search
description: Introduces maximum flow as well as flow with lower bounds.
frequency: 1
---
Has not been the solution to any platinum problem, but appeared in old gold.

View file

@ -6,8 +6,25 @@ prerequisites:
- Gold - Minimum Spanning Tree
- some familiarity with "Robotic Cow Herd" solution
description: A simple solution to "Robotic Cow Herd" that generalizes.
frequency: 1
---
import { Problem } from "../models";
export const metadata = {
problems: {
sample: [
new Problem("Plat", "Robotic Cow Herd", "674", "Normal", false, [], ""),
],
general: [
new Problem("CSES", "Baltic OI - Olympiads", "https://cses.fi/248/list/", "Hard", false, [], "Each state has $\le K$ children."),
new Problem("DMOJ", "CCO - Shopping Plans", "cco20p6", "Very Hard", false, [], "Generalization of RoboHerd."),
new Problem("YS", "K-th Shortest Walk", "k_shortest_walk", "Very Hard", false, [], "(english description?), [Relevant Paper](https://www.ics.uci.edu/~eppstein/pubs/Epp-SJC-98.pdf), Can use to solve RoboHerd!"),
],
}
};
## General Outline
### Problem
@ -22,7 +39,11 @@ Suppose that you have a rooted tree where each vertex $i$ has a value $v_i$. Als
We'll focus on the first approach.
*Note:* There are ways to do this in $O(K)$ time for a binary tree if you don't need to return the values in sorted order (see [here](https://www.sciencedirect.com/science/article/pii/S0890540183710308)), but we won't consider this.
<optional-content title="A Faster Solution">
There are ways to do this in $O(K)$ time for a binary tree if you don't need to return the values in sorted order (see [here](https://www.sciencedirect.com/science/article/pii/S0890540183710308)).
</optional-content>
### Generalizing
@ -35,13 +56,13 @@ Suppose that you want to find the $K$ objects with the smallest values in some (
Essentially, we start with the entire search space and then we *fracture* it into *subspaces* based on the children of the root. Then we can finish with either of the two approaches.
## Finding K-th Smallest Spanning Tree (USACO Camp 2018)
## $K$-th Smallest Spanning Tree (USACO Camp 2018)
Let's look at an example.
### Problem
Given a graph with $N\le 50$ vertices and at most $\binom{N}{2}$ edges, find the $K$-th ($K\le 10^4$) smallest spanning tree.
> Given a graph with $N\le 50$ vertices and at most $\binom{N}{2}$ edges, find the $K$-th ($K\le 10^4$) smallest spanning tree.
(Note: not solved in contest.)
@ -124,7 +145,9 @@ int main() {
</spoiler>
## [USACO Robotic Cow Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=674)
## Robotic Cow Herd
<problems-list problems={metadata.problems.sample} />
As with the analysis, for each location you should
@ -134,7 +157,7 @@ As with the analysis, for each location you should
Importantly, we should then sort the locations by their respective second-minimum controller costs.
## Approach 1
### Approach 1
Binary search on the cost $c$ of the $K$-th robot. If we can compute the costs of all robots with cost at most $c$ or say that there are more than $K$ in $O(K)$ time, then we can solve this problem in $O(N\log N+K\log \max(c))$ time (similar to "Approach 2" above). This is the approach that the first analysis solution takes, although it includes an extra $\log N$ factor due to `upper_bound`. I have removed this in my solution below.
@ -199,7 +222,7 @@ int main() {
</spoiler>
## Approach 2
### Approach 2
There's also an $O(N\log N+K\log K)$ time solution with a priority queue that constructs the robots in increasing order of cost. As before, we want each robot to have a bounded number of "child" robots. However, if you look at my DFS function above, it seems that every robot can have up to $N$ children! Nevertheless, the DFS takes $O(K)$ rather than $O(KN)$ time due to the break statement, which works since we sorted by second-cheapest robot.
@ -285,11 +308,4 @@ int main() {
## Other Problems
- [Baltic OI 2019 - Olympiads](https://cses.fi/248/list/)
- Each state has $\le K$ children.
- [CCO 20 Shopping Plans](https://dmoj.ca/problem/cco20p6)
- Generalization of RoboHerd
- [K-th Shortest Walk](https://judge.yosupo.jp/problem/k_shortest_walk)
- (english description?)
- [Relevant Paper](https://www.ics.uci.edu/~eppstein/pubs/Epp-SJC-98.pdf)
- Can use to solve RoboHerd!
<problems-list problems={metadata.problems.general} />

View file

@ -6,6 +6,7 @@ prerequisites:
- Gold - Euler Tour on Tree
- Platinum - Range Update Range Query
description: Path and subtree updates and queries.
frequency: 1
---
import { Problem } from "../models";

View file

@ -5,11 +5,38 @@ author: Benjamin Qi
description: Smallest convex polygon containing a set of points on a grid.
prerequisites:
- Platinum - Geometry Primitives
frequency: 2
---
import { Problem } from "../models";
export const metadata = {
problems: {
sample: [
new Problem("Kattis", "Convex Hull", "convexhull", "Intro", false, ["convex"], ""),
],
sample2: [
new Problem("Kattis","Robert Hood", "roberthood", "Intro", false, ["convex"], "doesn't require convex hull since coordinates are small"),
],
general: [
new Problem("Plat", "Balance Beam", "864", "Easy", false, ["convex"], ""),
new Problem("CF", "Geometers Anonymous", "problemset/problem/1195/F", "Normal", false, ["convex", "PURS"], ""),
new Problem("Old Gold", "Cow Curling", "382", "Normal", false, ["convex"], "testing whether points are inside hull"),
new Problem("AC", "AGC E - Random Pawn", "https://atcoder.jp/contests/agc044/tasks/agc044_e", "Very Hard", false, ["convex"], ""),
],
rotating: [
new Problem("Kattis", "Fence Orthogonality", "fenceortho", "Normal", false, ["convex"], "enclosing rectangle"),
],
cht: [
new Problem("Plat", "Circular Barn", "626", "Normal", false, ["DP", "convex"], ""),
new Problem("Plat", "Falling Portals", "998", "Hard", false, ["convex"], ""),
],
}
};
## [Convex Hull](https://en.wikipedia.org/wiki/Convex_hull_algorithms)
- [Kattis Convex Hull](https://open.kattis.com/problems/convexhull)
<problems-list problems={metadata.problems.sample} />
### Tutorial
@ -21,21 +48,21 @@ prerequisites:
- [Wikipedia](https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain)
- [My Implementation](https://github.com/bqi343/USACO/blob/master/Implementations/content/geometry%20(13)/Polygons/ConvexHull%20(13.2).h)
### Problems
<problems-list problems={metadata.problems.general} />
- [USACO Plat - Balance Beam](http://www.usaco.org/index.php?page=viewproblem2&cpid=864)
- quite easy (but make sure to avoid precision issues)
- [USACO Plat - Falling Portals](http://www.usaco.org/index.php?page=viewproblem2&cpid=998)
- [USACO Old Gold - Fencing](http://www.usaco.org/index.php?page=viewproblem2&cpid=534)
- [USACO Old Gold - Cow Curling](http://www.usaco.org/index.php?page=viewproblem2&cpid=382)
- [Kattis Fence Orthogonality](https://open.kattis.com/problems/fenceortho)
- [AGC 44 Random Pawn](https://atcoder.jp/contests/agc044/tasks/agc044_e)
- Generalization of "Balance Beam"
## Rotating Caliphers
Minkowski addition?
## With DP
<problems-list problems={metadata.problems.sample2} />
cbarn
diameter of point set:
mowing
- [CF Comment](https://codeforces.com/blog/entry/46162)
<problems-list problems={metadata.problems.rotating} />
## Convex Hull Trick
- [CF Tutorial](https://codeforces.com/blog/entry/63823)
<problems-list problems={metadata.problems.cht} />

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: Convex Container
prerequisites:
- Platinum - Convex Hull
frequency: 1
---
## Half-Plane Intersection / Convex Stuff
@ -22,5 +23,7 @@ prerequisites:
- [Bridges](https://csacademy.com/contest/archive/task/building-bridges/)
- direct application of LineContainer
- [USACO Old Gold - Fencing](http://www.usaco.org/index.php?page=viewproblem2&cpid=534)
(add ICPC probs)

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Gold - Topological Sort
description: Includes 2-edge-connected components, strongly connected components, and biconnected components.
frequency: 1
---
*Some problems sourced from [here](http://codeforces.com/blog/entry/54526?#comment-385354).*

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Gold - Point Update Range Query
description: Lazy updates on segment trees and two binary indexed trees in conjunction.
frequency: 1
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Gold - Shortest Paths with Non-Negative Edge Weights
description: Applications of Bellman-Ford.
frequency: 1
---
- Hasn't appeared in recent USACO Gold as far as I know.

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Platinum - Convex Hull
description: Ways to manipulate piecewise linear convex functions.
frequency: 1
---
import { Problem } from "../models";

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
prerequisites:
- Silver - Depth First Search
description: Knuth-Morris-Pratt and Z Algorithms (and a few more related topics).
frequency: 1
---
## General Resources

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: Sorting Suffixes of a String
prerequisites:
- Gold - Hashing
frequency: 1
---
https://judge.yosupo.jp/problem/suffixarray

View file

@ -3,6 +3,7 @@ id: tries
title: "Tries"
author: Benjamin Qi
description: ?
frequency: 1
---
import { Problem } from "../models";

View file

@ -5,12 +5,9 @@ author: Benjamin Qi
description: "CSES Critical Cities and Extensions"
prerequisites:
- Gold - Cycle Finding
frequency: 1
---
<info-block title="Pro Tip">
Historically restricted to USACO Camp.
</info-block>
## Paths
CSES Critical Cities https://cses.fi/problemset/task/1703/

View file

@ -4,6 +4,7 @@ title: "Fast Fourier Transform and Applications"
author: Benjamin Qi
prerequisites:
description: "?"
frequency: 0
---
import { Problem } from "../models";

View file

@ -3,6 +3,7 @@ id: game-theory
title: "Game Theory"
author: Benjamin Qi
description: "?"
frequency: 0
---
<info-block title="Pro Tip">

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: "?"
prerequisites:
- Advanced - Treaps
frequency: 1
---
import { Problem } from "../models";

View file

@ -4,12 +4,9 @@ title: "Matroid Intersection"
author: Benjamin Qi
description: "?"
prerequisites:
frequency: 0
---
<info-block title="Pro Tip">
Does not appear on USACO.
</info-block>
* Tutorial
* [CF Tutorial](https://codeforces.com/blog/entry/69287)
* [Parametrized Algorithms Ch 12](http://parameterized-algorithms.mimuw.edu.pl/parameterized-algorithms.pdf)

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: "?"
prerequisites:
- Platinum - Maximum Flow
frequency: 1
---
<info-block title="Pro Tip">

View file

@ -2,13 +2,10 @@
id: multiplicative
title: "Prefix Sums of Multiplicative Functions"
author: Benjamin Qi
description: ?
description: "?"
frequency: 0
---
<info-block title="Pro Tip">
Does not appear on USACO.
</info-block>
https://codeforces.com/blog/entry/54150
## Linear Time Sieve

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: "?"
prerequisites:
- Platinum - Range Update Range Query
frequency: 1
---
<info-block title="Pro Tip">

View file

@ -5,12 +5,9 @@ author: Benjamin Qi
description: "?"
prerequisites:
- Platinum - String Searching
frequency: 0
---
<info-block title="Pro Tip">
Does not appear on USACO.
</info-block>
* String Suffix Structures
* [Suffix Automata](http://codeforces.com/blog/entry/20861)
* Suffix Tree

View file

@ -5,6 +5,7 @@ author: Benjamin Qi
description: "?"
prerequisites:
- Platinum - Range Update Range Query
frequency: 2
---
<info-block title="Pro Tip">

View file

@ -10,7 +10,7 @@ export class ModuleLinkInfo {
}
}
export type ModuleFrequency = null | 1 | 2 | 3 | 4;
export type ModuleFrequency = null | 0 | 1 | 2 | 3 | 4;
// there's probably a way to do this without the duplicated types...
export class ModuleInfo extends ModuleLinkInfo {

View file

@ -293,20 +293,23 @@ const flattenNavLinks = (navLinks: NavLinkItem[]) => {
const Frequency = ({ frequency }: { frequency: ModuleFrequency }) => {
const textColors = [
'text-green-600',
'text-red-600',
'text-orange-600',
'text-yellow-600',
'text-teal-600',
];
const circleColors = [
'text-green-500',
'text-red-500',
'text-orange-500',
'text-yellow-500',
'text-teal-500',
];
const labels = [
'Rare (0-1 times)',
'Not Frequent (2-3 times)',
'Has Not Appeared',
'Rare (1-2 times)',
'Not Frequent (3-4 times)',
'Somewhat Frequent',
'Very Frequent (historically ~ once per contest)',
];
@ -314,14 +317,12 @@ const Frequency = ({ frequency }: { frequency: ModuleFrequency }) => {
return (
<span
className={`inline-flex items-center font-medium ${
textColors[frequency - 1]
}`}
className={`inline-flex items-center font-medium ${textColors[frequency]}`}
>
{new Array(4).fill(null).map((_, idx) => (
<svg
className={`-ml-1 mr-1.5 h-2.5 w-2.5 ${
idx >= frequency ? emptyCircle : circleColors[frequency - 1]
idx >= frequency ? emptyCircle : circleColors[frequency]
}`}
fill="currentColor"
viewBox="0 0 8 8"
@ -329,7 +330,7 @@ const Frequency = ({ frequency }: { frequency: ModuleFrequency }) => {
<circle cx="4" cy="4" r="3" />
</svg>
))}
{labels[frequency - 1]}
{labels[frequency]}
</span>
);
};