Managing Problem Constraints

Managing problem constraints in a central place is important to avoid disagreement among problem statements, generator, validator, judge etc. rules_contest supports describing problem constraints in a YAML file.

Constraint YAML files

Constraint YAML files describe problem constraints in the YAML format. Constraint YAML files should be a simple key-value mapping, such as:

VALUE_MAX: 1000000  # Maximum input number
ERROR_MAX: 0.001    # Permitted error in outputs

Generating source code from constraint YAML files

cc_yaml_library rule generates a C++ header file from a YAML file.

For example, the example YAML file above is converted to the following C++ header file.

#define VALUE_MAX 1000000
#define ERROR_MAX 0.001

There are other language variants such as py_yaml_library. See the reference for the complete list of available language variants.

Referencing problem constraints in problem statements

It is also possible to reference problem constraints in YAML files in problem statements. See Managing Problem Statements section for details.