-
Notifications
You must be signed in to change notification settings - Fork 10
Chained Tasks
This guide will help you go through the process of creating a chained task in kjudge!
- Download the sample problem
- Add problem to kjudge
- Add a build script
- Add a checker file
- Add .stages file
- The end
This guide uses a simple problem called Broken Bit
to illustrates the process of preparing a chained task in kjudge.
Given an integer N <= 10^9
, you need to implement two functions:
-
string encode(N)
encodes the integerN
and return a decoded stringS
. -
int decode(string S)
decodes the stringS
and return an integerN
.
The string S
can only contain 0
or 1
. Its size must be less than or equal 90
. It is guaranteed that when you encode N
and return S
, one position of S
will be flipped before the decode
function is called.
Two functions are run independently by the grader.
You can download the sample problem files and tests here.
After extracting the .zip
file, BrokenBit
folder will look like this:
First, you need to create a problem in kjudge. In this guide, a problem named Broken Bit
is added to the Weighted contest
in kjudge's test database:
Then, you can add Broken Bit
's tests:
In the next step, you need to add a customized build script for the problem.
In Broken Bit
, there is only a build script for C++
: compile_cc.sh
, which compiles contestant's solution (code.cc
) with the problem's grader file (grader.cpp
).
You can upload the files (grader.cpp
, broken_bit.h
and compile_cc.sh
) that the problem requires to compile and run contestant's solution to kjudge:
For more details about writing a custom compiler, refer to Custom Compilers.
To compare and score contestant's solution with the expected output, you need to add a checker file.
In BrokenBit
folder, there is a file called compare.cpp
that checks and scores contestant's output.
You can upload compare.cpp
and compile the file in kjudge.
Note: kjudge follows CMS's checker styleand it requires a binary file named compare
for a checker file. Users can upload a file named compare.[language]
( language
is one of the supported languages) and compile it direcly in the kjudge system.
For more details about writing a custom checker, refer to CMS's checker style and Custom diffs
Finally, you need to add a .stages
file that contains a list of arguments passed to the binary file when running contestant's solution.
The number of times the binary file is run is equal to the number of lines in .stages
.
Each line of .stages
is the arguments passed to the binary for a single run.
- In a single run, the binary file will receive input from standard input and return output to standard output.
- After a single run, the next input for the next run is the output of the previous run.
- The input for the first run is the problem's test input.
- The output for the last run is contestant's output, which will be checked again the problem's expected output by using a custom checker or the default diff checker.
In Broken Bit
, the grader will run contestant's implementation of encode
and decode
independently in two separate stages.
the grader (grader.cpp
) file:
and the .stages
file:
You can upload .stages
file to kjudge:
In kjudge, the necessary files for Broken Bit
will look like this:
You have finished all the steps needed to prepare a chained task in kjudge.
To test whether you follow all steps correctly, you can try to submit the solution file sol.cpp
in the BrokenBit
folder.
Now you can add your own chained task to kjudge!