From 0fd724f811b6b8653a02cf71f44e8ebdd4bec498 Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Sun, 28 Jun 2020 18:11:04 -0700 Subject: [PATCH 1/2] add embedded resources table and resources table with no source --- .../{Running_Cpp.md => Running_Cpp.mdx} | 34 ++++++++----- content/6_Plat/HLD.mdx | 2 + src/components/markdown/Resources.tsx | 51 ++++++++++--------- 3 files changed, 51 insertions(+), 36 deletions(-) rename content/1_Intro/{Running_Cpp.md => Running_Cpp.mdx} (88%) diff --git a/content/1_Intro/Running_Cpp.md b/content/1_Intro/Running_Cpp.mdx similarity index 88% rename from content/1_Intro/Running_Cpp.md rename to content/1_Intro/Running_Cpp.mdx index dfe2176..72386fd 100644 --- a/content/1_Intro/Running_Cpp.md +++ b/content/1_Intro/Running_Cpp.mdx @@ -27,19 +27,27 @@ You can share code with [pastebin](https://pastebin.com/) or [hastebin](https:// These often have C++ support already built-in. - - [Visual Studio Code](https://code.visualstudio.com/) - - lightweight, fast IDE, but requires some configuration - - see [PAPC Ch 2.1](http://www.csc.kth.se/~jsannemo/slask/main.pdf) for setup instructions - - [Visual Studio](https://visualstudio.microsoft.com/vs/) - - heavier cousin of VS Code, VS Code is better for competitive programming - - [Geany](https://www.geany.org/) - - Ben: I used at IOI - - [Codeblocks](http://www.codeblocks.org/) - - bad on Mac - - [XCode](https://developer.apple.com/xcode/) - - Mac only - - [CLion](https://www.jetbrains.com/clion/) - - requires a license, but [free for students](https://www.jetbrains.com/community/education/#students) + + + Lightweight, fast IDE, but requires some configuration. See PAPC Ch 2.1 for setup instructions. + + + Heavier cousin of VS Code, VS Code is better for competitive programming + + + Ben: I used at IOI + + + Bad on Mac + + + Macs Only + + + requires a license, but free for students + + + # Using Command Line diff --git a/content/6_Plat/HLD.mdx b/content/6_Plat/HLD.mdx index 60310cc..23e6119 100644 --- a/content/6_Plat/HLD.mdx +++ b/content/6_Plat/HLD.mdx @@ -24,6 +24,7 @@ export const metadata = { new Problem("HR", "Subtrees & Paths", "https://www.hackerrank.com/challenges/subtrees-and-paths", "Easy", false, ["HLD"], ""), new Problem("CF", "Tree Queries", "contest/1254/problem/D", "Normal", false, ["HLD"], ""), new Problem("ojuz", "JOI - Cats or Dogs", "https://oj.uz/problem/view/JOI18_catdog", "Hard", false, ["HLD"], ""), + new Problem("wcipeg", "COI 08-Otoci", "https://wcipeg.com/problem/coi08p2", "Hard", false, ["HLD"], "editorial available online"), ], } }; @@ -36,6 +37,7 @@ export const metadata = { explains what HLD is (but incomplete & overly complicated code) + ## Problems diff --git a/src/components/markdown/Resources.tsx b/src/components/markdown/Resources.tsx index cb45ce3..1f899db 100644 --- a/src/components/markdown/Resources.tsx +++ b/src/components/markdown/Resources.tsx @@ -2,31 +2,34 @@ import * as React from 'react'; import Dots from '../Dots'; export function ResourcesListComponent(props) { + const embedded = props.embedded; + const noSource = 'noSource' in props ? props.noSource : false; return (
-
-
+
+
@@ -70,10 +73,12 @@ export function ResourceComponent(props) { } return ( - - + )} + - From 76346a331aa661b77f122b9d9a5e37cb30422510 Mon Sep 17 00:00:00 2001 From: Hankai Zhang Date: Sun, 28 Jun 2020 21:13:40 -0400 Subject: [PATCH 2/2] Input and output using scanf/printf; minor addition to data types. --- content/1_Intro/Data_Types.md | 2 +- content/1_Intro/Input_Output.md | 38 +++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/content/1_Intro/Data_Types.md b/content/1_Intro/Data_Types.md index 5eed15d..564bdd9 100644 --- a/content/1_Intro/Data_Types.md +++ b/content/1_Intro/Data_Types.md @@ -18,7 +18,7 @@ There are several main **data types** that are used in contests: 64-bit integers It's a good idea to use 64-bit integers (`long long` in C++) instead of 32-bit integers (`int`). 64-bit integers are less likely to have overflow issues, since they can store any number 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. Of course, you shouldn't do this when time and/or memory limits are tight, which may be the case in higher divisions of USACO. -**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. (what's epsilon?) +**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. Never try to compare two floating-point numbers for exact equality (==); instead, check if their absolute difference is less than some small constant like $10^{-9}$. 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. (what's epsilon?) **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. diff --git a/content/1_Intro/Input_Output.md b/content/1_Intro/Input_Output.md index fa03cff..dfcf960 100644 --- a/content/1_Intro/Input_Output.md +++ b/content/1_Intro/Input_Output.md @@ -16,7 +16,7 @@ In most websites (such as CodeForces and CSES), input and output are **standard* ### C++ -The [](http://www.cplusplus.com/reference/iostream/) library suffices. +The [](http://www.cplusplus.com/reference/iostream/) library suffices. ```cpp #include @@ -28,9 +28,35 @@ int main() { } ``` +Alternatively, you can use the [](http://www.cplusplus.com/reference/cstdio/) library's `scanf` anf `printf` functions, which are slightly more complicated to use, but are significantly faster (generally only an issue with large input sizes): + +```cpp +#include +using namespace std; + +int main() { + int x, y; + // %d specifies that a value of type int is being input. + // Use %lld (a few judging platforms might need %I64d) + // to input a long long (64-bit) integer. + // Many other specifiers are also available; see link for more details. + // Be sure to add a & character (address-of operator) when using + // scanf, UNLESS you are inputing a string with %s. + // It is possible to input multiple values at a time as shown below. + scanf("%d%d", &x, &y); + + // Specifiers for printf are mostly the same as those used + // by scanf, with the notable exception of floating-point numbers. + // Use a backslash character followed by the lowercase + // letter n to denote a newline. + // The address-of operator, &, is not used here. + printf("Found %d and %d\n", x, y); +} +``` + ### Java -In your CS classes, you've probably implemented input and output using standard input and standard output, or using [`Scanner`](https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html) to read input and `System.out.print` to print output. These methods work, but `Scanner` and `System.out.print` are slow when we have to handle inputting and outputting tens of thousands of lines. Thus, we use `BufferedReader` and `PrintWriter` instead, which are faster because they buffer the input and output and handle it all at once as opposed to parsing each line individually. +In your CS classes, you've probably implemented input and output using standard input and standard output, or using [`Scanner`](https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html) to read input and `System.out.print` to print output. These methods work, but `Scanner` and `System.out.print` are slow when we have to handle inputting and outputting tens of thousands of lines. Thus, we use `BufferedReader` and `PrintWriter` instead, which are faster because they buffer the input and output and handle it all at once as opposed to parsing each line individually. Here is a Java template for input and output, which is effectively a faster Scanner. We import the entire `util` and `io` libraries for ease of use. @@ -109,11 +135,11 @@ In order to test a program, create a file called `problemname.in`, and then run ## C++ -You will need the [](http://www.cplusplus.com/reference/cstdio/) or the [](http://www.cplusplus.com/reference/fstream/) library. Essentially, replace every instance of the word `problemname` in the word below with the input/output file name, which should be given in the problem. +You will need the [](http://www.cplusplus.com/reference/cstdio/) or the [](http://www.cplusplus.com/reference/fstream/) library. Essentially, replace every instance of the word `problemname` in the word below with the input/output file name, which should be given in the problem. 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. -If `` is used: +If `` is used: ```cpp #include @@ -126,7 +152,7 @@ int main() { } ``` -If `` is used: (Note that you cannot use C-style I/O (`scanf`, `printf`) with this method): +If `` is used: (Note that you cannot use C-style I/O (`scanf`, `printf`) with this method): ```cpp #include @@ -189,7 +215,7 @@ public class template { PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("template.out"))); // YOUR CODE HERE - + pw.close(); // flushes the output once printing is done } }
-
- - - - Resources{props.title ? `: ${props.title}` : ''} -
+ Resources{props.title ? `: ${props.title}` : ''}
- {props.source} - + {props.source && ( + + {props.source} + {props.starred && ( {props.title} + {props.children}