Skip to main content

Clone Contest

cpbooster can clone a contest to your computer with the following command:

cpb clone

This command does 5 things:

  1. Waits for competitive companion extension to send the data from the contest.
  2. Creates a folder inside your contests directory with the same name as the contest that you are cloning.
  3. Creates source files for all the problems in the contest. Using the name of the corresponding problem as file name.
  4. Loads the template that corresponds to your preferred language to each source file.
  5. Downloads test cases as .in and .ans files. Using the name of the corresponding problem as file name as well.

Demo#

test

File Structure#

Running ls in the contest directory will show you something like the following.

Codeforces-CodeforcesRound665Div.2$ ls
A_DistanceandAxis.ans1 C_MereArray.ans1 E_DivideSquare.cpp
A_DistanceandAxis.cpp C_MereArray.cpp E_DivideSquare.in1
A_DistanceandAxis.in1 C_MereArray.in1 F_ReverseandSwap.ans1
A_DistanceandAxis.out1 D_MaximumDistributedTree.ans1 F_ReverseandSwap.ans2
B_TernarySequence.ans1 D_MaximumDistributedTree.cpp F_ReverseandSwap.cpp
B_TernarySequence.cpp D_MaximumDistributedTree.in1 F_ReverseandSwap.in1
B_TernarySequence.in1 E_DivideSquare.ans1 F_ReverseandSwap.in2

The first thing to notice is that every file that corresponds to the X problem has the same name as X, except for the extension. This is how cpbooster identifies which testcases correspond to a certain source file. This means that you could create a new test case attached to the problem A.DistanceandAxis just by creating the corresponding A.DistanceandAxis.in2 and A.DistanceandAxis.ans2 files, however, cpbooster has a way to automate this task. See Add Test Case. The same applies for executable files, they will use the same name except for the extension, which will be .exe.

The second thing to notice is that there are no subfolders!, the file structure is flat!, which is just amazing for several reasons. See Why Flat File Structure? to know more.

Why Flat File Structure?#

There are several reasons why a flat file structure is preferred when it comes to competitive programming contests.

But definitely the main reason, is because we want speed!, being fast in a contest is crucial.

For example, having to change the directory like this

$ cd ..
$ cd ProblemB

each time you switch to another problem is just so annoying and slow.

Having a flat file structure enables you to make every single file operation easier and faster, opening them, creating them, if you are a vim or neovim user you could just do

$ vim *.cpp

to open all your source files.

or let's say you want to see or modify the contents of some test case, you could just do :e ProblemName.in1 to open the file, without changing the directory or using long relative paths.

or imagine the situation where for some reason you just want to run your code with any of the available test cases manually (without using cpbooster), due to the fact that you will have a flat file structure you will be able to do it without changing the directory or using long relative paths. Just ./Program.exe < Program.in1 or python Program.py < Program.in1, etc. as usual.

This simplicity will also allow you to use cpbooster with any source file you already have, not just for cloned contests.

Also, do not forget that folders do use space, even when they are empty, Why would you like to use more space just for a competitive programming contest ???

So, leave folders and organization for more complex projects! Here you definitely DON'T NEED that, it makes you slow.#