small changes

This commit is contained in:
Michael Cao 2020-07-17 22:58:18 -05:00
commit 7a16b5d103
10 changed files with 137 additions and 67 deletions

View file

@ -19,9 +19,13 @@ prerequisites:
There are several main **data types** that are used in contests: integers, floating point numbers, booleans, characters, and strings. Assuming that you are familiar with the language you are using, this should be mostly review.
Some problems require you to use **64-bit integers** (`long long` in C++ and `long` in Java) 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}$. (what about int?)
Some problems require you to use **64-bit integers** (`long long` in C++ and `long` in Java) 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}$.
<IncompleteSection />
<IncompleteSection>
- missing 32-bit integer explanation
</IncompleteSection>
Sometimes (but not always) a USACO problem statement (ex. [Haircut](http://www.usaco.org/index.php?page=viewproblem2&cpid=1041)) will contain a warning such as the following:

View file

@ -1,7 +1,7 @@
---
id: bfs
title: "Breadth First Search (BFS)"
author: Benjamin Qi
author: Benjamin Qi, Michael Cao
prerequisites:
- Silver - Depth First Search
description: "Traversing a graph in a way such that vertices closer to the starting vertex are processed first."
@ -22,7 +22,7 @@ export const metadata = {
new Problem("Gold", "Dream", "575", "Hard", false, ["BFS"]),
],
example: [
new Problem("Gold", "Cow Navigation", "695", "Easy", false, ["BFS"]),
new Problem("Gold", "Cow Navigation", "695", "Normal", false, ["BFS"]),
]
}
};
@ -41,12 +41,14 @@ export const metadata = {
<Resource source="IUSACO" title="10.4 - Graph Traversal Algorithms"></Resource>
</Resources>
## Modifying Graphs
## Implementation
<IncompleteSection />
## Example: Cow Navigation
In the gold division, the problem statement will never directly be, "Given an unweighted graph, find the shortest path between node $u$ and $v$." Instead, the difficulty in many BFS problems are modifying the problem into a graph on which we can run BFS and get the answer.
### Example: Cow Navigation
<Problems problems={metadata.problems.example} />
In this problem, Bessie stands on a grid and wants to go from the lower left corner to upper-right corner in as few moves as possible. An initial idea could be to model the grid as a graph, where adjacent cells are connected by edges, and run a BFS to find the shortest path.
@ -60,20 +62,21 @@ For each pair of cells in the grid, $(x, y)$ and $x_2, y_2$, add 16 <!-- wow tha
Given this new graph, we add edges between two "states" which are reachable from each other. For example, if we apply the "turn left" operation, we add an edge to the state where both cows directions turn left.
<Warning>
Don't forget that once Bessie reaches the goal, she will ignore further commands. In the modified problem, if one of the two cows is at the goal, stop applying commands to her.
</Warning>
Don't forget that once Bessie reaches the goal, she will ignore further commands. In the modified problem, if one of the two cows is at the goal, stop applying commands to her.
<<<<<<< HEAD
On this new graph, we can directly run a BFS, and retrieve the answer at ${N, N, N, N, x, y}$ where $x$ and $y$ represent directions.
(Ben - equivalent to existing editorial)
<!-- You can change it, but keep the section on making modifications to graphs before. Maybe replace with a problem w/o a good editorial? -->
### Implementation
<!-- I really don't want to write Cow Navigation. Anyone have code? -->
<IncompleteSection />
## Implementation
<IncompleteSection />
## Problems
<Problems problems={metadata.problems.general} />

View file

@ -70,7 +70,11 @@ prerequisites:
...
```
## 4. MDX and Custom Components
## 4. Table of Contents
A table of contents will be auto-generated based off of the headings in the Markdown. Keep this in mind when formatting your module.
## 5. MDX and Custom Components
We're using [MDX](https://mdxjs.com/), a superset of Markdown. HTML and React components are supported, so it is possible to add interactivity / custom components to each module.
@ -145,7 +149,7 @@ when writing solutions to problems.
```
<Warning title="Insert Title Here">
**Markdown is Supported!!**
Fun fact: the title attribute is optional.
</Warning>
```
@ -162,20 +166,20 @@ Fun fact: the title attribute is optional.
### Problem Lists
todo document this... Relevant files are `content/models.ts` and `src/components/markdown/Problems.tsx`. Hopefully, the existing mdx files can help you out...
Problem constructor:
```typescript
constructor(
public source: string,
public name: string,
public id: string,
public difficulty?: 'Intro' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard',
public starred?: boolean,
public tags?: string[],
public sketch?: string,
)
class Problem {
constructor(
public source: string,
public name: string,
public id: string,
public difficulty?: 'Intro' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard',
public starred?: boolean,
public tags?: string[],
public sketch?: string,
) {}
}
```
Example usage:
@ -247,8 +251,33 @@ stub
### Language-Specific Content
stub
```mdx
<LanguageSection>
<CPPSection>
# A heading that only appears in C++
CPP content goes here, note the newlines!
</CPPSection>
<JavaSection>
Java content goes here!
</JavaSection>
<PySection />
</LanguageSection>
```
In the example above, nothing will be rendered for Python.
### Incomplete Section
stub
```mdx
<IncompleteSection>
- this list is optional and can be used to specify what is missing
- missing 32-bit integer explanation
</IncompleteSection>
```

View file

@ -1,10 +1,33 @@
import * as React from 'react';
export const IncompleteSection = () => {
export const IncompleteSection = ({ children }) => {
return (
<div className="p-4 bg-red-100 text-red-800 rounded">
<b>This section is not complete.</b> Feel free to file a request to
complete this using the "Contact Us" button.
<div className="p-4 bg-red-50 text-red-800 rounded-md tailwind-alert">
<div className="flex">
<div className="flex-shrink-0">
<svg
className="h-5 w-5 text-red-400"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fillRule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"
clipRule="evenodd"
/>
</svg>
</div>
<div className="ml-3">
<h3 className="text-sm leading-5 font-medium text-red-800">
This section is not complete.
</h3>
<div className="mt-2 text-sm leading-5 text-red-700 no-bottom-margin">
{children}
Feel free to file a request to complete this using the "Contact Us"
button.
</div>
</div>
</div>
</div>
);
};

View file

@ -7,7 +7,7 @@ const Info = ({
children: React.ReactNode;
title: string;
}) => (
<div className="rounded-md bg-blue-50 p-4 mb-4 info">
<div className="rounded-md bg-blue-50 p-4 mb-4 tailwind-alert">
<div className="flex">
<div className="flex-shrink-0">
<svg
@ -23,8 +23,12 @@ const Info = ({
</svg>
</div>
<div className="ml-3 flex-1">
<h3 className="info__heading">{title}</h3>
<div className="info__body no-bottom-margin">{children}</div>
<h3 className="text-sm leading-5 font-medium text-blue-800 my-0">
{title}
</h3>
<div className="text-sm leading-5 text-blue-700 mt-2 no-bottom-margin">
{children}
</div>
</div>
</div>
</div>

View file

@ -30,14 +30,33 @@ export const LanguageSection = props => {
if (!sections.hasOwnProperty(lang)) {
return (
<div className="p-4 bg-red-100 text-red-800 rounded">
<b>
This section isn't yet available in your chosen language:{' '}
{LANGUAGE_LABELS[lang]}.
</b>{' '}
Please choose a different default language for now. Feel free to file a
request to add support for {LANGUAGE_LABELS[lang]} using the "Contact
Us" button.
<div className="p-4 bg-red-50 text-red-800 rounded-md">
<div className="flex">
<div className="flex-shrink-0">
<svg
className="h-5 w-5 text-red-400"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fillRule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"
clipRule="evenodd"
/>
</svg>
</div>
<div className="ml-3">
<h3 className="text-sm leading-5 font-medium text-red-800">
This section isn't yet available in your chosen language:{' '}
{LANGUAGE_LABELS[lang]}.
</h3>
<div className="mt-2 text-sm leading-5 text-red-700">
Please choose a different default language for now. Feel free to
file a request to add support for {LANGUAGE_LABELS[lang]} using
the "Contact Us" button.
</div>
</div>
</div>
</div>
);
}

View file

@ -10,7 +10,7 @@ const Optional = ({
className?: string;
}) => (
<div
className={`bg-white overflow-hidden shadow rounded-lg border border-purple-400 mb-8`}
className={`bg-white overflow-hidden shadow rounded-lg border border-purple-400 mb-4`}
>
<div className="p-4 flex items-center font-medium text-purple-800 bg-purple-50">
<svg className="h-6 w-6 mr-3" fill="currentColor" viewBox="0 0 20 20">

View file

@ -5,29 +5,20 @@ import { useContext } from 'react';
import UserDataContext from '../../context/UserDataContext';
export function ResourcesList(props) {
const embedded = props.embedded;
return (
<div className="flex flex-col mb-4">
<div
className={`overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8 -my-2 py-2 ${
embedded ? 'mb-2' : ''
}`}
className={`overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8 -my-2 py-2`}
>
<div
className={`align-middle inline-block min-w-full overflow-hidden shadow ${
!embedded && 'rounded-lg border border-purple-400'
}`}
className={`align-middle inline-block min-w-full overflow-hidden shadow rounded-lg border border-purple-400`}
>
<table className="min-w-full">
<thead>
<tr>
<th
colSpan={4}
className={`px-4 sm:px-6 border-b text-left font-medium uppercase ${
embedded
? 'text-sm py-2 border-gray-200 bg-gray-50 text-gray-500'
: 'py-3 border-purple-200 bg-purple-50 text-purple-500'
}`}
className={`px-4 sm:px-6 border-b text-left font-medium uppercase py-3 border-purple-200 bg-purple-50 text-purple-500`}
>
Resources{props.title ? `: ${props.title}` : ''}
</th>

View file

@ -1,7 +1,7 @@
import * as React from 'react';
const Warning = ({ children, title }) => (
<div className="rounded-md bg-yellow-50 p-4 mb-4">
<div className="rounded-md bg-yellow-50 p-4 mb-4 tailwind-alert">
<div className="flex">
<div className="flex-shrink-0">
<svg

View file

@ -141,22 +141,19 @@
@apply mt-4;
}
.info .info__heading {
@apply text-sm leading-5 font-medium text-blue-800 my-0;
}
.info .info__body {
@apply text-sm leading-5 text-blue-700 mt-2;
}
.info .info__body p + ul {
.tailwind-alert p + ul {
@apply -mt-2;
}
.info .info__body ul {
@apply text-sm;
.tailwind-alert ul {
@apply mb-2;
}
.tailwind-alert ul li {
@apply mb-1;
}
.no-bottom-margin p:last-child {
@apply mb-0;
}
.info a {
.tailwind-alert a {
@apply text-black underline font-normal;
}