add functionality to dashboard; refactor problems

This commit is contained in:
Nathan Wang 2020-07-19 12:12:40 -07:00
parent b9737def53
commit 1a9151ec64
82 changed files with 515 additions and 507 deletions

View file

@ -9,15 +9,13 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
general: [
new Problem("Bronze", "Promotion Counting", "591", "Very Easy"),
new Problem("Bronze", "Word Processor", "987", "Very Easy"),
new Problem("Bronze", "Square Pasture", "663", "Very Easy"),
new Problem("Bronze", "Bucket Brigade", "939", "Very Easy"),
]
}
};
The remainder of this guide assumes that you know the basics of how to code in one of the languages listed above, including the following topics:
@ -52,7 +50,7 @@ You may find the following resources helpful for familiarizing yourself with you
The following require relatively little programming experience and no algorithmic knowledge.
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
Also check the [CSES Introductory Problems](https://cses.fi/problemset/list/) up to and including "Palindrome Reorder." Once you're done with these, you should continue onto Bronze.

View file

@ -9,21 +9,13 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
cses: [
new Problem("CSES", "Weird Algorithm", "1068", "Very Easy"),
],
fence: [
new Problem("Bronze", "Fence Painting", "567", "Very Easy"),
],
general: [
new Problem("Bronze", "Promotion Counting", "591", "Very Easy"),
new Problem("Bronze", "Word Processor", "987", "Very Easy"),
new Problem("Bronze", "Square Pasture", "663", "Very Easy"),
new Problem("Bronze", "Bucket Brigade", "939", "Very Easy"),
]
}
};
<Resources>
@ -38,7 +30,7 @@ export const metadata = {
In most websites (such as CodeForces and CSES), input and output are **standard**.
<Problems problems={metadata.problems.cses} />
<Problems problems={problems.cses} />
Note that this problem requires **64-bit integers**.
@ -170,7 +162,7 @@ public static void main(String[] args) {
## File I/O
<Problems problems={metadata.problems.fence} />
<Problems problems={problems.fence} />
In USACO, input is read from a file called `problemname.in`. After the program is run, output must be printed to a file called `problemname.out`. Note that you'll have to rename the `.in` and `.out` files depending on the problem. For example, in the above problem you would use `paint.in` and `paint.out`.

View file

@ -8,8 +8,7 @@ frequency: 4
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
easier: [
new Problem("CSES", "Apple Division", "1623", "Intro|Very Easy", false, ["Recursion"], "all $2^n$ subsets"),
new Problem("Bronze", "Diamond Collector", "639", "Easy", false, ["Nested Loop"], "fix the min"), // 99.9
@ -30,7 +29,6 @@ export const metadata = {
new Problem("Bronze", "Bull in a China Shop", "640", "Very Hard", false, [], "lots of WA on this one"), // 47.38
new Problem("Silver", "Field Reduction", "642", "Very Hard", false, [], ""),
],
}
};
<Resources>
@ -115,8 +113,8 @@ A couple notes:
### Easier
<Problems problems={metadata.problems.easier} />
<Problems problems={problems.easier} />
### Harder
<Problems problems={metadata.problems.harder} />
<Problems problems={problems.harder} />

View file

@ -10,8 +10,7 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
permSam: [
new Problem("CSES", "Creating Strings I", "1622", "Intro|Easy", false, [], "all perms of string"),
],
@ -22,10 +21,9 @@ export const metadata = {
new Problem("CSES", "Chessboard and Queens", "1624", "Normal", false, [], "Recursively backtrack. See CSES book for more details."),
new Problem("Bronze", "Livestock Lineup", "965", "Hard", false, ["permutations"], ""), // 91.95
]
}
};
<Problems problems={metadata.problems.permSam} />
<Problems problems={problems.permSam} />
<br />
@ -39,7 +37,7 @@ A **permutation** is a reordering of a list of elements. Some problems will ask
This term is mentioned quite frequently:
<Problems problems={metadata.problems.ex} />
<Problems problems={problems.ex} />
Think about how are words ordered in a dictionary. (In fact, this is where the term "lexicographical" comes from.)
@ -125,4 +123,4 @@ public class Test {
### Problems
<Problems problems={metadata.problems.perm} />
<Problems problems={problems.perm} />

View file

@ -8,8 +8,7 @@ frequency: 4
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
bubble: [
new Problem("HR", "Bubble Sort", "https://www.hackerrank.com/challenges/ctci-bubble-sort/problem", "Easy", false, [], "O(N^2)"),
],
@ -18,7 +17,6 @@ export const metadata = {
new Problem("CSES", "Stick Lengths", "1074", "Normal", false, [], "Spoiler: Optimal length is median"),
new Problem("Silver", "Teleportation", "812", "Very Hard", false, [], ""),
],
}
};
<Resources>
@ -279,7 +277,7 @@ for(auto element : v) {
## Sorting
<Problems problems={metadata.problems.bubble} />
<Problems problems={problems.bubble} />
**Sorting** refers to arranging items in some particular order. You do not need to know how to sort an array in $O(N\log N)$ time for Bronze, but you should be aware of how to use built-in methods to sort a (possibly dynamic) array.
@ -322,4 +320,4 @@ Two ways to avoid this:
## Problems
<Problems problems={metadata.problems.easy} />
<Problems problems={problems.easy} />

View file

@ -8,8 +8,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
general: [
new Problem("Silver", "Grass Planting", "894", "Normal", false, ["tree"]),
new Problem("Bronze", "The Great Revegetation", "916", "Hard", false, []),
@ -19,7 +18,6 @@ export const metadata = {
new Problem("Bronze", "Swapity Swap", "1013", "Hard", false, ["permutation"], "Hint: One option is to keep swapping until the permutation returns to its original state (but can you do better?)."),
new Problem("Bronze", "Cow Evolution", "941", "Hard", false, [], ""),
]
}
};
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 bidirectional roads connecting the cities. Some problems relating to graphs are:
@ -45,4 +43,4 @@ Both of these tasks will be covered in higher divisions. For now, it suffices to
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -8,8 +8,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
tutorial: [
new Problem("Bronze", "Mad Scientist", "1012", "Normal", false, [], ""),
],
@ -17,7 +16,6 @@ export const metadata = {
new Problem("Bronze", "Cow Tipping", "689", "Hard", false, [], "Cells in the last row and column can be toggled uniquely. Toggle the appropriate ones and then recurse to the rectangle in the previous row/column, and solve the same way."),
new Problem("Bronze", "Race", "989", "Very Hard", false, [], "Greedily increment/decrement Bessies speed to fit the conditions until her total distance exceeds K."),
],
}
};
## Ad Hoc
@ -141,7 +139,7 @@ If we use greedy based on highest value first, we choose item A and then we are
Try to come up with a greedy algorithm for the USACO Bronze problem "Mad Scientist."
<Problems problems={metadata.problems.tutorial} />
<Problems problems={problems.tutorial} />
<Spoiler title="Correct Greedy Algorithm">
@ -165,7 +163,7 @@ Sometimes, if the algorithm is easy enough to implement, you don't even need to
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
<IncompleteSection>

View file

@ -7,17 +7,15 @@ frequency: 2
---
import { Problem } from "../models";
export const metadata = {
problems: {
blocked: [
new Problem("Bronze", "Blocked Billboard", "759", "Easy", false, ["rect"]),
],
general: [
new Problem("Bronze", "Square Pasture", "663", "Very Easy", false, ["rect"]),
new Problem("Bronze", "Blocked Billboard II", "783", "Easy", false, ["rect"]),
new Problem("CF", "Div. 3 C - White Sheet", "contest/1216/problem/C", "Normal", false, ["rect"],"See this code (TODO; codeforces is down) for a nice implementation using the Java Rectangle class."),
]
}
export const problems = {
blocked: [
new Problem("Bronze", "Blocked Billboard", "759", "Easy", false, ["rect"]),
],
general: [
new Problem("Bronze", "Square Pasture", "663", "Very Easy", false, ["rect"]),
new Problem("Bronze", "Blocked Billboard II", "783", "Easy", false, ["rect"]),
new Problem("CF", "Div. 3 C - White Sheet", "contest/1216/problem/C", "Normal", false, ["rect"],"See this code (TODO; codeforces is down) for a nice implementation using the Java Rectangle class."),
]
};
<Resources>
@ -30,7 +28,7 @@ Most only include two or three squares or rectangles, in which case you can simp
## Example: Blocked Billboard
<Problems problems={metadata.problems.blocked} />
<Problems problems={problems.blocked} />
### Naive Solution
@ -212,4 +210,4 @@ int main(){
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -8,8 +8,7 @@ frequency: 4
import { Problem } from "../models"
export const metadata = {
problems: {
export const problems = {
easier: [
new Problem("Bronze", "Shell Game", "891", "Easy", false, ["Nested Loop"]), // 99.93
new Problem("Bronze", "Mixing Milk", "855", "Easy", false, ["Single Loop"], "just pour 100 times"), // 99.87
@ -26,7 +25,6 @@ export const metadata = {
new Problem("Bronze", "Milk Measurement", "761", "Hard"), // 95.97
new Problem("Bronze", "Angry Cows", "592", "Hard", false, [], ""), // 94.15
]
}
};
<Resources>
@ -186,8 +184,8 @@ pw.close(); // flush the output
### Easier
<Problems problems={metadata.problems.easier} />
<Problems problems={problems.easier} />
### Harder
<Problems problems={metadata.problems.harder} />
<Problems problems={problems.harder} />

View file

@ -10,8 +10,7 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
dis: [
new Problem("CSES", "Distinct Numbers", "1621", "Easy", false, [], "Store every number in a set and print the size."),
],
@ -23,7 +22,6 @@ export const metadata = {
new Problem("Bronze", "Where Am I?", "964", "Easy", false, [], "Store all substrings in a map of <string, count>, and then find the longest length such that no substring of that length appears twice."),
new Problem("Silver", "Cities & States", "667", "Hard", false, [], "Store two maps of counts for the first two letters of a city and state code, then iterate over the cities and use the maps to efficently query for the corresponding counts."),
],
}
};
<Resources>
@ -46,7 +44,7 @@ Both Java and C++ contain two versions of sets and maps; one in which the keys a
## Sets
<Problems problems={metadata.problems.dis} />
<Problems problems={problems.dis} />
<LanguageSection>
@ -105,7 +103,7 @@ for(int element : set){
## Maps
<Problems problems={metadata.problems.ex} />
<Problems problems={problems.ex} />
<LanguageSection>
@ -251,4 +249,4 @@ Mentioned in several of the links above. See Gold for dtails.
## Problems
<Problems problems={metadata.problems.standard} />
<Problems problems={problems.standard} />

View file

@ -10,8 +10,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
ex: [
new Problem("CF", "Div 2 C - Maximum Median", "contest/1201/problem/C", "Easy", false, [], ""),
],
@ -35,7 +34,6 @@ export const metadata = {
new Problem("CF", "Level Generation", "problemset/problem/818/F", "Hard", false, [], "first find out which is the best way to construct the graph, then it's possible to see that the number of edges increase for some range and then decrease; so, using binary search find the last i such that f(i-1)<=f(i)"),
new Problem("CF", "Packmen", "contest/847/problem/E", "Hard", false, [], "binary search on time and check if packmen can eat all keeping left and right endpoints"),
],
}
};
<Resources>
@ -154,7 +152,7 @@ static long search(){
## Example: Maximum Median
<Problems problems={metadata.problems.ex} />
<Problems problems={problems.ex} />
**Statement:** Given an array $\texttt{arr}$ of $n$ integers, where $n$ is odd, we can perform the following operation on it $k$ times: take any element of the array and increase it by $1$. We want to make the median of the array as large as possible after $k$ operations.
@ -261,8 +259,8 @@ static boolean check(long x){
## USACO Problems
<Problems problems={metadata.problems.usaco} />
<Problems problems={problems.usaco} />
## General Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
bubble: [
new Problem("HR", "Bubble Sort", "https://www.hackerrank.com/challenges/ctci-bubble-sort/problem", "Easy", false, [], "O(N^2)"),
new Problem("Silver", "Out of Sorts", "834", "Very Hard", false, []),
@ -19,7 +18,6 @@ export const metadata = {
count: [
new Problem("Silver", "Counting Haybales", "666", "Normal", false, []),
],
}
};
Suppose that we want to find an element in a sorted array of size $N$ in $O(\log N)$ time. We can do this with [**binary search**](https://en.wikipedia.org/wiki/Binary_search_algorithm); 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 every element in an array.
@ -60,7 +58,7 @@ Suppose that we want to find an element in a sorted array of size $N$ in $O(\log
A related topic is **coordinate compression**, which takes some points and reassigns them to remove wasted space.
<Problems problems={metadata.problems.count} />
<Problems problems={problems.count} />
> Farmer John has just arranged his $N$ haybales $(1\le N \le 100,000)$ at various points along the one-dimensional road running across his farm. To make sure they are spaced out appropriately, please help him answer $Q$ queries ($1 \le Q \le 100,000$), each asking for the number of haybales within a specific interval along the road.

View file

@ -10,8 +10,7 @@ frequency: 4
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Building Roads", "1666", "Intro|Easy", false, ["DFS"]),
],
@ -49,7 +48,6 @@ export const metadata = {
new Problem("Silver", "The Great Revegetation", "920", "Easy", false, ["Bipartite"]),
new Problem("Silver", "Clock Tree", "1016", "Hard", false, []),
],
}
};
## Resources
@ -66,7 +64,7 @@ export const metadata = {
## Counting Connected Components
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
### Implementation
@ -128,7 +126,7 @@ public static int count_components()
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
## Tree Problems
@ -192,14 +190,14 @@ public static void dfs(int node)
### Problems
<Problems problems={metadata.problems.tree} />
<Problems problems={problems.tree} />
## Graph Two-Coloring
*Graph two-coloring* refers to assigning a boolean value to each node of the graph, dictated by the edge configuration.
The most common example of a two-colored graph is a *bipartite graph*, in which each edge connects two nodes of opposite colors.
<Problems problems={metadata.problems.bipsample} />
<Problems problems={problems.bipsample} />
### Resources
@ -268,4 +266,4 @@ public static void dfs(int node)
### Problems
<Problems problems={metadata.problems.bip} />
<Problems problems={problems.bip} />

View file

@ -10,8 +10,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("LC", "Flood Fill", "https://leetcode.com/problems/flood-fill/", "Intro|Easy", false, []),
new Problem("CSES", "Counting Rooms", "1192", "Easy", false, []),
@ -29,10 +28,9 @@ export const metadata = {
new Problem("Silver", "Snow Boots", "811", "Hard", false, []),
new Problem("Silver", "Mooyo Mooyo", "860", "Hard", false, []),
],
}
};
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
<br />
@ -208,4 +206,4 @@ static void floodfill(int r, int c, int color){
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CF", "Div 2 B - Badge", "contest/1020/problem/B", "Very Easy", false, ["Func Graph"], "Try to solve the problem in $O(N)$!"),
],
@ -26,14 +25,13 @@ export const metadata = {
new Problem("POI", "Frog", "https://szkopul.edu.pl/problemset/problem/qDH9CkBHZKHY4vbKRBlXPrA7/site/?key=statement", "Hard", false, [], ""),
new Problem("ojuz", "Space Pirate", "JOI14_space_pirate", "Very Hard", false, ["Graphs"], "One of the most difficult problems of all time. Build a tree with a single back edge. Break into three cases: path -> other cycle, path -> subtree, path -> non-subtree. Then perform some black magic."),
],
}
};
## Functional Graphs
We'll consider graphs like the one presented in this problem:
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
< br/>
@ -122,4 +120,4 @@ pair<int, int> detect_cycle(int *next, int start_node) //return pair(length of c
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -12,8 +12,7 @@ frequency: 3
import {Problem} from "../models"
export const metadata = {
problems: {
export const problems = {
movie: [
new Problem("CSES", "Movie Festival", "1629", "Easy", false, [], ""),
],
@ -42,7 +41,6 @@ export const metadata = {
new Problem("CF", "Kayaking", "contest/863/problem/B", "?", false, [], "Huffman Coding?"),
new Problem("CF", "New Year and Three Musketeers", "contest/611/problem/E", "Hard", false, [], "needs maps"),
]
}
};
<Resources>
@ -64,7 +62,7 @@ Here, we'll focus on problems where some sorting step is involved.
## Example: The Scheduling Problem
<Problems problems={metadata.problems.movie} />
<Problems problems={problems.movie} />
There are $N$ events, each described by their starting and ending times. You can only attend one event at a time, and if you choose to attend an event, you must attend the entire event. Traveling between events is instantaneous. What's the maximum number of events you can attend?
@ -177,12 +175,12 @@ pw.close();
## CSES Problems
<Problems problems={metadata.problems.cses} />
<Problems problems={problems.cses} />
## USACO Problems
<Problems problems={metadata.problems.usaco} />
<Problems problems={problems.usaco} />
## Other Problems
<Problems problems={metadata.problems.other} />
<Problems problems={problems.other} />

View file

@ -11,8 +11,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Bit Inversions", "1188", "Normal", false, []),
],
@ -24,13 +23,12 @@ export const metadata = {
new Problem("CF", "Mahmoud & Ehab & Function", "contest/862/problem/E", "Hard", false, [], "Hard, do not attempt until Gold/Plat (2100 on CF)"),
new Problem("CF", "Tournament", "contest/878/problem/C", "Very Hard", false, [], "First solve problem for $n$-th tournament only. Extremely hard, do not attempt (2700 on CF)"),
]
}
};
## Example: Using Iterators
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
<Spoiler title="Solution">
@ -129,4 +127,4 @@ int main() {
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,13 +10,11 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
standard: [
new Problem("CSES", "Concert Tickets", "1091", "Easy", false, ["iterators"], "just do upper_bound"),
new Problem("CSES", "Traffic Lights", "1163", "Normal", false, ["set"], "just insert into set one at a time"),
],
}
};
<Resources>
@ -212,4 +210,4 @@ next(), prev(), ++, --
## Standard
<Problems problems={metadata.problems.standard} />
<Problems problems={problems.standard} />

View file

@ -10,8 +10,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("YS", "Static Range Sum", "static_range_sum", "Easy", false, [], "equivalent to [CSES Range Sum Queries I](https://cses.fi/problemset/task/1646)"),
],
@ -47,7 +46,6 @@ export const metadata = {
new Problem("Google KickStart", "Candies (Test Set 1)", "https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ff43/0000000000337b4d", "Easy", false, ["Prefix Sums"], ""),
new Problem("AC", "Multiple of 2019", "https://atcoder.jp/contests/abc164/tasks/abc164_d", "Hard", false, ["Prefix Sums"], "Make use of the fact that adding 0's to the end of a number does not affect whether it is a multiple of 2019 (because 10 and 2019 are coprime)."),
],
}
};
@ -59,7 +57,7 @@ export const metadata = {
## Introduction
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
Let's say we have a one-indexed integer array $\texttt{arr}$ of size $N$ and we want to compute the value of
$$
@ -206,13 +204,13 @@ These are also known as [partial sums](https://mathworld.wolfram.com/PartialSum.
### Problems
<Problems problems={metadata.problems.cum} />
<Problems problems={problems.cum} />
## Max Subarray Sum
Now we'll look at some extensions.
<Problems problems={metadata.problems.maxsum} />
<Problems problems={problems.maxsum} />
This problem has a solution known as [Kadane's Algorithm](https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane's_algorithm). Please don't use that solution; try to solve it with prefix sums.
@ -226,11 +224,11 @@ Consider the desired maximum subarray. As you go along from left to right, the p
Similar to prefix sums, you can also take prefix minimum or maximum; but *you cannot* answer min queries over an arbitrary range with prefix minimum. (This is because minimum doesn't have an inverse operation, the way subtraction is to addition.) On the other hand, XOR is its own inverse operation, meaning that the XOR of any number with itself is zero.
<Problems problems={metadata.problems.related} />
<Problems problems={problems.related} />
## 2D Prefix Sums
<Problems problems={metadata.problems.sample2} />
<Problems problems={problems.sample2} />
Now, what if we wanted to process $Q$ queries for the sum over a subrectangle of a $N$ rows by $M$ columns matrix in two dimensions? Let's assume both rows and columns are 1-indexed, and we use the following matrix as an example:
@ -475,7 +473,7 @@ as expected.
Since no matter the size of the submatrix we are summing, we only need to access four values of the 2D prefix sum array, this runs in $O(1)$ per query after an $O(NM)$ preprocessing.
<Problems problems={metadata.problems.cum2} />
<Problems problems={problems.cum2} />
## More Complex Applications
@ -508,4 +506,4 @@ $$
Which is what we were looking for!
<Problems problems={metadata.problems.complex} />
<Problems problems={problems.complex} />

View file

@ -11,8 +11,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Sum of Two Values", "1141", "Easy", false, []),
],
@ -38,13 +37,12 @@ export const metadata = {
qs: [
new Problem("YS","Queue Composite","queue_operate_all_composite","Hard",true,[],""),
],
}
};
## Two Pointers
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
Two pointers refers to iterating two monotonic pointers across an array to search for a pair of indices satisfying some condition in linear time.
@ -59,7 +57,7 @@ Two pointers refers to iterating two monotonic pointers across an array to searc
## Sliding Window
<Problems problems={metadata.problems.slide} />
<Problems problems={problems.slide} />
Let's envision a **sliding window** (or constant size subarray) of size $K$ moving left to right along an array, $a$.
@ -78,7 +76,7 @@ To compute the sum in the range, instead of using a set, we can store a variable
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
## Sliding Window Minimum in $O(N)$
@ -88,4 +86,4 @@ To compute the sum in the range, instead of using a set, we can store a variable
In particular, the second method allows us to solve the following generalization in linear time as well:
<Problems problems={metadata.problems.qs} />
<Problems problems={problems.qs} />

View file

@ -214,4 +214,4 @@ Comments: Comparator 1 sorts array $a$ in decreasing order. Comparator 2 sorts a
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ description: "Both Java and C++ have built-in functions for sorting. However, if
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("Silver", "Wormhole Sort", "992", "Normal", false, [], ""),
],
@ -25,7 +24,6 @@ export const metadata = {
new Problem("Silver", "Triangles", "1015", "Hard", false, [], ""),
new Problem("Silver", "Meetings", "967", "Very Hard", false, [], ""),
],
}
};
<Resources>
@ -36,7 +34,7 @@ export const metadata = {
## Example: Wormhole Sort
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
There are multiple ways to solve this problem. We won't discuss the full solution here, but all of them start by sorting the edges in nondecreasing order of weight. For example, the sample contains the following edges:
@ -573,4 +571,4 @@ public class Sol {
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,12 +10,10 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
bubble: [
new Problem("Silver", "Out of Sorts", "834", "Very Hard", false, []),
],
}
};
<Resources>
@ -32,7 +30,7 @@ There are many sorting algorithms, here are some sources to learn about the popu
## Bubble Sort
<Problems problems={metadata.problems.bubble} />
<Problems problems={problems.bubble} />
### Tutorial

View file

@ -10,8 +10,7 @@ description: "Both Java and C++ have built-in functions for sorting. However, if
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("Silver", "Wormhole Sort", "992", "Normal", false, [], ""),
],
@ -23,12 +22,11 @@ export const metadata = {
new Problem("Silver", "Mooyo Mooyo", "860", "Easy", false, [], "Not a sorting problem, but you can use sorting to simulate gravity. - Write a custom comparator which puts zeroes at the front and use `stable_sort` to keep the relative order of other elements the same."),
new Problem("Silver", "Meetings", "967", "Very Hard", false, [], ""),
],
}
};
## Example: Wormhole Sort
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
There are multiple ways to solve this problem. We won't discuss the full solution here, but all of them start by sorting the edges in nondecreasing order of weight.

View file

