This project was built in order to help with the generation of test files for competitive programming contests, with the pattern from the Romanian National Olympiad in Informatics in mind.
The project provides a generator base class implementing logic for creating a batch of numbered tests (input and ok files).
It also contains an example of a customized generator for a simple problem (a+b).
The project is implemented following the C++14 standard.
Below you can find the steps for creating tests for a problem:
- fork this project on your GitHub account (or simply download it if you are not planning to use version control);
- create a derived class from Generator for each problem (see an example);
- implement the
generateInputmethod for creating an input file based on a configuration. You can parametrize the function through the second argument of the method (in the example, it contains an upper bound for the values). This method can be omitted if the input files already exist in the destination folder - in this case, make sure you setgenerateInputFilestofalsein the constructor (the input files should still follow the naming convention). For random generation of various values and objects, the Utils class is provided and instantiated as a member in the generator; - implement the
solvemethod for creating ok files for existing input files. Here you should basically put your official solution (an example of how one can be easily adapted can be found here). The reading and writing is done through the streams passed as arguments (if you prefer thecstdioway, you may as well use bash scripts instead of this tool). Don't worry about opening and closing the files, as the generator does this automatically based on the naming convention. Thesolvemethod can be omitted if the problem has multiple solutions and verification is done by a program, or if the solution is not available yet - in this case, setgenerateOkFilestofalsein the constructor; - if the naming convention for the test files is different from the default (0-name.in, 0-name.ok), you can override the
getInputFileNameandgetOkFileNamemethods; - call the inherited
generatefunction. Pass as argument avectorcontaining the configuration for each test (limits, constraints - this should help you with creating data sets for partial scoring). The tests will be numbered in the order you provided, starting from 0 (alternatively you can settestIndexStartto other value in the constructor).