84 lines
2.9 KiB
Markdown
84 lines
2.9 KiB
Markdown
# USACO Workspace
|
|
|
|
Practice workspace for USACO problems, managed by the `./usaco` script.
|
|
|
|
## Layout
|
|
|
|
```
|
|
template.cpp starting template for every problem
|
|
solving/<name>/ problems in progress
|
|
solved/<name>/ finished problems
|
|
skipped/<name>/ problems set aside for later
|
|
```
|
|
|
|
Each problem dir contains `main.cpp` plus `<io>.in` / `<io>.out` files (USACO file IO is wired up automatically via `STDIO("<io>")`).
|
|
|
|
## Commands
|
|
|
|
### Start a problem
|
|
```
|
|
./usaco new diamond-collector
|
|
./usaco new diamond-collector diamond # if the freopen name differs
|
|
./usaco new diamond-collector --url https://usaco.org/index.php?page=viewproblem2&cpid=639
|
|
```
|
|
Creates `solving/<name>/main.cpp` from the template and an empty `.in` file, then opens it in `$EDITOR`. `--url` saves the problem link for `open`.
|
|
|
|
**Prefix matching:** everywhere a command takes a problem name, a unique prefix works — `./usaco e diam` finds `diamond-collector` (ambiguous prefixes list the candidates).
|
|
|
|
### Build & run
|
|
```
|
|
./usaco run diamond-collector # compile + run, then print the .out file
|
|
./usaco build diamond-collector # compile only
|
|
```
|
|
Compiles with `g++ -O2 -std=c++17 -Wall -Wextra` and runs inside the problem dir so file IO just works. Put your test input in the `.in` file first.
|
|
|
|
### Finish (or give up on) a problem
|
|
```
|
|
./usaco done diamond-collector # move to solved/ and auto git commit "Solve <name>"
|
|
./usaco skip diamond-collector # move to skipped/
|
|
./usaco undo diamond-collector # bring back to solving/ from solved/ or skipped/
|
|
```
|
|
|
|
### Edit
|
|
```
|
|
./usaco vim diamond-collector # open main.cpp in $EDITOR (defaults to vim)
|
|
./usaco e diamond-collector # same thing, shorter (also: edit)
|
|
```
|
|
Opens from inside the problem dir, so the `.in`/`.out` files are right there.
|
|
|
|
### Look around
|
|
```
|
|
./usaco list # all problems by status, oldest-touched first
|
|
./usaco stats # counts + problems solved in the last 7 / 30 days
|
|
./usaco open diamond-collector # open the saved problem URL in a browser
|
|
```
|
|
|
|
### Misc
|
|
```
|
|
./usaco template diamond-collector # reset main.cpp from template (old one saved as main.cpp.bak)
|
|
./usaco clean # delete compiled binaries (main, a.out) and .bak files everywhere
|
|
./usaco path diamond-collector # print the problem's directory
|
|
```
|
|
|
|
## Shell integration (recommended)
|
|
|
|
Add to `~/.zshrc`:
|
|
```
|
|
source ~/Coding/USACO/usaco.zsh
|
|
```
|
|
This gives you:
|
|
- `usaco` as a global command (no `./` needed, works from any directory)
|
|
- tab completion for commands and problem names (`usaco e diam<TAB>`)
|
|
- `ucd <name>` — cd straight into a problem's directory
|
|
|
|
## Typical session
|
|
|
|
```
|
|
./usaco new the-lost-cow --url <link>
|
|
./usaco open the-lost-cow # read the problem
|
|
# paste sample input into solving/the-lost-cow/the-lost-cow.in
|
|
# edit solving/the-lost-cow/main.cpp
|
|
./usaco run the-lost-cow # iterate until the output is right
|
|
./usaco done the-lost-cow # 🎉 (auto-commits)
|
|
```
|