@ -9,8 +9,7 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
nearest: [
new Problem("CSES", "Nearest Smaller Values", "1645", "Easy", false, [], ""),
],
@ -21,7 +20,6 @@ export const metadata = {
new Problem("Gold", "Modern Art 2","743", "Hard", false, [], ""),
new Problem("Gold", "Dishwashing","922", "Hard", false, [], ""),
],
}
};
## Additional Reading
@ -224,7 +222,7 @@ pq.add(6); // [7, 6, 5]
## Monotonic Stack
<Problems problems={metadata.problems.nearest} />
<Problems problems={problems.nearest} />
Consider the following problem:
@ -250,7 +248,7 @@ The stack we used is called a **monotonic stack** because we keep popping off th
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
<!--

View file

@ -10,8 +10,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Message Route", "1667", "Easy", false, ["BFS"]),
],
@ -25,10 +24,9 @@ export const metadata = {
example: [
new Problem("Gold", "Cow Navigation", "695", "Normal", false, ["BFS"]),
]
}
};
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
## Resources
@ -181,7 +179,7 @@ class Main {
In the gold division, the problem statement will never directly be, "Given an unweighted graph, find the shortest path between node $u$ and $v$." Instead, the difficulty in many BFS problems are modifying the problem into a graph on which we can run BFS and get the answer.
<Problems problems={metadata.problems.example} />
<Problems problems={problems.example} />
In this problem, Bessie stands on a grid and wants to go from the lower left corner to upper-right corner in as few moves as possible. An initial idea could be to model the grid as a graph, where adjacent cells are connected by edges, and run a BFS to find the shortest path.
@ -212,4 +210,4 @@ Don't forget that once Bessie reaches the goal, she will ignore further commands
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 0
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
und: [
new Problem("CSES", "Round Trip", "1669", "Easy", false, ["Cycle"]),
],
@ -21,7 +20,6 @@ export const metadata = {
general: [
new Problem("CSES", "Graph Girth", "1707", "Easy", false, ["Cycle"]),
],
}
};
@ -29,7 +27,7 @@ export const metadata = {
## Undirected Graphs
<Problems problems={metadata.problems.und} />
<Problems problems={problems.und} />
(explanation?)
@ -41,7 +39,7 @@ An algorithm known as **BFS-Cycle** returns an integer that is at most one more
## Directed Graphs
<Problems problems={metadata.problems.dir} />
<Problems problems={problems.dir} />
The same general idea is implemented below to find any cycle in a directed graph (if one exists). Note that this is almost identical to the DFS algorithm for topological sorting.
@ -107,6 +105,6 @@ int main()
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
VT-HSPC 2019?

View file

@ -11,8 +11,7 @@ frequency: 4
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
usacoEasy: [
new Problem("Gold", "Hoof Paper Scissors", "694", "Easy", false, ["DP"], "dp[first i games][# changes][last gesture] -> max games won"),
new Problem("Gold", "Time is Mooney", "993", "Easy", true, ["DP", "Graphs"], "dp[time][city] -> money"),
@ -50,7 +49,6 @@ export const metadata = {
new Problem("Old Gold", "Cowjog", "496", "Easy", false, ["DP"], "direct application of longest increasing subsequence"),
new Problem("Plat", "Sort It Out", "865", "Very Hard", false, ["DP"], "component of kth largest LIS, read editorial for more details"),
],
}
}
Dynamic Programming is an important algorithmic technique in competitive programming that appears at all levels of competition.
@ -83,31 +81,31 @@ Sometimes it's a good idea to write a slower polynomial-time solution and then o
These are easier USACO problems which use DP, and don't require many optimizations or complex states.
<Problems problems={metadata.problems.usacoEasy} />
<Problems problems={problems.usacoEasy} />
## Knapsack
Common variations on Knapsack, followed by more challenging problems which feature variations on the state and additional algorithms.
<Problems problems={metadata.problems.knapsack} />
<Problems problems={problems.knapsack} />
## Paths in a Grid (and related)
Interesting applications of "number of paths on a grid," some of which don't directly present a grid in the problem, but can be modelled as one. <Asterisk> Such as Longest Common Subsequence. </Asterisk>
<Problems problems={metadata.problems.pathsGrid} />
<Problems problems={problems.pathsGrid} />
## Longest Increasing Subsequence
Some of the problems in this section don't initially look like Longest Increasing Subsequence, but it ends up being the solution. <Asterisk>This can happen a lot, which is why it's a good idea to not focus on one topic unless you have a full solution</Asterisk>
<Problems problems={metadata.problems.lis} />
<Problems problems={problems.lis} />
## Harder USACO Problems
Finish with some more challenging Dynamic Programming problems! Some of these can be very difficult, so skip around if you want.
<Problems problems={metadata.problems.usacoPast} />
<Problems problems={problems.usacoPast} />
## Other DP Problemsets

View file

