Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cp-local-setup

Java Task runner

A small, local-first Java workspace for competitive programming. It removes the repetitive setup around contests—folders, boilerplate, local samples, compiling, and saving reference solutions—while keeping every command visible and simple.

Features

  • Java 17 contest boilerplate with fast input and buffered output.
  • Interactive contest scaffolding for Codeforces, AtCoder, or any named platform.
  • make run for root or contest-problem execution using local sample input.
  • Terminal-scoped contest mode, so repeated runs ask only for A, B, and so on.
  • Reusable algorithms for graphs, strings, range queries, math, and data structures.
  • make store for collecting polished solutions under Java-style filenames.
  • VS Code tasks, Java extension recommendations, and debug configuration.

Requirements

  • Java 17 or newer (javac and java)
  • GNU Make or a compatible make implementation
  • Bash (included by default on macOS and most Linux distributions)

Check the essentials:

javac -version
make --version

Quick start

git clone https://github.com/soumajitgh/cp-local-setup.git
cd cp-local-setup
make help
make contest new
make run

make run asks whether to execute the root Main.java or a contest problem. It reads that directory's input.txt and writes output.txt; both local files are ignored by Git.

Everyday workflow

Create a contest

Create a contest interactively:

make contest new

It asks for the contest slug and comma-separated problem labels. For another platform, include PLATFORM:

make contest new PLATFORM=atcoder

Each problem gets a copy of templates/java/boilerplate/Main.java plus an empty input.txt:

contests/codeforces/2112/
├── A/
│   ├── Main.java
│   └── input.txt
├── B/
└── C/

Run code

For a guided run:

make run

To run a known problem directly, provide its directory:

make run PROBLEM=contests/codeforces/2112/A

The compiled classes go to a local .build/ directory. make clean removes all generated builds and resets the root Main.java from the boilerplate, ready for a new scratch problem.

Contest mode

Enter contest mode after creating the contest:

make contest 2112

This opens an interactive child shell scoped to contests/codeforces/2112. In that shell, every make run asks only for the problem label. You can also add or remove problems without leaving the contest terminal:

make add                 # prompt for a label; creates Main.java and input.txt
make add PROBLEM=F        # add F directly
make problems             # list this contest's problem folders
make remove               # prompt for a label and confirm before deletion
make remove PROBLEM=F FORCE=1  # scripted removal without a prompt

Type exit when the contest is over.

make contest PLATFORM=atcoder CONTEST=abc400
make run   # then enter A, B, or C
exit

Store a solution

When the root Main.java is worth keeping, save it as a reference:

make store

Enter a descriptive name when prompted. The command converts it to PascalCase and stores a copy under store/: for example, binary search lower bound becomes store/BinarySearchLowerBound.java. It never overwrites an existing stored file.

Task reference

Command Purpose
make help Show the built-in command reference.
make contest new Interactively create problem workspaces.
make contest 2112 Open a terminal-scoped contest mode.
make add Add a boilerplate problem in contest mode.
make remove Remove a problem in contest mode after confirmation.
make problems List active-contest problem folders.
make compile PROBLEM=contests/codeforces/2112/A Compile one problem.
make run Interactively select and run code.
make store Save root Main.java into store/.
make list List all created problem folders.
make clean Remove builds and reset root Main.java.

Template library

The templates directory contains small, copy-ready Java snippets. Their comments state indexing conventions and constraints.

Area Included template
Boilerplate Fast scanner, buffered output, and solve() structure
Data structures Fenwick tree
Range queries Iterative segment tree for sums
Graphs Dijkstra for non-negative weights
Math Modular exponentiation and modular inverse
Strings Prefix function and KMP matching

Copy only the pieces a problem needs. Fewer lines mean fewer contest-time mistakes.

VS Code

Open this folder in VS Code and accept the recommended Java extensions. The included configuration supports:

  • Compile current Java file with Cmd+Shift+B
  • Debug current Java file with breakpoints
  • Code Runner execution with a sibling input.txt and output.txt

Repository layout

.
├── contests/       # created contest workspaces
├── scripts/        # Makefile helper scripts
├── store/          # saved reference solutions
├── templates/      # reusable Java boilerplate and algorithms
├── Main.java       # root scratch solution
└── Makefile        # task runner entry point

Contributing

This is intentionally lightweight. Improvements that make contest setup faster or templates safer are welcome. Keep templates dependency-free, document assumptions (especially indexing and complexity), and verify new commands with make help and a representative local run.

License

Distributed under the MIT License.

About

A local-first Java competitive programming workspace with Make-powered contest mode, templates, and solution storage.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages