From d3cdfba9d8dce9bbf09f4c9d7284d6eefaef4f9b Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Sat, 13 Jun 2020 01:01:52 -0700 Subject: [PATCH 01/97] update styling --- src/templates/moduleTemplate.js | 54 ++++++++++++++++--------------- src/templates/syllabusTemplate.js | 4 +-- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/templates/moduleTemplate.js b/src/templates/moduleTemplate.js index 0467dea..c6985fc 100644 --- a/src/templates/moduleTemplate.js +++ b/src/templates/moduleTemplate.js @@ -15,8 +15,8 @@ const renderPrerequisite = (prerequisite) => { }; export default function Template({ - data, // this prop will be injected by the GraphQL query below. -}) { + data, // this prop will be injected by the GraphQL query below. + }) { const { markdownRemark } = data; // data.markdownRemark holds your post data const { htmlAst } = markdownRemark; const prereqs = markdownRemark.frontmatter.prerequisites; @@ -31,36 +31,38 @@ export default function Template({ return (
- ← Back to Home -

{markdownRemark.frontmatter.title}

-

Author: {markdownRemark.frontmatter.author}

+
+ ← Back to Home +

{markdownRemark.frontmatter.title}

+

Author: {markdownRemark.frontmatter.author}

- {prereqs && -
-
-
- - - -
-
-

- Prerequisites -

-
-
    - {prereqs.map(renderPrerequisite)} -
+ {prereqs && +
+
+
+ + + +
+
+

+ Prerequisites +

+
+
    + {prereqs.map(renderPrerequisite)} +
+
-
-
} +
} - + +
) diff --git a/src/templates/syllabusTemplate.js b/src/templates/syllabusTemplate.js index d6e4fec..c118f8c 100644 --- a/src/templates/syllabusTemplate.js +++ b/src/templates/syllabusTemplate.js @@ -72,7 +72,7 @@ export default function Template(props) { {/* Begin Hero Section */} -
+
-
+
handleDivisionChange(e.target.value - '0')} + onChange={e => handleDivisionChange(e.target.value)} value={selectedDivision} > - - - - - - + {divisions.map(division => ( + + ))}
-- 2.46.0 From 78cc5471f198d40a411cdc9d376ebb787a42aca7 Mon Sep 17 00:00:00 2001 From: caoash Date: Tue, 16 Jun 2020 20:42:08 -0500 Subject: [PATCH 77/97] changed rect geo --- content/3_Bronze/Rect_Geo.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/3_Bronze/Rect_Geo.md b/content/3_Bronze/Rect_Geo.md index b00d805..af67149 100644 --- a/content/3_Bronze/Rect_Geo.md +++ b/content/3_Bronze/Rect_Geo.md @@ -21,14 +21,14 @@ Rectangle newRect = new Rectangle(x, y, width, height); The `Rectangle` class supports numerous useful methods. -```java -firstRect.intersects(secondRect)` checks if two rectangles intersect. +``` +firstRect.intersects(secondRect) checks if two rectangles intersect. -firstRect.union(secondRect)` returns a rectangle representing the union of two rectangles. +firstRect.union(secondRect) returns a rectangle representing the union of two rectangles. -firstRect.contains(x, y)` checks whether the integer point (x,y) exists in firstRect. +firstRect.contains(x, y) checks whether the integer point (x,y) exists in firstRect. -firstRect.intersect(secondRect)` returns a rectangle representing the intersection of two rectangles. +firstRect.intersect(secondRect) returns a rectangle representing the intersection of two rectangles. ``` This class can often lessen the implementation needed in a lot of bronze problems and codeforces problems. -- 2.46.0 From a5b75086bf36a87e675c5e0428a195ecf5301589 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Tue, 16 Jun 2020 18:42:09 -0700 Subject: [PATCH 78/97] add data structures gold to ordering --- content/ordering.js | 1 + 1 file changed, 1 insertion(+) diff --git a/content/ordering.js b/content/ordering.js index 4dfaecc..a8f1dfd 100644 --- a/content/ordering.js +++ b/content/ordering.js @@ -73,6 +73,7 @@ const ModuleOrdering = { "dp-trees" ] }, + "data-structures-gold", "intro-nt", "bit", ], -- 2.46.0 From e4e4c707f54d7d7c7e95f227adeec6a91183c0d2 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Tue, 16 Jun 2020 18:49:20 -0700 Subject: [PATCH 79/97] update license need to figure out what to put instead of just USACO --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 5169a5e..1dd6883 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 gatsbyjs +Copyright (c) 2020 USACO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal -- 2.46.0 From dedf6d56455774d289094e3be6abed389ddd9ef3 Mon Sep 17 00:00:00 2001 From: caoash Date: Tue, 16 Jun 2020 20:51:27 -0500 Subject: [PATCH 80/97] changed desc. --- content/5_Gold/DS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/5_Gold/DS.md b/content/5_Gold/DS.md index 98cd383..3a85f34 100644 --- a/content/5_Gold/DS.md +++ b/content/5_Gold/DS.md @@ -8,7 +8,7 @@ prerequisites: - (?) Silver - Data Structures --- -More advanced applications of data structures introduced in earlier divisions using USACO Gold Problems. +More advanced applications of data structures introduced in earlier divisions. -- 2.46.0 From 1f243cfa35776e077bc96eb1f763e9cc9400991a Mon Sep 17 00:00:00 2001 From: Siyong Date: Tue, 16 Jun 2020 18:55:44 -0700 Subject: [PATCH 81/97] Update Sorting_Custom.md --- content/4_Silver/Sorting_Custom.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/4_Silver/Sorting_Custom.md b/content/4_Silver/Sorting_Custom.md index 6bf7611..bedcaaf 100644 --- a/content/4_Silver/Sorting_Custom.md +++ b/content/4_Silver/Sorting_Custom.md @@ -179,6 +179,7 @@ I don't recommend using arrays to represent objects mostly because it's confusin ```py +import random class Foo: def __init__(self, _Bar): self.Bar = _Bar def __str__(self): return "Foo({})".format(self.Bar) @@ -204,6 +205,7 @@ Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) - This method maps an object to another comparable datatype with which to be sorted. In this case, `Foo` is sorted by the sum of its members `x` and `y`. ```py +import random class Foo: def __init__(self, _Bar, _Baz): self.Bar,self.Baz = _Bar,_Baz def __str__(self): return "Foo({},{})".format(self.Bar, self.Baz) @@ -239,6 +241,7 @@ Note how the comparator must be converted to a `key`. ```py +import random from functools import cmp_to_key class Foo: def __init__(self, _Bar): self.Bar = _Bar @@ -272,4 +275,4 @@ Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) - Not a sorting problem, but you can use sorting to simulate gravity nicely. - Write a custom comparator (read below) which puts zeroes at the front and use `stable_sort` to keep the relative order of other elements the same. - [Meetings](http://www.usaco.org/index.php?page=viewproblem2&cpid=967) - - hard! \ No newline at end of file + - hard! -- 2.46.0 From a8d0545b02bd587396bdfdb98ff5543767c6c70c Mon Sep 17 00:00:00 2001 From: Siyong Date: Tue, 16 Jun 2020 18:56:34 -0700 Subject: [PATCH 82/97] Update Sorting_Custom.md --- content/4_Silver/Sorting_Custom.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/4_Silver/Sorting_Custom.md b/content/4_Silver/Sorting_Custom.md index bedcaaf..7d62caa 100644 --- a/content/4_Silver/Sorting_Custom.md +++ b/content/4_Silver/Sorting_Custom.md @@ -203,6 +203,8 @@ Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) ### Remapping Key - This method maps an object to another comparable datatype with which to be sorted. In this case, `Foo` is sorted by the sum of its members `x` and `y`. + + ```py import random -- 2.46.0 From 1a5c9113d769ea01d8c45a692e71a1172ea5b7bd Mon Sep 17 00:00:00 2001 From: caoash Date: Tue, 16 Jun 2020 21:02:55 -0500 Subject: [PATCH 83/97] extra SPACE LOL --- content/5_Gold/DS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/5_Gold/DS.md b/content/5_Gold/DS.md index 3a85f34..9520c53 100644 --- a/content/5_Gold/DS.md +++ b/content/5_Gold/DS.md @@ -79,7 +79,7 @@ When merging two sets, you move from the smaller set to the larger set. If the s Additionally, a set doesn't have to be an `std::set`. Many data structures can be merged, such as `std::map` or even adjacency lists. -[[info | Challenge]] +[[info | Challenge]] | Prove that if you instead merge sets that have size equal to the depths of the subtrees, then small to large merging does $O(N)$ insert calls. ## Further Reading -- 2.46.0 From 9fc00032f65937f6966da40e9516b972e58254fc Mon Sep 17 00:00:00 2001 From: caoash Date: Tue, 16 Jun 2020 21:04:48 -0500 Subject: [PATCH 84/97] exponent --- content/5_Gold/DS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/5_Gold/DS.md b/content/5_Gold/DS.md index 9520c53..af6a8f8 100644 --- a/content/5_Gold/DS.md +++ b/content/5_Gold/DS.md @@ -74,7 +74,7 @@ In other words, by merging the smaller set into the larger one, the runtime comp
Proof -When merging two sets, you move from the smaller set to the larger set. If the size of the smaller set is $X$, then the size of the resulting set is at least $2X$. Thus, an element that has been moved $Y$ times will be in a set of size $2Y$, and since the maximum size of a set is $N$ (the root), each element will be moved at most $O(\log N$) times leading to a total complexity of $O(N\log N)$. +When merging two sets, you move from the smaller set to the larger set. If the size of the smaller set is $X$, then the size of the resulting set is at least $2X$. Thus, an element that has been moved $Y$ times will be in a set of size $2^Y$, and since the maximum size of a set is $N$ (the root), each element will be moved at most $O(\log N$) times leading to a total complexity of $O(N\log N)$.
Additionally, a set doesn't have to be an `std::set`. Many data structures can be merged, such as `std::map` or even adjacency lists. -- 2.46.0 From 21dcd332d6b7ca34151b03d348d1a8850440ffab Mon Sep 17 00:00:00 2001 From: caoash Date: Tue, 16 Jun 2020 21:14:52 -0500 Subject: [PATCH 85/97] rearrange containers --- content/3_Bronze/Cpp_Containers.md | 145 ------------------------- content/4_Silver/Containers_Silver.md | 150 ++++++++++++++++++++++++++ content/ordering.js | 3 +- 3 files changed, 152 insertions(+), 146 deletions(-) create mode 100644 content/4_Silver/Containers_Silver.md diff --git a/content/3_Bronze/Cpp_Containers.md b/content/3_Bronze/Cpp_Containers.md index b92874b..bb1002b 100644 --- a/content/3_Bronze/Cpp_Containers.md +++ b/content/3_Bronze/Cpp_Containers.md @@ -141,148 +141,3 @@ q.push(4); // [4, 3, 1] q.pop(); // [4, 3] cout << q.front() << endl; // 3 ``` - -### [Deques](http://www.cplusplus.com/reference/deque/deque/) - -A deque (usually pronounced "deck") stands for double ended queue and is a combination of a stack and a queue, in that it supports $O(1)$ insertions and deletions from both the front and the back of the deque. The four methods for adding and removing are `push_back`, `pop_back`, `push_front`, and `pop_front`. Not very common in Bronze / Silver. - -```cpp -deque d; -d.push_front(3); // [3] -d.push_front(4); // [4, 3] -d.push_back(7); // [4, 3, 7] -d.pop_front(); // [3, 7] -d.push_front(1); // [1, 3, 7] -d.pop_back(); // [1, 3] -``` - -### [Priority Queues](http://www.cplusplus.com/reference/queue/priority_queue/) - -A priority queue supports the following operations: insertion of elements, deletion of the element considered highest priority, and retrieval of the highest priority element, all in $O(\log n)$ time according to the number of elements in the priority queue. Priority is based on a comparator function, but by default the highest element is at the top of the priority queue. The priority queue is one of the most important data structures in competitive programming, so make sure you understand how and when to use it. - -```cpp -priority_queue pq; -pq.push(7); // [7] -pq.push(2); // [2, 7] -pq.push(1); // [1, 2, 7] -pq.push(5); // [1, 2, 5, 7] -cout << pq.top() << endl; // 7 -pq.pop(); // [1, 2, 5] -pq.pop(); // [1, 2] -pq.push(6); // [1, 2, 6] -``` - -## Sets and Maps - -A set is a collection of objects that contains no duplicates. There are two types of sets: unordered sets (`unordered_set` in C++), and ordered set (`set` in C++). - -### Unordered Sets - -The unordered set works by hashing, which is assigning a unique code to every variable/object which allows insertions, deletions, and searches in $O(1)$ time, albeit with a high constant factor, as hashing requires a large constant number of operations. However, as the name implies, elements are not ordered in any meaningful way, so traversals of an unordered set will return elements in some arbitrary order. The operations on an unordered set are `insert`, which adds an element to the set if not already present, `erase`, which deletes an element if it exists, and `count`, which returns 1 if the set contains the element and 0 if it doesn't. - -```cpp -unordered_set s; -s.insert(1); // [1] -s.insert(4); // [1, 4] in arbitrary order -s.insert(2); // [1, 4, 2] in arbitrary order -s.insert(1); // [1, 4, 2] in arbitrary order -// the add method did nothing because 1 was already in the set -cout << s.count(1) << endl; // 1 -set.erase(1); // [2, 4] in arbitrary order -cout << s.count(5) << endl; // 0 -s.erase(0); // [2, 4] in arbitrary order -// if the element to be removed does not exist, nothing happens - -for(int element : s){ - cout << element << " "; -} -cout << endl; -// You can iterate through an unordered set, but it will do so in arbitrary order -``` - -### [Ordered Sets](http://www.cplusplus.com/reference/set/set/) - -The second type of set data structure is the ordered or sorted set. Insertions, deletions, and searches on the ordered set require $O(\log n)$ time, based on the number of elements in the set. As well as those supported by the unordered set, the ordered set also allows four additional operations: `begin()`, which returns an iterator to the lowest element in the set, `end()`, which returns an iterator to the highest element in the set, `lower_bound`, which returns an iterator to the least element greater than or equal to some element `k`, and `upper_bound`, which returns an iterator to the least element strictly greater than some element `k`. - -```cpp -set s; -s.insert(1); // [1] -s.insert(14); // [1, 14] -s.insert(9); // [1, 9, 14] -s.insert(2); // [1, 2, 9, 14] -cout << *s.upper_bound(7) << '\n'; // 9 -cout << *s.upper_bound(9) << '\n'; // 14 -cout << *s.lower_bound(5) << '\n'; // 9 -cout << *s.lower_bound(9) << '\n'; // 9 -cout << *s.begin() << '\n'; // 1 -auto it = s.end(); -cout << *(--it) << '\n'; // 14 -s.erase(s.upper_bound(6)); // [1, 2, 14] -``` - -The primary limitation of the ordered set is that we can't efficiently access the $k^{th}$ largest element in the set, or find the number of elements in the set greater than some arbitrary $x$. These operations can be handled using a data structure called an order statistic tree (see Gold - Binary Indexed Trees). - -### [Maps](http://www.cplusplus.com/reference/map/map/) - -A map is a set of ordered pairs, each containing a key and a value. In a map, all keys are required to be unique, but values can be repeated. Maps have three primary methods: one to add a specified key-value pairing, one to retrieve the value for a given key, and one to remove a key-value pairing from the map. Like sets, maps can be unordered (`unordered_map` in C++) or ordered (`map` in C++). In an unordered map, hashing is used to support $O(1)$ operations. In an ordered map, the entries are sorted in order of key. Operations are $O(\log n)$, but accessing or removing the next key higher or lower than some input `k` is also supported. - -### Unordered Maps - -In an unordered map `m`, the `m[key] = value` operator assigns a value to a key and places the key and value pair into the map. The operator `m[key]` returns the value associated with the key. If the key is not present in the map, then `m[key]` is set to 0. The `count(key)` method returns the number of times the key is in the map (which is either one or zero), and therefore checks whether a key exists in the map. Lastly, `erase(key)` and `erase(it)` removes the map entry associated with the specified key or iterator. All of these operations are $O(1)$, but again, due to the hashing, this has a high constant factor. - -```cpp -unordered_map m; -m[1] = 5; // [(1, 5)] -m[3] = 14; // [(1, 5); (3, 14)] -m[2] = 7; // [(1, 5); (3, 14); (2, 7)] -m.erase(2); // [(1, 5); (3, 14)] -cout << m[1] << '\n'; // 5 -cout << m.count(7) << '\n' ; // 0 -cout << m.count(1) << '\n' ; // 1 -``` - -### Ordered Maps - -The ordered map supports all of the operations that an unordered map supports, and additionally supports `lower_bound` and `upper_bound`, returning the iterator pointing to the lowest entry not less than the specified key, and the iterator pointing to the lowest entry strictly greater than the specified key respectively. - -```cpp -map m; -m[3] = 5; // [(3, 5)] -m[11] = 4; // [(3, 5); (11, 4)] -m[10] = 491; // [(3, 5); (10, 491); (11, 4)] -cout << m.lower_bound(10)->first << " " << m.lower_bound(10)->second << '\n'; // 10 491 -cout << m.upper_bound(10)->first << " " << m.upper_bound(10)->second << '\n'; // 11 4 -m.erase(11); // [(3, 5); (10, 491)] -if (m.upper_bound(10) == m.end()) -{ - cout << "end" << endl; // Prints end -} -``` - -A note on unordered sets and maps: In USACO contests, they're generally fine, but in CodeForces contests, you should always use sorted sets and maps. This is because the built-in hashing algorithm is vulnerable to pathological data sets causing abnormally slow runtimes, in turn causing failures on some test cases (see [neal's blog](https://codeforces.com/blog/entry/62393)). Alternatively, use a different hashing algorithm. - -### [Multisets](http://www.cplusplus.com/reference/set/multiset/) - -Lastly, there is the multiset, which is essentially a sorted set that allows multiple copies of the same element. In addition to all of the regular set operations, the multiset `count()` method returns the number of times an element is present in the multiset. (Actually, you shouldn't use `count()` because this takes time **linear** in the number of matches.) - - -The `begin()`, `end()`, `lower_bound()`, and `upper_bound()` operations work the same way they do in the normal sorted set. - -**Warning:** If you want to remove a value *once*, make sure to use `multiset.erase(multiset.find(val))` rather than `multiset.erase(val)`. The latter will remove *all* instances of `val`. - -```cpp -multiset ms; -ms.insert(1); // [1] -ms.insert(14); // [1, 14] -ms.insert(9); // [1, 9, 14] -ms.insert(2); // [1, 2, 9, 14] -ms.insert(9); // [1, 2, 9, 9, 14] -ms.insert(9); // [1, 2, 9, 9, 9, 14] -cout << ms.count(4) << '\n'; // 0 -cout << ms.count(9) << '\n'; // 3 -cout << ms.count(14) << '\n'; // 1 -ms.erase(ms.find(9)); -cout << ms.count(9) << '\n'; // 2 -ms.erase(9); -cout << ms.count(9) << '\n'; // 0 -``` \ No newline at end of file diff --git a/content/4_Silver/Containers_Silver.md b/content/4_Silver/Containers_Silver.md new file mode 100644 index 0000000..3743b55 --- /dev/null +++ b/content/4_Silver/Containers_Silver.md @@ -0,0 +1,150 @@ +--- +id: containers-silver +title: Built-In C++ Containers (Silver) +author: Darren Yao +--- + +### [Deques](http://www.cplusplus.com/reference/deque/deque/) + +A deque (usually pronounced "deck") stands for double ended queue and is a combination of a stack and a queue, in that it supports $O(1)$ insertions and deletions from both the front and the back of the deque. The four methods for adding and removing are `push_back`, `pop_back`, `push_front`, and `pop_front`. Not very common in Bronze / Silver. + +```cpp +deque d; +d.push_front(3); // [3] +d.push_front(4); // [4, 3] +d.push_back(7); // [4, 3, 7] +d.pop_front(); // [3, 7] +d.push_front(1); // [1, 3, 7] +d.pop_back(); // [1, 3] +``` + +### [Priority Queues](http://www.cplusplus.com/reference/queue/priority_queue/) + +A priority queue supports the following operations: insertion of elements, deletion of the element considered highest priority, and retrieval of the highest priority element, all in $O(\log n)$ time according to the number of elements in the priority queue. Priority is based on a comparator function, but by default the highest element is at the top of the priority queue. The priority queue is one of the most important data structures in competitive programming, so make sure you understand how and when to use it. + +```cpp +priority_queue pq; +pq.push(7); // [7] +pq.push(2); // [2, 7] +pq.push(1); // [1, 2, 7] +pq.push(5); // [1, 2, 5, 7] +cout << pq.top() << endl; // 7 +pq.pop(); // [1, 2, 5] +pq.pop(); // [1, 2] +pq.push(6); // [1, 2, 6] +``` + +## Sets and Maps + +A set is a collection of objects that contains no duplicates. There are two types of sets: unordered sets (`unordered_set` in C++), and ordered set (`set` in C++). + +### Unordered Sets + +The unordered set works by hashing, which is assigning a unique code to every variable/object which allows insertions, deletions, and searches in $O(1)$ time, albeit with a high constant factor, as hashing requires a large constant number of operations. However, as the name implies, elements are not ordered in any meaningful way, so traversals of an unordered set will return elements in some arbitrary order. The operations on an unordered set are `insert`, which adds an element to the set if not already present, `erase`, which deletes an element if it exists, and `count`, which returns 1 if the set contains the element and 0 if it doesn't. + +```cpp +unordered_set s; +s.insert(1); // [1] +s.insert(4); // [1, 4] in arbitrary order +s.insert(2); // [1, 4, 2] in arbitrary order +s.insert(1); // [1, 4, 2] in arbitrary order +// the add method did nothing because 1 was already in the set +cout << s.count(1) << endl; // 1 +set.erase(1); // [2, 4] in arbitrary order +cout << s.count(5) << endl; // 0 +s.erase(0); // [2, 4] in arbitrary order +// if the element to be removed does not exist, nothing happens + +for(int element : s){ + cout << element << " "; +} +cout << endl; +// You can iterate through an unordered set, but it will do so in arbitrary order +``` + +### [Ordered Sets](http://www.cplusplus.com/reference/set/set/) + +The second type of set data structure is the ordered or sorted set. Insertions, deletions, and searches on the ordered set require $O(\log n)$ time, based on the number of elements in the set. As well as those supported by the unordered set, the ordered set also allows four additional operations: `begin()`, which returns an iterator to the lowest element in the set, `end()`, which returns an iterator to the highest element in the set, `lower_bound`, which returns an iterator to the least element greater than or equal to some element `k`, and `upper_bound`, which returns an iterator to the least element strictly greater than some element `k`. + +```cpp +set s; +s.insert(1); // [1] +s.insert(14); // [1, 14] +s.insert(9); // [1, 9, 14] +s.insert(2); // [1, 2, 9, 14] +cout << *s.upper_bound(7) << '\n'; // 9 +cout << *s.upper_bound(9) << '\n'; // 14 +cout << *s.lower_bound(5) << '\n'; // 9 +cout << *s.lower_bound(9) << '\n'; // 9 +cout << *s.begin() << '\n'; // 1 +auto it = s.end(); +cout << *(--it) << '\n'; // 14 +s.erase(s.upper_bound(6)); // [1, 2, 14] +``` + +The primary limitation of the ordered set is that we can't efficiently access the $k^{th}$ largest element in the set, or find the number of elements in the set greater than some arbitrary $x$. These operations can be handled using a data structure called an order statistic tree (see Gold - Binary Indexed Trees). + +### [Maps](http://www.cplusplus.com/reference/map/map/) + +A map is a set of ordered pairs, each containing a key and a value. In a map, all keys are required to be unique, but values can be repeated. Maps have three primary methods: one to add a specified key-value pairing, one to retrieve the value for a given key, and one to remove a key-value pairing from the map. Like sets, maps can be unordered (`unordered_map` in C++) or ordered (`map` in C++). In an unordered map, hashing is used to support $O(1)$ operations. In an ordered map, the entries are sorted in order of key. Operations are $O(\log n)$, but accessing or removing the next key higher or lower than some input `k` is also supported. + +### Unordered Maps + +In an unordered map `m`, the `m[key] = value` operator assigns a value to a key and places the key and value pair into the map. The operator `m[key]` returns the value associated with the key. If the key is not present in the map, then `m[key]` is set to 0. The `count(key)` method returns the number of times the key is in the map (which is either one or zero), and therefore checks whether a key exists in the map. Lastly, `erase(key)` and `erase(it)` removes the map entry associated with the specified key or iterator. All of these operations are $O(1)$, but again, due to the hashing, this has a high constant factor. + +```cpp +unordered_map m; +m[1] = 5; // [(1, 5)] +m[3] = 14; // [(1, 5); (3, 14)] +m[2] = 7; // [(1, 5); (3, 14); (2, 7)] +m.erase(2); // [(1, 5); (3, 14)] +cout << m[1] << '\n'; // 5 +cout << m.count(7) << '\n' ; // 0 +cout << m.count(1) << '\n' ; // 1 +``` + +### Ordered Maps + +The ordered map supports all of the operations that an unordered map supports, and additionally supports `lower_bound` and `upper_bound`, returning the iterator pointing to the lowest entry not less than the specified key, and the iterator pointing to the lowest entry strictly greater than the specified key respectively. + +```cpp +map m; +m[3] = 5; // [(3, 5)] +m[11] = 4; // [(3, 5); (11, 4)] +m[10] = 491; // [(3, 5); (10, 491); (11, 4)] +cout << m.lower_bound(10)->first << " " << m.lower_bound(10)->second << '\n'; // 10 491 +cout << m.upper_bound(10)->first << " " << m.upper_bound(10)->second << '\n'; // 11 4 +m.erase(11); // [(3, 5); (10, 491)] +if (m.upper_bound(10) == m.end()) +{ + cout << "end" << endl; // Prints end +} +``` + +A note on unordered sets and maps: In USACO contests, they're generally fine, but in CodeForces contests, you should always use sorted sets and maps. This is because the built-in hashing algorithm is vulnerable to pathological data sets causing abnormally slow runtimes, in turn causing failures on some test cases (see [neal's blog](https://codeforces.com/blog/entry/62393)). Alternatively, use a different hashing algorithm. + +### [Multisets](http://www.cplusplus.com/reference/set/multiset/) + +Lastly, there is the multiset, which is essentially a sorted set that allows multiple copies of the same element. In addition to all of the regular set operations, the multiset `count()` method returns the number of times an element is present in the multiset. (Actually, you shouldn't use `count()` because this takes time **linear** in the number of matches.) + + +The `begin()`, `end()`, `lower_bound()`, and `upper_bound()` operations work the same way they do in the normal sorted set. + +**Warning:** If you want to remove a value *once*, make sure to use `multiset.erase(multiset.find(val))` rather than `multiset.erase(val)`. The latter will remove *all* instances of `val`. + +```cpp +multiset ms; +ms.insert(1); // [1] +ms.insert(14); // [1, 14] +ms.insert(9); // [1, 9, 14] +ms.insert(2); // [1, 2, 9, 14] +ms.insert(9); // [1, 2, 9, 9, 14] +ms.insert(9); // [1, 2, 9, 9, 9, 14] +cout << ms.count(4) << '\n'; // 0 +cout << ms.count(9) << '\n'; // 3 +cout << ms.count(14) << '\n'; // 1 +ms.erase(ms.find(9)); +cout << ms.count(9) << '\n'; // 2 +ms.erase(9); +cout << ms.count(9) << '\n'; // 0 +``` diff --git a/content/ordering.js b/content/ordering.js index a8f1dfd..eb6fa98 100644 --- a/content/ordering.js +++ b/content/ordering.js @@ -46,6 +46,7 @@ const ModuleOrdering = { "binary-search", "2P", "data-structures", + "containers-silver" "greedy", "prefix-sums", { @@ -117,4 +118,4 @@ export const divisionLabels = { "silver": "Silver", "gold": "Gold", "plat": "Platinum", -}; \ No newline at end of file +}; -- 2.46.0 From 8772d3169bfbe95dea84fd936a533570f6eb8bb2 Mon Sep 17 00:00:00 2001 From: Siyong Date: Tue, 16 Jun 2020 19:43:31 -0700 Subject: [PATCH 86/97] Update Sorting_Custom.md --- content/4_Silver/Sorting_Custom.md | 183 +++++++++++++++++++---------- 1 file changed, 119 insertions(+), 64 deletions(-) diff --git a/content/4_Silver/Sorting_Custom.md b/content/4_Silver/Sorting_Custom.md index 7d62caa..0655b88 100644 --- a/content/4_Silver/Sorting_Custom.md +++ b/content/4_Silver/Sorting_Custom.md @@ -1,7 +1,7 @@ --- id: sorting-custom title: "Sorting with Custom Comparators" -author: Darren Yao +author: Darren Yao, Siyong Huang prerequisites: - - Silver - Introduction to Sorting @@ -110,6 +110,103 @@ When using `Comparator`, the syntax for using the built-in sorting function requ If we instead wanted to sort in descending order, this is also very simple. Instead of the comparing function returning `Integer.compare(x, y)` of the arguments, it should instead return `-Integer.compare(x, y)`. +### Python + +There are 3 main ways to create a custom comparator in python + +#### 1) Operator Overloading + + +```py +import random +class Foo: + def __init__(self, _Bar): self.Bar = _Bar + def __str__(self): return "Foo({})".format(self.Bar) + def __lt__(self, o): # lt means less than + return self.Bar < o.Bar + +a = [] +for i in range(8): + a.append(Foo(random.randint(1, 10))) +print(*a) +print(*sorted(a)) +``` + +Output: + +``` +Foo(0) Foo(1) Foo(2) Foo(1) Foo(9) Foo(5) Foo(5) Foo(8) +Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) +``` + +#### 2) Remapping Key + + - This method maps an object to another comparable datatype with which to be sorted. In this case, `Foo` is sorted by the sum of its members `x` and `y`. + + + +```py +import random +class Foo: + def __init__(self, _Bar, _Baz): self.Bar,self.Baz = _Bar,_Baz + def __str__(self): return "Foo({},{})".format(self.Bar, self.Baz) + +a = [] +for i in range(8): + a.append(Foo(random.randint(1, 9)*10, random.randint(1, 9))) +print(*a) + +print(*sorted(a, key=lambda foo: foo.Bar+foo.Baz)) +def key(foo): + return foo.Bar + foo.Baz +print(*sorted(a, key=key)) +``` + +Output: + +``` +Foo(10,2) Foo(30,2) Foo(60,6) Foo(90,7) Foo(80,7) Foo(80,9) Foo(60,9) Foo(90,8) +Foo(10,2) Foo(30,2) Foo(60,6) Foo(60,9) Foo(80,7) Foo(80,9) Foo(90,7) Foo(90,8) +Foo(10,2) Foo(30,2) Foo(60,6) Foo(60,9) Foo(80,7) Foo(80,9) Foo(90,7) Foo(90,8) +``` + +#### 3) Function / Lambda + + - This method defines how to compare two elements represented by an integer + - Positive: First term is greater than the second term + - Zero: First term and second term are equal + - Negative: First term is less than the second term + +Note how the comparator must be converted to a `key`. + + + +```py +import random +from functools import cmp_to_key +class Foo: + def __init__(self, _Bar): self.Bar = _Bar + def __str__(self): return "Foo({})".format(self.Bar) + +a = [] +for i in range(8): + a.append(Foo(random.randint(0, 9))) +print(*a) + +print(*sorted(a, key=cmp_to_key(lambda foo1, foo2: foo1.Bar - foo2.Bar))) +def cmp(foo1, foo2): + return foo1.Bar - foo2.Bar +print(*sorted(a, key=cmp_to_key(cmp))) +``` + +Output: + +``` +Foo(0) Foo(1) Foo(2) Foo(1) Foo(9) Foo(5) Foo(5) Foo(8) +Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) +Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) +``` + ## Sorting by Multiple Criteria @@ -169,41 +266,9 @@ static class Comp implements Comparator{ I don't recommend using arrays to represent objects mostly because it's confusing, but it's worth noting that some competitors do this. -## Python - -(merge w/ sections above?) - -### Operator Overloading - - - Overloads operators - - -```py -import random -class Foo: - def __init__(self, _Bar): self.Bar = _Bar - def __str__(self): return "Foo({})".format(self.Bar) - def __lt__(self, o): # lt means less than - return self.Bar < o.Bar - -a = [] -for i in range(8): - a.append(Foo(random.randint(1, 10))) -print(*a) -print(*sorted(a)) -``` - -Output: - -``` -Foo(0) Foo(1) Foo(2) Foo(1) Foo(9) Foo(5) Foo(5) Foo(8) -Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) -``` - -### Remapping Key - - - This method maps an object to another comparable datatype with which to be sorted. In this case, `Foo` is sorted by the sum of its members `x` and `y`. +### Python +Operator Overloading can be used ```py @@ -211,61 +276,51 @@ import random class Foo: def __init__(self, _Bar, _Baz): self.Bar,self.Baz = _Bar,_Baz def __str__(self): return "Foo({},{})".format(self.Bar, self.Baz) + def __lt__(self, o): # sort by increasing Bar, breaking ties by decreasing Baz + if self.Bar != o.Bar: return self.Bar < o.Bar + if self.Baz != o.Baz: return self.Baz > o.Baz + return False a = [] for i in range(8): - a.append(Foo(random.randint(1, 9)*10, random.randint(1, 9))) + a.append(Foo(random.randint(1, 9), random.randint(1, 9))) print(*a) - -print(*sorted(a, key=lambda foo: foo.Bar+foo.Baz)) -def key(foo): - return foo.Bar + foo.Baz -print(*sorted(a, key=key)) +print(*sorted(a)) ``` Output: ``` -Foo(10,2) Foo(30,2) Foo(60,6) Foo(90,7) Foo(80,7) Foo(80,9) Foo(60,9) Foo(90,8) -Foo(10,2) Foo(30,2) Foo(60,6) Foo(60,9) Foo(80,7) Foo(80,9) Foo(90,7) Foo(90,8) -Foo(10,2) Foo(30,2) Foo(60,6) Foo(60,9) Foo(80,7) Foo(80,9) Foo(90,7) Foo(90,8) +Foo(1,2) Foo(3,2) Foo(6,6) Foo(9,7) Foo(8,7) Foo(8,9) Foo(6,9) Foo(9,8) +Foo(1,2) Foo(3,2) Foo(6,9) Foo(6,6) Foo(8,9) Foo(8,7) Foo(9,8) Foo(9,7) ``` -### Function / Lambda - - - This method defines how to compare two elements represented by an integer - - Positive: First term is greater than the second term - - Zero: First term and second term are equal - - Negative: First term is less than the second term - -Note how the comparator must be converted to a `key`. - - +A custom comparator works as well + - Lambdas aren't shown here because they are typically used as one-liners ```py import random from functools import cmp_to_key + class Foo: - def __init__(self, _Bar): self.Bar = _Bar - def __str__(self): return "Foo({})".format(self.Bar) + def __init__(self, _Bar, _Baz): self.Bar,self.Baz = _Bar,_Baz + def __str__(self): return "Foo({},{})".format(self.Bar, self.Baz) a = [] for i in range(8): - a.append(Foo(random.randint(0, 9))) + a.append(Foo(random.randint(1, 9), random.randint(1, 9))) print(*a) -print(*sorted(a, key=cmp_to_key(lambda foo1, foo2: foo1.Bar - foo2.Bar))) def cmp(foo1, foo2): - return foo1.Bar - foo2.Bar + if foo1.Bar != foo2.Bar: return -1 if foo1.Bar < foo2.Bar else 1 + if foo1.Baz != foo2.Baz: return -1 if foo1.Baz > foo2.Baz else 1 + return 0 print(*sorted(a, key=cmp_to_key(cmp))) ``` - Output: - ``` -Foo(0) Foo(1) Foo(2) Foo(1) Foo(9) Foo(5) Foo(5) Foo(8) -Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) -Foo(0) Foo(1) Foo(1) Foo(2) Foo(5) Foo(5) Foo(8) Foo(9) +Foo(1,2) Foo(3,2) Foo(6,6) Foo(9,7) Foo(8,7) Foo(8,9) Foo(6,9) Foo(9,8) +Foo(1,2) Foo(3,2) Foo(6,9) Foo(6,6) Foo(8,9) Foo(8,7) Foo(9,8) Foo(9,7) ``` ## Problems -- 2.46.0 From 0ce2f6bcb7fb8d540df1eb4251f3cbbb8138b533 Mon Sep 17 00:00:00 2001 From: Siyong Date: Tue, 16 Jun 2020 19:49:41 -0700 Subject: [PATCH 87/97] Update Sorting_Custom.md --- content/4_Silver/Sorting_Custom.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/content/4_Silver/Sorting_Custom.md b/content/4_Silver/Sorting_Custom.md index 0655b88..0f7bcc4 100644 --- a/content/4_Silver/Sorting_Custom.md +++ b/content/4_Silver/Sorting_Custom.md @@ -311,16 +311,22 @@ for i in range(8): a.append(Foo(random.randint(1, 9), random.randint(1, 9))) print(*a) -def cmp(foo1, foo2): +def cmp(foo1, foo2): # Increasing Bar, breaking ties with decreasing Baz if foo1.Bar != foo2.Bar: return -1 if foo1.Bar < foo2.Bar else 1 if foo1.Baz != foo2.Baz: return -1 if foo1.Baz > foo2.Baz else 1 return 0 print(*sorted(a, key=cmp_to_key(cmp))) + +# Python automatically sorts tuples in increasing order with priority to the leftmost element +# You can sort objects by its mapping to a tuple of its elements +# The following sorts Foo by increasing Bar values, breaking ties with increasing Baz value +print(*sorted(a, key=lambda foo: (foo.Bar, foo.Baz))) ``` Output: ``` Foo(1,2) Foo(3,2) Foo(6,6) Foo(9,7) Foo(8,7) Foo(8,9) Foo(6,9) Foo(9,8) Foo(1,2) Foo(3,2) Foo(6,9) Foo(6,6) Foo(8,9) Foo(8,7) Foo(9,8) Foo(9,7) +Foo(1,2) Foo(3,2) Foo(6,6) Foo(6,9) Foo(8,7) Foo(8,9) Foo(9,7) Foo(9,8) ``` ## Problems -- 2.46.0 From 470d49cb6146c5d5445aea9853acd955733a0bbd Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Tue, 16 Jun 2020 20:25:28 -0700 Subject: [PATCH 88/97] remove about this guide --- content/1_Intro/About_This.md | 2 ++ content/ordering.js | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/content/1_Intro/About_This.md b/content/1_Intro/About_This.md index c7c9f38..c2d60e3 100644 --- a/content/1_Intro/About_This.md +++ b/content/1_Intro/About_This.md @@ -4,6 +4,8 @@ title: About This Guide author: Nathan Wang, Benjamin Qi --- +// todo transfer all of this to the homepage + - Goals - Module Organization - Contact Information diff --git a/content/ordering.js b/content/ordering.js index a8f1dfd..e154976 100644 --- a/content/ordering.js +++ b/content/ordering.js @@ -1,7 +1,6 @@ const ModuleOrdering = { "intro": [ "getting-started", - "about-this", "prereqs", "running-cpp", "data-types", -- 2.46.0 From 124d11134b877c9e140938015571dc7e4d80ae24 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Tue, 16 Jun 2020 20:27:48 -0700 Subject: [PATCH 89/97] add missing semicolon --- content/ordering.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/ordering.js b/content/ordering.js index 9212b12..12c8ebe 100644 --- a/content/ordering.js +++ b/content/ordering.js @@ -45,7 +45,7 @@ const ModuleOrdering = { "binary-search", "2P", "data-structures", - "containers-silver" + "containers-silver", "greedy", "prefix-sums", { -- 2.46.0 From 5a1dcccae6e950478144967ab7a27e756e4a0023 Mon Sep 17 00:00:00 2001 From: summitwei Date: Wed, 17 Jun 2020 14:05:00 -0400 Subject: [PATCH 90/97] added some problems --- content/6_Plat/Trees.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/content/6_Plat/Trees.md b/content/6_Plat/Trees.md index 97a67fc..1f63681 100644 --- a/content/6_Plat/Trees.md +++ b/content/6_Plat/Trees.md @@ -64,6 +64,7 @@ Other: ### Problems + - [Ciel the Commander](https://codeforces.com/problemset/problem/321/C) - [USACO Plat - At Large](http://www.usaco.org/index.php?page=viewproblem2&cpid=793) - very tricky - [DMOJ Bob Equilibrium](https://dmoj.ca/problem/dmopc19c7p6) @@ -83,5 +84,6 @@ Other: ?? ## Small to Large (Offline) - -?? \ No newline at end of file +Sample codes: [DSU on Tree code](https://codeforces.com/blog/entry/44351), [explanation of code](https://codeforces.com/blog/entry/67696) + - USACO Disrupt again! + - [Lomsat gelral](https://codeforces.com/contest/600/problem/E) -- 2.46.0 From bb202d94a6a3d3b10f426c641aa0d39c89843c3e Mon Sep 17 00:00:00 2001 From: Benjamin Qi Date: Wed, 17 Jun 2020 14:05:19 -0400 Subject: [PATCH 91/97] modify intro / general --- content/1_Intro/Getting_Started.md | 14 +-- content/1_Intro/Practicing.md | 6 +- content/1_Intro/Prerequisites.md | 13 ++- content/1_Intro/Running_Cpp.md | 74 ++++++------ content/2_General/Contest_Strategy.md | 22 +++- content/2_General/Contests.md | 159 +++++++++++++------------- content/2_General/Debugging.md | 8 +- content/2_General/Macros.md | 2 +- content/2_General/Proposing.md | 5 +- content/3_Bronze/Rect_Geo.md | 33 +++--- content/6_Plat/1DRQ.md | 2 +- 11 files changed, 183 insertions(+), 155 deletions(-) diff --git a/content/1_Intro/Getting_Started.md b/content/1_Intro/Getting_Started.md index d81d247..ca7145d 100644 --- a/content/1_Intro/Getting_Started.md +++ b/content/1_Intro/Getting_Started.md @@ -12,14 +12,14 @@ author: Nathan Wang, Benjamin Qi, Darren Yao ## Introduction -The goal of **competitive programming** is to write code to solve given problems "quickly." These problems are not open problems; they are problems that are designed to be solved in the short timeframe of a contest, and have already been solved by the problem writer(s) and tester(s). In general, each problem in competitive programming is solved by a two-step process: +A **programming competition** generally lasts for several hours and consists of a set of problems. These problems are not open problems; they have already been solved by the problem writer(s) and tester(s) and (hopefully) are designed to be solved in the short timeframe of a contest. In general, each problem in competitive programming is solved by a two-step process: 1. coming up with the algorithm, which involves problem solving skills and intuition 2. implementing the algorithm, which requires programming skills to translate the algorithm into working code. -A contest generally lasts for several hours and consists of a set of problems. For each problem, when you complete your code, you submit it to a grader, which checks the answers calculated by the your program against a set of predetermined test cases. For each problem, you are given a time limit (usually 2 seconds) and a memory limit (usually 256 megabytes) that your program must satisfy. +For each problem, when you complete your code you submit it to a grader, which checks the answers calculated by the your program against a set of predetermined test cases. For each problem, you are given a time limit (usually 2 seconds) and a memory limit (usually 256 megabytes) that your program must satisfy. -For those of you with experience in software development, note that competitive programming is quite different, as the goal is to write programs that compute the correct answer, run quickly, and can be implemented quickly. Note that nowhere was maintainability of code mentioned. This means that you should throw away everything you know about traditional code writing; you don't need to bother documenting your code, because it only needs to be readable to you, during the contest. +For those of you with experience in software development, note that competitive programming is quite different, as the goal is to write programs that compute the correct answer, run quickly, and can be implemented quickly. Note that nowhere was maintainability of code mentioned. So you don't need to bother documenting your code because it only needs to be readable to you during the contest. ### Videos @@ -29,11 +29,11 @@ For those of you with experience in software development, note that competitive ## Contest Format -The [USA Computing Olympiad](http://www.usaco.org/index.php?page=contests) is a national programming competition that occurs four times a year, with December, January, February, and US Open (March) contests. The regular contests are four hours long, and the US Open is five hours long. Each contest contains three problems. Solutions are evaluated and scored against a set of predetermined test cases that are not visible to the student. Scoring is out of 1000 points, with each problem being weighted equally. There are four divisions of contests: Bronze, Silver, Gold, and Platinum. After each contest, students who meet the contest-dependent cutoff for promotion will compete in the next division for future contests. +The [USA Computing Olympiad](http://www.usaco.org/index.php?page=contests) is a national programming competition that occurs four times a year, with December, January, February, and US Open (March) contests. The regular contests are four hours long, and the US Open is five hours long. Each contest contains three problems. Solutions are evaluated and scored against a set of predetermined test cases that are not visible to the student. Scoring is out of 1000 points, with each problem being weighted equally (\~333 points). There are four divisions of contests: Bronze, Silver, Gold, and Platinum. After each contest, students who meet the contest-dependent cutoff for promotion will compete in the next division for future contests. ## Choosing a Language -If you're in Bronze, **don't worry about the language!** If you already know a language, just use it. You can always switch languages down the road. +If you're in Bronze, **don't worry about the language!** If you already know a language, just use it. In general, we recommend the following: @@ -42,9 +42,7 @@ In general, we recommend the following: - For Silver, Gold, and Platinum, we recommend C++/Java. - If you know multiple languages, we recommend you pick C++ over Java. -Note: A majority of high level contestants use C++ and Java. Between those, C++ is more popular. - -Keep in mind that it's easy to switch languages down the road! Don't get caught up on which language to choose. Just pick the one you feel most comfortable with! +A majority of high level contestants use C++ and Java. Between those, C++ is more popular. Keep in mind that it's easy to switch languages down the road! Don't get caught up on which language to choose. Just pick the one you feel most comfortable with! ### Language References diff --git a/content/1_Intro/Practicing.md b/content/1_Intro/Practicing.md index f9ae029..c0eb61d 100644 --- a/content/1_Intro/Practicing.md +++ b/content/1_Intro/Practicing.md @@ -95,4 +95,8 @@ I follow three guidelines (from most important to least important) ## Eric Wei -I think the most important thing regarding practicing is to try to get something out of every problem, whether it's a new algorithm or idea, an implementation trick that can help in the future, or just a bug you hopefully won't mess up in the future. That being said, editorials are more useful once you've been stuck for a while; I think the exploration that happens from being a little stuck is often instructive (and good practice for contests, when it's your only option). But at some point the problem's more frustrating than helpful, and sometime before this is probably the right time to take a hint or read the editorial. \ No newline at end of file +I think the most important thing regarding practicing is to try to get something out of every problem, whether it's a new algorithm or idea, an implementation trick that can help in the future, or just a bug you hopefully won't mess up in the future. That being said, editorials are more useful once you've been stuck for a while; I think the exploration that happens from being a little stuck is often instructive (and good practice for contests, when it's your only option). But at some point the problem's more frustrating than helpful, and sometime before this is probably the right time to take a hint or read the editorial. + +## Additional + + - [E869120 - A Way to Practice CP](http://codeforces.com/blog/entry/53341) \ No newline at end of file diff --git a/content/1_Intro/Prerequisites.md b/content/1_Intro/Prerequisites.md index 5b476ce..7dc69b1 100644 --- a/content/1_Intro/Prerequisites.md +++ b/content/1_Intro/Prerequisites.md @@ -1,7 +1,7 @@ --- id: prereqs title: Prerequisites -author: Nathan Wang +author: Nathan Wang, Benjamin Qi --- Here's what you should learn before reading these resources. @@ -37,9 +37,12 @@ Familiarity with [competition math](https://github.com/bqi343/USACO/blob/master/ ### Resources for Getting Started +Note: We don't agree with all views expressed in the links below. Feel free to let us know what works (or doesn't) for you. + - [CodeSignal](https://codesignal.com/) - - good place to practice basics - - [IOI: Getting Started](https://ioinformatics.org/page/getting-started/14) + - can practice basics with "Arcade," "Interview Practice" - [Philippines OI: Prepare](https://noi.ph/prepare/) - - [Schedule for Beginners](https://www.quora.com/What-is-a-good-schedule-to-follow-for-becoming-better-at-competitive-programming-for-beginners) - - [E869120 Tutorial](http://codeforces.com/blog/entry/53341) \ No newline at end of file + - lots of links! + - [IOI - Getting Started](https://ioinformatics.org/page/getting-started/14) + - not so up to date + - [Quora - Schedule for Beginners (Joshua Pan)](https://www.quora.com/What-is-a-good-schedule-to-follow-for-becoming-better-at-competitive-programming-for-beginners) \ No newline at end of file diff --git a/content/1_Intro/Running_Cpp.md b/content/1_Intro/Running_Cpp.md index 7dfbca0..d5249f6 100644 --- a/content/1_Intro/Running_Cpp.md +++ b/content/1_Intro/Running_Cpp.md @@ -10,29 +10,29 @@ Running C++ both online and locally. # Running C++ Online - * [OnlineGDB](https://www.onlinegdb.com/) - * online compiler with an embedded GDB debugger - * can be buggy sometimes - * supports files and file I/O - * [CSAcademy](https://csacademy.com/workspace/) - * pretty nice (unless you get "Estimated Queue Time: ...") - * "saved locally" will not save your code if you close the tab, press Command-S to save. - * [Ideone](http://ideone.com/) - * okay ... with an ad blocker - * make sure your code is not public - * sometimes erases your code when you first create it (so get in the habit of copying your code first) + - [OnlineGDB](https://www.onlinegdb.com/) + - online compiler with an embedded GDB debugger + - can be buggy sometimes + - supports files and file I/O + - [CSAcademy](https://csacademy.com/workspace/) + - pretty nice (unless you get "Estimated Queue Time: ...") + - "saved locally" will not save your code if you close the tab, press Command-S to save. + - [Ideone](http://ideone.com/) + - okay ... with an ad blocker + - make sure your code is not public + - sometimes erases your code when you first create it (so get in the habit of copying your code first) -Of course, you can't use file I/O on the latter two websites and they are often quite limited. +Of course, you can't use file I/O on the latter two websites. # Running C++ Locally ## On Mac -[Clang](https://en.wikipedia.org/wiki/Clang) is the default compiler for Mac OS X, but you should use GCC's [g++](https://en.wikipedia.org/wiki/GNU_Compiler_Collection). +[Clang](https://en.wikipedia.org/wiki/Clang) is the default compiler for Mac OS X, but you should use [GCC](https://en.wikipedia.org/wiki/GNU_Compiler_Collection)'s g++. ### Installation -Open **Terminal**. First, familiarize yourself with some basic commands given [here](https://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line). You will also need to install [Homebrew](https://brew.sh/). +First, Open **Terminal**. Familiarize yourself with some basic commands given [here](https://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line). You will also need to install [Homebrew](https://brew.sh/). Run @@ -181,28 +181,32 @@ Note that all occurrences of `$1` are replaced with `name`. ## IDEs - * [Geany](https://www.geany.org/) - * [Visual Studio Code](https://code.visualstudio.com/) - * lightweight, fast IDE, but requires some configuration - * [Visual Studio](https://visualstudio.microsoft.com/vs/) - * heavier cousin of Visual Studio Code - * [XCode](https://developer.apple.com/xcode/) - * Mac only - * [Codeblocks](http://www.codeblocks.org/) - * bad on Mac - * [CLion](https://www.jetbrains.com/clion/) - * requires a license, but [free for students](https://www.jetbrains.com/community/education/#students) + - [Geany](https://www.geany.org/) + - [Visual Studio Code](https://code.visualstudio.com/) + - lightweight, fast IDE, but requires some configuration + - [Visual Studio](https://visualstudio.microsoft.com/vs/) + - heavier cousin of Visual Studio Code + - [XCode](https://developer.apple.com/xcode/) + - Mac only + - [Codeblocks](http://www.codeblocks.org/) + - bad on Mac + - [CLion](https://www.jetbrains.com/clion/) + - requires a license, but [free for students](https://www.jetbrains.com/community/education/#students) ## Text Editors -Again, many options. - * [Sublime Text 3](https://www.sublimetext.com/) - a fast, lightweight text editor for Windows, Mac, and Linux - * [Editing Build Settings](https://stackoverflow.com/questions/23789410/how-to-edit-sublime-text-build-settings) - * [FastOlympicCoding Addon](https://github.com/Jatana/FastOlympicCoding) - * [Sublime Snippets](https://www.granneman.com/webdev/editors/sublime-text/top-features-of-sublime-text/quickly-insert-text-and-code-with-sublime-text-snippets) - * [Symlink](https://www.sublimetext.com/docs/3/osx_command_line.html) - * Using `/usr/local/bin/subl` instead of `~/bin/subl` worked for me on OS X Mojave. - * [Atom](https://atom.io/) - another text editor for Windows, Mac, and Linux, from the makers of Github - * [Vim](https://www.vim.org/) - the classic text editor, usually preinstalled on Mac and Linux, and also available for Windows - * Others? + + - [Sublime Text 3](https://www.sublimetext.com/) + - a fast, lightweight text editor for Windows, Mac, and Linux + - [Editing Build Settings](https://stackoverflow.com/questions/23789410/how-to-edit-sublime-text-build-settings) + - [FastOlympicCoding Addon](https://github.com/Jatana/FastOlympicCoding) + - [Sublime Snippets](https://www.granneman.com/webdev/editors/sublime-text/top-features-of-sublime-text/quickly-insert-text-and-code-with-sublime-text-snippets) + - [Symlink](https://www.sublimetext.com/docs/3/osx_command_line.html) + - Using `/usr/local/bin/subl` instead of `~/bin/subl` worked for me on OS X Mojave. + - [Atom](https://atom.io/) + - another text editor for Windows, Mac, and Linux, from the makers of Github + - [Vim](https://www.vim.org/) + - the classic text editor, usually preinstalled on Mac and Linux, and also available for Windows + - probably easiest way to print syntax-highlighted code on Mac, see [here](https://stackoverflow.com/questions/1656914/printing-code-with-syntax-highlighting) + - Others? diff --git a/content/2_General/Contest_Strategy.md b/content/2_General/Contest_Strategy.md index 584ba7b..6258978 100644 --- a/content/2_General/Contest_Strategy.md +++ b/content/2_General/Contest_Strategy.md @@ -4,7 +4,11 @@ title: Contest Strategy author: Nathan Chen --- -The best contest strategy is to go in knowing everything. However, only few people can do this (see [BenQ](https://codeforces.com/profile/benq) or [TMW](https://codeforces.com/profile/tmwilliamlin168)) (I kid). Once the timer starts, there's no more studying you can do, and managing your time wisely is the best thing you can do to maximize your score. +The best contest strategy is to go in knowing everything. However, only few people can do this, see [BenQ](https://codeforces.com/profile/benq) or [TMW](https://codeforces.com/profile/tmwilliamlin168). (I kid). + + + +Once the timer starts, there's no more studying you can do, and managing your time wisely is the best thing you can do to maximize your score. ## Strategy @@ -12,28 +16,36 @@ Below are some general ideas on how to strategize during a contest. Strategy is flexible and all advice should be taken with a grain of salt. Strategy should be personal to *you* specifically. ### The beginning of a contest + You should read *all* the problems first (don't give up on any problems prematurely). Generally, a lot of thinking should happen before any coding. Depending on the difficulty of a contest, you can spend anywhere from 5 minutes to 2 hours with a pencil and paper before touching the keyboard. -Sometimes, problem difficulties can be out of order, so keep that in mind before focusing down 3 hours on problem 1 and not getting anywhere. Do a good amount of thinking on each problem before deciding which ones to focus on and which to put aside. +Problem difficulties can be out of order, so keep that in mind before focusing down 3 hours on problem 1 and not getting anywhere. Do a good amount of thinking on each problem before deciding which ones to focus on and which to put aside. ### Time allocation + It's the worst feeling in the world to sink 4 hours into a problem and not get it, only for another problem to have an easier solution. You have to use your own judgement in deciding what is likely solvable and what should be quit. Generally, don't spend "too long" on one problem, and stay away from problems that look like they test something you don't know well. ### When you see a solution + If you immediately get the solution to a problem while reading it, it might be a good idea to code it up quickly and get it out of the way. It also might be a good idea to make some progress on other problems before coding the one you know how to do. When you come back and start coding, you can make sure your solution still makes sense and then you have ideas from the other problems bouncing around in your head while you're coding. ### When there are partials + If you can get points from partially solving a problem (e.g. in USACO), then it's a good idea to keep those subtasks in mind. There are two main approaches to partially solving problems. + - Use most of your time to think about the full problem, then code the partials if you haven't found the solution and your time will soon run out. - If you find the full solution, be certain your solution is correct, lest you waste an hour coding something completely wrong. - - Judge the difficulty of the partials carefully! It could take anywhere from 30 seconds 30 minutes to code a partial, or maybe a partial wasn't as trivial as you thought! + - Judge the difficulty of the partials carefully! It could take anywhere from 30 seconds to 30 minutes to code a partial, or maybe a partial wasn't as trivial as you thought! - Work up from the partials, coding the easiest and then going to the hardest. The partial subtasks may help you think of the full solution, and will also help you stay on track. ## Personal Commentaries + ### Nathan Chen + At the Platinum level, I first read everything and then I usually spend the first hour thinking about the easiest two problems (the hardest problem is usually VERY hard). I continue thinking for the rest of the contest window and I code them if I think I have the solution. I'm also the type to save partials for last, when time is running out and I still have nothing. -### Anther Person -Somethign something +### Benjamin Qi + +Do the partials you can; hopefully by then you've figured out the full solution. :D \ No newline at end of file diff --git a/content/2_General/Contests.md b/content/2_General/Contests.md index 0d676c6..4df0d74 100644 --- a/content/2_General/Contests.md +++ b/content/2_General/Contests.md @@ -4,102 +4,103 @@ title: Contests author: Benjamin Qi --- -Contests that I participate in, as well as a few tools. +Contests that I participate in as well as a few tools. -See [clist.by](https://clist.by/coder/bqi343/) for an extensive list. Most of the contests which I do are a subset of those shown in "Programming Contests.png". A link to my google calendar for contests is available [here.](https://calendar.google.com/calendar?cid=Y2s5ZjdmZDBkNjdmOGFxZ2oxbDVrMHJ1OGtAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ) See the other page for olympiads such as USACO. +See [clist.by](https://clist.by/coder/bqi343/) for an extensive list of contests. -Make sure to [upsolve](https://en.wiktionary.org/wiki/upsolve) after the contest ends! I particularly enjoy problems from AtCoder and CSAcademy. :) +Make sure to [upsolve](https://en.wiktionary.org/wiki/upsolve) after the contest ends! - * [AtCoder](https://beta.atcoder.jp/contests/archive) - * Contests - * Beginner / Regular: 4 problems, 100 min - * Grand: 6 problems, ~110 min - * [Visualizer](https://kenkoooo.com/atcoder/#/table/Benq) - * I've done nearly all of the AGC problems. - * [Codeforces](http://codeforces.com/problemset) - * Contests - * Div 2, Div 1: 5 problems, 2 hrs - * Archive - * problem quality, difficulty ratings are ok but not always great - * [Topcoder](https://www.topcoder.com/my-dashboard/) - * Div 2, Div 1 - * 75 min coding, 15 min challenge - * Solutions only tested after contest! - * [Don Mills OJ](http://dmoj.ca/) - * at least one contest every month during school year - * [Google Kickstart](https://codingcompetitions.withgoogle.com/kickstart) - * Feb - Nov - * [Kattis](https://open.kattis.com/) - * random ICPC stuff - * [HackerEarth](http://hackerearth.com/) - * Monthly "Easy" - * quality is not always good - * [Codechef](http://codechef.com/) - * Lunchtime, Cookoff - * quality is not always good + - [AtCoder](https://beta.atcoder.jp/contests/archive) + - probably the highest quality, although difficulty isn't always reasonable + - Contests + - Beginner / Regular: 4 problems, 100 min + - Grand: 6 problems, ~110 min + - [Visualizer](https://kenkoooo.com/atcoder/#/table/Benq) + - I've done nearly all of the AGC problems. + - [Codeforces](http://codeforces.com/problemset) + - Contests + - Div 2, Div 1: 5 problems, 2 hrs + - Archive + - problem quality, difficulty ratings are ok but not always great + - [Topcoder](https://www.topcoder.com/my-dashboard/) + - Div 2, Div 1 + - 75 min coding, 15 min challenge + - Solutions only tested after contest! + - [Don Mills OJ](http://dmoj.ca/) + - at least one contest every month during school year + - [Google Kickstart](https://codingcompetitions.withgoogle.com/kickstart) + - Feb - Nov + - [Kattis](https://open.kattis.com/) + - misc ICPC contests + - [HackerEarth](http://hackerearth.com/) + - Monthly "Easy" + - quality is not always good + - [Codechef](http://codechef.com/) + - Lunchtime, Cookoff + - quality is not always good The following websites do not hold regular contests anymore, but they're still worth looking at. - * [CS Academy](https://csacademy.com/contest/archive/) - * Contests - * Div 2: 5 problems, 2 hrs - * Open: 7 problems, 2 hrs - * no more? D: - * Archive - * short statements, editorials - * solve statistics - * ability to view best solutions - * I've done nearly all of the problems. :D - * [HackerRank](https://www.hackerrank.com/dashboard) + - [CS Academy](https://csacademy.com/contest/archive/) + - Contests + - Div 2: 5 problems, 2 hrs + - Open: 7 problems, 2 hrs + - no more? D: + - Archive + - short statements, editorials + - solve statistics + - ability to view best solutions + - I've done nearly all of the problems. :D + - [HackerRank](https://www.hackerrank.com/dashboard) ## Annual Contests - * [Google Code Jam](https://code.google.com/codejam/): Apr - * 25 from R3 - * [Facebook Hacker Cup](https://www.facebook.com/hackercup/): Jun-Jul -> Oct?? - * 25 from R3 - * [Topcoder Open](https://tco19.topcoder.com/): Apr-Aug -> Nov - * 4 from SRMs - * 10 from R4 - * 2 from Wildcard - * [AtCoder World Tour Finals](https://codeforces.com/blog/entry/56623) - * 8 from AGC - * [Bubble Cup](http://bubblecup.org/): Apr + - [Google Code Jam](https://code.google.com/codejam/): Apr + - 25 from R3 + - [Facebook Hacker Cup](https://www.facebook.com/hackercup/): Jun-Jul -> Oct?? + - 25 from R3 + - [Topcoder Open](https://tco19.topcoder.com/): Apr-Aug -> Nov + - 4 from SRMs + - 10 from R4 + - 2 from Wildcard + - [AtCoder World Tour Finals](https://codeforces.com/blog/entry/56623) + - 8 from AGC + - [Bubble Cup](http://bubblecup.org/): Apr ## US High School - * [VT HSPC](https://icpc.cs.vt.edu/#/hscontest2017) - * Online - * 5 hours - * [Kattis](https://open.kattis.com/problem-sources/2016%20Virginia%20Tech%20High%20School%20Programming%20Contest) - * December - * [UCF HSPT](https://hspt.ucfprogrammingteam.org/index.php/hspt-online-edition) - * Online - * 4 hours - * December - * [Cornell HSPC](https://www.cs.cornell.edu/events/cornell-high-school-programming-contest) - * [2019](https://cornell-hspc19.kattis.com/problems) - * [PClassic (Philadelphia)](https://pclassic.org/) - * Java only :(( - * [mBIT (Montgomery Blair HS)](https://mbit.mbhs.edu/) + - [VT HSPC](https://icpc.cs.vt.edu/#/hscontest2017) + - Online + - 5 hours + - [Kattis](https://open.kattis.com/problem-sources/2016%20Virginia%20Tech%20High%20School%20Programming%20Contest) + - December + - [UCF HSPT](https://hspt.ucfprogrammingteam.org/index.php/hspt-online-edition) + - Online + - 4 hours + - December + - [Cornell HSPC](https://www.cs.cornell.edu/events/cornell-high-school-programming-contest) + - [2019](https://cornell-hspc19.kattis.com/problems) + - [PClassic (Philadelphia)](https://pclassic.org/) + - Java only :(( + - [mBIT (Montgomery Blair HS)](https://mbit.mbhs.edu/) ## Codeforces Tools - * [Stopstalk](https://www.stopstalk.com) - * [Code Drills](http://code-drills.com/) - * [CF Visualizer](http://cfviz.netlify.com/compare.html) - * [CF Rating Predictor](https://chrome.google.com/webstore/detail/cf-predictor/ocfloejijfhhkkdmheodbaanephbnfhn) - * [CF Command Line](https://codeforces.com/blog/entry/66552) - * [CF Editor](https://codeforces.com/blog/entry/72952) - * [CF Enhancer](https://chrome.google.com/webstore/detail/codeforces-enhancer/ocmandagmgmkcplckgnfgaokpgkfenmp) - * no longer works + - [Stopstalk](https://www.stopstalk.com) + - [Code Drills](http://code-drills.com/) + - [CF Visualizer](http://cfviz.netlify.com/compare.html) + - [CF Rating Predictor](https://chrome.google.com/webstore/detail/cf-predictor/ocfloejijfhhkkdmheodbaanephbnfhn) + - [CF Command Line](https://codeforces.com/blog/entry/66552) + - [CF Editor](https://codeforces.com/blog/entry/72952) + - [CF Enhancer](https://chrome.google.com/webstore/detail/codeforces-enhancer/ocmandagmgmkcplckgnfgaokpgkfenmp) + - no longer works ## Contest Tools - * [2D Geo Visualizer](https://codeforces.com/blog/entry/70330) - * [CSAcademy Graph Editor (+ Geo Visualizer + Diff Tool)](https://csacademy.com/app/graph_editor/) - * [Desmos Grapher](https://www.desmos.com/calculator) - * [Wolfram Alpha](https://www.wolframalpha.com/) - * [OEIS](https://oeis.org/) + - [2D Geo Visualizer](https://codeforces.com/blog/entry/70330) + - [CSAcademy Graph Editor (+ Geo Visualizer + Diff Tool)](https://csacademy.com/app/graph_editor/) + - [Desmos Grapher](https://www.desmos.com/calculator) + - [Wolfram Alpha](https://www.wolframalpha.com/) + - [OEIS](https://oeis.org/) diff --git a/content/2_General/Debugging.md b/content/2_General/Debugging.md index 7674872..5b38421 100644 --- a/content/2_General/Debugging.md +++ b/content/2_General/Debugging.md @@ -10,7 +10,7 @@ Detecting issues within your program and figuring out how to avoid them in the f ## Style Guide -[Swift](https://codeforces.com/blog/entry/64218) +[Competitive C++ Manifesto: A Style Guide](https://codeforces.com/blog/entry/64218) ## Compilation @@ -27,6 +27,8 @@ See [here](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html). `-Wall -Wextra -Wshadow` +[Variable shadowing](https://en.wikipedia.org/wiki/Variable_shadowing) should be avoided whenever possible. + ### Stack Size According to [this comment](https://codeforces.com/blog/entry/60999?#comment-449312), `-Wl,-stack_size -Wl,0xF0000000` increases the stack size on Mac (otherwise, you might get a runtime error). @@ -75,11 +77,9 @@ In essense, a debugger is a tool to "trace code" for you. It is not much differe Pros of using a debugger: - No need to write print statements so you save time - - You can step through the code in real time Cons of using a debugger: - - You cannot see the overall "output" of your program at each stage. For example, if I wanted to see the every single value of `i` in the program, I could not using a debugger. - + - You cannot see the overall "output" of your program at each stage. For example, if I wanted to see every single value of `i` in the program, I could not using a debugger. - Most advanced competitive programmers do not use debuggers; it is quite time inefficient. diff --git a/content/2_General/Macros.md b/content/2_General/Macros.md index 6d71dc4..dfe28f4 100644 --- a/content/2_General/Macros.md +++ b/content/2_General/Macros.md @@ -74,7 +74,7 @@ Most USACO problems satisfy $N\le 2\cdot 10^5$. mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); ``` -See [neal's blog](https://codeforces.com/blog/entry/61587) about why `rand()` is bad. Uuse `rng()` instead. +See [neal's blog](https://codeforces.com/blog/entry/61587) about why `rand()` is bad. Use `rng()` instead. ### ckmin diff --git a/content/2_General/Proposing.md b/content/2_General/Proposing.md index 1f97b56..c63f07d 100644 --- a/content/2_General/Proposing.md +++ b/content/2_General/Proposing.md @@ -10,9 +10,8 @@ Anyone can propose problems for monthly contests. Email your proposal to Professor Dean. In the [past](http://www.usaco.org/index.php?page=viewproblem2&cpid=817), contestants have even written problems for their own divisions! -All problems should have 10 test cases at minimum (I believe that the maximum was 21 for [valleys](http://www.usaco.org/index.php?page=viewproblem2&cpid=950)). - -All statements must eventually be converted to the following format; please save us time by following it as best you can. + - All problems should have 10 test cases at minimum (I believe that the maximum was 21 for [valleys](http://www.usaco.org/index.php?page=viewproblem2&cpid=950)). You do not need to include these in your proposal. + - All statements must eventually be converted to the following format. It's not required, but please save us time by following it as best you can.
diff --git a/content/3_Bronze/Rect_Geo.md b/content/3_Bronze/Rect_Geo.md index af67149..fe8eff2 100644 --- a/content/3_Bronze/Rect_Geo.md +++ b/content/3_Bronze/Rect_Geo.md @@ -12,7 +12,8 @@ author: Darren Yao, Michael Cao - Also, the coordinates typically only go up to $1000$, so a program that performs $\approx 1000^2$ operations (ex. with a nested loop) should pass. ## Rectangle Class (Java) -A useful class in `Java` for dealing with rectangle geometry problems is the built-in `Rectangle` class. To create a new rectangle, use the following constructor: + +A useful class in `Java` for dealing with rectangle geometry problems is the built-in [`Rectangle`](https://docs.oracle.com/javase/8/docs/api/java/awt/Rectangle.html) class. To create a new rectangle, use the following constructor: ```java //creates a rectangle with upper-left corner at (x,y) with a specified width and height @@ -21,22 +22,21 @@ Rectangle newRect = new Rectangle(x, y, width, height); The `Rectangle` class supports numerous useful methods. -``` -firstRect.intersects(secondRect) checks if two rectangles intersect. + - `firstRect.intersects(secondRect)`: checks if two rectangles intersect. + - `firstRect.union(secondRect)`: returns a rectangle representing the union of two rectangles. + - `firstRect.contains(x, y)`: checks whether the integer point (x,y) exists in firstRect. + - `firstRect.intersect(secondRect)`: returns a rectangle representing the intersection of two rectangles. -firstRect.union(secondRect) returns a rectangle representing the union of two rectangles. +This class can often lessen the implementation needed in a lot of bronze problems and CodeForces problems. -firstRect.contains(x, y) checks whether the integer point (x,y) exists in firstRect. +For example, here is a nice implementation of the problem [Blocked Billboard](http://usaco.org/index.php?page=viewproblem2&cpid=759) ([editorial](http://www.usaco.org/current/data/sol_billboard_bronze_dec17.html)). -firstRect.intersect(secondRect) returns a rectangle representing the intersection of two rectangles. -``` +
-This class can often lessen the implementation needed in a lot of bronze problems and codeforces problems. - -For example, here is a nice implementation of the problem Blocked Billboard (see below). See the editorial [here](http://www.usaco.org/current/data/sol_billboard_bronze_dec17.html) for more information on the solution. +Java Solution ```java -import java.awt.Rectangle; //needed to use Rectangle class +import java.awt.Rectangle; //need to use Rectangle class public class BlockedBillboard{ public static void main(String[] args) throws IOException{ @@ -49,18 +49,23 @@ public class BlockedBillboard{ - getArea(firstRect.intersect(truck)) - getArea(secondRect.intersect(truck))); pw.close(); } - public static long getArea(Rectangle r){ return r.getHeight() * r.getWidth() } } ``` +
+ (someone test code pls) ## Rectangle Class (C++) Unfortunately, C++ doesn't have a built in rectangle class, so you need to write the functions yourself. Here is the solution to Blocked Billboard written in C++ (thanks, Brian Dean!). +
+ +C++ Solution + ```cpp struct Rect{ int x1, y1, x2, y2; @@ -88,8 +93,10 @@ int main(){ cout << area(a) + area(b) - intersect(a, t) - intersect(b, t); } ``` +
## Problems + - USACO Bronze - [Fence Painting](http://usaco.org/index.php?page=viewproblem2&cpid=567) - 1D geometry!! @@ -100,5 +107,5 @@ int main(){ - Also rectangles - Other - [CF 587 (Div. 3) C: White Sheet](https://codeforces.com/contest/1216/problem/C) - - See this code (TODO; codeforces is down) for a nice implementation using the Java Rectangle class. + - See this code (TODO; codeforces is down) for a nice implementation using the Java Rectangle class. diff --git a/content/6_Plat/1DRQ.md b/content/6_Plat/1DRQ.md index 48f05a0..aa32f8d 100644 --- a/content/6_Plat/1DRQ.md +++ b/content/6_Plat/1DRQ.md @@ -13,7 +13,7 @@ General range queries for associative operations, including segment tree. ## Static Range Queries -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]$ in $O(1)$ time each with $O(N\log N)$ time preprocessing, where $\ominus$ denotes any associative operation. In the case when $\ominus$ denotes `min`, preprocessing can be done in $O(1)$ time. +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]$ in $O(1)$ time each with $O(N\log N)$ time preprocessing, where $\ominus$ denotes any associative operation. In the case when $\ominus$ denotes `min`, preprocessing can be done in $O(N)$ time. ### Tutorial -- 2.46.0 From 0693a604f0dcaf2d541464214af80c0ddd5e2b3b Mon Sep 17 00:00:00 2001 From: caoash Date: Wed, 17 Jun 2020 13:42:42 -0500 Subject: [PATCH 92/97] tested/changed code, all works now --- content/3_Bronze/Rect_Geo.md | 54 +++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/content/3_Bronze/Rect_Geo.md b/content/3_Bronze/Rect_Geo.md index af67149..29e48ed 100644 --- a/content/3_Bronze/Rect_Geo.md +++ b/content/3_Bronze/Rect_Geo.md @@ -21,15 +21,13 @@ Rectangle newRect = new Rectangle(x, y, width, height); The `Rectangle` class supports numerous useful methods. -``` -firstRect.intersects(secondRect) checks if two rectangles intersect. +`firstRect.intersects(secondRect)` checks if two rectangles intersect. -firstRect.union(secondRect) returns a rectangle representing the union of two rectangles. +`firstRect.union(secondRect)` returns a rectangle representing the union of two rectangles. -firstRect.contains(x, y) checks whether the integer point (x,y) exists in firstRect. +`firstRect.contains(x, y)` checks whether the integer point (x,y) exists in firstRect. -firstRect.intersect(secondRect) returns a rectangle representing the intersection of two rectangles. -``` +`firstRect.intersection(secondRect)` returns a rectangle representing the intersection of two rectangles. This class can often lessen the implementation needed in a lot of bronze problems and codeforces problems. @@ -37,38 +35,61 @@ For example, here is a nice implementation of the problem Blocked Billboard (see ```java import java.awt.Rectangle; //needed to use Rectangle class +import java.io.*; +import java.util.*; -public class BlockedBillboard{ +public class blockedBillboard{ public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(new File("billboard.in")); PrintWriter pw = new PrintWriter(new FileWriter("billboard.out")); - Rectangle firstRect = new Rectangle(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()); - Rectangle secondRect = new Rectangle(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()); - Rectangle truck = new Rectangle(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()); + int x1, y1, x2, y2; + + //the top left point is (0,0), so you need to do -y2 + + x1 = sc.nextInt(); y1 = sc.nextInt(); x2 = sc.nextInt(); y2 = sc.nextInt(); + Rectangle firstRect = new Rectangle(x1, -y2, x2-x1, y2-y1); + + x1 = sc.nextInt(); y1 = sc.nextInt(); x2 = sc.nextInt(); y2 = sc.nextInt(); + Rectangle secondRect = new Rectangle(x1, -y2, x2-x1, y2-y1); + + x1 = sc.nextInt(); y1 = sc.nextInt(); x2 = sc.nextInt(); y2 = sc.nextInt(); + Rectangle truck = new Rectangle(x1, -y2, x2-x1, y2-y1); + + long firstIntersect = getArea(firstRect.intersection(truck)); + long secondIntersect = getArea(secondRect.intersection(truck)); + pw.println(getArea(firstRect) + getArea(secondRect) - - getArea(firstRect.intersect(truck)) - getArea(secondRect.intersect(truck))); + - firstIntersect - secondIntersect); pw.close(); } public static long getArea(Rectangle r){ - return r.getHeight() * r.getWidth() + if(r.getWidth() <= 0 || r.getHeight() <= 0){ + return 0; + } + return (long)r.getHeight() * (long)r.getWidth(); } } + ``` -(someone test code pls) ## Rectangle Class (C++) Unfortunately, C++ doesn't have a built in rectangle class, so you need to write the functions yourself. Here is the solution to Blocked Billboard written in C++ (thanks, Brian Dean!). ```cpp +#include +#include +using namespace std; + struct Rect{ int x1, y1, x2, y2; - int area(Rect r){ - return (y2 - y1) * (x2 - x1); - } }; +int area(Rect r){ + return (r.y2 - r.y1) * (r.x2 - r.x1); +} + int intersect(Rect p, Rect q){ int xOverlap = max(0, min(p.x2, q.x2) - max(p.x1, q.x1)); int yOverlap = max(0, min(p.y2, q.y2) - max(p.y1, q.y1)); @@ -87,6 +108,7 @@ int main(){ cout << area(a) + area(b) - intersect(a, t) - intersect(b, t); } + ``` ## Problems -- 2.46.0 From 75742f0a692b0dfe01149b5ef1439c1458f3e128 Mon Sep 17 00:00:00 2001 From: caoash Date: Wed, 17 Jun 2020 13:47:10 -0500 Subject: [PATCH 93/97] minor fix --- content/5_Gold/DS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/5_Gold/DS.md b/content/5_Gold/DS.md index af6a8f8..47283c3 100644 --- a/content/5_Gold/DS.md +++ b/content/5_Gold/DS.md @@ -36,7 +36,7 @@ The stack we used is called a "monotonic stack" because we keep popping off the (add more once codeforces comes up) -# Sliding Window (Deque) +# Sliding Window Let's envision a sliding window (or constant size subarray) of size $K$ moving left to right along an array, $a$. For each position of the window, we want to compute some information. -- 2.46.0 From 76f66a88cc85435bc3ca5f22531fbaf201426ce0 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Wed, 17 Jun 2020 15:18:07 -0700 Subject: [PATCH 94/97] migrate to gatsby mdx --- Content Documentation.md | 16 +- content/1_Intro/About_This.md | 4 +- content/1_Intro/Data_Types.md | 4 +- content/1_Intro/Example_Problem.md | 4 +- content/1_Intro/Getting_Started.md | 4 +- content/1_Intro/Input_Output.md | 4 +- content/1_Intro/Practicing.md | 4 +- content/1_Intro/Prerequisites.md | 4 +- content/1_Intro/Running_Cpp.md | 4 +- content/2_General/Contests.md | 4 +- content/2_General/Debugging.md | 4 +- content/2_General/Macros.md | 4 +- content/2_General/Proposing.md | 6 +- content/2_General/Resources.md | 4 +- content/2_General/Why_Cpp.md | 4 +- content/3_Bronze/0_Bronze_Overview.md | 4 +- content/3_Bronze/Complete_Search.md | 4 +- content/3_Bronze/Cpp_Containers.md | 4 +- content/3_Bronze/DS.md | 4 +- content/3_Bronze/Intro_Graphs.md | 4 +- content/3_Bronze/Java_Collections.md | 4 +- content/3_Bronze/Pairs.md | 4 +- content/3_Bronze/Rect_Geo.md | 4 +- content/3_Bronze/Simulation.md | 4 +- content/3_Bronze/Time_Comp.md | 4 +- content/4_Silver/2P.md | 4 +- content/4_Silver/Binary_Search.md | 4 +- content/4_Silver/Cyc.md | 4 +- content/4_Silver/DFS.md | 6 +- content/4_Silver/Data_Structures.md | 4 +- content/4_Silver/Greedy.md | 4 +- content/4_Silver/Intro_Sorting.md | 4 +- content/4_Silver/Prefix_Sums.md | 4 +- content/4_Silver/Sorting_Custom.md | 4 +- content/4_Silver/Sorting_Custom_2.md | 4 +- content/5_Gold/BFS.md | 4 +- content/5_Gold/BIT.md | 4 +- content/5_Gold/DP.md | 4 +- content/5_Gold/DP_Trees.md | 4 +- content/5_Gold/DS.md | 4 +- content/5_Gold/Intro_NT.md | 6 +- content/5_Gold/MST.md | 4 +- content/5_Gold/SP.md | 6 +- content/6_Plat/1DRQ.md | 4 +- content/6_Plat/2DRQ.md | 4 +- content/6_Plat/Bitsets.md | 4 +- content/6_Plat/DP_Bitmasks.md | 4 +- content/6_Plat/DP_Ranges.md | 4 +- content/6_Plat/Fracture.md | 4 +- content/6_Plat/Geometry.md | 4 +- content/6_Plat/Graphs.md | 6 +- content/6_Plat/Olympiads.md | 4 +- content/6_Plat/Slope.md | 4 +- content/6_Plat/Strings.md | 6 +- content/6_Plat/Trees.md | 4 +- content/Syllabus.md | 4 +- gatsby-browser.js | 60 ++++- gatsby-config.js | 13 +- package.json | 3 + src/components/Markdown.js | 47 +--- src/templates/moduleTemplate.js | 16 +- src/templates/syllabusTemplate.js | 6 +- yarn.lock | 374 +++++++++++++++++++++++++- 63 files changed, 623 insertions(+), 144 deletions(-) diff --git a/Content Documentation.md b/Content Documentation.md index edfe362..da49b85 100644 --- a/Content Documentation.md +++ b/Content Documentation.md @@ -42,13 +42,7 @@ prerequisites: ### Module Description -Everything after the frontmatter, and before this line: - -``` - -``` - -is part of the "module description." It gets rendered on the homepage. Be careful not to use headers +Everything contained in `module-excerpt` tags is part of the "module description." It gets rendered on the homepage. Be careful not to use headers as they will look really weird on the homepage. The module description is also included in the article itself. If you don't want a description for the module, just put the `END DESCRIPTION` line as the first line @@ -59,6 +53,8 @@ an HTML element with the class `syllabus-only`. Note that you can't use markdown Example: ``` + +
  • Contest Format
  • Choosing a Language
  • @@ -66,7 +62,7 @@ Example:
  • Contest Strategies
- +
``` This will render as a list in the homepage, but won't appear in the article. @@ -134,6 +130,8 @@ problems: - bronze_square --- + +
  • Contest Format
  • Choosing a Language
  • @@ -141,7 +139,7 @@ problems:
  • Contest Strategies
- +
Show Solution diff --git a/content/1_Intro/About_This.md b/content/1_Intro/About_This.md index c2d60e3..2ee71dd 100644 --- a/content/1_Intro/About_This.md +++ b/content/1_Intro/About_This.md @@ -4,13 +4,15 @@ title: About This Guide author: Nathan Wang, Benjamin Qi --- + + // todo transfer all of this to the homepage - Goals - Module Organization - Contact Information - + ## Goals diff --git a/content/1_Intro/Data_Types.md b/content/1_Intro/Data_Types.md index 4bb09d4..268fd9c 100644 --- a/content/1_Intro/Data_Types.md +++ b/content/1_Intro/Data_Types.md @@ -4,9 +4,11 @@ title: Data Types author: Darren Yao --- + + There are several main **data types** that are used in contests: 32-bit and 64-bit integers, floating point numbers, booleans, characters, and strings. - + ## Reading diff --git a/content/1_Intro/Example_Problem.md b/content/1_Intro/Example_Problem.md index fe150cd..f73f275 100644 --- a/content/1_Intro/Example_Problem.md +++ b/content/1_Intro/Example_Problem.md @@ -14,9 +14,11 @@ prerequisites: - Intro - Input & Output --- + + Solutions for an example USACO problem in multiple languages. - + [Technical Specifications for USACO Contests](http://www.usaco.org/index.php?page=instructions) diff --git a/content/1_Intro/Getting_Started.md b/content/1_Intro/Getting_Started.md index d81d247..c8b2e68 100644 --- a/content/1_Intro/Getting_Started.md +++ b/content/1_Intro/Getting_Started.md @@ -4,11 +4,13 @@ title: Getting Started author: Nathan Wang, Benjamin Qi, Darren Yao --- + + - Introduction - Contest Format - Choosing a Language - + ## Introduction diff --git a/content/1_Intro/Input_Output.md b/content/1_Intro/Input_Output.md index 1dfa5c0..3b67df4 100644 --- a/content/1_Intro/Input_Output.md +++ b/content/1_Intro/Input_Output.md @@ -4,9 +4,11 @@ title: Input & Output author: Darren Yao --- + + Demonstrates how to read input and print output for USACO. - + ## C++ diff --git a/content/1_Intro/Practicing.md b/content/1_Intro/Practicing.md index f9ae029..3fb3be8 100644 --- a/content/1_Intro/Practicing.md +++ b/content/1_Intro/Practicing.md @@ -4,9 +4,11 @@ title: How to Practice author: Many --- + + How to practice, when to read editorials (analyses), etc. - + Knowing when to "give up" on a problem and start reading the problem's editorial is challenging. Below are the opinions of various individuals. Note that "give up" is in quotes, because one still learns when they "give up" and read an editorial! diff --git a/content/1_Intro/Prerequisites.md b/content/1_Intro/Prerequisites.md index 5b476ce..f64379b 100644 --- a/content/1_Intro/Prerequisites.md +++ b/content/1_Intro/Prerequisites.md @@ -4,9 +4,11 @@ title: Prerequisites author: Nathan Wang --- + + Here's what you should learn before reading these resources. - + These resources do **not** teach you how to code. We recommend you learn roughly the first half of AP Computer Science A before continuing. If you do not meet these prerequisites, you can go to the resources below to get started. diff --git a/content/1_Intro/Running_Cpp.md b/content/1_Intro/Running_Cpp.md index 7dfbca0..ce24b52 100644 --- a/content/1_Intro/Running_Cpp.md +++ b/content/1_Intro/Running_Cpp.md @@ -4,9 +4,11 @@ title: Running C++ author: Nathan Wang, Benjamin Qi, Anthony Wang --- + + Running C++ both online and locally. - + # Running C++ Online diff --git a/content/2_General/Contests.md b/content/2_General/Contests.md index 0d676c6..ff89201 100644 --- a/content/2_General/Contests.md +++ b/content/2_General/Contests.md @@ -4,9 +4,11 @@ title: Contests author: Benjamin Qi --- + + Contests that I participate in, as well as a few tools. - + See [clist.by](https://clist.by/coder/bqi343/) for an extensive list. Most of the contests which I do are a subset of those shown in "Programming Contests.png". A link to my google calendar for contests is available [here.](https://calendar.google.com/calendar?cid=Y2s5ZjdmZDBkNjdmOGFxZ2oxbDVrMHJ1OGtAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ) See the other page for olympiads such as USACO. diff --git a/content/2_General/Debugging.md b/content/2_General/Debugging.md index 7674872..e2b77fd 100644 --- a/content/2_General/Debugging.md +++ b/content/2_General/Debugging.md @@ -4,9 +4,11 @@ title: Debugging author: Benjamin Qi, Aaron Chew --- + + Detecting issues within your program and figuring out how to avoid them in the first place. - + ## Style Guide diff --git a/content/2_General/Macros.md b/content/2_General/Macros.md index 6d71dc4..c4056cf 100644 --- a/content/2_General/Macros.md +++ b/content/2_General/Macros.md @@ -4,9 +4,11 @@ title: C++ Macros author: Benjamin Qi --- + + Shortening code and making it (un?)readable. - + ## Introduction diff --git a/content/2_General/Proposing.md b/content/2_General/Proposing.md index 1f97b56..1955627 100644 --- a/content/2_General/Proposing.md +++ b/content/2_General/Proposing.md @@ -4,9 +4,11 @@ title: Proposing Problems for USACO Monthlies author: Benjamin Qi --- + + Anyone can propose problems for monthly contests. - + Email your proposal to Professor Dean. In the [past](http://www.usaco.org/index.php?page=viewproblem2&cpid=817), contestants have even written problems for their own divisions! @@ -24,6 +26,8 @@ bolded text should be surrounded by [b][/b], italics by [i][/i] use [ol][/ol] for numbered list --- + + Each of Farmer John's $N$ cows ($1\le N\le 2\cdot 10^5$) has a favorite color. The cows are conveniently labeled $1\ldots N$ (as always), and each color can be represented by an integer in the range $1\ldots N$. diff --git a/content/2_General/Resources.md b/content/2_General/Resources.md index 0fd313e..3b8d776 100644 --- a/content/2_General/Resources.md +++ b/content/2_General/Resources.md @@ -4,9 +4,11 @@ title: Additional Resources author: Benjamin Qi --- + + Helpful Links! Some (such as **CPH** and **Intro to USACO**) will be mentioned again in later modules. - + ## Lists diff --git a/content/2_General/Why_Cpp.md b/content/2_General/Why_Cpp.md index 7d6f8c8..1c6cdb0 100644 --- a/content/2_General/Why_Cpp.md +++ b/content/2_General/Why_Cpp.md @@ -4,9 +4,11 @@ title: Why C++? author: Benjamin Qi --- + + A few reasons why choice of language matters significantly (outside of Bronze). - + ## Time Limit diff --git a/content/3_Bronze/0_Bronze_Overview.md b/content/3_Bronze/0_Bronze_Overview.md index 9225cee..7cec4a3 100644 --- a/content/3_Bronze/0_Bronze_Overview.md +++ b/content/3_Bronze/0_Bronze_Overview.md @@ -4,7 +4,9 @@ title: "Bronze Overview" author: Brian Dean --- - + + + Todo: - Brian's advice for new bronze competitors diff --git a/content/3_Bronze/Complete_Search.md b/content/3_Bronze/Complete_Search.md index 44baa3e..9bb400c 100644 --- a/content/3_Bronze/Complete_Search.md +++ b/content/3_Bronze/Complete_Search.md @@ -4,9 +4,11 @@ title: "Complete Search" author: Darren Yao --- + + In many problems (especially in Bronze), it's sufficient to check all possible cases in the solution space, whether it be all elements, all pairs of elements, or all subsets, or all permutations. Unsurprisingly, this is called **complete search** (or **brute force**), because it completely searches the entire solution space. - + ## Example 1 diff --git a/content/3_Bronze/Cpp_Containers.md b/content/3_Bronze/Cpp_Containers.md index bb1002b..32ca1b4 100644 --- a/content/3_Bronze/Cpp_Containers.md +++ b/content/3_Bronze/Cpp_Containers.md @@ -4,9 +4,11 @@ title: Built-In C++ Containers author: Darren Yao --- + + Introduces C++ [containers](http://www.cplusplus.com/reference/stl/) that are frequently used in competitive programming. - + A **data structure** determines how data is stored (is it sorted? indexed? what operations does it support?). Each data structure supports some operations efficiently, while other operations are either inefficient or not supported at all. diff --git a/content/3_Bronze/DS.md b/content/3_Bronze/DS.md index 2d83661..280fef8 100644 --- a/content/3_Bronze/DS.md +++ b/content/3_Bronze/DS.md @@ -5,11 +5,13 @@ author: Nathan Wang, Darren Yao, Benjamin Qi order: 5 --- + + Problems and additional resources regarding built-in data structures. (clean this up) - + ## Problems diff --git a/content/3_Bronze/Intro_Graphs.md b/content/3_Bronze/Intro_Graphs.md index 6cf0f5b..47383eb 100644 --- a/content/3_Bronze/Intro_Graphs.md +++ b/content/3_Bronze/Intro_Graphs.md @@ -4,9 +4,11 @@ title: Introduction to Graphs author: Darren Yao, Benjamin Qi --- + + **Graph theory** is one of the most important topics at the Silver level and above, although some basic problems occasionally appear in Bronze. - + Graphs can be used to represent many things, from images to wireless signals, but one of the simplest analogies is to a map. Consider a map with several cities and highways connecting the cities. Some problems relating to graphsare: diff --git a/content/3_Bronze/Java_Collections.md b/content/3_Bronze/Java_Collections.md index 0b65773..8862cee 100644 --- a/content/3_Bronze/Java_Collections.md +++ b/content/3_Bronze/Java_Collections.md @@ -4,9 +4,11 @@ title: Built-In Java Collections author: Darren Yao --- + + Introduces data structures from Java [Collections](https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html) that are frequently used in competitive programming. - + A **data structure** determines how data is stored (is it sorted? indexed? what operations does it support?). Each data structure supports some operations efficiently, while other operations are either inefficient or not supported at all. diff --git a/content/3_Bronze/Pairs.md b/content/3_Bronze/Pairs.md index 127c5a2..2af4f06 100644 --- a/content/3_Bronze/Pairs.md +++ b/content/3_Bronze/Pairs.md @@ -5,11 +5,13 @@ author: Aaron Chew, Benjamin Qi, Nathan Wang, Darren Yao order: 6 --- + + A **pair** is a structure that holds two values, not necessarily of the same type. (tuples?) - + Of course, we can hold more than two values with something like ```pair>```. diff --git a/content/3_Bronze/Rect_Geo.md b/content/3_Bronze/Rect_Geo.md index af67149..c90fa0f 100644 --- a/content/3_Bronze/Rect_Geo.md +++ b/content/3_Bronze/Rect_Geo.md @@ -4,9 +4,11 @@ title: "Rectangle Geometry" author: Darren Yao, Michael Cao --- + + "Geometry" problems on USACO Bronze are usually quite simple and limited to intersections and unions of squares or rectangles. - + - Some only include two or three squares or rectangles, in which case you can simply draw out cases on paper. This should logically lead to a solution. - Also, the coordinates typically only go up to $1000$, so a program that performs $\approx 1000^2$ operations (ex. with a nested loop) should pass. diff --git a/content/3_Bronze/Simulation.md b/content/3_Bronze/Simulation.md index afd1d0e..229e0dd 100644 --- a/content/3_Bronze/Simulation.md +++ b/content/3_Bronze/Simulation.md @@ -4,9 +4,11 @@ title: "Simulation" author: Darren Yao --- + + In many problems, we can **simulate** what we're told to do by the problem statement. - + Since there's no formal algorithm involved, the intent of the problem is to assess competence with one's programming language of choice and knowledge of built-in data structures. At least in USACO Bronze, when a problem statement says to find the end result of some process, or to find when something occurs, it's usually sufficient to simulate the process naively. diff --git a/content/3_Bronze/Time_Comp.md b/content/3_Bronze/Time_Comp.md index 7555c24..5986831 100644 --- a/content/3_Bronze/Time_Comp.md +++ b/content/3_Bronze/Time_Comp.md @@ -4,9 +4,11 @@ title: "Time Complexity" author: Darren Yao, Benjamin Qi --- + + In programming contests, there is a strict limit on program runtime. This means that in order to pass, your program needs to finish running within a certain timeframe. - + For USACO, this limit is $4$ seconds for Java submissions. A conservative estimate for the number of operations the grading server can handle per second is $10^8$ (but could be closer to $5 \cdot 10^8$ given good constant factors). diff --git a/content/4_Silver/2P.md b/content/4_Silver/2P.md index f059b31..7e43a05 100644 --- a/content/4_Silver/2P.md +++ b/content/4_Silver/2P.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Sorting --- + + **Two pointers** refers to iterating two monotonic pointers across an array to search for a pair of indices satisfying some condition in $O(n)$ time. - + ## Tutorials diff --git a/content/4_Silver/Binary_Search.md b/content/4_Silver/Binary_Search.md index d474fc7..7196644 100644 --- a/content/4_Silver/Binary_Search.md +++ b/content/4_Silver/Binary_Search.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Introduction to Sorting --- + + You should already be familiar with the concept of **binary searching** for a number in a sorted array. However, binary search can be extended to binary searching on the answer itself. - + When we binary search on the answer, we start with a search space of size $N$ which we know the answer lies in. Then, each iteration of the binary search cuts the search space in half, so the algorithm tests $O(\log N)$ values. This is efficient and much better than testing each possible value in the search space. diff --git a/content/4_Silver/Cyc.md b/content/4_Silver/Cyc.md index b134453..887af16 100644 --- a/content/4_Silver/Cyc.md +++ b/content/4_Silver/Cyc.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Depth First Search --- + + A *cycle* is a non-empty path of distinct edges that start and end at the same node. - + *Cycle detection* determines properties of cycles in a directed or undirected graph, such as whether each node of the graph is part of a cycle or just checking whether a cycle exists. diff --git a/content/4_Silver/DFS.md b/content/4_Silver/DFS.md index e2c15d1..49f7ba5 100644 --- a/content/4_Silver/DFS.md +++ b/content/4_Silver/DFS.md @@ -7,12 +7,14 @@ prerequisites: - Bronze - Introduction to Graphs --- - - Depth First Search (DFS) + + +- Depth First Search (DFS) - Flood Fill - Graph Two-Coloring - + ## Depth First Search (DFS) diff --git a/content/4_Silver/Data_Structures.md b/content/4_Silver/Data_Structures.md index 7a69938..98baa8f 100644 --- a/content/4_Silver/Data_Structures.md +++ b/content/4_Silver/Data_Structures.md @@ -7,9 +7,11 @@ prerequisites: - Bronze - Data Structures --- + + More practice with data structures introduced in bronze. - + (set iterators?) diff --git a/content/4_Silver/Greedy.md b/content/4_Silver/Greedy.md index e552648..ba9afa7 100644 --- a/content/4_Silver/Greedy.md +++ b/content/4_Silver/Greedy.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Sorting with Custom Comparators --- + + **Greedy** algorithms select the optimal choice at each step instead of looking at the solution space as a whole. This reduces the problem to a smaller problem at each step. - + Greedy does not refer to a single algorithm, but rather a way of thinking that is applied to problems. There's no one way to do greedy algorithms. Hence, we use a selection of well-known examples to help you understand the greedy paradigm. diff --git a/content/4_Silver/Intro_Sorting.md b/content/4_Silver/Intro_Sorting.md index ad04d54..c1c40a1 100644 --- a/content/4_Silver/Intro_Sorting.md +++ b/content/4_Silver/Intro_Sorting.md @@ -4,9 +4,11 @@ title: "Introduction to Sorting" author: Siyong Huang, Michael Cao, Nathan Chen --- + + Introduces sorting, binary search, coordinate compression. - + **Sorting** is exactly what it sounds like: arranging items in some particular order. diff --git a/content/4_Silver/Prefix_Sums.md b/content/4_Silver/Prefix_Sums.md index c54a36b..1b28dbb 100644 --- a/content/4_Silver/Prefix_Sums.md +++ b/content/4_Silver/Prefix_Sums.md @@ -4,9 +4,11 @@ title: "Prefix Sums" author: Darren Yao, Eric Wei --- + + Let's say we have a one-indexed integer array $\texttt{arr}$ of size $N$ and we want to answer $Q$ queries of the following form: compute $\texttt{arr[L]+arr[L+1]+}\cdots\texttt{+arr[R]}$. - + ## Standard diff --git a/content/4_Silver/Sorting_Custom.md b/content/4_Silver/Sorting_Custom.md index 0f7bcc4..f961880 100644 --- a/content/4_Silver/Sorting_Custom.md +++ b/content/4_Silver/Sorting_Custom.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Introduction to Sorting --- + + Both Java and C++ have built-in functions for sorting. However, if we use custom objects, or if we want to sort elements in a different order, then we'll need to use a **custom comparator**. - + ## Comparators diff --git a/content/4_Silver/Sorting_Custom_2.md b/content/4_Silver/Sorting_Custom_2.md index b4e8be4..982881d 100644 --- a/content/4_Silver/Sorting_Custom_2.md +++ b/content/4_Silver/Sorting_Custom_2.md @@ -9,9 +9,11 @@ prerequisites: - Silver - Sorting with Custom Comparators --- + + More information about sorting with custom comparators in C++. Some overlap with the previous article. - + ## Additional Resources diff --git a/content/5_Gold/BFS.md b/content/5_Gold/BFS.md index 95e684d..fbff2c7 100644 --- a/content/5_Gold/BFS.md +++ b/content/5_Gold/BFS.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Depth First Search --- + + Compute shortest paths where all edge weights are 1. - + - [CSES Message Route](https://cses.fi/problemset/task/1667) diff --git a/content/5_Gold/BIT.md b/content/5_Gold/BIT.md index 6a9d083..aad0f8c 100644 --- a/content/5_Gold/BIT.md +++ b/content/5_Gold/BIT.md @@ -7,12 +7,14 @@ prerequisites: - Silver - Prefix Sums --- + + A **Binary Indexed Tree** allows you to perform the following tasks in $O(\log N)$ time each on an array of size $N$: - Update the element at a single position (point). - Query the sum of a prefix of the array. - + ## Binary Indexed Tree diff --git a/content/5_Gold/DP.md b/content/5_Gold/DP.md index aa218e3..38f9c17 100644 --- a/content/5_Gold/DP.md +++ b/content/5_Gold/DP.md @@ -9,9 +9,11 @@ prerequisites: - Silver - Prefix Sums --- + + **Dynamic Programming (DP)** is a very important concept which emerges in the Gold division and extends to the IOI. - + [[info | Contest Tip]] | Usually at least one problem from every gold division contest involves some sort of DP. diff --git a/content/5_Gold/DP_Trees.md b/content/5_Gold/DP_Trees.md index 0670cbd..d1c3552 100644 --- a/content/5_Gold/DP_Trees.md +++ b/content/5_Gold/DP_Trees.md @@ -9,7 +9,9 @@ prerequisites: - Gold - Introduction to Dynamic Programming --- - + + + ## Tutorial diff --git a/content/5_Gold/DS.md b/content/5_Gold/DS.md index af6a8f8..bffa882 100644 --- a/content/5_Gold/DS.md +++ b/content/5_Gold/DS.md @@ -8,9 +8,11 @@ prerequisites: - (?) Silver - Data Structures --- + + More advanced applications of data structures introduced in earlier divisions. - + # Monotonic Stack diff --git a/content/5_Gold/Intro_NT.md b/content/5_Gold/Intro_NT.md index 1af24bc..ca19712 100644 --- a/content/5_Gold/Intro_NT.md +++ b/content/5_Gold/Intro_NT.md @@ -4,11 +4,13 @@ title: "Introductory Number Theory" author: Darren Yao --- - - Prime Factorization + + +- Prime Factorization - GCD & LCM - Modular Arithmetic - + ## Additional Resources diff --git a/content/5_Gold/MST.md b/content/5_Gold/MST.md index 8e6fee9..bf99bed 100644 --- a/content/5_Gold/MST.md +++ b/content/5_Gold/MST.md @@ -7,9 +7,11 @@ prerequisites: - Gold - Shortest Paths --- + + **Disjoint Set Union** and **Minimum Spanning Trees** - + ## Standard diff --git a/content/5_Gold/SP.md b/content/5_Gold/SP.md index 02ceab9..12b8edf 100644 --- a/content/5_Gold/SP.md +++ b/content/5_Gold/SP.md @@ -7,11 +7,13 @@ prerequisites: - Gold - Breadth First Search --- - - Shortest Path Without Negative Edge Weights + + +- Shortest Path Without Negative Edge Weights - Shortest Path With Negative Edge Weights - All Pairs Shortest Path - + ## Non-Negative Edge Weights diff --git a/content/6_Plat/1DRQ.md b/content/6_Plat/1DRQ.md index 48f05a0..fc1032e 100644 --- a/content/6_Plat/1DRQ.md +++ b/content/6_Plat/1DRQ.md @@ -7,9 +7,11 @@ prerequisites: - Gold - Binary Indexed Trees --- + + General range queries for associative operations, including segment tree. - + ## Static Range Queries diff --git a/content/6_Plat/2DRQ.md b/content/6_Plat/2DRQ.md index 72f49e8..622fe01 100644 --- a/content/6_Plat/2DRQ.md +++ b/content/6_Plat/2DRQ.md @@ -7,9 +7,11 @@ prerequisites: - Platinum - 1D Range Queries --- + + Extending Range Queries to 2D (and beyond). - + See [my implementations](https://github.com/bqi343/USACO/tree/master/Implementations/content/data-structures/2D%20Range%20Queries%20(15.2)). diff --git a/content/6_Plat/Bitsets.md b/content/6_Plat/Bitsets.md index 0d09cb7..c37c29b 100644 --- a/content/6_Plat/Bitsets.md +++ b/content/6_Plat/Bitsets.md @@ -4,9 +4,11 @@ title: "Bitsets" author: Benjamin Qi --- + + Three examples of how **bitsets** lead to some unintended solutions on recent USACO problems. - + ## Tutorial diff --git a/content/6_Plat/DP_Bitmasks.md b/content/6_Plat/DP_Bitmasks.md index cb8d314..1cc8b76 100644 --- a/content/6_Plat/DP_Bitmasks.md +++ b/content/6_Plat/DP_Bitmasks.md @@ -9,7 +9,9 @@ prerequisites: - Gold - Introduction to Dynamic Programming --- - + + + Note: Has not appeared on recent USACO. diff --git a/content/6_Plat/DP_Ranges.md b/content/6_Plat/DP_Ranges.md index 3aafd36..e1b471d 100644 --- a/content/6_Plat/DP_Ranges.md +++ b/content/6_Plat/DP_Ranges.md @@ -7,7 +7,9 @@ prerequisites: - Gold - Introduction to Dynamic Programming --- - + + + ## Problems diff --git a/content/6_Plat/Fracture.md b/content/6_Plat/Fracture.md index f86e94b..9b65364 100644 --- a/content/6_Plat/Fracture.md +++ b/content/6_Plat/Fracture.md @@ -9,9 +9,11 @@ prerequisites: - some familiarity with "Robotic Cow Herd" analysis --- + + A simple solution to [Robotic Cow Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=674) that generalizes. - + ## General Outline diff --git a/content/6_Plat/Geometry.md b/content/6_Plat/Geometry.md index 4058ec0..30c3171 100644 --- a/content/6_Plat/Geometry.md +++ b/content/6_Plat/Geometry.md @@ -4,9 +4,11 @@ title: "Geometry" author: Benjamin Qi --- + + Geometry primitives and convex hull. - + ## Primitives diff --git a/content/6_Plat/Graphs.md b/content/6_Plat/Graphs.md index 594e486..3ed9fc7 100644 --- a/content/6_Plat/Graphs.md +++ b/content/6_Plat/Graphs.md @@ -7,11 +7,13 @@ prerequisites: - Gold - Topological Sort --- - - Eulerian Tours + + +- Eulerian Tours - SCCs - BCCs - + Note: all except the third have not appeared on a recent USACO contest. diff --git a/content/6_Plat/Olympiads.md b/content/6_Plat/Olympiads.md index c12405a..680419f 100644 --- a/content/6_Plat/Olympiads.md +++ b/content/6_Plat/Olympiads.md @@ -4,9 +4,11 @@ title: "Olympiads" author: Benjamin Qi --- + + Once you've reached Platinum, it may be helpful to practice with problems from other (inter)national olympiads. - + > Hello, Which online judge should I practice more to do well in **IOI** ? > the closest OJ for IOI style? diff --git a/content/6_Plat/Slope.md b/content/6_Plat/Slope.md index 4b1d3be..1eed4bb 100644 --- a/content/6_Plat/Slope.md +++ b/content/6_Plat/Slope.md @@ -7,9 +7,11 @@ prerequisites: - some familiarity with at least one of the two tutorials mentioned in this module --- + + **Slope trick** refers to manipulating piecewise linear convex functions. Includes a simple solution to [Landscaping](http://www.usaco.org/index.php?page=viewproblem2&cpid=650). - + ## Tutorials diff --git a/content/6_Plat/Strings.md b/content/6_Plat/Strings.md index c1df6ca..1ba5e2d 100644 --- a/content/6_Plat/Strings.md +++ b/content/6_Plat/Strings.md @@ -7,7 +7,9 @@ prerequisites: - Silver - Depth First Search --- - - Tries + + +- Tries - Hashing - Z - KMP @@ -15,7 +17,7 @@ prerequisites: - Aho-Corasick - Suffix Array - + Note: String algorithms do not appear very frequently. Hashing has appeared on gold (rarely). diff --git a/content/6_Plat/Trees.md b/content/6_Plat/Trees.md index 97a67fc..1f27c4b 100644 --- a/content/6_Plat/Trees.md +++ b/content/6_Plat/Trees.md @@ -7,9 +7,11 @@ prerequisites: - Silver - Depth First Search --- + + Lowest Common Ancestor and other tree topics. - + ## Tree Diameter diff --git a/content/Syllabus.md b/content/Syllabus.md index fda568b..f4731ea 100644 --- a/content/Syllabus.md +++ b/content/Syllabus.md @@ -4,11 +4,13 @@ title: Syllabus author: Benjamin Qi --- + + (outdated) Below, we've compiled some of the main topics for each division. - + This USACO guide will try to cover all of these topics. Note that USACO contest problems are not limited to just these topics, though _most_ of them should fall into one of the catgories listed below. diff --git a/gatsby-browser.js b/gatsby-browser.js index 3d974af..e57533d 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1 +1,59 @@ -import "./src/styles/main.css"; \ No newline at end of file +import "./src/styles/main.css"; +import React from "react"; +import { MDXProvider } from "@mdx-js/react"; + +const SpoilerComponent = ({ children }) => { + const [show, setShow] = React.useState(false); + + return ( +
{if (e.target.classList.contains("spoiler-label")) setShow(!show) }}> + {children} +
+ ); +}; + +const components = { + wrapper: ({ excerptOnly = false, children }) => { + if (excerptOnly) { + for (let child of children) { + if (child.props.originalType === "module-excerpt") return child; + } + return null; + } + + return children; + }, + "module-excerpt": (props) =>
, + details: SpoilerComponent, + summary: ({ children }) => ( +

+ + + {children} +

+ ), + "info-block": ({ children }) => ( +
+
+
+ + + +
+
+ {children} +
+
+
+ ), +}; + +export const wrapRootElement = ({ element }) => ( + + {element} + +); \ No newline at end of file diff --git a/gatsby-config.js b/gatsby-config.js index ce88243..606484a 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -18,14 +18,10 @@ module.exports = { }, }, { - resolve: `gatsby-transformer-remark`, + resolve: `gatsby-plugin-mdx`, options: { - // commonmark: true, - // footnotes: true, - // pedantic: false, - // gfm: true, - "excerpt_separator": ``, - plugins: [ + extensions: [`.mdx`, `.md`], + gatsbyRemarkPlugins: [ `gatsby-remark-autolink-headers`, { resolve: "gatsby-remark-custom-blocks", @@ -52,6 +48,9 @@ module.exports = { }, }, ], + plugins: [ + `gatsby-remark-autolink-headers`, + ] }, }, { diff --git a/package.json b/package.json index f73f3d7..e9b2d12 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,14 @@ "version": "0.1.0", "author": "Kyle Mathews ", "dependencies": { + "@mdx-js/mdx": "^1.6.5", + "@mdx-js/react": "^1.6.5", "@tailwindcss/ui": "^0.3.0", "esm": "^3.2.25", "gatsby": "^2.22.15", "gatsby-image": "^2.4.5", "gatsby-plugin-manifest": "^2.4.9", + "gatsby-plugin-mdx": "^1.2.15", "gatsby-plugin-offline": "^3.2.7", "gatsby-plugin-postcss": "^2.3.3", "gatsby-plugin-react-helmet": "^3.3.2", diff --git a/src/components/Markdown.js b/src/components/Markdown.js index fbd0ade..e3c393f 100644 --- a/src/components/Markdown.js +++ b/src/components/Markdown.js @@ -1,55 +1,14 @@ import React from "react"; -import rehypeReact from "rehype-react" import "../styles/markdown.css"; import "katex/dist/katex.min.css"; import "../styles/prism-theme.css"; +import { MDXRenderer } from "gatsby-plugin-mdx"; -const SpoilerComponent = ({ children }) => { - const [show, setShow] = React.useState(false); - - return ( -
{if (e.target.classList.contains("spoiler-label")) setShow(!show) }}> - {children} -
- ); -}; - -const renderAst = new rehypeReact({ - createElement: React.createElement, - components: { - details: SpoilerComponent, - summary: ({ children }) => ( -

- - - {children} -

- ), - "info-block": ({ children }) => ( -
-
-
- - - -
-
- {children} -
-
-
- ) - }, -}).Compiler; - -const Markdown = ({ htmlAst, className }) => { +const Markdown = ({ body, className, excerptOnly = false }) => { return (
- {renderAst(htmlAst)} + {body}
); }; diff --git a/src/templates/moduleTemplate.js b/src/templates/moduleTemplate.js index 29df0a3..f5f981b 100644 --- a/src/templates/moduleTemplate.js +++ b/src/templates/moduleTemplate.js @@ -15,9 +15,9 @@ const renderPrerequisite = (prerequisite) => { }; export default function Template(props) { - const { markdownRemark } = props.data; // data.markdownRemark holds your post data - const { htmlAst } = markdownRemark; - const prereqs = markdownRemark.frontmatter.prerequisites; + const { mdx } = props.data; // data.markdownRemark holds your post data + const { body } = mdx; + const prereqs = mdx.frontmatter.prerequisites; const division = props.pageContext.division; return ( @@ -25,8 +25,8 @@ export default function Template(props) {
← Back to Home -

{markdownRemark.frontmatter.title}

-

Author: {markdownRemark.frontmatter.author}

+

{mdx.frontmatter.title}

+

Author: {mdx.frontmatter.author}

{prereqs && @@ -53,7 +53,7 @@ export default function Template(props) {
} - +
@@ -61,8 +61,8 @@ export default function Template(props) { } export const pageQuery = graphql` query($id: String!) { - markdownRemark(frontmatter: { id: { eq: $id } }) { - htmlAst + mdx(frontmatter: { id: { eq: $id } }) { + body frontmatter { title author diff --git a/src/templates/syllabusTemplate.js b/src/templates/syllabusTemplate.js index a299b67..1836762 100644 --- a/src/templates/syllabusTemplate.js +++ b/src/templates/syllabusTemplate.js @@ -25,7 +25,7 @@ const renderModule = (node, idx, parentIdx = -1) => { prerequisites={data.prerequisites} author={data.author} > - + ); }; @@ -191,7 +191,7 @@ export default function Template(props) { } export const pageQuery = graphql` query { - modules: allMarkdownRemark { + modules: allMdx { edges { node { id @@ -202,7 +202,7 @@ export const pageQuery = graphql` problems prerequisites } - excerptAst + body } } } diff --git a/yarn.lock b/yarn.lock index 31812db..4589f35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -40,7 +40,7 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/core@^7.0.0", "@babel/core@^7.9.6": +"@babel/core@^7.0.0", "@babel/core@^7.10.2", "@babel/core@^7.9.6": version "7.10.2" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.10.2.tgz#bd6786046668a925ac2bd2fd95b579b92a23b36a" integrity sha512-KQmV9yguEjQsXqyOUGKjS4+3K8/DlOCE2pZcq4augdQmtTy5iv5EHtmMSJ7V4c1BIPjuwtZYqYLCq9Ga+hGBRQ== @@ -839,7 +839,7 @@ core-js "^2.6.5" regenerator-runtime "^0.13.4" -"@babel/preset-env@^7.9.6": +"@babel/preset-env@^7.10.2", "@babel/preset-env@^7.9.6": version "7.10.2" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.10.2.tgz#715930f2cf8573b0928005ee562bed52fb65fdfb" integrity sha512-MjqhX0RZaEgK/KueRzh+3yPSk30oqDKJ5HP5tqTSB1e2gzGS3PLy7K0BIpnp78+0anFuSwOeuCf1zZO7RzRvEA== @@ -920,7 +920,7 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" -"@babel/preset-react@^7.9.4": +"@babel/preset-react@^7.10.1", "@babel/preset-react@^7.9.4": version "7.10.1" resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.10.1.tgz#e2ab8ae9a363ec307b936589f07ed753192de041" integrity sha512-Rw0SxQ7VKhObmFjD/cUcKhPTtzpeviEFX1E6PgP+cYOhQ98icNqtINNFANlsdbQHrmeWnqdxA4Tmnl1jy5tp3Q== @@ -3504,7 +3504,7 @@ blob@0.0.5: resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" integrity sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig== -bluebird@^3.5.5, bluebird@^3.7.2: +bluebird@^3.0.5, bluebird@^3.5.5, bluebird@^3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== @@ -3912,6 +3912,14 @@ camel-case@4.1.1: pascal-case "^3.1.1" tslib "^1.10.0" +camel-case@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-3.0.0.tgz#ca3c3688a4e9cf3a4cda777dc4dcbc713249cf73" + integrity sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M= + dependencies: + no-case "^2.2.0" + upper-case "^1.1.1" + camelcase-css@2.0.1, camelcase-css@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" @@ -4011,6 +4019,30 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +change-case@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/change-case/-/change-case-3.1.0.tgz#0e611b7edc9952df2e8513b27b42de72647dd17e" + integrity sha512-2AZp7uJZbYEzRPsFoa+ijKdvp9zsrnnt6+yFokfwEpeJm0xuJDVoxiRCAaTzyJND8GJkofo2IcKWaUZ/OECVzw== + dependencies: + camel-case "^3.0.0" + constant-case "^2.0.0" + dot-case "^2.1.0" + header-case "^1.0.0" + is-lower-case "^1.1.0" + is-upper-case "^1.1.0" + lower-case "^1.1.1" + lower-case-first "^1.0.0" + no-case "^2.3.2" + param-case "^2.1.0" + pascal-case "^2.0.0" + path-case "^2.1.0" + sentence-case "^2.1.0" + snake-case "^2.1.0" + swap-case "^1.1.0" + title-case "^2.1.0" + upper-case "^1.1.1" + upper-case-first "^1.1.0" + character-entities-html4@^1.0.0: version "1.1.4" resolved "https://registry.yarnpkg.com/character-entities-html4/-/character-entities-html4-1.1.4.tgz#0e64b0a3753ddbf1fdc044c5fd01d0199a02e125" @@ -4046,6 +4078,28 @@ charenc@~0.0.1: resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc= +cheerio@^0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" + integrity sha1-qbqoYKP5tZWmuBsahocxIe06Jp4= + dependencies: + css-select "~1.2.0" + dom-serializer "~0.1.0" + entities "~1.1.1" + htmlparser2 "^3.9.1" + lodash.assignin "^4.0.9" + lodash.bind "^4.1.4" + lodash.defaults "^4.0.1" + lodash.filter "^4.4.0" + lodash.flatten "^4.2.0" + lodash.foreach "^4.3.0" + lodash.map "^4.4.0" + lodash.merge "^4.4.0" + lodash.pick "^4.2.1" + lodash.reduce "^4.4.0" + lodash.reject "^4.4.0" + lodash.some "^4.4.0" + cheerio@^1.0.0-rc.3: version "1.0.0-rc.3" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.3.tgz#094636d425b2e9c0f4eb91a46c05630c9a1a8bf6" @@ -4467,6 +4521,14 @@ console-stream@^0.1.1: resolved "https://registry.yarnpkg.com/console-stream/-/console-stream-0.1.1.tgz#a095fe07b20465955f2fafd28b5d72bccd949d44" integrity sha1-oJX+B7IEZZVfL6/Si11yvM2UnUQ= +constant-case@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/constant-case/-/constant-case-2.0.0.tgz#4175764d389d3fa9c8ecd29186ed6005243b6a46" + integrity sha1-QXV2TTidP6nI7NKRhu1gBSQ7akY= + dependencies: + snake-case "^2.1.0" + upper-case "^1.1.1" + constants-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" @@ -4558,7 +4620,7 @@ core-js-pure@^3.0.0: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813" integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA== -core-js@^2.4.0, core-js@^2.4.1, core-js@^2.6.11, core-js@^2.6.5: +core-js@2, core-js@^2.4.0, core-js@^2.4.1, core-js@^2.6.11, core-js@^2.6.5: version "2.6.11" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c" integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg== @@ -4955,6 +5017,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +dataloader@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8" + integrity sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw== + dataloader@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-2.0.0.tgz#41eaf123db115987e21ca93c005cd7753c55fe6f" @@ -5403,7 +5470,7 @@ dom-serializer@0, dom-serializer@^0.2.1: domelementtype "^2.0.1" entities "^2.0.0" -dom-serializer@~0.1.1: +dom-serializer@~0.1.0, dom-serializer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.1.tgz#1ec4059e284babed36eec2941d4a970a189ce7c0" integrity sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA== @@ -5470,6 +5537,13 @@ domutils@^2.0.0: domelementtype "^2.0.1" domhandler "^3.0.0" +dot-case@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-2.1.1.tgz#34dcf37f50a8e93c2b3bca8bb7fb9155c7da3bee" + integrity sha1-NNzzf1Co6TwrO8qLt/uRVcfaO+4= + dependencies: + no-case "^2.2.0" + dot-prop@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" @@ -6009,6 +6083,13 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= +eval@^0.1.0, eval@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/eval/-/eval-0.1.4.tgz#e05dbe0dab4b9330215cbb7bf4886eb24bd58700" + integrity sha512-npGsebJejyjMRnLdFu+T/97dnigqIU0Ov3IGrZ8ygd1v7RL1vGkEKtvyWZobqUH1AQgKlg0Yqqe2BtMA9/QZLw== + dependencies: + require-like ">= 0.1.1" + event-source-polyfill@^1.0.14: version "1.0.15" resolved "https://registry.yarnpkg.com/event-source-polyfill/-/event-source-polyfill-1.0.15.tgz#a28e116281be677af4b055b67d95517e35c92435" @@ -6891,6 +6972,18 @@ gatsby-core-utils@^1.3.4: proper-lockfile "^4.1.1" xdg-basedir "^4.0.0" +gatsby-core-utils@^1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/gatsby-core-utils/-/gatsby-core-utils-1.3.5.tgz#3c8f2dc940cec6570d1317f02ba028f327d1e773" + integrity sha512-kbwJ5BeQ8OixJVuBb1AGRL6vdkFz9nFBa6gXqjQ6AAXHhYDrjOYrRMIENT1QLoabWo6tlh0Hyl1agfWaQwW8lg== + dependencies: + ci-info "2.0.0" + configstore "^5.0.1" + fs-extra "^8.1.0" + node-object-hash "^2.0.0" + proper-lockfile "^4.1.1" + xdg-basedir "^4.0.0" + gatsby-design-tokens@^2.0.2: version "2.0.6" resolved "https://registry.yarnpkg.com/gatsby-design-tokens/-/gatsby-design-tokens-2.0.6.tgz#593aa969e360560369fc59054c01236beed9be7d" @@ -6967,6 +7060,47 @@ gatsby-plugin-manifest@^2.4.9: semver "^5.7.1" sharp "^0.25.1" +gatsby-plugin-mdx@^1.2.15: + version "1.2.15" + resolved "https://registry.yarnpkg.com/gatsby-plugin-mdx/-/gatsby-plugin-mdx-1.2.15.tgz#359195813490873749fbcacc76151790b2db8451" + integrity sha512-qLtb4bvsEYDNyO/qrGgdjSUeNDH33uN+UZpG3OHz9UjVv4WxcYO1NfKbkjw3Uy62ajjcBr0zuyZJMm4WyQWu4w== + dependencies: + "@babel/core" "^7.10.2" + "@babel/generator" "^7.10.2" + "@babel/helper-plugin-utils" "^7.10.1" + "@babel/plugin-proposal-object-rest-spread" "^7.10.1" + "@babel/preset-env" "^7.10.2" + "@babel/preset-react" "^7.10.1" + "@babel/types" "^7.10.2" + camelcase-css "^2.0.1" + change-case "^3.1.0" + core-js "2" + dataloader "^1.4.0" + debug "^4.1.1" + escape-string-regexp "^1.0.5" + eval "^0.1.4" + fs-extra "^8.1.0" + gatsby-core-utils "^1.3.5" + gray-matter "^4.0.2" + json5 "^2.1.3" + loader-utils "^1.4.0" + lodash "^4.17.15" + mdast-util-to-string "^1.1.0" + mdast-util-toc "^3.1.0" + mime "^2.4.6" + p-queue "^5.0.0" + pretty-bytes "^5.3.0" + remark "^10.0.1" + remark-retext "^3.1.3" + retext-english "^3.0.4" + static-site-generator-webpack-plugin "^3.4.2" + style-to-object "^0.3.0" + underscore.string "^3.3.5" + unified "^8.4.2" + unist-util-map "^1.0.5" + unist-util-remove "^1.0.3" + unist-util-visit "^1.4.1" + gatsby-plugin-offline@^3.2.7: version "3.2.7" resolved "https://registry.yarnpkg.com/gatsby-plugin-offline/-/gatsby-plugin-offline-3.2.7.tgz#6afab6c485dcc4cbbe433232703794ca8ac8407d" @@ -8166,6 +8300,14 @@ he@^1.1.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== +header-case@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/header-case/-/header-case-1.0.1.tgz#9535973197c144b09613cd65d317ef19963bd02d" + integrity sha1-lTWXMZfBRLCWE81l0xfvGZY70C0= + dependencies: + no-case "^2.2.0" + upper-case "^1.1.3" + hex-color-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e" @@ -9018,6 +9160,13 @@ is-jpg@^2.0.0: resolved "https://registry.yarnpkg.com/is-jpg/-/is-jpg-2.0.0.tgz#2e1997fa6e9166eaac0242daae443403e4ef1d97" integrity sha1-LhmX+m6RZuqsAkLarkQ0A+TvHZc= +is-lower-case@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-lower-case/-/is-lower-case-1.1.3.tgz#7e147be4768dc466db3bfb21cc60b31e6ad69393" + integrity sha1-fhR75HaNxGbbO/shzGCzHmrWk5M= + dependencies: + lower-case "^1.1.0" + is-natural-number@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" @@ -9197,6 +9346,13 @@ is-unc-path@^1.0.0: dependencies: unc-path-regex "^0.1.2" +is-upper-case@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/is-upper-case/-/is-upper-case-1.1.2.tgz#8d0b1fa7e7933a1e58483600ec7d9661cbaf756f" + integrity sha1-jQsfp+eTOh5YSDYA7H2WYcuvdW8= + dependencies: + upper-case "^1.1.0" + is-url@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" @@ -9429,7 +9585,7 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" -json5@^2.1.2: +json5@^2.1.2, json5@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43" integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== @@ -9667,6 +9823,16 @@ lodash._reinterpolate@^3.0.0: resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= +lodash.assignin@^4.0.9: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" + integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI= + +lodash.bind@^4.1.4: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" + integrity sha1-euMBfpOWIqwxt9fX3LGzTbFpDTU= + lodash.clonedeep@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" @@ -9677,17 +9843,32 @@ lodash.debounce@^4.0.8: resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168= +lodash.defaults@^4.0.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" + integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw= + lodash.every@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.every/-/lodash.every-4.6.0.tgz#eb89984bebc4364279bb3aefbbd1ca19bfa6c6a7" integrity sha1-64mYS+vENkJ5uzrvu9HKGb+mxqc= +lodash.filter@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" + integrity sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4= + +lodash.flatten@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" + integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= + lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= -lodash.foreach@^4.5.0: +lodash.foreach@^4.3.0, lodash.foreach@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" integrity sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM= @@ -9697,7 +9878,7 @@ lodash.isequal@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA= -lodash.map@^4.6.0: +lodash.map@^4.4.0, lodash.map@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM= @@ -9712,11 +9893,36 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= +lodash.merge@^4.4.0: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +lodash.pick@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" + integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM= + +lodash.reduce@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" + integrity sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs= + +lodash.reject@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" + integrity sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU= + lodash.sample@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.sample/-/lodash.sample-4.2.1.tgz#5e4291b0c753fa1abeb0aab8fb29df1b66f07f6d" integrity sha1-XkKRsMdT+hq+sKq4+ynfG2bwf20= +lodash.some@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" + integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0= + lodash.template@^4.4.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" @@ -9807,6 +10013,18 @@ loud-rejection@^2.2.0: currently-unhandled "^0.4.1" signal-exit "^3.0.2" +lower-case-first@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/lower-case-first/-/lower-case-first-1.0.2.tgz#e5da7c26f29a7073be02d52bac9980e5922adfa1" + integrity sha1-5dp8JvKacHO+AtUrrJmA5ZIq36E= + dependencies: + lower-case "^1.1.2" + +lower-case@^1.1.0, lower-case@^1.1.1, lower-case@^1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" + integrity sha1-miyr0bno4K6ZOkv31YdcOcQujqw= + lower-case@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.1.tgz#39eeb36e396115cc05e29422eaea9e692c9408c7" @@ -10034,6 +10252,16 @@ mdast-util-to-string@^1.0.5, mdast-util-to-string@^1.1.0: resolved "https://registry.yarnpkg.com/mdast-util-to-string/-/mdast-util-to-string-1.1.0.tgz#27055500103f51637bd07d01da01eb1967a43527" integrity sha512-jVU0Nr2B9X3MU4tSK7JP1CMkSvOj7X5l/GboG1tKRw52lLF1x2Ju92Ms9tNetCcbfX3hzlM73zYo2NKkWSfF/A== +mdast-util-toc@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/mdast-util-toc/-/mdast-util-toc-3.1.0.tgz#395eeb877f067f9d2165d990d77c7eea6f740934" + integrity sha512-Za0hqL1PqWrvxGtA/3NH9D5nhGAUS9grMM4obEAz5+zsk1RIw/vWUchkaoDLNdrwk05A0CSC5eEXng36/1qE5w== + dependencies: + github-slugger "^1.2.1" + mdast-util-to-string "^1.0.5" + unist-util-is "^2.1.2" + unist-util-visit "^1.1.0" + mdast-util-toc@^5.0: version "5.0.3" resolved "https://registry.yarnpkg.com/mdast-util-toc/-/mdast-util-toc-5.0.3.tgz#5fb1503e3655688929d596799a6910cc6548e420" @@ -10176,7 +10404,7 @@ mime@1.6.0, mime@^1.3.4: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== -mime@^2.0.3, mime@^2.4.4, mime@^2.4.5: +mime@^2.0.3, mime@^2.4.4, mime@^2.4.5, mime@^2.4.6: version "2.4.6" resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1" integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA== @@ -10456,6 +10684,13 @@ nlcst-to-string@^2.0.0: resolved "https://registry.yarnpkg.com/nlcst-to-string/-/nlcst-to-string-2.0.4.tgz#9315dfab80882bbfd86ddf1b706f53622dc400cc" integrity sha512-3x3jwTd6UPG7vi5k4GEzvxJ5rDA7hVUIRNHPblKuMVP9Z3xmlsd9cgLcpAMkc5uPOBna82EeshROFhsPkbnTZg== +no-case@^2.2.0, no-case@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac" + integrity sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ== + dependencies: + lower-case "^1.1.1" + no-case@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.3.tgz#c21b434c1ffe48b39087e86cfb4d2582e9df18f8" @@ -11030,6 +11265,13 @@ p-pipe@^1.1.0: resolved "https://registry.yarnpkg.com/p-pipe/-/p-pipe-1.2.0.tgz#4b1a11399a11520a67790ee5a0c1d5881d6befe9" integrity sha1-SxoROZoRUgpneQ7loMHViB1r7+k= +p-queue@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-5.0.0.tgz#80f1741d5e78a6fa72fce889406481baa5617a3c" + integrity sha512-6QfeouDf236N+MAxHch0CVIy8o/KBnmhttKjxZoOkUlzqU+u9rZgEyXH3OdckhTgawbqf5rpzmyR+07+Lv0+zg== + dependencies: + eventemitter3 "^3.1.0" + p-reduce@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" @@ -11090,6 +11332,13 @@ parallel-transform@^1.1.0: inherits "^2.0.3" readable-stream "^2.1.5" +param-case@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/param-case/-/param-case-2.1.1.tgz#df94fd8cf6531ecf75e6bef9a0858fbc72be2247" + integrity sha1-35T9jPZTHs915r75oIWPvHK+Ikc= + dependencies: + no-case "^2.2.0" + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -11259,6 +11508,14 @@ parseurl@^1.3.3, parseurl@~1.3.2, parseurl@~1.3.3: resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== +pascal-case@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-2.0.1.tgz#2d578d3455f660da65eca18ef95b4e0de912761e" + integrity sha1-LVeNNFX2YNpl7KGO+VtODekSdh4= + dependencies: + camel-case "^3.0.0" + upper-case-first "^1.1.0" + pascal-case@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-3.1.1.tgz#5ac1975133ed619281e88920973d2cd1f279de5f" @@ -11285,6 +11542,13 @@ path-browserify@0.0.1: resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== +path-case@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/path-case/-/path-case-2.1.1.tgz#94b8037c372d3fe2906e465bb45e25d226e8eea5" + integrity sha1-lLgDfDctP+KQbkZbtF4l0ibo7qU= + dependencies: + no-case "^2.2.0" + path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -12946,6 +13210,11 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= +"require-like@>= 0.1.1": + version "0.1.2" + resolved "https://registry.yarnpkg.com/require-like/-/require-like-0.1.2.tgz#ad6f30c13becd797010c468afa775c0c0a6b47fa" + integrity sha1-rW8wwTvs15cBDEaK+ndcDAprR/o= + require-main-filename@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" @@ -13305,6 +13574,14 @@ send@0.17.1: range-parser "~1.2.1" statuses "~1.5.0" +sentence-case@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/sentence-case/-/sentence-case-2.1.1.tgz#1f6e2dda39c168bf92d13f86d4a918933f667ed4" + integrity sha1-H24t2jnBaL+S0T+G1KkYkz9mftQ= + dependencies: + no-case "^2.2.0" + upper-case-first "^1.1.2" + serialize-javascript@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" @@ -13536,6 +13813,13 @@ slugify@^1.4.0: resolved "https://registry.yarnpkg.com/slugify/-/slugify-1.4.0.tgz#c9557c653c54b0c7f7a8e786ef3431add676d2cb" integrity sha512-FtLNsMGBSRB/0JOE2A0fxlqjI6fJsgHGS13iTuVT28kViI4JjUiNqp/vyis0ZXYcMnpR3fzGNkv+6vRlI2GwdQ== +snake-case@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-2.1.0.tgz#41bdb1b73f30ec66a04d4e2cad1b76387d4d6d9f" + integrity sha1-Qb2xtz8w7GagTU4srRt2OH1NbZ8= + dependencies: + no-case "^2.2.0" + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -13675,6 +13959,11 @@ sort-keys@^2.0.0: dependencies: is-plain-obj "^1.0.0" +source-list-map@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-1.1.2.tgz#9889019d1024cce55cdc069498337ef6186a11a1" + integrity sha1-mIkBnRAkzOVc3AaUmDN+9hhqEaE= + source-list-map@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" @@ -13709,7 +13998,7 @@ source-map@0.7.3, source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -source-map@^0.5.0, source-map@^0.5.6, source-map@^0.5.7: +source-map@^0.5.0, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.3: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= @@ -13882,6 +14171,17 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" +static-site-generator-webpack-plugin@^3.4.2: + version "3.4.2" + resolved "https://registry.yarnpkg.com/static-site-generator-webpack-plugin/-/static-site-generator-webpack-plugin-3.4.2.tgz#ad9fd0a4fb8b6f439a7a66018320b459bdb6d916" + integrity sha512-39Kn+fZDVjolLYuX5y1rDvksJIW0QEUaEC/AVO/UewNXxGzoSQI1UYnRsL+ocAcN5Yti6d6rJgEL0qZ5tNXfdw== + dependencies: + bluebird "^3.0.5" + cheerio "^0.22.0" + eval "^0.1.0" + url "^0.11.0" + webpack-sources "^0.2.0" + "statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" @@ -14313,6 +14613,14 @@ svgo@1.3.2, svgo@^1.0.0: unquote "~1.1.1" util.promisify "~1.0.0" +swap-case@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/swap-case/-/swap-case-1.1.2.tgz#c39203a4587385fad3c850a0bd1bcafa081974e3" + integrity sha1-w5IDpFhzhfrTyFCgvRvK+ggZdOM= + dependencies: + lower-case "^1.1.1" + upper-case "^1.1.1" + symbol-observable@^1.0.4, symbol-observable@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" @@ -14553,6 +14861,14 @@ tinycolor2@^1.4.1: resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8" integrity sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g= +title-case@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/title-case/-/title-case-2.1.1.tgz#3e127216da58d2bc5becf137ab91dae3a7cd8faa" + integrity sha1-PhJyFtpY0rxb7PE3q5Ha46fNj6o= + dependencies: + no-case "^2.2.0" + upper-case "^1.0.3" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -14963,7 +15279,7 @@ unist-util-generated@^1.0.0, unist-util-generated@^1.1.0: resolved "https://registry.yarnpkg.com/unist-util-generated/-/unist-util-generated-1.1.5.tgz#1e903e68467931ebfaea386dae9ea253628acd42" integrity sha512-1TC+NxQa4N9pNdayCYA1EGUOCAO0Le3fVp7Jzns6lnua/mYgwHo0tz5WUAfrdpNch1RZLHc61VZ1SDgrtNXLSw== -unist-util-is@^2.0.0: +unist-util-is@^2.0.0, unist-util-is@^2.1.2: version "2.1.3" resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-2.1.3.tgz#459182db31f4742fceaea88d429693cbf0043d20" integrity sha512-4WbQX2iwfr/+PfM4U3zd2VNXY+dWtZsN1fLnWEi2QQXA4qyDYAZcDMfXUX0Cu6XZUHHAO9q4nyxxLT4Awk1qUA== @@ -14978,6 +15294,13 @@ unist-util-is@^4.0.0: resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-4.0.2.tgz#c7d1341188aa9ce5b3cff538958de9895f14a5de" integrity sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ== +unist-util-map@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/unist-util-map/-/unist-util-map-1.0.5.tgz#701069b72e1d1cc02db265502a5e82b77c2eb8b7" + integrity sha512-dFil/AN6vqhnQWNCZk0GF/G3+Q5YwsB+PqjnzvpO2wzdRtUJ1E8PN+XRE/PRr/G3FzKjRTJU0haqE0Ekl+O3Ag== + dependencies: + object-assign "^4.0.1" + unist-util-modify-children@^1.0.0: version "1.1.6" resolved "https://registry.yarnpkg.com/unist-util-modify-children/-/unist-util-modify-children-1.1.6.tgz#1587130ca0ab5c56155fa60837ff524c3fbfbfaa" @@ -15004,6 +15327,13 @@ unist-util-remove-position@^2.0.0: dependencies: unist-util-visit "^2.0.0" +unist-util-remove@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/unist-util-remove/-/unist-util-remove-1.0.3.tgz#58ec193dfa84b52d5a055ffbc58e5444eb8031a3" + integrity sha512-mB6nCHCQK0pQffUAcCVmKgIWzG/AXs/V8qpS8K72tMPtOSCMSjDeMc5yN+Ye8rB0FhcE+JvW++o1xRNc0R+++g== + dependencies: + unist-util-is "^3.0.0" + unist-util-remove@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/unist-util-remove/-/unist-util-remove-2.0.0.tgz#32c2ad5578802f2ca62ab808173d505b2c898488" @@ -15126,6 +15456,18 @@ update-notifier@^3.0.1: semver-diff "^2.0.0" xdg-basedir "^3.0.0" +upper-case-first@^1.1.0, upper-case-first@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/upper-case-first/-/upper-case-first-1.1.2.tgz#5d79bedcff14419518fd2edb0a0507c9b6859115" + integrity sha1-XXm+3P8UQZUY/S7bCgUHybaFkRU= + dependencies: + upper-case "^1.1.1" + +upper-case@^1.0.3, upper-case@^1.1.0, upper-case@^1.1.1, upper-case@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598" + integrity sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg= + uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" @@ -15494,6 +15836,14 @@ webpack-merge@^4.2.2: dependencies: lodash "^4.17.15" +webpack-sources@^0.2.0: + version "0.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" + integrity sha1-F8Yr+vE8cH+dAsR54Nzd6DgGl/s= + dependencies: + source-list-map "^1.1.1" + source-map "~0.5.3" + webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1: version "1.4.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" -- 2.46.0 From 42d664328584dea85f9e9aabc98380d8606f22b1 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Wed, 17 Jun 2020 16:10:45 -0700 Subject: [PATCH 95/97] convert details to spoiler tag --- Content Documentation.md | 5 +++-- content/2_General/Proposing.md | 8 ++------ content/2_General/Why_Cpp.md | 17 ++++++----------- content/3_Bronze/Rect_Geo.md | 12 ++++-------- content/6_Plat/Fracture.md | 18 ++++++------------ content/6_Plat/Slope.md | 18 ++++++------------ gatsby-browser.js | 23 +++++++++++------------ src/styles/markdown.css | 15 ++++----------- 8 files changed, 42 insertions(+), 74 deletions(-) diff --git a/Content Documentation.md b/Content Documentation.md index da49b85..78661b7 100644 --- a/Content Documentation.md +++ b/Content Documentation.md @@ -72,9 +72,10 @@ This will render as a list in the homepage, but won't appear in the article. Spoilers are collapsible elements that only show themselves when the user clicks on it. It's useful when writing solutions to problems. The styling of the spoilers is still a work in progress (especially for spoilers in lists). +// TODO update spoiler docs to reflect new tag + ``` -
- Show Solution + - Insert OP benq solution here
diff --git a/content/2_General/Proposing.md b/content/2_General/Proposing.md index 153ceee..4c5c1d4 100644 --- a/content/2_General/Proposing.md +++ b/content/2_General/Proposing.md @@ -15,9 +15,7 @@ Email your proposal to Professor Dean. In the [past](http://www.usaco.org/index. - All problems should have 10 test cases at minimum (I believe that the maximum was 21 for [valleys](http://www.usaco.org/index.php?page=viewproblem2&cpid=950)). You do not need to include these in your proposal. - All statements must eventually be converted to the following format. It's not required, but please save us time by following it as best you can. -
- -2020 Open Gold - Favorite Colors + ``` http://www.usaco.org/index.php?page=viewproblem2&cpid=1042 @@ -25,8 +23,6 @@ bolded text should be surrounded by [b][/b], italics by [i][/i] use [ol][/ol] for numbered list --- - - Each of Farmer John's $N$ cows ($1\le N\le 2\cdot 10^5$) has a favorite color. The cows are conveniently labeled $1\ldots N$ (as always), and each color can be represented by an integer in the range $1\ldots N$. @@ -73,4 +69,4 @@ favorite color 1. [/section] ``` -
\ No newline at end of file + \ No newline at end of file diff --git a/content/2_General/Why_Cpp.md b/content/2_General/Why_Cpp.md index 1c6cdb0..81752b9 100644 --- a/content/2_General/Why_Cpp.md +++ b/content/2_General/Why_Cpp.md @@ -16,9 +16,7 @@ Although both Python and Java receive two times the C++ time limit in USACO, thi - Rewriting the C++ solution for [USACO Silver Wormsort](http://www.usaco.org/index.php?page=viewproblem2&cpid=992) in Python receives TLE (Time Limit Exceeded) on 2/10 cases. I'm not sure whether it is possible to pass this problem with Python. -
- - Python3 8/10 Solution + ```py # 8/10 test cases ... @@ -91,13 +89,11 @@ Although both Python and Java receive two times the C++ time limit in USACO, thi fout.write('\n') ``` -
+ - A similar solution in Java requires almost 3s, which is fairly close to the time limit of 4s. -
- - Java Solution + ```java import java.io.*; // from Nick Wu @@ -167,12 +163,11 @@ Although both Python and Java receive two times the C++ time limit in USACO, thi } ``` -
+ - A comparable C++ solution runs in less than 700ms. -
- C++ Solution + ```cpp #include @@ -228,7 +223,7 @@ Although both Python and Java receive two times the C++ time limit in USACO, thi cout << minW; } ``` -
+ ## Other Notes diff --git a/content/3_Bronze/Rect_Geo.md b/content/3_Bronze/Rect_Geo.md index c34f7d2..90cb5c6 100644 --- a/content/3_Bronze/Rect_Geo.md +++ b/content/3_Bronze/Rect_Geo.md @@ -36,9 +36,7 @@ This class can often lessen the implementation needed in a lot of bronze problem For example, here is a nice implementation of the problem [Blocked Billboard](http://usaco.org/index.php?page=viewproblem2&cpid=759) ([editorial](http://www.usaco.org/current/data/sol_billboard_bronze_dec17.html)). -
- -Java Solution + ```java import java.awt.Rectangle; //needed to use Rectangle class @@ -78,15 +76,13 @@ public class blockedBillboard{ } ``` -
+ ## Rectangle Class (C++) Unfortunately, C++ doesn't have a built in rectangle class, so you need to write the functions yourself. Here is the solution to Blocked Billboard written in C++ (thanks, Brian Dean!). -
- -C++ Solution + ```cpp #include @@ -121,7 +117,7 @@ int main(){ } ``` -
+ ## Problems diff --git a/content/6_Plat/Fracture.md b/content/6_Plat/Fracture.md index 9b65364..98158ee 100644 --- a/content/6_Plat/Fracture.md +++ b/content/6_Plat/Fracture.md @@ -69,9 +69,7 @@ for each $i\in [1,N-1]$. Every spanning tree other than the root is contained wi Overall, the runtime is $O(NMK\alpha(N))$ for storing the information about each spanning tree and $O(NK\log (NK))$ for maintaing the priority queue of objects so that we can extract the minimum. Note that with the second approach mentioned in the first section the running time would instead be $O(NMK\alpha(N)\log ans)$, which may be too slow. -
- -My Solution + ```cpp #include @@ -128,7 +126,7 @@ int main() { } ``` -
+ ## [USACO Robotic Cow Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=674) @@ -145,9 +143,7 @@ Importantly, we should then sort the locations by their respective second-minimu Binary search on the cost $c$ of the $K$-th robot. If we can compute the costs of all robots with cost at most $c$ or say that there are more than $K$ in $O(K)$ time, then we can solve this problem in $O(N\log N+K\log \max(c))$ time (similar to "Approach 2" above). This is the approach that the first analysis solution takes, although it includes an extra $\log N$ factor due to `upper_bound`. I have removed this in my solution below. -
- -My Solution 1 + ```cpp #include @@ -206,7 +202,7 @@ int main() { } ``` -
+ ## Approach 2 @@ -242,9 +238,7 @@ None of these options can result in a robot of lower cost. In general, suppose t Since there exists exactly one way to get from the cheapest robot to every possible robot, we can just use a priority queue. -
- -My Solution 2 + ```cpp #include @@ -292,7 +286,7 @@ int main() { } ``` -
+ ## Other Problems diff --git a/content/6_Plat/Slope.md b/content/6_Plat/Slope.md index 1eed4bb..7ae5052 100644 --- a/content/6_Plat/Slope.md +++ b/content/6_Plat/Slope.md @@ -45,9 +45,7 @@ We'll process the shares in order. Suppose that on the current day shares are wo The implementation is quite simple; maintain a priority queue that allows you to pop the minimum element. -
- -My Solution + ```cpp #include @@ -68,7 +66,7 @@ int main() { cout << ans << "\n"; } ``` -
+ ## [Potatoes](https://oj.uz/problem/view/LMIO19_bulves) @@ -83,9 +81,7 @@ As before, this DP is concave up for a fixed $i$! Given a piecewise linear funct Again, these can be done with a priority queue in $O(N\log N)$ time! -
- -My Solution + ```cpp #include @@ -119,7 +115,7 @@ int main() { } ``` -
+ ## [Landscaping](http://www.usaco.org/index.php?page=viewproblem2&cpid=650) @@ -143,9 +139,7 @@ If we maintain separate deques for $dif$ depending on whether $j\ge 0$ or $j<0$ Bonus: Solve this problem when $\sum A_i+\sum B_i$ is not so small. -
- -My Solution + ```cpp #include @@ -184,7 +178,7 @@ int main() { cout << ans << "\n"; } ``` -
+ ## Problems diff --git a/gatsby-browser.js b/gatsby-browser.js index e57533d..6ce0b90 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -2,13 +2,19 @@ import "./src/styles/main.css"; import React from "react"; import { MDXProvider } from "@mdx-js/react"; -const SpoilerComponent = ({ children }) => { +const SpoilerComponent = ({ children, title }) => { const [show, setShow] = React.useState(false); return ( -
{if (e.target.classList.contains("spoiler-label")) setShow(!show) }}> - {children} +
+

setShow(!show)} style={{ marginBottom: 0 }}> + {show && } + {!show && } + {title} +

+ + {show &&
{children}
}
); }; @@ -25,14 +31,7 @@ const components = { return children; }, "module-excerpt": (props) =>
, - details: SpoilerComponent, - summary: ({ children }) => ( -

- - - {children} -

- ), + spoiler: SpoilerComponent, "info-block": ({ children }) => (
diff --git a/src/styles/markdown.css b/src/styles/markdown.css index 30eb985..4cc09da 100644 --- a/src/styles/markdown.css +++ b/src/styles/markdown.css @@ -137,17 +137,10 @@ display: none; } -.spoiler--hide > *:not(.spoiler-label) { - display: none; -} -.spoiler--hide .spoiler-label__open { - display: none; -} -.spoiler--show .spoiler-label__closed { - display: none; -} -.spoiler-label { - margin-bottom: 0 !important; +.spoiler-body pre { + margin-left: -1rem !important; + margin-right: -1rem !important; + margin-bottom: -1rem !important; } .info-block .custom-block-heading { -- 2.46.0 From 1f97f0adf07a8195d04371e9cbe1784f7e153380 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Wed, 17 Jun 2020 19:49:21 -0700 Subject: [PATCH 96/97] remove cards --- gatsby-node.esm.js | 1 - src/templates/syllabusTemplate.js | 216 +++++++++++++----------------- 2 files changed, 96 insertions(+), 121 deletions(-) diff --git a/gatsby-node.esm.js b/gatsby-node.esm.js index d1d98b5..7e19be0 100644 --- a/gatsby-node.esm.js +++ b/gatsby-node.esm.js @@ -1,4 +1,3 @@ -import { getModule } from "./src/utils"; import ModuleOrdering, { divisions } from "./content/ordering"; exports.createPages = async ({ actions, graphql, reporter }) => { diff --git a/src/templates/syllabusTemplate.js b/src/templates/syllabusTemplate.js index 1836762..cec0d59 100644 --- a/src/templates/syllabusTemplate.js +++ b/src/templates/syllabusTemplate.js @@ -2,34 +2,10 @@ import React from "react" import Layout from "../components/layout" import SEO from "../components/seo" -import SyllabusModule from "../components/SyllabusModule"; import { graphql, Link } from "gatsby"; -import Markdown from "../components/Markdown"; -import ModuleOrdering, { divisionLabels, divisions } from "../../content/ordering"; +import { divisionLabels, divisions } from "../../content/ordering"; import { getModule } from "../utils"; -const renderModule = (node, idx, parentIdx = -1) => { - if (node.hasOwnProperty("items")) { - return node.items.map((x, i) => renderModule(x, i, idx)); - } - - const data = node.frontmatter; - if (!data.title) return; - - return ( - - - - ); -}; - export default function Template(props) { const data = props.data; @@ -79,111 +55,112 @@ export default function Template(props) { - {/* Begin Hero Section */} -
-
-
- - - - - - - - - - - - - - - - +
+ + {/* Begin Hero Section */} +
+
+
+ + + + + + + + + + + + + + + + +
-
-
-
-
-

- USACO Guide -

-

- A collection of curated, high-quality resources to take you from Bronze to Platinum. -

-
-
- - About This Guide - +
+
+
+

+ USACO Guide +

+

+ A collection of curated, high-quality resources to take you from Bronze to Platinum. +

+
+
+ + About This Guide + +
-
- {/* End Hero Section */} + {/* End Hero Section */} -
-
-
-
- -
- +
+
+
+
+ +
+ -
    - {module.map((m, idx) => { - if (m.hasOwnProperty("items")) { +
      + {module.map((m, idx) => { + if (m.hasOwnProperty("items")) { + return ( +
    1. + {idx+1}. {m.name} +
        + {m.items.map((m, idx2) => ( +
      1. + {idx+1}.{idx2+1}. {m.frontmatter.title} +
      2. + ))} +
      +
    2. + ) + } return ( -
    3. - {idx+1}. {m.name} -
        - {m.items.map((m, idx2) => ( -
      1. - {idx+1}.{idx2+1}. {m.frontmatter.title} -
      2. - ))} -
      +
    4. + {idx+1}. {m.frontmatter.title}
    5. - ) - } - return ( -
    6. - {idx+1}. {m.frontmatter.title} -
    7. - ); - })} -
    + ); + })} +
+
- - {module.map((x, idx) => renderModule(x, idx))}
@@ -202,7 +179,6 @@ export const pageQuery = graphql` problems prerequisites } - body } } } -- 2.46.0 From 4083bbf72eb2e37f3065ffcc18208050685c3478 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Thu, 18 Jun 2020 10:08:18 -0700 Subject: [PATCH 97/97] add description field --- content/1_Intro/Data_Types.md | 1 + content/1_Intro/Getting_Started.md | 1 + src/templates/syllabusTemplate.js | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/content/1_Intro/Data_Types.md b/content/1_Intro/Data_Types.md index 268fd9c..7af4eb9 100644 --- a/content/1_Intro/Data_Types.md +++ b/content/1_Intro/Data_Types.md @@ -2,6 +2,7 @@ id: data-types title: Data Types author: Darren Yao +description: Learn about the basic data types needed for competitive programming. --- diff --git a/content/1_Intro/Getting_Started.md b/content/1_Intro/Getting_Started.md index 6b4a6ed..a138b2e 100644 --- a/content/1_Intro/Getting_Started.md +++ b/content/1_Intro/Getting_Started.md @@ -2,6 +2,7 @@ id: getting-started title: Getting Started author: Nathan Wang, Benjamin Qi, Darren Yao +description: Welcome to the guide! Here we'll explain what a programming competition is, how it works, and how to choose a language. --- diff --git a/src/templates/syllabusTemplate.js b/src/templates/syllabusTemplate.js index cec0d59..0592e9c 100644 --- a/src/templates/syllabusTemplate.js +++ b/src/templates/syllabusTemplate.js @@ -5,6 +5,29 @@ import SEO from "../components/seo" import { graphql, Link } from "gatsby"; import { divisionLabels, divisions } from "../../content/ordering"; import { getModule } from "../utils"; +import SyllabusModule from "../components/SyllabusModule"; + +const renderModule = (node, idx, parentIdx = -1) => { + if (node.hasOwnProperty("items")) { + return node.items.map((x, i) => renderModule(x, i, idx)); + } + + const data = node.frontmatter; + if (!data.title) return; + + return ( + + {data.description} + + ); +}; export default function Template(props) { const data = props.data; @@ -160,6 +183,8 @@ export default function Template(props) { })}
+ + {module.map((x, idx) => renderModule(x, idx))}
@@ -178,6 +203,7 @@ export const pageQuery = graphql` author problems prerequisites + description } } } -- 2.46.0