This commit is contained in:
Benjamin Qi 2020-06-15 21:44:03 -04:00
parent 0c521b8cb3
commit 7cbdfba674
17 changed files with 43 additions and 43 deletions

View file

@ -13,17 +13,16 @@ author: Nathan Wang, Benjamin Qi
## Goals ## Goals
- Intended audience: anybody in Bronze - Gold. - Intended audience: anybody in Bronze - Gold.
- We are **not** teaching people how to code (but we'll provide some links for this purpose). - We are **not** teaching people how to code (but some resources for this purpose are provided in "Prerequisites").
- should be a "one stop shop," meaning that this is the only site they have to use. - should be a "one stop shop," meaning that this is the only site they have to use.
- The idea is that people will no longer have to go resource hunting as well do all of that for them. - The idea is that people will no longer have to go resource hunting as well do all of that for them.
- For Bronze - Gold, most but not all problems on monthly contests will fall into the categories that we have designated. For Platinum, there are no guarantees. - For Bronze - Gold, most but not all problems on monthly contests will fall into the categories that we have designated. For Platinum, there are no guarantees.
- Note that topics may cross divisions without warning! (ex. Gold seems to have more and more tree problems that used to be confined to Platinum). - Note that topics may cross divisions without warning! (ex. Gold seems to have more and more tree problems that used to be confined to Platinum).
- Material will be grouped into **modules**. - Material will be grouped into **modules**.
- USACO-Focused: generally avoid covering topics that will not appear on USACO or IOI. - USACO-Focused: Modules should generally stick to topics that can appear on USACO or IOI.
- Maybe designate some "optional" modules.
- "Dont Reinvent the Wheel" - "Dont Reinvent the Wheel"
- Should set guidelines as to what counts and what doesnt.
- Link to online resources that already exist. - Link to online resources that already exist.
- Should set guidelines as to what counts and what doesnt.
- Not *just* a collection of links - Not *just* a collection of links
- There exist plenty of resources out there. While we can link to all of them, we should not expect users to click through all of them to find the information they want. This means in addition to links we need to provide information about what the link talks about, as well as the quality of the link. - There exist plenty of resources out there. While we can link to all of them, we should not expect users to click through all of them to find the information they want. This means in addition to links we need to provide information about what the link talks about, as well as the quality of the link.
- We dont want to say something like “learn DP, here are 50 links that can teach you that.” Instead, we want to say “learn DP by first reading this one article, then reading this other article. For reference, here are some other links you can explore as you wish.” - We dont want to say something like “learn DP, here are 50 links that can teach you that.” Instead, we want to say “learn DP by first reading this one article, then reading this other article. For reference, here are some other links you can explore as you wish.”
@ -37,8 +36,8 @@ author: Nathan Wang, Benjamin Qi
- Everything should be completed in order. - Everything should be completed in order.
- Any problems here should be pure implementation. - Any problems here should be pure implementation.
- Languages - Languages
- Include C++, Java, Python for Bronze. - Include C++ and Java for all divisions. (C++ takes priority)
- Include C++, Java for Silver and beyond (C++ takes priority) - Possibly Python for Bronze.
### Practice ### Practice

View file

@ -12,12 +12,12 @@ There are several main **data types** that are used in contests: 32-bit and 64-b
- CPH 1.1 - 1.3 - CPH 1.1 - 1.3
The 32-bit integer supports values between $-2\,147\,483\,648$ and $2\,147\,483\,647$, which is roughly equal to $\pm$ $2 \times 10^9$. If the input, output, or \textit{any intermediate values used in calculations} exceed the range of a 32-bit integer, then a 64-bit integer must be used. The range of the 64-bit integer is between $-9\,223\,372\,036\,854\,775\,808$ and $9\,223\,372\,036\,854\,775\,807$ which is roughly equal to $\pm$ $9 \times 10^{18}$. Contest problems are usually set such that the 64-bit integer is sufficient. If it's not, the problem will ask for the answer modulo $m$, instead of the answer itself, where $m$ is a prime. In this case, make sure to use 64-bit integers, and take the remainder of $x$ modulo $m$ after every step using `x %= m;`. The **32-bit integer** supports values between $-2\,147\,483\,648$ and $2\,147\,483\,647$, which is roughly equal to $\pm$ $2 \times 10^9$. If the input, output, or \textit{any intermediate values used in calculations} exceed the range of a 32-bit integer, then a **64-bit integer** must be used. The range of the 64-bit integer is between $-9\,223\,372\,036\,854\,775\,808$ and $9\,223\,372\,036\,854\,775\,807$ which is roughly equal to $\pm$ $9 \times 10^{18}$. Contest problems are usually set such that the 64-bit integer is sufficient. If it's not, the problem will ask for the answer modulo $m$, instead of the answer itself, where $m$ is a prime. In this case, make sure to use 64-bit integers, and take the remainder of $x$ modulo $m$ after every step using `x %= m;`.
Floating point numbers are used to store decimal values. It is important to know that floating point numbers are not exact, because the binary architecture of computers can only store decimals to a certain precision. Hence, we should always expect that floating point numbers are slightly off. Contest problems will accommodate this by either asking for the greatest integer less than $10^k$ times the value, or will mark as correct any output that is within a certain $\epsilon$ of the judge's answer. **Floating point numbers** are used to store decimal values. It is important to know that floating point numbers are not exact, because the binary architecture of computers can only store decimals to a certain precision. Hence, we should always expect that floating point numbers are slightly off. Contest problems will accommodate this by either asking for the greatest integer less than $10^k$ times the value, or will mark as correct any output that is within a certain $\epsilon$ of the judge's answer.
Boolean variables have two possible states: `true` and `false`. We'll usually use booleans to mark whether a certain process is done, and arrays of booleans to mark which components of an algorithm have finished. **Boolean** variables have two possible states: `true` and `false`. We'll usually use booleans to mark whether a certain process is done, and arrays of booleans to mark which components of an algorithm have finished.
Character variables represent a single Unicode character. They are returned when you access the character at a certain index within a string. Characters are represented using the ASCII standard, which assigns each character to a corresponding integer. This allows us to do arithmetic with them; for example, both `cout << ('f' - 'a');` in C++ and `System.out.print('f' - 'a');` in Java will print `5`. **Character** variables represent a single Unicode character. They are returned when you access the character at a certain index within a string. Characters are represented using the ASCII standard, which assigns each character to a corresponding integer. This allows us to do arithmetic with them; for example, both `cout << ('f' - 'a');` in C++ and `System.out.print('f' - 'a');` in Java will print `5`.
Strings are stored as an array of characters. You can easily access the character at a certain index and take substrings of the string. String problems on USACO are generally very easy and don't involve any special data structures. **Strings** are stored as an array of characters. You can easily access the character at a certain index and take substrings of the string. String problems on USACO Bronze or Silver generally don't involve any special data structures.

View file

@ -7,6 +7,11 @@ problems:
- bronze_word - bronze_word
- bronze_paint - bronze_paint
- bronze_square - bronze_square
prerequisites:
-
- Intro - Data Types
-
- Intro - Input & Output
--- ---
Solutions for an example USACO problem in multiple languages. Solutions for an example USACO problem in multiple languages.
@ -70,11 +75,6 @@ int main() {
### Java ### Java
(link?)
(Scanner?)
(FastScanner?)
Class name can be whatever you want. (?) Class name can be whatever you want. (?)
@ -103,6 +103,7 @@ public class paintSol { // must be declared in paintSol.java
``` ```
Alternatively, an InputReader class that functions very similarly to Scanner but has the faster runtime of BufferedReader. Alternatively, an InputReader class that functions very similarly to Scanner but has the faster runtime of BufferedReader.
```java ```java
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;

View file

@ -10,14 +10,9 @@ author: Nathan Wang, Benjamin Qi, Darren Yao
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->
Todo:
- Video clip from Brian Dean?
## Introduction ## 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: coming up with the algorithm, which involves problem solving skills and intuition, and implementing the algorithm, which requires programming skills to translate the algorithm into working code. 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: coming up with the algorithm, which involves problem solving skills and intuition, and 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 and a memory limit that your program must satisfy. 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 and a memory limit that your program must satisfy.

View file

@ -10,16 +10,14 @@ Demonstrates how to read input and print output for USACO.
## C++ ## C++
In CodeForces and CSES, input and output are standard, meaning that using the library [<iostream>](http://www.cplusplus.com/reference/iostream/) suffices. In CodeForces and CSES, input and output are **standard**, meaning that using the library [\<iostream\>](http://www.cplusplus.com/reference/iostream/) suffices.
However, in USACO, input is read from a file called `problemname.in`, and printing output to a file called `problemname.out`. Note that you'll have to rename the `.in` and `.out` files. You will need the [<cstdio>](http://www.cplusplus.com/reference/cstdio/) or the [<fstream>](http://www.cplusplus.com/reference/fstream/) library. Essentially, replace every instance of the word *template* in the word below with the input/output file name, which should be given in the problem. However, in USACO, input is read from a file called `problemname.in`, and printing output to a file called `problemname.out`. Note that you'll have to rename the `.in` and `.out` files. You will need the [\<cstdio\>](http://www.cplusplus.com/reference/cstdio/) or the [\<fstream\>](http://www.cplusplus.com/reference/fstream/) library. Essentially, replace every instance of the word *template* in the word below with the input/output file name, which should be given in the problem.
In order to test a program, create a file called `problemname.in`, and then run the program. The output will be printed to `problemname.out`. In order to test a program, create a file called `problemname.in`, and then run the program. The output will be printed to `problemname.out`.
Below, we have included C++ templates for input and output. We use `using namespace std;` so that we don't have to preface standard library functions with `std::` each time we use them. Below, we have included C++ templates for input and output. We use `using namespace std;` so that we don't have to preface standard library functions with `std::` each time we use them.
For USACO:
If `<cstdio>` is used: If `<cstdio>` is used:
```cpp ```cpp

View file

@ -1,7 +1,7 @@
--- ---
id: practicing id: practicing
title: How to Practice title: How to Practice
author: Benjamin Qi, William Lin, Eric Wei, Nathan Wang, Nathan Chen, Darren Yao author: Many
--- ---
How to practice, when to read editorials (analyses), etc. How to practice, when to read editorials (analyses), etc.

View file

@ -4,11 +4,13 @@ title: Proposing Problems for USACO Monthlies
author: Benjamin Qi author: Benjamin Qi
--- ---
Anyone can propose problems for monthly contests (email your proposal to Professor Dean). Anyone can propose problems for monthly contests.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->
In the [past](http://www.usaco.org/index.php?page=viewproblem2&cpid=817), contestants have even written problems for their own divisions! 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 statements must eventually be converted to the following format; please save us time by following it as best you can.

View file

@ -4,7 +4,7 @@ title: Additional Resources
author: Benjamin Qi author: Benjamin Qi
--- ---
Helpful Links! Some (such as CPH and Intro to USACO) will be mentioned again in later modules. Helpful Links! Some (such as **CPH** and **Intro to USACO**) will be mentioned again in later modules.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->

View file

@ -4,7 +4,7 @@ title: Built-In C++ Containers
author: Darren Yao author: Darren Yao
--- ---
Introduces the data structures in the C++ standard library that are frequently used in competitive programming. Introduces C++ [containers](http://www.cplusplus.com/reference/stl/) that are frequently used in competitive programming.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->

View file

@ -12,9 +12,10 @@ Problems and additional resources regarding built-in data structures.
## Problems ## Problems
**CSES:** **CSES:**
Do roughly the first half of the Sorting and Searching section in the [CSES Problem Set](https://cses.fi/problemset/) Do roughly the first half of the Sorting and Searching section in the [CSES Problem Set](https://cses.fi/problemset/)
(actually go through these ...) (actually go through these and check ...)
**Stack:**: **Stack:**:
- UVa 00514 - Rails - UVa 00514 - Rails

View file

@ -4,7 +4,7 @@ title: Built-In Java Collections
author: Darren Yao author: Darren Yao
--- ---
Introduces the data structures in the Java standard library that are frequently used in competitive programming. 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.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->

View file

@ -4,12 +4,11 @@ title: "Simulation"
author: Darren Yao author: Darren Yao
--- ---
In many problems, we can simply simulate what we're told to do by the problem statement. In many problems, we can **simulate** what we're told to do by the problem statement.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->
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.
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.
## Example 1 ## Example 1

View file

@ -42,6 +42,7 @@ Other variations are similar, such as the following:
- [upper_bound](http://www.cplusplus.com/reference/algorithm/upper_bound/) - [upper_bound](http://www.cplusplus.com/reference/algorithm/upper_bound/)
### Problems ### Problems
- [USACO Silver Counting Haybales](http://www.usaco.org/index.php?page=viewproblem2&cpid=666) - [USACO Silver Counting Haybales](http://www.usaco.org/index.php?page=viewproblem2&cpid=666)
## Binary Searching on the Answer ## Binary Searching on the Answer

View file

@ -4,14 +4,18 @@ title: "Greedy Algorithms"
author: Darren Yao author: Darren Yao
--- ---
**Greedy algorithms** are algorithms that 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** 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.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->
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.
Usually, when using a greedy algorithm, there is a heuristic or value function that determines which choice is considered most optimal.
(convert Intro to USACO Chapter 9, Interval Cover)
# Tutorials # Tutorials
- Intro to USACO, Chapter 9
- Interval Cover
- CPH 6 - CPH 6
- [CPC.5](https://github.com/SuprDewd/T-414-AFLV/tree/master/05_greedy_algorithms) - [CPC.5](https://github.com/SuprDewd/T-414-AFLV/tree/master/05_greedy_algorithms)

View file

@ -4,7 +4,7 @@ title: "Sorting"
author: Siyong (WIP) author: Siyong (WIP)
prerequisites: prerequisites:
- -
- Silver - Containers - Bronze - Data Structures
--- ---
<div class="syllabus-only"> <div class="syllabus-only">
Description: Todo Description: Todo

View file

@ -10,7 +10,7 @@ prerequisites:
A **Binary Indexed Tree** allows you to perform the following tasks in $O(\log N)$ time each on an array of size $N$: 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). - Update the element at a single position (point).
- Querying the sum of a prefix of the array. - Query the sum of a prefix of the array.
<!-- END DESCRIPTION --> <!-- END DESCRIPTION -->

View file

@ -1,7 +1,7 @@
const ModuleOrdering = { const ModuleOrdering = {
"intro": [ "intro": [
"about-this",
"getting-started", "getting-started",
"about-this",
"prereqs", "prereqs",
"running-cpp", "running-cpp",
"data-types", "data-types",
@ -38,8 +38,8 @@ const ModuleOrdering = {
"sorting", "sorting",
"binary-search", "binary-search",
"2P", "2P",
"prefix-sums",
"data-structures", "data-structures",
"prefix-sums",
"dfs" "dfs"
], ],
"gold": [ "gold": [