@ -10,8 +10,7 @@ frequency: 2
---
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Tree Matching", "1130", "Easy", false, ["DP"], ""),
],
@ -29,10 +28,9 @@ export const metadata = {
new Problem("CSES", "Creating Offices", "1752", "Hard", false, ["Greedy"], "equivalent to BOI - Cat in a Tree"),
new Problem("Plat", "Cow At Large", "793", "Hard", false, [], "This is not too hard to fakesolve. First write an (optimized?) O(N^2) DP to pass test cases 1-6. This won't work for test cases 7-11, but in these test cases all trees have at most 20 leaves. Therefore it suffices to compress tree edges (repeatedly remove vertices of degree 2) and run the same solution. For a legit DP solution, see Eric Zhang's comment here: https://codeforces.com/blog/entry/57170?#comment-410179"),
],
}
}
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
## Tutorial
@ -45,7 +43,7 @@ export const metadata = {
## Solving for All Roots
<Problems problems={metadata.problems.allRoots} />
<Problems problems={problems.allRoots} />
(dfs twice)
@ -99,7 +97,6 @@ template<int SZ> struct SubtreeDP {
T p = T(); trav(t,adj[i]) p += getSub(t,i);
ps(p.v);
}
}
};
int main() {
@ -132,7 +129,7 @@ Don't just dive into trying to figure out a DP state and transitions -- make som
</Info>
<Problems problems={metadata.problems.usaco} />
<Problems problems={problems.usaco} />
<Spoiler title="Ostap & Tree">

View file

@ -10,8 +10,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("YS", "Union Find", "unionfind", "Intro|Easy", false, []),
],
@ -20,10 +19,9 @@ export const metadata = {
new Problem("Gold", "Mootube", "789", "Normal", false, [], "Answer queries in decreasing order of $k$. Maintain size of each connected component. Same as [CSES Road Construction](https://cses.fi/problemset/task/1676)"),
new Problem("Gold", "Favorite Colors", "1042", "Very Hard", false, ["DSU"], "Small to large merging is mentioned in the editorial, but we were unable to break solutions that just merged naively. Alternatively, just merge linked lists in $O(1)$ time."),
],
}
};
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
## Resources
@ -102,4 +100,4 @@ boolean merge(int a, int b) {
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,12 +10,10 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
three: [
new Problem("Gold", "3SUM", "994", "Normal", false, [], ""),
],
}
};
<Resources>
@ -97,7 +95,7 @@ then the actual size of `g` is always at least `1<<16` (regardless of calls to `
### Solving ThreeSum
<Problems problems={metadata.problems.three} />
<Problems problems={problems.three} />
You're supposed to use array since values are small :|

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CF", "VK Cup Wildcard R1 C - Prime Factorization", "problemset/problem/162/C", "Intro|Very Easy", false, []),
],
@ -25,7 +24,6 @@ export const metadata = {
new Problem("Gold", "Cow Poetry", "897", "Normal", false, ["Knapsack", "Exponentiation"], "First consider the case where there are only two lines with the same class."),
new Problem("Gold", "Exercise", "1043", "Normal", false, ["Knapsack", "Prime Factorization"], "Prime factorize $K$."),
],
}
};
<Resources>
@ -39,7 +37,7 @@ export const metadata = {
## Prime Factorization
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
A number $a$ is called a **divisor** or a **factor** of a number $b$ if $b$ is divisible by $a$, which means that there exists some integer $k$ such that $b = ka$. Conventionally, $1$ and $n$ are considered divisors of $n$. A number $n > 1$ is **prime** if its only divisors are $1$ and $n$. Numbers greater than \(1\) that are not prime are **composite**.
@ -226,4 +224,4 @@ See the module in the [Advanced](../adv/extend-euclid) section.
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -11,8 +11,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
standard: [
new Problem("Kattis", "MST", "minspantree", "Easy", false, ["MST"], ""),
new Problem("CSES", "Road Reparation", "1675", "Easy", false, ["MST"], ""),
@ -24,10 +23,9 @@ export const metadata = {
new Problem("HR", "Spanning Tree Fraction", "https://www.hackerrank.com/contests/w31/challenges/spanning-tree-fraction/problem", "Normal", false, ["MST", "Binary Search"], ""),
new Problem("Plat", "Fencedin", "625", "Hard", false, ["Kruskal"], ""),
],
}
};
<Problems problems={metadata.problems.standard} />
<Problems problems={problems.standard} />
## Resources
@ -48,4 +46,4 @@ export const metadata = {
## USACO Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
seg: [
new Problem("CSES", "Range Minimum Queries II", "1649", "Intro|Easy", false, ["PURQ"], ""),
new Problem("YS", "Point Set Range Composite", "point_set_range_composite", "Easy", false, ["PURQ"], "Order of operations matters!"),
@ -44,10 +43,9 @@ export const metadata = {
new Problem("Old Gold", "Cow Hopscotch", "532", "Hard", false, [], ""),
new Problem("Plat", "Out of Sorts", "840", "Hard", false, [], ""),
],
}
};
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
<br />
@ -60,7 +58,7 @@ Both **segment trees** and **binary indexed trees** can accomplish this.
## Segment Tree
<Problems problems={metadata.problems.seg} />
<Problems problems={problems.seg} />
A **segment tree** allows you to do point update and range query in $O(\log N)$ time each for **any** associative operation, not just summation.
@ -106,7 +104,6 @@ template<class T> struct Seg { // comb(ID,b) = b
if (r&1) rb = comb(seg[--r],rb);
}
return comb(ra,rb);
}
};
```
@ -208,10 +205,10 @@ Covered in [platinum](../plat/seg-ext).
## Practice Problems
<Problems problems={metadata.problems.practice} />
<Problems problems={problems.practice} />
## USACO Problems
Haircut, Balanced Photo, and Circle Cross are just variations on inversion counting.
<Problems problems={metadata.problems.usaco} />
<Problems problems={problems.usaco} />

View file

@ -11,8 +11,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Shortest Routes I", "1671", "Easy", false, ["SP"], "equivalent to [Kattis SSSP Non-Negative](https://open.kattis.com/problems/shortestpath1)"),
],
@ -33,12 +32,11 @@ export const metadata = {
apsp: [
new Problem("Gold", "Moortal Cowmbat", "971", "Hard", false, ["APSP", "DP"], ""),
],
}
};
## Single-Source Shortest Path
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
### Tutorial
@ -78,11 +76,11 @@ Can be done in $O(M+N\log N)$ with [Fibonacci heap](https://en.wikipedia.org/wik
### Problems
<Problems problems={metadata.problems.dijk} />
<Problems problems={problems.dijk} />
## All Pairs Shortest Path (APSP)
<Problems problems={metadata.problems.apspSam} />
<Problems problems={problems.apspSam} />
Use the *Floyd-Warshall* algorithm.
@ -112,6 +110,6 @@ just to be safe.
### Problems
<Problems problems={metadata.problems.apsp} />
<Problems problems={problems.apsp} />
(more?)

View file

@ -8,12 +8,11 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
rmqSample: [
new Problem("YS", "Static RMQ", "staticrmq", "Easy", false, [], "equivalent to [CSES Range Minimum Queries I](https://cses.fi/problemset/task/1647)"),
],
diviSample: [
diviSample: [
new Problem("ojuz", "JOI Secret", "JOI14_secret", "Easy", false, [], ""),
],
general: [
@ -21,7 +20,6 @@ export const metadata = {
new Problem("DMOJ", "Continued Fractions", "dmopc19c7p4", "Hard", false, [], ""),
new Problem("Plat", "Non-Decreasing Subsequences", "997", "Very Hard", false, [], ""),
],
}
};
Given a static array $A[1],A[2],\ldots,A[N]$, you want to answer queries in the form $A[l]\ominus A[l+1]\ominus \cdots \ominus A[r]$ where $\ominus$ denotes any associative operation.
@ -32,7 +30,7 @@ With $O(N\log N)$ time preprocessing, we can get $O(1)$ queries.
First we'll consider the special case when $\ominus$ denotes `min`.
<Problems problems={metadata.problems.rmqSample} />
<Problems problems={problems.rmqSample} />
### Resources
@ -55,7 +53,7 @@ First we'll consider the special case when $\ominus$ denotes `min`.
## Divide & Conquer
<Problems problems={metadata.problems.diviSample} />
<Problems problems={problems.diviSample} />
**Divide & conquer** can refer to many different techniques. In this case, we use it to answer $Q$ queries offline in $O((N+Q)\log N)$ time.
@ -86,4 +84,4 @@ A data structure known as **sqrt-tree** can speed up preprocessing time to $O(N\
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("Gold", "Springboards", "995", "Hard", false, [], ""),
],
@ -20,10 +19,9 @@ export const metadata = {
new Problem("CF", "Karen & Cards", "contest/815/problem/D", "Very Hard", false, [], "For each a from p to 1, calculate the number of possible cards with that value of a."),
new Problem("CF", "GP of Korea 19 - Interesting Drug", "gym/102059/problem/K", "Very Hard", false, [], "Genfuncs not required but possibly helpful"),
]
}
};
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
<br/>
@ -78,4 +76,4 @@ ll query(int x) { auto it = m.lb(x);
<IncompleteSection />
<Problems problems={metadata.problems.problems} />
<Problems problems={problems.problems} />

View file

@ -10,8 +10,7 @@ prerequisites:
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
ex: [
new Problem("Gold", "Cownomics", "741", "Easy", false, [], ""),
],
@ -25,7 +24,6 @@ export const metadata = {
adj: [
new Problem("CF", "Berland SU Computer Network", "contest/847/problem/L", "Normal", false, [], ""),
]
}
};
## Tutorial
@ -45,7 +43,7 @@ My implementation can be found [here](https://github.com/bqi343/USACO/blob/maste
## Example: Cownomics (Gold)
<Problems problems={metadata.problems.ex} />
<Problems problems={problems.ex} />
- Use two pointers; for a fixed $l$, keep extending $r$ to the right until the positions $l\ldots r$ explain spotiness.
- Hashing gives you a way to quickly check whether two substrings of different cow types are equal. So for a single $[l,r]$ pair you can check whether it works in $O(N\log N)$ time (and you only need to check $O(M)$ of these pairs in total).
@ -55,7 +53,7 @@ My implementation can be found [here](https://github.com/bqi343/USACO/blob/maste
(elaborate)
<Problems problems={metadata.problems.adj} />
<Problems problems={problems.adj} />
-->
## Hacking
@ -66,4 +64,4 @@ My implementation can be found [here](https://github.com/bqi343/USACO/blob/maste
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Course Schedule", "1679", "Easy", false, []),
],
@ -26,14 +25,13 @@ export const metadata = {
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)"),
],
}
};
To review, a **directed** graph consists of edges that can only be traversed in one direction. Additionally, a **acyclic** graph defines a graph which does not contain cycles, meaning you are unable to traverse across one or more edges and return to the node you started on. Putting these definitions together, a **directed acyclic** graph, sometimes abbreviated as DAG, is a graph which has edges which can only be traversed in one direction and does not contain cycles.
## Topological Sort
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
A [topological sort](https://en.wikipedia.org/wiki/Topological_sorting) of a directed acyclic 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.
@ -136,7 +134,7 @@ void compute() {
One useful property of directed acyclic graphs is, as the name suggests, that no cycles exist. If we consider each node in the graph as a state, we can perform dynamic programming on the graph if we process the states in an order that guarantees for every edge $u\to v$ that $u$ is processed before $v$. Fortunately, this is the exact definition of a topological sort!
<Problems problems={metadata.problems.dp} />
<Problems problems={problems.dp} />
In this task, we must find the longest path in a DAG.
@ -459,4 +457,4 @@ public class Main {
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -12,8 +12,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Subtree Queries", "1137", "Easy", false, ["Euler-Tree"], "equivalent to https://judge.yosupo.jp/problem/vertex_add_subtree_sum"),
new Problem("CSES", "Path Queries", "1138", "Easy", false, ["Euler-Tree","PURS"], "equivalent to https://judge.yosupo.jp/problem/vertex_add_path_sum"),
@ -29,12 +28,11 @@ export const metadata = {
new Problem("ojuz", "IOI - Regions", "IOI09_regions", "Hard", false, ["Euler-Tree", "Binary Search"], ""),
new Problem("Plat", "Snow-Cow", "973", "Hard", false, ["Euler-Tree","PURS"], ""),
]
}
};
## Introduction
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
If we can preprocess a rooted tree such that every subtree corresponds to a contiguous range on an array, we can do updates and range queries on it!
@ -50,7 +48,7 @@ If we can preprocess a rooted tree such that every subtree corresponds to a cont
## LCA
<Problems problems={metadata.problems.lca} />
<Problems problems={problems.lca} />
### Tutorial
@ -65,4 +63,4 @@ If we can preprocess a rooted tree such that every subtree corresponds to a cont
## Problems
<Problems problems={metadata.problems.problems} />
<Problems problems={problems.problems} />

View file

@ -8,8 +8,7 @@ description: "Extending Range Queries to 2D (and beyond)."
frequency: 1
---
export const metadata = {
problems: {
export const problems = {
bitSam: [
new Problem("CSES", "Forest Queries II", "1739", "Easy", false, ["2D BIT"], "[thecodingwizard's implementation](https://github.com/thecodingwizard/competitive-programming/blob/master/cses/Forest%20Queries%20II.cpp)"),
],
@ -29,7 +28,6 @@ export const metadata = {
new Problem("ojuz", "IOI 2013 - Game", "IOI13_game", "Very Hard", false, ["2D Seg"], "Alternatively, use BBST in place of sparse segment tree (see Advanced - Treaps)"),
new Problem("ojuz", "JOI - Golf", "JOI17_golf", "Very Hard", false, ["Seg"], ""),
],
}
};
See [my implementations](https://github.com/bqi343/USACO/tree/master/Implementations/content/data-structures/2D%20Range%20Queries%20(15.2)).
@ -44,7 +42,7 @@ See [my implementations](https://github.com/bqi343/USACO/tree/master/Implementat
## 2D BIT
<Problems problems={metadata.problems.bitSam} />
<Problems problems={problems.bitSam} />
### Tutorial
@ -55,7 +53,7 @@ See [my implementations](https://github.com/bqi343/USACO/tree/master/Implementat
### Problems
<Problems problems={metadata.problems.bit} />
<Problems problems={problems.bit} />
<Optional title="Range Update and Range Query in Higher Dimensions">
@ -67,7 +65,7 @@ Lazy propagation on segment trees does not extend to higher dimensions. However,
## 2D Offline Sum Queries
<Problems problems={metadata.problems.offSam} />
<Problems problems={problems.offSam} />
The intended complexity is $O(N\log^2 N)$ with a good constant factor. This requires updating points and querying rectangle sums $N$ times for points with coordinates in the range $[1,N]$. However The 2D BITs mentioned above use $O(N^2)$ memory, which is too much. Since we know all of the updates and queries beforehand, we can reduce the memory usage while maintaining a decent constant factor.
@ -93,7 +91,7 @@ It's a bit difficult to pass the above problem within the time limit. Make sure
### Problems
<Problems problems={metadata.problems.off} />
<Problems problems={problems.off} />
## 2D Segment Tree
@ -124,4 +122,4 @@ To resolve this, reduce the memory usage of sparse segment tree while maintaing
Can also try the USACO problems from above.
<Problems problems={metadata.problems.seg} />
<Problems problems={problems.seg} />

View file

@ -10,8 +10,7 @@ frequency: 1
---
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sam2: [
new Problem("YS", "Two-Edge-Connected Components", "two_edge_connected_components", "Easy", false, [], ""),
],
@ -31,7 +30,6 @@ export const metadata = {
new Problem("DMOJ", "Investment", "tle17c1p6", "Hard", false, [], ""),
new Problem("ojuz", "CEOI - Pipes", "CEOI15_pipes", "Hard", false, [], ""),
],
}
};
<Resources>
@ -40,13 +38,13 @@ export const metadata = {
## 2-Edge-Connected Components
<Problems problems={metadata.problems.sam2} />
<Problems problems={problems.sam2} />
(implementation)
### With DSU
<Problems problems={metadata.problems.disrupt} />
<Problems problems={problems.disrupt} />
The analysis for the above problem mentions an $O(m\alpha(n))$ solution. Although this is not a two-connected component problem, we can in fact use DSU to generate two-connected components.
@ -91,7 +89,6 @@ struct TwoEdgeCC {
void gen() {
F0R(i,N) if (par[i] == -1) dfs(i); // independently for each connected component
DSU.init(N); trav(t,extra) ad(t.f,t.s); // add non-spanning edges
}
};
```
@ -99,13 +96,13 @@ struct TwoEdgeCC {
### Problems
<Problems problems={metadata.problems.probs2} />
<Problems problems={problems.probs2} />
- SRM 787 1000
## [Biconnected Components](https://en.wikipedia.org/wiki/Biconnected_component)
<Problems problems={metadata.problems.bccSam} />
<Problems problems={problems.bccSam} />
note that BCCs contain EDGES not VERTICES
@ -125,4 +122,4 @@ Related topics include
### Problems
<Problems problems={metadata.problems.gen} />
<Problems problems={problems.gen} />

View file

@ -8,8 +8,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Company Queries I", "1687", "Easy", false, ["Binary Jumping"], ""),
],
@ -31,16 +30,15 @@ export const metadata = {
new Problem("Plat", "Gathering", "866", "Hard", false, ["LCA"], "interactive!!"),
new Problem("Plat", "Exercise", "901", "Very Hard", false, ["LCA"], ""),
]
}
};
## Binary Jumping
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
## Lowest Common Ancestor
<Problems problems={metadata.problems.lca} />
<Problems problems={problems.lca} />
### Tutorial
@ -59,4 +57,4 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
school: [
new Problem("CSES", "School Excursion", "1706", "Easy", false, ["Knapsack", "Bitset"], ""),
],
@ -29,7 +28,6 @@ export const metadata = {
new Problem("CSES", "BOI - Nautilus", "https://cses.fi/247/submit/B", "Normal", false, ["Bitset"], ""),
new Problem("ojuz", "IZhO - Bootfall", "IZhO17_bootfall", "Hard", false, ["Knapsack", "Bitset"], ""),
],
}
};
## Tutorial
@ -42,7 +40,7 @@ tl;dr some operations are 32x-64x faster compared to a boolean array. See the [C
## Knapsack
<Problems problems={metadata.problems.school} />
<Problems problems={problems.school} />
Of course, the first step is to generate the sizes of each connected component.
@ -103,7 +101,7 @@ int main() {
## Cowpatibility (Gold)
<Problems problems={metadata.problems.cow} />
<Problems problems={problems.cow} />
Label the cows from $0\ldots N-1$. For two cows $x$ and $y$ set `adj[x][y]=1` if they share a common flavor. Then the number of pairs of cows that are compatible (counting each pair where $x$ and $y$ are distinct twice) is equal to the sum of `adj[x].count()` over all $x$. It remains to compute `adj[x]` for all $x$.
@ -189,7 +187,7 @@ Apparently no test case contains more than $25000$ distinct colors, so we don't
## Lots of Triangles
<Problems problems={metadata.problems.lots} />
<Problems problems={problems.lots} />
First, we read in the input data. `cross(a,b,c)` is positive iff `c` lies to the left of the line from `a` to `b`.
@ -350,10 +348,10 @@ Operations such as `_Find_first()` and `_Find_next()` mentioned in Errichto's bl
Regarding the last application:
<Problems problems={metadata.problems.bfs} />
<Problems problems={problems.bfs} />
In USACO Camp, this problem appeared with $N\le 10^5$ and a large time limit ...
## Additional Problems
<Problems problems={metadata.problems.ad} />
<Problems problems={problems.ad} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
general: [
new Problem("CF", "Ciel the Commander", "problemset/problem/321/C", "Easy", false, ["Centroid"], ""),
new Problem("CF", "Sherlock's bet to Moriarty", "contest/776/problem/F", "Normal", false, ["Centroid"], ""),
@ -26,7 +25,6 @@ export const metadata = {
new Problem("ojuz", "JOI - Synchronization", "JOI13_synchronization", "Hard", false, ["Centroid", "Small to Large"], "Looks like $O(N \log^3 N)$ is very fast!"),
new Problem("Plat", "At Large", "793", "Very Hard", false, ["Centroid"], "tight time limit"),
]
}
};
## Centroid Decomposition
@ -92,6 +90,6 @@ void centroid(int n = 1)
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
*Note:* Unfortunately, it seems like constant factor is especially important for DMOJ. :|

View file

@ -10,8 +10,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("Kattis", "Convex Hull", "convexhull", "Easy", false, ["convex"], ""),
],
@ -32,12 +31,11 @@ export const metadata = {
new Problem("Plat", "Circular Barn", "626", "Hard", false, ["DP", "convex"], ""),
new Problem("Plat", "Falling Portals", "998", "Very Hard", false, ["convex"], ""),
],
}
};
## [Convex Hull](https://en.wikipedia.org/wiki/Convex_hull_algorithms)
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
### Tutorial
@ -49,17 +47,17 @@ export const metadata = {
- [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={metadata.problems.general} />
<Problems problems={problems.general} />
## Rotating Caliphers
<Problems problems={metadata.problems.sample2} />
<Problems problems={problems.sample2} />
<Resources>
<Resource source="CF" title="Rotating calipers technique and applications" url="blog/entry/46162"> </Resource>
</Resources>
<Problems problems={metadata.problems.rotating} />
<Problems problems={problems.rotating} />
## Convex Hull Trick
@ -68,6 +66,6 @@ export const metadata = {
<Resource source="CF" title="Convex Hull Trick - Geo Being Useful" url="blog/entry/63823" starred> </Resource>
</Resources>
<Problems problems={metadata.problems.cht} />
<Problems problems={problems.cht} />
https://codeforces.com/contest/1083/problem/E

View file

@ -11,8 +11,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
general: [
new Problem("AC", "Matching", "https://atcoder.jp/contests/dp/tasks/dp_o?lang=en", "Easy", false, ["Bitmasks"], ""),
new Problem("CSES", "Hamiltonian Flights", "1690", "Easy", false, ["Bitmasks"], ""),
@ -28,7 +27,6 @@ export const metadata = {
new Problem("CF", "Guards in the Storehouse", "problemset/problem/845/F", "Normal", false, [], ""),
new Problem("Plat", "Compound Escape", "949", "Very Hard", false, [], ""),
],
}
};
<Info title="Pro Tip">
@ -48,7 +46,7 @@ You can often use this to solve subtasks.
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
## DP on Broken Profile
@ -58,4 +56,4 @@ You can often use this to solve subtasks.
(fill in? more probs?)
<Problems problems={metadata.problems.broken} />
<Problems problems={problems.broken} />

View file

@ -10,8 +10,7 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
general: [
new Problem("Gold", "248", "647", "Easy", false, ["Range DP"]),
new Problem("CSES", "Empty String", "1080", "Normal", false, ["Range DP"]),
@ -19,7 +18,6 @@ export const metadata = {
new Problem("Plat", "Greedy Pie Eaters", "972", "Hard", false, ["Range DP"]),
new Problem("Plat", "Subsequence Reversal", "698", "Hard", false, ["Range DP"]),
]
}
};
## Tutorial
@ -28,6 +26,6 @@ export const metadata = {
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
* TC SRM 787 500

View file

@ -12,8 +12,7 @@ Has not appeared on a recent USACO contest.
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sam: [
new Problem("CSES", "Mail Delivery (Undirected)", "1691", "Easy", false, ["Euler Tour"], ""),
new Problem("CSES", "Teleporters (Directed)", "1693", "Easy", false, ["Euler Tour"], ""),
@ -23,12 +22,11 @@ export const metadata = {
new Problem("CF", "Johnny and Megan's Necklace", "contest/1361/problem/C", "Normal", false, ["Euler Tour"], ""),
new Problem("CF", "Data Center Drama", "contest/528/problem/C", "Normal", false, ["Euler Tour"], ""),
]
}
};
### Standard
<Problems problems={metadata.problems.sam} />
<Problems problems={problems.sam} />
### Tutorial
@ -36,4 +34,4 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
e1: [
new Problem("DMOJ", "Land of the Rainbow Gold", "apio17p1", "Hard", false, [],""),
],
@ -21,17 +20,16 @@ export const metadata = {
other: [
new Problem("Kattis", "Island Archipelago", "https://utipc20s.kattis.com/problems/utipc20s.islandarchipelago", "Very Hard", false, [],""),
],
}
};
## Example 1
<Problems problems={metadata.problems.e1} />
<Problems problems={problems.e1} />
## Example 2
<Problems problems={metadata.problems.e2} />
<Problems problems={problems.e2} />
Extension:
<Problems problems={metadata.problems.other} />
<Problems problems={problems.other} />

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
maxSam: [
new Problem("CSES", "Download Speed", "1694", "Easy", false, ["Max Flow"], ""),
],
@ -35,12 +34,11 @@ export const metadata = {
new Problem("CF", "Goods Transportation", "problemset/problem/724/E", "Hard", false, [], ""),
new Problem("AC", "ARC E - MUL", "http://arc085.contest.atcoder.jp/tasks/arc085_c", "Hard", false, [], ""),
]
}
};
## Maximum Flow
<Problems problems={metadata.problems.maxSam} />
<Problems problems={problems.maxSam} />
### Tutorial
@ -51,15 +49,15 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.flow} />
<Problems problems={problems.flow} />
## Bipartite Matching
<Problems problems={metadata.problems.match} />
<Problems problems={problems.match} />
## Dinic's Algorithm
<Problems problems={metadata.problems.dinic} />
<Problems problems={problems.dinic} />
Hopcroft-Karp Bipartite Matching?
@ -75,7 +73,7 @@ However, the standard implementation of Dinic's is (almost) always fast enough.
## Min-Cut Max Flow
<Problems problems={metadata.problems.minEx} />
<Problems problems={problems.minEx} />
(show equivalence)
@ -89,4 +87,4 @@ https://maps20.kattis.com/problems/thewrathofkahn
## Problems
<Problems problems={metadata.problems.cut} />
<Problems problems={problems.cut} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("Plat", "Robotic Cow Herd", "674", "Normal", false, [], ""),
],
@ -21,7 +20,6 @@ export const metadata = {
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!"),
],
}
};
@ -147,7 +145,7 @@ int main() {
## Robotic Cow Herd
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
As with the analysis, for each location you should
@ -308,4 +306,4 @@ int main() {
## Other Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -7,8 +7,7 @@ description: Basic setup for geometry problems.
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
standard: [
new Problem("YS", "Sort Points by Argument", "sort_points_by_argument", "Intro", false, [], ""),
new Problem("Kattis", "Segment Intersection", "segmentintersection", "Intro", false, [], ""),
@ -23,7 +22,6 @@ export const metadata = {
new Problem("Kattis", "Max Collinear", "maxcolinear", "Easy", false, [], ""),
new Problem("Kattis", "Birthday Cake", "birthdaycake", "Easy", false, [], ""),
]
}
};
## Primitives
@ -50,11 +48,11 @@ You should know basic operations like cross product and dot product.
<Resource source="IUSACO" title="14.2 - Segment Intersection"></Resource>
</Resources>
<Problems problems={metadata.problems.standard} />
<Problems problems={problems.standard} />
### Misc Problems
<Problems problems={metadata.problems.other} />
<Problems problems={problems.other} />
- [Racing Off Track](https://open.kattis.com/contests/acpc17open/problems/racingofftrack) (link doesn't work ...)
- [TopCoder Watchtower](https://community.topcoder.com/stat?c=problem_statement&pm=2014&rd=4685)

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("CSES", "Company Queries II", "1688", "Intro|Easy", false, ["LCA"], "Pure implementation; see Benq's library code, it has a function for LCA. Though this problem can be solved with binary lifting as well, you should do it with HLD to get practice."),
],
@ -28,10 +27,9 @@ export const metadata = {
new Problem("ojuz", "JOI - Synchronization", "JOI13_synchronization", "Hard", false, ["HLD"], "$O(N\\log N)$ :D"),
new Problem("ojuz", "JOI - Cats or Dogs", "JOI18_catdog", "Very Hard", false, ["HLD"], ""),
],
}
};
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
## Tutorial
@ -50,4 +48,4 @@ export const metadata = {
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("YS", "Line Add Get Min", "line_add_get_min", "Normal", false, [], ""),
],
@ -24,7 +23,6 @@ export const metadata = {
new Problem("TOKI", "Mall & Transportation", "https://tlx.toki.id/contests/troc-13-div-1/problems/D", "Very Hard", false, [], ""),
new Problem("Old Gold", "Fencing the Herd", "534", "Very Hard", false, [], ""),
]
}
};
## Half-Plane Intersection
@ -34,11 +32,11 @@ export const metadata = {
<Resource source="Petr" title="Linear Half-Plane Intersection" url="https://petr-mitrichev.blogspot.com/2016/07/a-half-plane-week.html" starred>expected linear!</Resource>
</Resources>
<Problems problems={metadata.problems.half} />
<Problems problems={problems.half} />
## LineContainer
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
<Resources>
<Resource source="KACTL" title="LineContainer" url="https://github.com/kth-competitive-programming/kactl/blob/master/content/data-structures/LineContainer.h" starred>code</Resource>
@ -48,6 +46,6 @@ export const metadata = {
## Problems
<Problems problems={metadata.problems.probs} />
<Problems problems={problems.probs} />
https://atcoder.jp/contests/arc066/tasks/arc066_d

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("Plat", "Tall Barn", "697", "Easy", false, [], ""),
],
@ -20,12 +19,11 @@ export const metadata = {
new Problem("Kattis", "Blazing New Trails", "blazingnewtrails", "Normal", false, [], ""),
new Problem("ojuz", "Aliens", "IOI16_aliens", "Hard", false, [], ""),
]
}
};
adding lambda\*smth
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
## Tutorial
@ -35,4 +33,4 @@ adding lambda\*smth
## Problems
<Problems problems={metadata.problems.probs} />
<Problems problems={problems.probs} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sam: [
new Problem("CSES", "Distinct Colors", "1139", "Intro", false, ["Merging"]),
],
@ -23,7 +22,6 @@ export const metadata = {
new Problem("Plat", "Disruption", "842", "Normal", false, ["Merging"]),
new Problem("POI", "Tree Rotations", "https://szkopul.edu.pl/problemset/problem/sUe3qzxBtasek-RAWmZaxY_p/site/?key=statement", "Normal", false, ["Merging", "Indexed Set"], ""),
],
}
};
## Additional Reading
@ -38,7 +36,7 @@ export const metadata = {
Obviously [linked lists](http://www.cplusplus.com/reference/list/list/splice/) can be merged in $O(1)$ time. But what about sets or vectors?
<Problems problems={metadata.problems.sam} />
<Problems problems={problems.sam} />
Let's consider a tree rooted at node $1$, where each node has a color.
@ -122,7 +120,7 @@ A set doesn't have to be an `std::set`. Many data structures can be merged, such
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
<Spoiler title="Solution to Promotion Counting">

View file

@ -10,8 +10,7 @@ frequency: 0
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
rollback: [
new Problem("YS", "Persistent Union Find", "persistent_unionfind", "Normal", false, [], ""),
new Problem("YS", "Vertex Add Component Sum", "dynamic_graph_vertex_add_component_sum", "Hard", false, [], ""),
@ -20,7 +19,6 @@ export const metadata = {
ins: [
new Problem("Old Gold", "Fencing the Herd", "534", "Hard", false, [], ""),
],
}
};
### DSU With Rollback
@ -29,7 +27,7 @@ no path compression
(tutorial?)
<Problems problems={metadata.problems.rollback} />
<Problems problems={problems.rollback} />
<!-- ## Dynamic Insertion
@ -37,4 +35,4 @@ mention sqrt
(online Aho-Corasick)
<Problems problems={metadata.problems.ins} /> -->
<Problems problems={problems.ins} /> -->

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
bitSample: [
new Problem("SPOJ", "Horrible Queries", "HORRIBLE", "Easy", false, ["BIT-Range"], ""),
],
@ -34,12 +33,11 @@ export const metadata = {
segTreeBeats: [
new Problem("YS", "Range Chmin Chmax Add Range Sum", "range_chmin_chmax_add_range_sum", "Very Hard", false, ["SegTreeBeats"], ""),
],
}
};
## BIT Revisited
<Problems problems={metadata.problems.bitSample} />
<Problems problems={problems.bitSample} />
Binary Indexed Trees can support range increments in addition to range sum queries.
@ -54,11 +52,11 @@ Binary Indexed Trees can support range increments in addition to range sum queri
### Problems
<Problems problems={metadata.problems.bitProb} />
<Problems problems={problems.bitProb} />
## Lazy Segment Tree
<Problems problems={metadata.problems.lazySample} />
<Problems problems={problems.lazySample} />
### Tutorial
@ -71,7 +69,7 @@ Binary Indexed Trees can support range increments in addition to range sum queri
### Problems
<Problems problems={metadata.problems.lazySegTree} />
<Problems problems={problems.lazySegTree} />
## Lazy Segment Tree - Counting Minimums
@ -79,4 +77,4 @@ use segment tree that keeps track of minimum and # of minimums
(describe)
<Problems problems={metadata.problems.lazySegCnt} />
<Problems problems={problems.lazySegCnt} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
ex: [
new Problem("CSES", "Planets & Kingdoms", "1683", "Easy", false, [], ""),
],
@ -27,12 +26,11 @@ export const metadata = {
satEx: [
new Problem("CSES", "Giant Pizza", "1684", "Normal", false, [], "")
],
}
};
## SCCs
<Problems problems={metadata.problems.ex} />
<Problems problems={problems.ex} />
### Tutorial
@ -49,11 +47,11 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
## 2-SAT
<Problems problems={metadata.problems.satEx} />
<Problems problems={problems.satEx} />
(impl)

View file

@ -10,8 +10,7 @@ frequency: 0
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sam: [
new Problem("Kattis", "SSSP Negative", "shortestpath3", "Easy", false, [], ""),
new Problem("Kattis", "APSP (with negative weights)", "allpairspath", "Easy", false, [], ""),
@ -24,10 +23,9 @@ export const metadata = {
linear: [
new Problem("ojuz", "Restore Array", "RMI19_restore", "Normal", false, [], "similar to [Art](https://codeforces.com/gym/102394/problem/A)"),
],
}
};
<Problems problems={metadata.problems.sam} />
<Problems problems={problems.sam} />
<br/>
@ -46,7 +44,7 @@ Can also use [Shortest Path Faster Algorithm](https://en.wikipedia.org/wiki/Shor
### Problems
<Problems problems={metadata.problems.probs} />
<Problems problems={problems.probs} />
## Simple Linear Programming
@ -64,4 +62,4 @@ You can also use shortest path algorithms to solve the following problem (a very
### Problems
<Problems problems={metadata.problems.linear} />
<Problems problems={problems.linear} />

View file

@ -10,8 +10,7 @@ frequency: 3
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
walkSam: [
new Problem("CSES", "Hotel Queries", "1143", "Easy", false, ["PURQ"], "walk"),
],
@ -35,12 +34,11 @@ export const metadata = {
new Problem("Kattis", "Easy Query", "easyquery", "Hard", false, ["Wavelet"], ""),
new Problem("DMOJ", "Ninjaclasher's Wrath 2", "globexcup19s4", "Hard", false, ["Wavelet"], ""),
],
}
};
## Walking on a Segment Tree
<Problems problems={metadata.problems.walkSam} />
<Problems problems={problems.walkSam} />
You want to support queries of the following form on an array $a_1,\ldots,a_N$ (along with point updates).
@ -48,19 +46,19 @@ You want to support queries of the following form on an array $a_1,\ldots,a_N$ (
Of course, you can do this in $O(\log^2N)$ time with a max segment tree and binary searching on the first $i$ such that $\max(a_1,\ldots,a_i)\ge x$. But try to do this in $O(\log N)$ time.
<Problems problems={metadata.problems.walk} />
<Problems problems={problems.walk} />
## Combining
<Problems problems={metadata.problems.combSam} />
<Problems problems={problems.combSam} />
(solution to above problem)
<Problems problems={metadata.problems.comb} />
<Problems problems={problems.comb} />
## Wavelet Tree
<Problems problems={metadata.problems.waveletSam} />
<Problems problems={problems.waveletSam} />
### Tutorial
@ -70,4 +68,4 @@ Of course, you can do this in $O(\log^2N)$ time with a max segment tree and bina
### Problems
<Problems problems={metadata.problems.wavelet} />
<Problems problems={problems.wavelet} />

View file

@ -11,8 +11,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
ex: [
new Problem("CF", "Problem Without a Legend", "contest/713/problem/C", "Easy", false, ["Slope Trick"], ""),
],
@ -34,7 +33,6 @@ export const metadata = {
new Problem("CF", "April Fools' Problem", "contest/802/problem/O", "Very Hard", false, ["Slope Trick"], "binary search on top of slope trick"),
new Problem("ICPC World Finals", "Conquer the World", "https://icpc.kattis.com/problems/conquertheworld", "Very Hard", false, ["Slope Trick", "Small to Large"], "ICPC world finals, 0 solves in contest - \"Potatoes\" on tree!!"),
],
}
};
## Tutorials
@ -61,13 +59,13 @@ Usually you can come up with a slower (usually $O(N^2)$) DP first and then optim
The rest of this module assumes that you know the basic idea of this trick. In particular, you should be at least somewhat familiar with the $O(N\log N)$ time solution to the first problem in zscoder's tutorial:
<Problems problems={metadata.problems.ex} />
<Problems problems={problems.ex} />
It's ok if you found the explanations confusing; the example below should help clarify.
## Buy Low Sell High
<Problems problems={metadata.problems.buy} />
<Problems problems={problems.buy} />
### Slow Solution
@ -212,7 +210,7 @@ int main() {
## Potatoes & Fertilizers
<Problems problems={metadata.problems.potatoes} />
<Problems problems={problems.potatoes} />
### Simplifying the Problem
@ -290,7 +288,7 @@ int main() {
## USACO Landscaping
<Problems problems={metadata.problems.landscaping} />
<Problems problems={problems.landscaping} />
This looks similar to the previous task (we're moving dirt instead of fertilizer), so it's not too hard to guess that slope trick is applicable.
@ -367,4 +365,4 @@ We can solve this problem when $\sum A_i+\sum B_i$ is not so small with lazy bal
## Problems
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />

View file

@ -7,8 +7,7 @@ frequency: 1
---
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
fst: [
new Problem("CF", "Tree Queries", "contest/1254/problem/D", "Hard", false, [], ""),
new Problem("wcipeg", "COI 08-Otoci", "https://wcipeg.com/problem/coi08p2", "Hard", false, ["HLD"], "Editorial rebuilds HLD after certain # of updates ..."),
@ -22,7 +21,6 @@ export const metadata = {
other: [
new Problem("Plat", "Train Tracking", "841", "Insane", false, [], ""),
]
}
};
<IncompleteSection />
@ -35,7 +33,7 @@ partitioning into sqrt blocks (each block can have some sort of data structure .
optimization tips? (ez to get TLE with bad constant ..., can get AC with suboptimal complexity ...)
<Problems problems={metadata.problems.fst} />
<Problems problems={problems.fst} />
## Mo's
@ -50,7 +48,7 @@ optimization tips? (ez to get TLE with bad constant ..., can get AC with subopti
### Block Tree
<Problems problems={metadata.problems.block} />
<Problems problems={problems.block} />
<Resources>
<Resource source="CF" title="Block Tree" url="blog/entry/46843"></Resource>
@ -58,4 +56,4 @@ optimization tips? (ez to get TLE with bad constant ..., can get AC with subopti
### Train Tracking
<Problems problems={metadata.problems.other} />
<Problems problems={problems.other} />

View file

@ -8,8 +8,7 @@ description: Knuth-Morris-Pratt and Z Algorithms (and a few more related topics)
frequency: 1
---
export const metadata = {
problems: {
export const problems = {
KMP: [
new Problem("Kattis", "String Matching", "problems/stringmatching", "Easy", false, ["Strings"], "Naive KMP works. Just be careful about I/O"),
new Problem("POJ", "(USACO Gold 05) Cow Patterns", "http://poj.org/problem?id=3167", "Hard", false, ["Strings"], "Run KMP, except each state needs to be considered as not only a length, but also mapping of pattern to # of spots"),
@ -36,7 +35,6 @@ export const metadata = {
pal: [
new Problem("ojuz", "Palindrome", "APIO14_palindrome", "Easy", false, [], ""),
]
}
};
## General
@ -59,7 +57,7 @@ Specifically, it computes the longest substring that is both a prefix and suffix
<Resource source="TC" title="String Searching" url="introduction-to-string-searching-algorithms"></Resource>
</Resources>
<Problems problems={metadata.problems.KMP} />
<Problems problems={problems.KMP} />
## Z Algorithm
@ -71,7 +69,7 @@ The **Z-Algorithm** is another linear time string comparison algorithm like KMP,
<Resource source="CF" title="Z Algorithm" url="blog/entry/3107"></Resource>
</Resources>
<Problems problems={metadata.problems.Z} />
<Problems problems={problems.Z} />
## Manacher
@ -88,7 +86,7 @@ It can determine the longest palindrome centered at each character.
If s[l, r] is a palindrome, then s[l+1, r-1] is as well.
</Info>
<Problems problems={metadata.problems.mana} />
<Problems problems={problems.mana} />
# Multiple Strings
@ -104,7 +102,7 @@ This means that every prefix of a string is an ancestor of that string's node.
<Resource source="PAPS" title="14.1 - Tries"></Resource>
</Resources>
<Problems problems={metadata.problems.trie} />
<Problems problems={problems.trie} />
## Aho-Corasick
@ -122,7 +120,7 @@ Build the entire trie first, and then run a *BFS* to construct the fail array.
<Resource source="GFG" title="Aho-Corasick for Pattern Searching" url="aho-corasick-algorithm-pattern-searching"></Resource>
</Resources>
<Problems problems={metadata.problems.aho} />
<Problems problems={problems.aho} />
## Palindromic Tree
@ -132,6 +130,6 @@ Build the entire trie first, and then run a *BFS* to construct the fail array.
<Resource source="CF" title="adamant - Palindromic Tree" url="blog/entry/13959"></Resource>
</Resources>
<Problems problems={metadata.problems.pal} />
<Problems problems={problems.pal} />
DMOJ thing

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
sample: [
new Problem("YS", "Suffix Array", "suffixarray", "Easy", false, [], ""),
],
@ -28,7 +27,6 @@ export const metadata = {
runSam: [
new Problem("YS", "Run Enumerate", "runenumerate", "Hard", false, [], ""),
]
}
};
## Resources
@ -41,7 +39,7 @@ export const metadata = {
## Suffix Array
<Problems problems={metadata.problems.sample} />
<Problems problems={problems.sample} />
### Implementations
@ -53,11 +51,11 @@ export const metadata = {
## LCP Array
<Problems problems={metadata.problems.lcpSam} />
<Problems problems={problems.lcpSam} />
Quickly compute longest common prefix of two suffixes.
<Problems problems={metadata.problems.lcp} />
<Problems problems={problems.lcp} />
## Inverse Burrows-Wheeler
@ -67,7 +65,7 @@ Quickly compute longest common prefix of two suffixes.
CSES Guide?
<Problems problems={metadata.problems.burSam} />
<Problems problems={problems.burSam} />
## Run Enumerate
@ -77,5 +75,5 @@ CSES Guide?
(describe how to do easily w/ suffix array)
<Problems problems={metadata.problems.runSam} />
<Problems problems={problems.runSam} />

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
closest: [
new Problem("Kattis", "Closest Pair", "closestpair2", "Normal", false, [], ""),
],
@ -24,7 +23,6 @@ export const metadata = {
man: [
new Problem("CSA", "The Sprawl", "the-sprawl", "Hard", false, [], ""),
]
}
};
(what's line sweep?)
@ -36,7 +34,7 @@ export const metadata = {
## Closest Pair
<Problems problems={metadata.problems.closest} />
<Problems problems={problems.closest} />
(explanation? KACTL?)
@ -44,18 +42,18 @@ export const metadata = {
(refer to previous module)
<Problems problems={metadata.problems.seg} />
<Problems problems={problems.seg} />
(filling in the details?)
## Manhattan MST
<Problems problems={metadata.problems.manSam} />
<Problems problems={problems.manSam} />
(KACTL code)
explanation? topcoder prob has
<Problems problems={metadata.problems.man} />
<Problems problems={problems.man} />
TC 760 ComponentsForever

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
kat: [
new Problem("Kattis","Modular Arithmetic", "modulararithmetic"),
],
@ -19,7 +18,6 @@ export const metadata = {
new Problem("Kattis","Chinese Remainder", "chineseremainder"),
new Problem("Kattis","Chinese Remainder (non-relatively prime moduli)", "generalchineseremainder"),
],
}
};
## Euclidean Algorithm
@ -140,7 +138,7 @@ Note that this works when $a,b$ are quite large (say, $\approx 2^{60}$) and we w
<Resource source="cp-algo" url="algebra/module-inverse.html" title="Modular Inverse"> </Resource>
</Resources>
<Problems problems={metadata.problems.kat} />
<Problems problems={problems.kat} />
It seems that when multiplication / division is involved in this problem, $n^2 < \texttt{LLONG\_MAX}$.
@ -176,4 +174,4 @@ int main() {
<Resource source="cp-algo" url="algebra/chinese-remainder-theorem.html" title="Chinese Remainder Theorem"></Resource>
</Resources>
<Problems problems={metadata.problems.crt} />
<Problems problems={problems.crt} />

View file

@ -9,8 +9,7 @@ frequency: 0
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
ys: [
new Problem("YS", "Partition Function", "partition_function", "?", false, [], ""),
new Problem("YS", "Bernoulli Number", "bernoulli_number", "?", false, [], ""),
@ -19,7 +18,6 @@ export const metadata = {
new Problem("Plat", "Tree Depth", "974", "Hard", false, ["genfunc"], ""),
new Problem("Plat", "Exercise", "1045", "Hard", false, ["permutation"], "genfuncs not required but possibly helpful"),
],
}
};
## More Complex Operations
@ -36,13 +34,13 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.ys} />
<Problems problems={problems.ys} />
## Counting
No advanced knowledge about generating functions is required for either of these problems.
<Problems problems={metadata.problems.general} />
<Problems problems={problems.general} />
However, these do:

View file

@ -10,8 +10,7 @@ frequency: 0
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
hungry: [
new Problem("DMOJ", "Hungry Squirrels", "wac4p6", "Normal", false, [], ""),
],
@ -21,10 +20,9 @@ export const metadata = {
new Problem("CF", "Incorrect Flow", "contest/708/problem/D", "Normal", false, [], ""),
new Problem("AC", "Multi-Path Story", "https://atcoder.jp/contests/jag2013summer-day4/tasks/icpc2013summer_day4_i", "Normal", false, [], ""),
],
}
};
<Problems problems={metadata.problems.hungry} />
<Problems problems={problems.hungry} />
### Tutorial
@ -34,4 +32,4 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.lower} />
<Problems problems={problems.lower} />

View file

@ -10,8 +10,7 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
lctSam: [
new Problem("YS", "Vertex Add Path Sum", "dynamic_tree_vertex_add_path_sum", "Normal", false, ["LCT"], ""),
],
@ -38,7 +37,6 @@ export const metadata = {
new Problem("CF", "Old Driver Tree", "contest/1172/problem/E", "Hard", false, ["LCT"], ""),
new Problem("DMOJ", "Dynamic Tree Test", "ds5", "Very Hard", false, ["LCT"], ""),
]
}
};
## Splay Tree
@ -54,7 +52,7 @@ export const metadata = {
## Link Cut Tree - Paths
<Problems problems={metadata.problems.lctSam} />
<Problems problems={problems.lctSam} />
### Tutorial
@ -65,7 +63,7 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.lct} />
<Problems problems={problems.lct} />
<!--
@ -84,7 +82,7 @@ export const metadata = {
## Link Cut Tree - Subtrees
<Problems problems={metadata.problems.subSam} />
<Problems problems={problems.subSam} />
### Tutorial
@ -92,4 +90,4 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.sub} />
<Problems problems={problems.sub} />

View file

@ -10,12 +10,10 @@ frequency: 1
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
segTreeBeats: [
new Problem("YS", "Range Chmin Chmax Add Range Sum", "range_chmin_chmax_add_range_sum", "Hard", false, ["SegTreeBeats"], ""),
],
}
};
### Tutorial
@ -26,6 +24,6 @@ export const metadata = {
### Problems
<Problems problems={metadata.problems.segTreeBeats} />
<Problems problems={problems.segTreeBeats} />
(300iq insane problem??)

View file

@ -8,15 +8,13 @@ prerequisites:
frequency: 0
---
export const metadata = {
problems: {
export const problems = {
auto: [
new Problem("Plat", "Standing Out from the Herd", "768", "Hard", false, [], ""),
],
tree: [
new Problem("CF", "Security", "contest/1037/problem/H", "Hard", false, ["Suffix Tree"], ""),
]
}
};
## Suffix Automaton
@ -38,7 +36,7 @@ Most problems can be solved with Suffix Arrays, Suffix Automata, or Suffix Trees
### Problems
<Problems problems={metadata.problems.auto} />
<Problems problems={problems.auto} />
<Spoiler title="USACO Standing Out using Suffix Automata">
@ -202,7 +200,7 @@ Naively, this would take up $O(N^2)$ memory, but *path compression* enables it t
### Problems
<Problems problems={metadata.problems.tree} />
<Problems problems={problems.tree} />
### Generate Suffix Array

View file

@ -10,12 +10,10 @@ frequency: 2
import { Problem } from "../models";
export const metadata = {
problems: {
export const problems = {
treeRot: [
new Problem("POI", "Tree Rotations 2", "https://szkopul.edu.pl/problemset/problem/b0BM0al2crQBt6zovEtJfOc6/site/?key=statement", "Normal", false, [], ""),
]
}
};
## Merging
@ -24,7 +22,7 @@ export const metadata = {
## Merging (Arbitrary Keys)
<Problems problems={metadata.problems.treeRot} />
<Problems problems={problems.treeRot} />
<Spoiler title="Tree Rotations 2 Solution">

View file

@ -196,41 +196,39 @@ prerequisites:
import { Problem } from '../models';
export const metadata = {
problems: {
standard: [
new Problem('YS', 'Associative Array', 'associative_array', 'Intro'),
new Problem('CSES', 'Distinct Numbers', '1621', 'Intro'),
new Problem(
'CSES',
'Sum of Two Values',
'1640',
'Intro',
false,
[],
'Can be solved without sets.'
),
new Problem('CSES', 'Concert Tickets', '1091', 'Easy', false, [
'iterators',
]),
new Problem('CSES', 'Towers', '1073', 'Easy', false, [
'multiset',
'greedy',
]),
new Problem('CSES', 'Traffic Lights', '1163', 'Normal', false, ['set']),
new Problem('CSES', 'Room Allocation', '1164', 'Normal', false, [
'multiset',
'greedy',
]),
],
},
export const problems = {
standard: [
new Problem('YS', 'Associative Array', 'associative_array', 'Intro'),
new Problem('CSES', 'Distinct Numbers', '1621', 'Intro'),
new Problem(
'CSES',
'Sum of Two Values',
'1640',
'Intro',
false,
[],
'Can be solved without sets.'
),
new Problem('CSES', 'Concert Tickets', '1091', 'Easy', false, [
'iterators',
]),
new Problem('CSES', 'Towers', '1073', 'Easy', false, [
'multiset',
'greedy',
]),
new Problem('CSES', 'Traffic Lights', '1163', 'Normal', false, ['set']),
new Problem('CSES', 'Room Allocation', '1164', 'Normal', false, [
'multiset',
'greedy',
]),
],
};
## Standard
Do roughly the first half of the Sorting and Searching section in the [CSES Problem Set](https://cses.fi/problemset/).
<Problems problems={metadata.problems.standard} />
<Problems problems={problems.standard} />
```
### Resource Lists

View file

@ -1,6 +1,8 @@
import { SECTIONS } from './content/ordering';
const toString = require('mdast-util-to-string');
const mdastToString = require('mdast-util-to-string');
const Slugger = require('github-slugger');
const Problem = require('./src/models/problem').Problem; // needed to eval export
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions;
@ -83,6 +85,19 @@ exports.createSchemaCustomization = ({ actions }) => {
java: [Heading]
py: [Heading]
}
type Problem {
source: String!
name: String!
id: String!
difficulty: String
starred: Boolean
tags: [String]
sketch: String
url: String
isIntro: Boolean
uniqueID: String
}
`;
createTypes(typeDefs);
};
@ -118,8 +133,8 @@ exports.createResolvers = ({ createResolvers }) => {
if (node.type === 'heading') {
let val = {
depth: node.depth,
value: toString(node),
slug: slugger.slug(toString(node)),
value: mdastToString(node),
slug: slugger.slug(mdastToString(node)),
};
if (cppCt === 0 && javaCt === 0 && pyCt === 0) {
cpp.push(val);
@ -143,6 +158,29 @@ exports.createResolvers = ({ createResolvers }) => {
};
},
},
problems: {
type: `[Problem]`,
async resolve(source, args, context, info) {
const { resolve } = info.schema.getType('Mdx').getFields().mdxAST;
let mdast = await resolve(source, args, context, {
fieldName: 'mdast',
});
let problems = [];
mdast.children.forEach(node => {
if (
node.type === 'export' &&
node.value.includes('export const problems =')
) {
let str = node.value.replace('export ', '') + '; problems';
let res = eval(str);
Object.keys(res).forEach(k => {
problems.push(...res[k]);
});
}
});
return problems;
},
},
},
};
createResolvers(resolvers);

View file

@ -5,6 +5,7 @@
"version": "0.1.0",
"author": "Nathan Wang <nathan.r.wang@gmail.com>",
"dependencies": {
"@babel/core": "^7.10.5",
"@mapbox/rehype-prism": "^0.5.0",
"@mdx-js/mdx": "^1.6.6",
"@mdx-js/react": "^1.6.6",

View file

@ -28,30 +28,6 @@ export default function ActiveItems({
<h3 className="text-lg leading-6 font-medium text-gray-900">
Active {type === 'problems' ? 'Problems' : 'Modules'}
</h3>
{/*<div className="mt-3 max-w-xl text-gray-500">*/}
{/* <p className="mb-2">*/}
{/* <a*/}
{/* href="#"*/}
{/* className="inline-flex items-center font-medium text-blue-600 hover:text-blue-500 transition ease-in-out duration-150"*/}
{/* >*/}
{/* Intro: Input & Output*/}
{/* <span className="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-green-100 text-green-800">*/}
{/* Practicing*/}
{/* </span>*/}
{/* </a>*/}
{/* </p>*/}
{/* <p>*/}
{/* <a*/}
{/* href="#"*/}
{/* className="inline-flex items-center font-medium text-blue-600 hover:text-blue-500 transition ease-in-out duration-150"*/}
{/* >*/}
{/* Intro: Expected Knowledge*/}
{/* <span className="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-gray-100 text-gray-800">*/}
{/* Skipped*/}
{/* </span>*/}
{/* </a>*/}
{/* </p>*/}
{/*</div>*/}
<div className="mt-4 text-gray-500">
{items.map((item, idx) => (
<p className={idx === 0 ? '' : 'mt-2'}>

View file

@ -77,7 +77,7 @@ const Breadcrumbs = () => {
return (
<nav className="flex flex-wrap items-center text-sm leading-loose font-medium">
<Link
to="/"
to="/dashboard"
className="text-gray-500 hover:text-gray-700 transition duration-150 ease-in-out"
>
Home

View file

@ -147,9 +147,16 @@ export function ProblemComponent(props: ProblemComponentProps) {
};
const [showTags, setShowTags] = React.useState(false);
const { problem } = props;
const id = `problem-${problem.uniqueID}`;
return (
<tr>
<tr
id={id}
style={
window && window.location && window.location.hash === '#' + id
? { backgroundColor: '#FDFDEA' }
: null
}
>
<td className="pl-4 md:pl-6 whitespace-no-wrap text-sm text-gray-500 font-medium">
<div
style={{ height: '1.25rem' }}

View file

@ -22,9 +22,22 @@ export default function DashboardPage(props: PageProps) {
acc[cur.node.frontmatter.id] = cur.node.frontmatter.title;
return acc;
}, {});
const problemIDMap = modules.edges.reduce((acc, cur) => {
cur.node.problems.forEach(problem => {
console.log(problem.uniqueID, cur.node.frontmatter.id);
acc[problem.uniqueID] = {
label: `${problem.source}: ${problem.name}`,
url: `${moduleIDToURLMap[cur.node.frontmatter.id]}/#problem-${
problem.uniqueID
}`,
};
});
return acc;
}, {});
const {
lastViewedModule: lastViewedModuleID,
userProgressOnModules,
userProgressOnProblems,
} = React.useContext(UserDataContext);
const lastViewedModuleURL = moduleIDToURLMap[lastViewedModuleID];
const activeModules: ActiveItem[] = React.useMemo(() => {
@ -44,7 +57,18 @@ export default function DashboardPage(props: PageProps) {
userProgressOnModules[x] === 'Skipped' ? 'Skipped' : 'In Progress',
}));
}, [userProgressOnModules]);
const activeProblems: ActiveItem[] = [];
const activeProblems: ActiveItem[] = React.useMemo(() => {
return Object.keys(userProgressOnProblems)
.filter(
x =>
userProgressOnProblems[x] === 'Solving' ||
userProgressOnProblems[x] === 'Skipped'
)
.map(x => ({
...problemIDMap[x],
status: userProgressOnProblems[x] as 'Solving' | 'Skipped',
}));
}, [userProgressOnProblems]);
return (
<Layout>
@ -201,6 +225,11 @@ export const pageQuery = graphql`
title
id
}
problems {
uniqueID
source
name
}
}
}
}

