Merge branch 'master' of https://github.com/thecodingwizard/usaco-training-2.0
This commit is contained in:
commit
5ed200ef20
39 changed files with 379 additions and 212 deletions
|
@ -1,12 +1,23 @@
|
|||
---
|
||||
slug: /intro/getting-started
|
||||
title: "Intro - Getting Started"
|
||||
title: Getting Started
|
||||
author: Nathan Wang
|
||||
order: 1
|
||||
---
|
||||
|
||||
# Introduction to Competitive Programming
|
||||
|
||||
Author: Nathan Wang
|
||||
<ul class="syllabus-only">
|
||||
<li>Contest Format</li>
|
||||
<li>Choosing a Language</li>
|
||||
<li>Practicing and Debugging</li>
|
||||
<li>Contest Strategies</li>
|
||||
</ul>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
Todo:
|
||||
- Video clip from Brian Dean
|
||||
- Explains what USACO is all about & how it works
|
||||
|
||||
## Choosing a Language
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
---
|
||||
slug: /intro/containers
|
||||
title: "Intro - Containers"
|
||||
title: Containers
|
||||
author: Unknown
|
||||
order: 5
|
||||
---
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
---
|
||||
slug: /intro/files
|
||||
title: "Intro - File IO"
|
||||
title: File IO
|
||||
author: Unknown
|
||||
order: 3
|
||||
---
|
||||
|
||||
do we still need this if USACO is transitioning to standard input/output?
|
|
@ -1,13 +1,14 @@
|
|||
---
|
||||
slug: /intro/prerequisites
|
||||
title: "Intro - Prerequisites"
|
||||
title: Prerequisites
|
||||
author: Nathan Wang
|
||||
order: 2
|
||||
---
|
||||
|
||||
# Intro - Prerequisites
|
||||
|
||||
Author: Nathan Wang
|
||||
Here's what you should learn before reading these resources.
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
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.
|
||||
|
||||
## Resources for Learning to Code
|
||||
|
|
|
@ -2,14 +2,20 @@
|
|||
slug: /intro/problems
|
||||
title: Introductory Problems
|
||||
author: Nathan Wang
|
||||
problems:
|
||||
- bronze_promote
|
||||
- bronze_word
|
||||
- bronze_paint
|
||||
- bronze_square
|
||||
order: 4
|
||||
---
|
||||
|
||||
# Introductory Problems
|
||||
|
||||
Let's begin by solving a few fun problems! The following problems require relatively little programming experience and no algorithmic knowledge.
|
||||
|
||||
Do as many as you want, then move on! You do not have to do all of them.
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Problems
|
||||
|
||||
- [Promotion Counting](http://usaco.org/index.php?page=viewproblem2&cpid=591)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
---
|
||||
slug: /bronze/complete-search
|
||||
title: "Bronze - Complete Search"
|
||||
title: "Complete Search"
|
||||
author: Unknown
|
||||
order: 3
|
||||
---
|
||||
|
||||
# Bronze - Complete Search
|
||||
|
||||
See 6 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
13
content/1_Bronze/Bronze_Overview.md
Normal file
13
content/1_Bronze/Bronze_Overview.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
slug: /bronze/overview
|
||||
title: "Bronze Overview"
|
||||
author: Brian Dean
|
||||
order: 1
|
||||
---
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
Todo:
|
||||
- Brian's advice for new bronze competitors
|
||||
- Potentially a video of select concepts that are most important for bronze problems
|
||||
- in general, words of advice/wisdom
|
|
@ -1,11 +1,10 @@
|
|||
---
|
||||
slug: /bronze/rectangle-geometry
|
||||
title: "Bronze - Rectangle Geometry"
|
||||
title: "Rectangle Geometry"
|
||||
author: Unknown
|
||||
order: 4
|
||||
---
|
||||
|
||||
# Bronze - Rectangle Geometry
|
||||
|
||||
See 7.1 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
||||
|
||||
usually just loop over 2D array
|
|
@ -1,9 +1,8 @@
|
|||
---
|
||||
slug: /bronze/simulation
|
||||
title: "Bronze - Simulation"
|
||||
title: "Simulation"
|
||||
author: Unknown
|
||||
order: 2
|
||||
---
|
||||
|
||||
# Bronze - Simulation
|
||||
|
||||
See 5 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
|
@ -1,11 +1,12 @@
|
|||
---
|
||||
slug: /silver/two-pointers
|
||||
title: "Silver - Two Pointers"
|
||||
title: "Two Pointers"
|
||||
author: Unknown
|
||||
order: 5
|
||||
---
|
||||
|
||||
# Silver - Two Pointers
|
||||
|
||||
- CPH 8.1
|
||||
|
||||
See 14.1 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
||||
See 14.1 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
||||
|
||||
<!-- END DESCRIPTION -->
|
|
@ -2,6 +2,7 @@
|
|||
slug: /silver/binary-search
|
||||
title: "Silver - Binary Search"
|
||||
author: Unknown
|
||||
order: 4
|
||||
---
|
||||
|
||||
# Silver - Binary Search
|
||||
<!-- END DESCRIPTION -->
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
---
|
||||
slug: /silver/containers
|
||||
title: "Silver - Containers"
|
||||
title: "Containers"
|
||||
author: Unknown
|
||||
order: 2
|
||||
---
|
||||
|
||||
Containers from C++ standard template library (STL)
|
||||
|
@ -20,14 +21,10 @@ author: Unknown
|
|||
- HashSets / HashMaps
|
||||
- ex?
|
||||
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
(from github)
|
||||
|
||||
# STL
|
||||
|
||||
## 2
|
||||
|
||||
* Types
|
||||
* Set, Multiset, Unordered Set
|
||||
* Map, Unordered Map (Hashmap)
|
||||
|
@ -47,12 +44,4 @@ author: Unknown
|
|||
* [Jury Marks](http://codeforces.com/contest/831/problem/C) [](67)
|
||||
* [Mahmoud & Ehab & Function](http://codeforces.com/contest/862/problem/E) [](74)
|
||||
* [Karen & Cards](http://codeforces.com/contest/815/problem/D) [](86)
|
||||
* [Tournament](http://codeforces.com/contest/878/problem/C) [](106)
|
||||
|
||||
# 4
|
||||
|
||||
* Order Statistics Tree
|
||||
* [Codeforces Tutorial](http://codeforces.com/blog/entry/11080)
|
||||
* Good to know for gold, sometimes can be used in place of BIT
|
||||
* Rope
|
||||
* [Codeforces Tutorial](https://codeforces.com/blog/entry/10355)
|
||||
* [Tournament](http://codeforces.com/contest/878/problem/C) [](106)
|
|
@ -1,12 +1,19 @@
|
|||
---
|
||||
slug: /silver/dfs
|
||||
title: "Silver - DFS"
|
||||
title: "DFS"
|
||||
author: Siyong Huang
|
||||
order: 7
|
||||
---
|
||||
|
||||
# Silver - DFS
|
||||
<ul class="syllabus-only">
|
||||
<li>Prerequisites</li>
|
||||
<li>Depth First Search (DFS)</li>
|
||||
<li>Flood Fill</li>
|
||||
<li>Graph Two-Coloring</li>
|
||||
<li>Cycle Detection</li>
|
||||
</ul>
|
||||
|
||||
Author: Siyong Huang
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Overview
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
---
|
||||
slug: /silver/greedy
|
||||
title: "Silver - Greedy"
|
||||
title: "Greedy"
|
||||
author: Unknown
|
||||
order: 1
|
||||
---
|
||||
|
||||
# Silver - Greedy
|
||||
|
||||
See 9 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
||||
|
||||
- CPH 6
|
||||
- CPH 6
|
||||
|
||||
<!-- END DESCRIPTION -->
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /silver/prefix-sums
|
||||
title: "Silver - Prefix Sums"
|
||||
title: "Prefix Sums"
|
||||
author: Eric Wei (incomplete)
|
||||
order: 6
|
||||
---
|
||||
|
||||
# Silver - Prefix Sums
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Eric Wei
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## The Task
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
---
|
||||
slug: /silver/sorting
|
||||
title: "Silver - Sorting"
|
||||
title: "Sorting"
|
||||
author: Unknown
|
||||
order: 3
|
||||
---
|
||||
|
||||
# Silver - Sorting
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
- Comparators
|
||||
- CPH 3
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /gold/bit
|
||||
title: "Gold - Binary Indexed Trees"
|
||||
title: "Binary Indexed Trees"
|
||||
author: Benjamin Qi
|
||||
order: 5
|
||||
---
|
||||
|
||||
# Gold - Range Sum Queries with Point Updates
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Benjamin Qi
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /gold/dp
|
||||
title: "Gold - Dynamic Programming"
|
||||
title: "Dynamic Programming"
|
||||
author: Michael Cao
|
||||
order: 1
|
||||
---
|
||||
|
||||
# Gold - Dynamic Programming
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Michael Cao
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
---
|
||||
slug: /gold/mst
|
||||
title: "Gold - Minimum Spanning Tree"
|
||||
title: "Minimum Spanning Tree"
|
||||
author: Benjamin Qi
|
||||
order: 3
|
||||
---
|
||||
|
||||
# Gold - Minimum Spanning Tree
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
Standard Problems:
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
---
|
||||
slug: /gold/introductory-number-theory
|
||||
title: "Gold - Introductory Number Theory"
|
||||
title: "Introductory Number Theory"
|
||||
author: Unknown
|
||||
order: 6
|
||||
---
|
||||
|
||||
# Gold - Introductory Number Theory
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
See 13 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /gold/sp
|
||||
title: "Gold - Shortest Path"
|
||||
title: "Shortest Path"
|
||||
author: Benjamin Qi
|
||||
order: 2
|
||||
---
|
||||
|
||||
# Gold - Shortest Path
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Benjamin Qi
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
[CPC.7](https://github.com/SuprDewd/T-414-AFLV/tree/master/07_graphs_1)
|
||||
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
---
|
||||
slug: /gold/topological-sort
|
||||
title: "Gold - Topological Sort"
|
||||
title: "Topological Sort"
|
||||
author: Benjamin Qi
|
||||
order: 4
|
||||
---
|
||||
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
# Gold - [Topological Sort](https://en.wikipedia.org/wiki/Topological_sorting)
|
||||
|
||||
Author: Benjamin Qi
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /plat/1DRQ
|
||||
title: "Platinum - 1D Range Queries"
|
||||
title: "1D Range Queries"
|
||||
author: Benjamin Qi
|
||||
order: 3
|
||||
---
|
||||
|
||||
# Platinum - 1D Range Queries
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Benjamin Qi
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Static Range Queries
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
---
|
||||
slug: /plat/2DRQ
|
||||
title: "Platinum - 2D Range Queries"
|
||||
title: "2D Range Queries"
|
||||
author: Benjamin Qi
|
||||
order: 4
|
||||
---
|
||||
|
||||
# Platinum - 2D Range Queries
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
See [my implementations](https://github.com/bqi343/USACO/tree/master/Implementations/content/data-structures/2D%20Range%20Queries%20(15.2)).
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /plat/bitset
|
||||
title: "Platinum - Bitset"
|
||||
title: "Bitset"
|
||||
author: Benjamin Qi
|
||||
order: 2
|
||||
---
|
||||
|
||||
# Platinum - Bitset
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Benjamin Qi
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Tutorial
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
slug: /plat/fracture
|
||||
title: "Platinum - Fracturing Search"
|
||||
title: "Fracturing Search"
|
||||
author: Benjamin Qi
|
||||
order: 5
|
||||
---
|
||||
|
||||
# Platinum - Fracturing Search
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
Author: Benjamin Qi
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## General Outline
|
||||
|
||||
|
@ -39,7 +42,7 @@ For this problem, the objects are spanning trees and the "root" is the minimum s
|
|||
This is equivalent to the solution given in the video. The runtime is $O(NMK\alpha(N))$ for storing the information about each spanning tree and $O(NK\log (NK))$ for the priority queue.
|
||||
|
||||
```cpp
|
||||
#include<bits/stdc++.h>
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef bitset<1225> B;
|
||||
typedef vector<int> vi;
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
---
|
||||
slug: /plat/geo
|
||||
title: "Platinum - Geometry"
|
||||
title: "Geometry"
|
||||
author: Benjamin Qi
|
||||
order: 6
|
||||
---
|
||||
|
||||
# Platinum - Geometry
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Primitives
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
---
|
||||
slug: /plat/trees
|
||||
title: "Platinum - Graphs"
|
||||
title: "Graphs"
|
||||
author: ?
|
||||
order: 8
|
||||
---
|
||||
|
||||
SCC
|
||||
|
@ -12,6 +13,7 @@ BCC
|
|||
|
||||
[USACO Plat Push a Box](http://www.usaco.org/index.php?page=viewproblem2&cpid=769)
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
*Some problems sourced from [here](http://codeforces.com/blog/entry/54526?#comment-385354).*
|
||||
|
||||
|
@ -50,4 +52,4 @@ BCC
|
|||
* [A2OJ](https://a2oj.com/category?ID=231)
|
||||
* [Proving Equivalences](https://open.kattis.com/problems/equivalences) [](78)
|
||||
* [Festival](https://szkopul.edu.pl/problemset/problem/p9uJo01RR9ouMLLAYroFuQ-7/site/?key=statement) [](173)
|
||||
* [Linear Programming Trick](https://www.cs.rit.edu/~spr/COURSES/ALG/MIT/lec18.pdf)
|
||||
* [Linear Programming Trick](https://www.cs.rit.edu/~spr/COURSES/ALG/MIT/lec18.pdf)
|
|
@ -1,12 +1,16 @@
|
|||
---
|
||||
slug: /plat/slope
|
||||
title: "Platinum - Slope Trick"
|
||||
title: "Slope Trick"
|
||||
author: Benjamin Qi
|
||||
order: 7
|
||||
---
|
||||
|
||||
# Platinum - Slope Trick
|
||||
**Slope trick** is a way to represent a function that satisfies the following conditions:
|
||||
|
||||
Author: Benjamin Qi
|
||||
* It can be divided into multiple sections, where each section is a linear function (usually) with an integer slope.
|
||||
* It is a convex/concave function. In other words, the slope of each section is non-decreasing or non-increasing when scanning the function from left to right.
|
||||
|
||||
<!-- END EXCERPT -->
|
||||
|
||||
## Tutorials
|
||||
|
||||
|
@ -140,7 +144,9 @@ As before, it helps to look at the differences $dif[j]=DP[j+1]-dif[j]$ instead.
|
|||
* For all $j\ge 0$, we set $dif[j] = \min(dif[j]+Z,X)$
|
||||
* For all $j<0$, we set $dif[j] = \max(dif[j]-Z,-Y)$.
|
||||
|
||||
If we maintain separate deques for $dif$ depending on whether $j\ge 0$ or $j<0$ and update all of the differences in the deques "lazily" then we can do this in $O(\sum A_i+\sum B_i)$ time.
|
||||
If we maintain separate deques for $dif$ depending on whether $j\ge 0$ or $j<0$ and update all of the differences in the deques "lazily" then we can do this in $O(\sum A_i+\sum B_i)$ time.
|
||||
|
||||
Bonus: Solve this problem when $\sum A_i+\sum B_i$ is not so small.
|
||||
|
||||
<details>
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
---
|
||||
slug: /plat/trees
|
||||
title: "Platinum - Trees"
|
||||
title: "Trees"
|
||||
author: Benjamin Qi
|
||||
order: 1
|
||||
---
|
||||
|
||||
# Platinum - Trees
|
||||
<div class="syllabus-only">
|
||||
Description: Todo
|
||||
</div>
|
||||
|
||||
<!-- END DESCRIPTION -->
|
||||
|
||||
## Tree Diameter
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ module.exports = {
|
|||
{
|
||||
resolve: `gatsby-transformer-remark`,
|
||||
options: {
|
||||
commonmark: true,
|
||||
footnotes: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
"excerpt_separator": `<!-- END DESCRIPTION -->`,
|
||||
plugins: [
|
||||
{
|
||||
resolve: `gatsby-remark-katex`,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"react-dom": "^16.12.0",
|
||||
"react-helmet": "^6.0.0",
|
||||
"rehype-react": "^5.0.1",
|
||||
"remark": "^12.0.0",
|
||||
"tailwindcss": "^1.4.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -3,16 +3,36 @@ import rehypeReact from "rehype-react"
|
|||
|
||||
import "katex/dist/katex.min.css";
|
||||
import "../components/prism-theme.css";
|
||||
import "./spoiler.css"
|
||||
|
||||
const SpoilerComponent = ({ children }) => {
|
||||
const [show, setShow] = React.useState(false);
|
||||
|
||||
return (
|
||||
<div className={`px-4 border border-gray-200 rounded-md spoiler ${show?"spoiler--show":"spoiler--hide"}`}
|
||||
onClick={e => {if (e.target.classList.contains("spoiler-label")) setShow(!show) }}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const renderAst = new rehypeReact({
|
||||
createElement: React.createElement,
|
||||
components: {
|
||||
details: SpoilerComponent,
|
||||
summary: ({ children }) => (
|
||||
<p className="spoiler-label py-4 flex items-start">
|
||||
<svg className="h-6 w-6 text-gray-500 mr-4 spoiler-label__open" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
|
||||
<svg className="h-6 w-6 text-gray-500 mr-4 spoiler-label__closed" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg>
|
||||
{children}
|
||||
</p>
|
||||
)
|
||||
},
|
||||
}).Compiler;
|
||||
|
||||
const Markdown = ({ htmlAst }) => {
|
||||
const Markdown = ({ htmlAst, className }) => {
|
||||
return (
|
||||
<div className="markdown">
|
||||
<div className={`markdown ${className}`}>
|
||||
{renderAst(htmlAst)}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
import React from "react";
|
||||
import { Link } from "gatsby";
|
||||
import Markdown from "./Markdown";
|
||||
|
||||
// const CompletedCheck = () => (<svg className="h-6 w-6 mr-2 text-green-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
// <path fillRule="evenodd"
|
||||
// d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
// clipRule="evenodd" />
|
||||
// </svg>);
|
||||
//
|
||||
// const IncompleteCheck = () => (<svg className="h-6 w-6 mr-2 text-gray-200" fill="currentColor" viewBox="0 0 20 20">
|
||||
// <path fillRule="evenodd"
|
||||
// d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
// clipRule="evenodd" />
|
||||
// </svg>);
|
||||
//
|
||||
// const renderProblem = (problem, idx) => {
|
||||
// return (
|
||||
// <li className="flex items-center" key={problem[1]}>
|
||||
// {idx>0?<IncompleteCheck/>:<CompletedCheck/>}
|
||||
// <a className="text-blue-600" href={problem[1]}>{problem[0]}</a>
|
||||
// </li>
|
||||
// );
|
||||
// };
|
||||
const CompletedCheck = () => (<svg className="h-6 w-6 mr-2 text-green-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd"
|
||||
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
clipRule="evenodd" />
|
||||
</svg>);
|
||||
|
||||
const SyllabusModule = ({ title, children, url }) => {
|
||||
const IncompleteCheck = () => (<svg className="h-6 w-6 mr-2 text-gray-200" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd"
|
||||
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
clipRule="evenodd" />
|
||||
</svg>);
|
||||
|
||||
const renderProblem = (problem, idx) => {
|
||||
return (
|
||||
<li className="flex items-center" key={problem}>
|
||||
{idx>0?<IncompleteCheck/>:<CompletedCheck/>}
|
||||
<a className="text-blue-600" href="#">{problem}</a>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
const SyllabusModule = ({ title, children, author, problems, url }) => {
|
||||
// in the future, fetch this data either from localStorage or from server.
|
||||
const isComplete = title === "Prerequisites" || title === "What is Competitive Programming?";
|
||||
const isComplete = title === "Prerequisites" || title === "Getting Started";
|
||||
|
||||
return (
|
||||
<div className="bg-white overflow-hidden shadow rounded-lg mb-8">
|
||||
|
@ -40,6 +41,10 @@ const SyllabusModule = ({ title, children, url }) => {
|
|||
</div>
|
||||
<div className="px-4 py-4 sm:p-6">
|
||||
{children}
|
||||
|
||||
{problems&&(<>Problems:<ul className="ml-3 space-y-1 py-2">{problems.map(renderProblem)}</ul></>)}
|
||||
|
||||
{author&&<p className="mt-2">Author: {author}</p>}
|
||||
</div>
|
||||
<Link to={url || "/"}
|
||||
className="block border-t border-gray-200 px-4 py-4 sm:px-6 text-blue-600 font-bold uppercase text-sm hover:bg-gray-50 transition duration-150">
|
||||
|
|
12
src/components/spoiler.css
Normal file
12
src/components/spoiler.css
Normal file
|
@ -0,0 +1,12 @@
|
|||
.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;
|
||||
}
|
|
@ -4,6 +4,7 @@ import Layout from "../components/layout"
|
|||
import SEO from "../components/seo"
|
||||
import SyllabusModule from "../components/SyllabusModule";
|
||||
import { graphql } from "gatsby";
|
||||
import Markdown from "../components/Markdown";
|
||||
|
||||
const renderModule = ({ node }) => {
|
||||
const data = node.frontmatter;
|
||||
|
@ -11,17 +12,23 @@ const renderModule = ({ node }) => {
|
|||
|
||||
return (
|
||||
<SyllabusModule
|
||||
title={data.title}
|
||||
title={`${data.order}. ${data.title}`}
|
||||
url={data.slug}
|
||||
key={data.slug}
|
||||
problems={data.problems}
|
||||
author={data.author}
|
||||
>
|
||||
Author: {data.author}
|
||||
<Markdown htmlAst={node.excerptAst} className="markdown--syllabus" />
|
||||
</SyllabusModule>
|
||||
);
|
||||
};
|
||||
|
||||
const IndexPage = ({ data }) => {
|
||||
const modules = data.modules.edges;
|
||||
const introModules = data.introModules.edges;
|
||||
const bronzeModules = data.bronzeModules.edges;
|
||||
const silverModules = data.silverModules.edges;
|
||||
const goldModules = data.goldModules.edges;
|
||||
const platModules = data.platModules.edges;
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
|
@ -80,104 +87,34 @@ const IndexPage = ({ data }) => {
|
|||
|
||||
<div className="bg-gray-50 pb-8" id="content">
|
||||
<div className="py-12 text-center">
|
||||
<h2 className="font-bold text-4xl">Demo Dashboard</h2>
|
||||
<h2 className="font-bold text-4xl">Introduction</h2>
|
||||
</div>
|
||||
<div className="max-w-3xl mx-auto sm:px-6 lg:px-8">
|
||||
<SyllabusModule
|
||||
title="Prerequisites"
|
||||
url="/intro/prerequisites"
|
||||
>
|
||||
<ul className="list-disc pl-6">
|
||||
<li>
|
||||
What you should know before starting
|
||||
</li>
|
||||
<li>
|
||||
Choosing a Language
|
||||
</li>
|
||||
</ul>
|
||||
</SyllabusModule>
|
||||
<SyllabusModule
|
||||
title="What is Competitive Programming?"
|
||||
>
|
||||
<ul className="list-disc pl-6">
|
||||
<li>
|
||||
Contest Format
|
||||
</li>
|
||||
<li>
|
||||
Practicing and Debugging
|
||||
</li>
|
||||
<li>
|
||||
Contest Strategies
|
||||
</li>
|
||||
</ul>
|
||||
</SyllabusModule>
|
||||
<SyllabusModule
|
||||
title="Introductory Problems"
|
||||
url="/intro/problems"
|
||||
>
|
||||
<p className="mb-3">If you're new to competitive programming, we recommend you try to solve a few of these
|
||||
problems. Once you're comfortable, move on!</p>
|
||||
Problem List:
|
||||
<ul className="ml-3 space-y-1 py-2">
|
||||
<li className="flex items-center">
|
||||
<svg className="h-6 w-6 mr-2 text-green-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd"
|
||||
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
clipRule="evenodd" />
|
||||
</svg>
|
||||
<a className="text-blue-600" href="http://usaco.org/index.php?page=viewproblem2&cpid=567">Fence
|
||||
Painting</a>
|
||||
</li>
|
||||
<li className="flex items-center">
|
||||
<svg className="h-6 w-6 mr-2 text-gray-200" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd"
|
||||
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
clipRule="evenodd" />
|
||||
</svg>
|
||||
<a className="text-blue-600" href="http://usaco.org/index.php?page=viewproblem2&cpid=987">Word
|
||||
Processing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</SyllabusModule>
|
||||
<SyllabusModule
|
||||
title="Useful Containers"
|
||||
>
|
||||
<ul className="list-disc pl-6 mb-4">
|
||||
<li>Arrays (C++11)</li>
|
||||
<li>Vectors and ArrayList</li>
|
||||
<li>C++ Pairs</li>
|
||||
<li>Structs</li>
|
||||
</ul>
|
||||
Problem List:
|
||||
<ul className="ml-3 space-y-1 py-2">
|
||||
<li className="flex items-center">
|
||||
<svg className="h-6 w-6 mr-2 text-gray-200" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd"
|
||||
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
clipRule="evenodd" />
|
||||
</svg>
|
||||
<a className="text-blue-600" href="http://usaco.org/index.php?page=viewproblem2&cpid=567">Lorem
|
||||
Ipsum</a>
|
||||
</li>
|
||||
<li className="flex items-center">
|
||||
<svg className="h-6 w-6 mr-2 text-gray-200" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fillRule="evenodd"
|
||||
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
||||
clipRule="evenodd" />
|
||||
</svg>
|
||||
<a className="text-blue-600" href="http://usaco.org/index.php?page=viewproblem2&cpid=987">Lorem
|
||||
Ipsum</a>
|
||||
</li>
|
||||
</ul>
|
||||
</SyllabusModule>
|
||||
{introModules.map(renderModule)}
|
||||
</div>
|
||||
|
||||
|
||||
<div className="py-12 text-center">
|
||||
<h2 className="font-bold text-4xl">Actual Modules</h2>
|
||||
<h2 className="font-bold text-4xl">Bronze</h2>
|
||||
</div>
|
||||
<div className="max-w-3xl mx-auto sm:px-6 lg:px-8">
|
||||
{modules.map(renderModule)}
|
||||
{bronzeModules.map(renderModule)}
|
||||
</div>
|
||||
<div className="py-12 text-center">
|
||||
<h2 className="font-bold text-4xl">Silver</h2>
|
||||
</div>
|
||||
<div className="max-w-3xl mx-auto sm:px-6 lg:px-8">
|
||||
{silverModules.map(renderModule)}
|
||||
</div>
|
||||
<div className="py-12 text-center">
|
||||
<h2 className="font-bold text-4xl">Gold</h2>
|
||||
</div>
|
||||
<div className="max-w-3xl mx-auto sm:px-6 lg:px-8">
|
||||
{goldModules.map(renderModule)}
|
||||
</div>
|
||||
<div className="py-12 text-center">
|
||||
<h2 className="font-bold text-4xl">Platinum</h2>
|
||||
</div>
|
||||
<div className="max-w-3xl mx-auto sm:px-6 lg:px-8">
|
||||
{platModules.map(renderModule)}
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
|
@ -188,7 +125,7 @@ export default IndexPage;
|
|||
|
||||
export const query = graphql`
|
||||
query {
|
||||
modules: allMarkdownRemark(sort: {fields: frontmatter___title}) {
|
||||
introModules: allMarkdownRemark(sort: {fields: frontmatter___order}, filter: {fileAbsolutePath: {regex: "/0_Intro/"}}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
|
@ -196,7 +133,70 @@ export const query = graphql`
|
|||
title
|
||||
slug
|
||||
author
|
||||
problems
|
||||
order
|
||||
}
|
||||
excerptAst
|
||||
}
|
||||
}
|
||||
}
|
||||
bronzeModules: allMarkdownRemark(sort: {fields: frontmatter___order}, filter: {fileAbsolutePath: {regex: "/1_Bronze/"}}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
frontmatter {
|
||||
title
|
||||
slug
|
||||
author
|
||||
problems
|
||||
order
|
||||
}
|
||||
excerptAst
|
||||
}
|
||||
}
|
||||
}
|
||||
silverModules: allMarkdownRemark(sort: {fields: frontmatter___order}, filter: {fileAbsolutePath: {regex: "/2_Silver/"}}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
frontmatter {
|
||||
title
|
||||
slug
|
||||
author
|
||||
problems
|
||||
order
|
||||
}
|
||||
excerptAst
|
||||
}
|
||||
}
|
||||
}
|
||||
goldModules: allMarkdownRemark(sort: {fields: frontmatter___order}, filter: {fileAbsolutePath: {regex: "/3_Gold/"}}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
frontmatter {
|
||||
title
|
||||
slug
|
||||
author
|
||||
problems
|
||||
order
|
||||
}
|
||||
excerptAst
|
||||
}
|
||||
}
|
||||
}
|
||||
platModules: allMarkdownRemark(sort: {fields: frontmatter___order}, filter: {fileAbsolutePath: {regex: "/4_Plat/"}}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
frontmatter {
|
||||
title
|
||||
slug
|
||||
author
|
||||
problems
|
||||
order
|
||||
}
|
||||
excerptAst
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,23 @@
|
|||
}
|
||||
|
||||
.markdown ul {
|
||||
@apply text-base pl-8 list-disc mb-4;
|
||||
@apply text-base list-disc mb-4;
|
||||
}
|
||||
|
||||
.markdown ul ul {
|
||||
list-style-type: circle;
|
||||
}
|
||||
|
||||
.markdown ul ul ul {
|
||||
list-style-type: square;
|
||||
}
|
||||
|
||||
.markdown--module ul {
|
||||
@apply pl-8;
|
||||
}
|
||||
|
||||
.markdown--syllabus ul {
|
||||
@apply pl-5;
|
||||
}
|
||||
|
||||
.markdown p {
|
||||
|
@ -119,4 +135,8 @@
|
|||
.markdown .highlight pre {
|
||||
@apply bg-gray-100 !important;
|
||||
}
|
||||
|
||||
.markdown--module .syllabus-only {
|
||||
display: none;
|
||||
}
|
||||
/*! purgecss end ignore */
|
|
@ -13,7 +13,8 @@ export default function Template({
|
|||
<Layout>
|
||||
<div className="max-w-4xl mx-auto my-8">
|
||||
<Link className="underline text-blue-600" to="/">← Back to Home</Link>
|
||||
<Markdown htmlAst={htmlAst} />
|
||||
<h1 className="text-3xl font-bold mb-4">{markdownRemark.frontmatter.title}</h1>
|
||||
<Markdown htmlAst={htmlAst} className="markdown--module" />
|
||||
</div>
|
||||
</Layout>
|
||||
)
|
||||
|
@ -23,6 +24,7 @@ export const pageQuery = graphql`
|
|||
markdownRemark(frontmatter: { slug: { eq: $slug } }) {
|
||||
htmlAst
|
||||
frontmatter {
|
||||
title
|
||||
slug
|
||||
}
|
||||
}
|
||||
|
|
13
yarn.lock
13
yarn.lock
|
@ -12731,7 +12731,7 @@ remark-mdx@^1.6.1, remark-mdx@^1.6.5:
|
|||
remark-parse "8.0.2"
|
||||
unified "9.0.0"
|
||||
|
||||
remark-parse@8.0.2:
|
||||
remark-parse@8.0.2, remark-parse@^8.0.0:
|
||||
version "8.0.2"
|
||||
resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-8.0.2.tgz#5999bc0b9c2e3edc038800a64ff103d0890b318b"
|
||||
integrity sha512-eMI6kMRjsAGpMXXBAywJwiwAse+KNpmt+BK55Oofy4KvBZEqUDj6mWbGLJZrujoPIPPxDXzn3T9baRlpsm2jnQ==
|
||||
|
@ -12837,6 +12837,15 @@ remark@^10.0.1:
|
|||
remark-stringify "^6.0.0"
|
||||
unified "^7.0.0"
|
||||
|
||||
remark@^12.0.0:
|
||||
version "12.0.0"
|
||||
resolved "https://registry.yarnpkg.com/remark/-/remark-12.0.0.tgz#d1c145c07341c9232f93b2f8539d56da15a2548c"
|
||||
integrity sha512-oX4lMIS0csgk8AEbzY0h2jdR0ngiCHOpwwpxjmRa5TqAkeknY+tkhjRJGZqnCmvyuWh55/0SW5WY3R3nn3PH9A==
|
||||
dependencies:
|
||||
remark-parse "^8.0.0"
|
||||
remark-stringify "^8.0.0"
|
||||
unified "^9.0.0"
|
||||
|
||||
remove-trailing-separator@^1.0.1:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
|
||||
|
@ -14809,7 +14818,7 @@ unicode-property-aliases-ecmascript@^1.0.4:
|
|||
resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz#dd57a99f6207bedff4628abefb94c50db941c8f4"
|
||||
integrity sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==
|
||||
|
||||
unified@9.0.0:
|
||||
unified@9.0.0, unified@^9.0.0:
|
||||
version "9.0.0"
|
||||
resolved "https://registry.yarnpkg.com/unified/-/unified-9.0.0.tgz#12b099f97ee8b36792dbad13d278ee2f696eed1d"
|
||||
integrity sha512-ssFo33gljU3PdlWLjNp15Inqb77d6JnJSfyplGJPT/a+fNRNyCBeveBAYJdO5khKdF6WVHa/yYCC7Xl6BDwZUQ==
|
||||
|
|
Reference in a new issue