Skip to content

Creating a method to do precalculation once per test

Alexey Dmitriev edited this page Nov 11, 2018 · 2 revisions

In problems with multiple tests per input file it may be beneficial to run some code once, before any test is run. Solver is by default created once per input file, so default constructor is called once and you may put this code in the constructor. But you may find this not intuitive and want a separate method to be called instead. It may be done by adding to run.template and submission.template call to this method after creating a class, for example:

%ClassName% solver;
solver.setup();

In that case you may want to add this method to a task.template also (if you do not enjoy retyping it)