118
yarn.lock
View file

@ -69,6 +69,28 @@
semver "^5.4.1"
source-map "^0.5.0"
"@babel/core@^7.10.5":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.10.5.tgz#1f15e2cca8ad9a1d78a38ddba612f5e7cdbbd330"
integrity sha512-O34LQooYVDXPl7QWCdW9p4NR+QlzOr7xShPPJz8GsuCU3/8ua/wqTr7gmnxXv+WBESiGU/G5s16i6tUvHkNb+w==
dependencies:
"@babel/code-frame" "^7.10.4"
"@babel/generator" "^7.10.5"
"@babel/helper-module-transforms" "^7.10.5"
"@babel/helpers" "^7.10.4"
"@babel/parser" "^7.10.5"
"@babel/template" "^7.10.4"
"@babel/traverse" "^7.10.5"
"@babel/types" "^7.10.5"
convert-source-map "^1.7.0"
debug "^4.1.0"
gensync "^1.0.0-beta.1"
json5 "^2.1.2"
lodash "^4.17.19"
resolve "^1.3.2"
semver "^5.4.1"
source-map "^0.5.0"
"@babel/generator@^7.10.1", "@babel/generator@^7.10.3", "@babel/generator@^7.5.0", "@babel/generator@^7.9.6":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.10.3.tgz#32b9a0d963a71d7a54f5f6c15659c3dbc2a523a5"
@ -89,6 +111,15 @@
lodash "^4.17.13"
source-map "^0.5.0"
"@babel/generator@^7.10.5":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.10.5.tgz#1b903554bc8c583ee8d25f1e8969732e6b829a69"
integrity sha512-3vXxr3FEW7E7lJZiWQ3bM4+v/Vyr9C+hpolQ8BGFr9Y8Ri2tFLWTixmwKBafDujO1WVah4fhZBeU1bieKdghig==
dependencies:
"@babel/types" "^7.10.5"
jsesc "^2.5.1"
source-map "^0.5.0"
"@babel/helper-annotate-as-pure@^7.0.0":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3"
@ -223,7 +254,14 @@
dependencies:
"@babel/types" "^7.10.3"
"@babel/helper-module-imports@^7.0.0":
"@babel/helper-member-expression-to-functions@^7.10.4":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.5.tgz#172f56e7a63e78112f3a04055f24365af702e7ee"
integrity sha512-HiqJpYD5+WopCXIAbQDG0zye5XYVvcO9w/DHp5GsaGkRUaamLj2bEtu6i8rnGGprAhHM3qidCMgp71HF4endhA==
dependencies:
"@babel/types" "^7.10.5"
"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz#4c5c54be04bd31670a7382797d75b9fa2e5b5620"
integrity sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==
@ -250,6 +288,19 @@
"@babel/types" "^7.10.1"
lodash "^4.17.13"
"@babel/helper-module-transforms@^7.10.5":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.10.5.tgz#120c271c0b3353673fcdfd8c053db3c544a260d6"
integrity sha512-4P+CWMJ6/j1W915ITJaUkadLObmCRRSC234uctJfn/vHrsLNxsR8dwlcXv9ZhJWzl77awf+mWXSZEKt5t0OnlA==
dependencies:
"@babel/helper-module-imports" "^7.10.4"
"@babel/helper-replace-supers" "^7.10.4"
"@babel/helper-simple-access" "^7.10.4"
"@babel/helper-split-export-declaration" "^7.10.4"
"@babel/template" "^7.10.4"
"@babel/types" "^7.10.5"
lodash "^4.17.19"
"@babel/helper-optimise-call-expression@^7.10.1", "@babel/helper-optimise-call-expression@^7.10.3":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.3.tgz#f53c4b6783093195b0f69330439908841660c530"
@ -257,6 +308,13 @@
dependencies:
"@babel/types" "^7.10.3"
"@babel/helper-optimise-call-expression@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz#50dc96413d594f995a77905905b05893cd779673"
integrity sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==
dependencies:
"@babel/types" "^7.10.4"
"@babel/helper-plugin-utils@7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz#9ea293be19babc0f52ff8ca88b34c3611b208670"
@ -295,6 +353,16 @@
"@babel/traverse" "^7.10.1"
"@babel/types" "^7.10.1"
"@babel/helper-replace-supers@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.10.4.tgz#d585cd9388ea06e6031e4cd44b6713cbead9e6cf"
integrity sha512-sPxZfFXocEymYTdVK1UNmFPBN+Hv5mJkLPsYWwGBxZAxaWfFu+xqp7b6qWD0yjNuNL2VKc6L5M18tOXUP7NU0A==
dependencies:
"@babel/helper-member-expression-to-functions" "^7.10.4"
"@babel/helper-optimise-call-expression" "^7.10.4"
"@babel/traverse" "^7.10.4"
"@babel/types" "^7.10.4"
"@babel/helper-simple-access@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.10.1.tgz#08fb7e22ace9eb8326f7e3920a1c2052f13d851e"
@ -303,6 +371,14 @@
"@babel/template" "^7.10.1"
"@babel/types" "^7.10.1"
"@babel/helper-simple-access@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.10.4.tgz#0f5ccda2945277a2a7a2d3a821e15395edcf3461"
integrity sha512-0fMy72ej/VEvF8ULmX6yb5MtHG4uH4Dbd6I/aHDb/JVg0bbivwt9Wg+h3uMvX+QSFtwr5MeItvazbrc4jtRAXw==
dependencies:
"@babel/template" "^7.10.4"
"@babel/types" "^7.10.4"
"@babel/helper-split-export-declaration@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz#c6f4be1cbc15e3a868e4c64a17d5d31d754da35f"
@ -346,6 +422,15 @@
"@babel/traverse" "^7.10.1"
"@babel/types" "^7.10.1"
"@babel/helpers@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.10.4.tgz#2abeb0d721aff7c0a97376b9e1f6f65d7a475044"
integrity sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==
dependencies:
"@babel/template" "^7.10.4"
"@babel/traverse" "^7.10.4"
"@babel/types" "^7.10.4"
"@babel/highlight@^7.10.3":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.3.tgz#c633bb34adf07c5c13156692f5922c81ec53f28d"
@ -379,6 +464,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.10.4.tgz#9eedf27e1998d87739fb5028a5120557c06a1a64"
integrity sha512-8jHII4hf+YVDsskTF6WuMB3X4Eh+PsUkC2ljq22so5rHvH+T8BzyL94VOdyFLNR8tBSVXOTbNHOKpR4TfRxVtA==
"@babel/parser@^7.10.5":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.10.5.tgz#e7c6bf5a7deff957cec9f04b551e2762909d826b"
integrity sha512-wfryxy4bE1UivvQKSQDU4/X6dr+i8bctjUjj8Zyt3DQy7NtPizJXT8M52nqpNKL+nq2PW8lxk4ZqLj0fD4B4hQ==
"@babel/plugin-proposal-async-generator-functions@^7.10.3":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.10.3.tgz#5a02453d46e5362e2073c7278beab2e53ad7d939"
@ -1089,6 +1179,21 @@
globals "^11.1.0"
lodash "^4.17.13"
"@babel/traverse@^7.10.4", "@babel/traverse@^7.10.5":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.10.5.tgz#77ce464f5b258be265af618d8fddf0536f20b564"
integrity sha512-yc/fyv2gUjPqzTz0WHeRJH2pv7jA9kA7mBX2tXl/x5iOE81uaVPuGPtaYk7wmkx4b67mQ7NqI8rmT2pF47KYKQ==
dependencies:
"@babel/code-frame" "^7.10.4"
"@babel/generator" "^7.10.5"
"@babel/helper-function-name" "^7.10.4"
"@babel/helper-split-export-declaration" "^7.10.4"
"@babel/parser" "^7.10.5"
"@babel/types" "^7.10.5"
debug "^4.1.0"
globals "^11.1.0"
lodash "^4.17.19"
"@babel/traverse@^7.4.5":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.10.4.tgz#e642e5395a3b09cc95c8e74a27432b484b697818"
@ -1131,6 +1236,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"
"@babel/types@^7.10.5":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.10.5.tgz#d88ae7e2fde86bfbfe851d4d81afa70a997b5d15"
integrity sha512-ixV66KWfCI6GKoA/2H9v6bQdbfXEwwpOdQ8cRvb4F+eyvhlaHxWFMQB4+3d9QFJXZsiiiqVrewNV0DFEQpyT4Q==
dependencies:
"@babel/helper-validator-identifier" "^7.10.4"
lodash "^4.17.19"
to-fast-properties "^2.0.0"
"@emotion/is-prop-valid@^0.8.8":
version "0.8.8"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a"
@ -9840,7 +9954,7 @@ lodash@4.17.15, lodash@^4.11.1, lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
lodash@~4.17.4:
lodash@^4.17.19, lodash@~4.17.4:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==