Problem description package format

ru en

Version 1.10

download sample problem package

Problem is stored in a ZIP archive, which should contain exactly one XML file with the problem descrition in the root directory, and arbitraty number of additional files with tests, solutions etc.

Structure of XML file

Tag name
Parent tag
Attributes Comments
<CATS>
  • version o — version number ("1.4" by default).
Required top-level tag.
<Problem>
<CATS>
  • title — problem title in the first language of the lang list.
  • lang o — comma-separated list1.10 of (natural) languages of the problem text.
  • tlimit — time limit for a single test (in seconds).
  • mlimit1.1 — memory limit for a single test (in megabytes or other units).
  • wlimit o 1.9 — write limit for a single test (in megabytes or other units), default value is 30.
  • author o — author name.
  • inputFile — input file name or *STDIN1.8 or *NONE1.10.
  • outputFile — output file name or *STDOUT1.8 or *NONE1.10.
  • difficulty o −1.4 — author's estimate of the problem difficulty (1 to 100).
  • stdChecker o −1.4 — standard checker name.
  • maxPoints o 1.3 — maximum number of points per problem, overrides the sum of points for each test.
  • saveInputPrefix o 1.9 — store starting part of each generated test up to a given length (in megabytes or other units).
  • saveOutputPrefix o 1.9 — store starting part of submission output on each test up to a given length (in megabytes or other units).
  • saveAnswerPrefix o 1.9 — store starting part of solution output on each test up to a given length (in megabytes or other units).
Standard checker program compares output file with the answer file for a given test. Following standard checkers are defined:
  • nums — compares lists of 4-byte integers.
  • floats2 — compares lists of long doubles.
  • strs — compares lists of short strings (up to 256 characters).
  • longnums — compares lists of long unmbers (up to 10000 digits).
  • longstrs — compares lists of long strings (up to 10000 characters).

Since version 1.4, stdChecker attribute is deprecated. It is recommended to use <Import> tag instead with the following standard guid's:
  • std.nums — checks equivalency of lists of 32-bit integers.
  • std.longnums — checks equivalency of arbitrary length unsigned integers.
  • std.floats<n>, for n from 2 to 5 — checks equivalency of floating point numbers with precision of n digits.
  • std.strs — checks equivalency of arbitrary length strings.
<Keyword>
<Problem>
  • code — keyword code.
Keyword code must be pre-defined in a system.
<ProblemStatement>
<Problem>
  • attachment o 1.9 — identifier of the <Attachment> object.
  • url o 1.9 — arbitrary URL.
Problem statement text in STML format. If attachment or url attribute is present, statement text is replaced by a link.
<ProblemConstraints>
<Problem>
  Problem input constraints in STML format.
<InputFormat>
<Problem>
  Input file format description in STML format.
<OutputFormat>
<Problem>
  Output file format description in STML format.
<JsonData>1.7
<Problem>
  Additional data in JSON format. Recommended to use <include> tag.
<Explanation>1.5
<Problem>
  • attachment o 1.9 — identifier of the <Attachment> object.
  • url o 1.9 — arbitrary URL.
Solution explanation in STML format. If attachment or url attribute is present, explanation text is replaced by a link.
<Checker>
<Problem>
  • name — object identifier <Checker> (arbitrary string).
  • src — path to the source.
  • de_code o — development environment code.
  • style o 1.2 — checker arguments format, can be one of:
    • "legacy" — arguments are input answer output, used by default for backwards compatibility.
    • "testlib" — arguments are input output answer, compatible with the testlib library. Recommended for new problems.
    • "partial" — arguments are similar to testlib. Points for test are read from the checker's standard output.
    • "multiple"1.10 — arguments are similar to testlib. Used for competitive problems. Output file is expected to contain controller log. Standard output is expected to contain a line for each agent.
  • export o 1.4 — global identifier.
  • timeLimit o 1.7 — time limit in seconds.
  • memoryLimit o 1.7 — memory limit (in megabytes or other units).
  • writeLimit o 1.9 — write limit (in megabytes or other units).
Checker program descriton. This tag is ignored if the problem has stdChecker attribute. "src" — is a path to the file relative to the archive root. Nested directories are allowed. Path is case-sensitive. The list of standard development environments:
  • 11.2 — None (h;inc)
  • 21.6 — Answers in zip (zip)
  • 101 — Cross-platform C/C++ compiler (cpp;c)
  • 102 — GNU C++ (cc;cxx)
  • 103 — MS Visual C++ (cpp;c)
  • 104 — Borland C++ 3.1 (cpp;c)
  • 105 — GNU C (c)
  • 201 — Borland Pascal 7.0 (pas)
  • 202 — Free Pascal (pp)
  • 203 — Borland Delphi (dpr)
  • 301 — Quick Basic (qb) (partially supported)1.1
  • 302 — Free Basic (bas) 1.4
  • 401 — Java (java)1.3
  • 402 — C# (cs)1.6
  • 501 — Perl (pl)1.4
  • 502 — Python (py)1.6
  • 503 — Haskell (hs)1.6
  • 504 — Ruby (rb)1.6

If the de_code is omitted, it is defined by the source file extension according to the list above.

Checker's exit code: 0 — OK, 1 — WA, 2 — PE, 3 — Internal error.

<Picture>
<Problem>
  • name — identifier of the <Picture> object (arbitrary string).
  • src — path to the image file.
Describes a picture to be inserted into a problem text.
<Attachment>1.6
<Problem>
  • name — identifier of the <Attachment> object (arbitrary string).
  • src — path to the attachment file.
Arbitrary file available for download from the problem text.
<Solution>
<Problem>
  • name — identifier of the <Solution> object.
  • src — path to the source code file.
  • de_code o — development environment code.
  • export o 1.4 — globally unique identifier.
  • timeLimit o 1.7 — time limit in seconds. By default equal to the problem's limit.
  • memoryLimit o 1.7 — memory limit (in megabytes or other units). By default equal to the problem's limit.
  • writeLimit o 1.9 — write limit (in megabytes or other units). By default equal to the problem's limit.
Description of the jury solution.
<Generator>
<Problem>
  • name — identifier of the <Generator> object.
  • src — path to the source code file.
  • de_code o — development environment code.
  • outputFile o 1.2 — input file name or *STDOUT.
  • export o 1.4 — globally unique identifier.
  • timeLimit o 1.7 — time limit in seconds.
  • memoryLimit o 1.7 — memory limit (in megabytes or other units).
  • writeLimit o 1.9 — write limit (in megabytes or other units). By default is 999.
Description of the test generator. Generator must produce a file named according to the outputFile attribute. That file is used as an input data by the <In> tag. By default the file name is equal to the value of inputFile attribute of the <Problem> tag. Special value of outputFile="*STDOUT" means that the generator should print the test to the standard output.
For group generators outputFile attribute may contain context variables which are expanded to the test number 1.5, or file pattern characters 1.9 '?' and '*'. For example, to describe a generator producing test files t01, t02, ..., t50 in subdirectories subtask1, subtask2, ...:
      <Generator name="gen" src="gen.pas" outputFile="subtask?/t%0n" />
      <Test rank="1-50" > <In use="gen" genAll="1"> ...
<GeneratorRange>1.2
<Problem>
  • from — sequential number of the first generator.
  • to — sequential number of the first generator.
  • name — identifier of the <Generator> object.
  • src — path to the source code file.
  • de_code o — development environment code.
  • outputFile o 1.2 — input file name or "*STDOUT".
  • export o 1.4 — globally unique identifier.
  • timeLimit o 1.7 — time limit in seconds.
  • memoryLimit o 1.7 — memory limit (in megabytes or other units).
  • writeLimit o 1.9 — write limit (in megabytes or other units). By default is 999.
Attributes name, src and export of <GeneratorRange> tag may contain context variables which are expanded to the current generator number. For example:
<GeneratorRange from="1" to="10" name="g%0n" src="gen%0n.pas"/>
<Validator>1.10
<Problem>
  • name — identifier of the <Validator> object.
  • src — path to the source code file.
  • de_code o — development environment code.
  • export o — globally unique identifier.
  • timeLimit o — time limit in seconds.
  • memoryLimit o — memory limit (in megabytes or other units).
  • writeLimit o — write limit (in megabytes or other units). By default is 999.
Test data validator. Reads data from standard input and/or input file. Exits with code 0 if the data is valid, 0 otherwise.
<Visualizer>1.9
<Problem>
  • name — identifier of the <Visualizer> object.
  • src — path to the source code file.
  • de_code o — development environment code, it is recommended to use code 1.
  • export o — globally unique identifier.
Test data visualizer.
<Interactor>1.9
<Problem>
  • name — identifier of the <Interactor> object.
  • src — path to the source code file.
  • de_code o — development environment code.
  • export o — globally unique identifier.
  • timeLimit o — time limit in seconds.
  • memoryLimit o — memory limit (in megabytes or other units).
  • writeLimit o — write limit (in megabytes or other units).
Interactor or controller (see <Run>). Only one iterator per problem is allowed.
<Linter>1.10
<Problem>
  • name — identifier of the <Linter> object.
  • src — path to the source code file.
  • stage — either 'before' or 'after'.
  • de_code o — development environment code.
  • export o — globally unique identifier.
  • timeLimit o — time limit in seconds.
  • memoryLimit o — memory limit (in megabytes or other units).
  • writeLimit o — write limit (in megabytes or other units).
Linter runs either before or after compilation, depending on 'stage' attribute. Linter accepts source file names on command line and exits with non-zero code if the source does not pass the check. Standard output of linter may contain error message. Linter can be imported by its global identifier. See <Import>.
<Run>1.9
<Problem>
  • method — solution running method.
Possible values of method attribute:
  • default — run a single process of solution.
  • interactive — run solution and interactor (see <Interactor>) simultaneously, exchanging data via standard input/output streams.
  • competitive1.10 — run controller (see <Interactor>) and several solutions (agents) simultaneously, exchanging data via standard input/output streams.
<Test>
<Problem>
  • rank — test ranks specifier. If rank attribute is equal to "*", parameters given in the text are set as defaults for all tests. 1.6
  • points o — number of points for the test.
Test description. Problem must have tests with ranks from 1 upto some N. If there is no tests, any compilable submission will be judged WA. Since version 1.5 attributes of <In> and <Out> tags, nested inside <Test> tag, may contain context variables which are expanded to the current test number. For example:
<Test rank="1-10">
  <In src="%0n.in"/><Out use="solution"/>
</Test>
To avoid duplication, test description may be split between several tags, for example:
<Test rank="1-5" points="1" />
<Test rank="6-10" points="2" />
<Test rank="1-10"><Out use="sol"></Test>
Despite of that, the data about each test must not overlap between tags.
<TestRange>1.1 −1.5
<Problem>
  • from — sequential number of the first test.
  • to — sequential number of the last test.
  • points o — number of points for each test in range.
Since version 1.5, this tag is deprecated — use <Test> tag instead.
Attributes of <In> and <Out> tags, nested inside <TestRange> tag, may contain context variables which are expanded to the current test number. For example:
<TestRange from="1" to="10">
  <In src="%0n.in"/><Out use="solution"/>
</TestRange>
<In>
<Test>
, <TestRange>1.1
  • use o — identifier of the <Generator> object.
  • param o — command-line parameters passed to the generator.
  • src o — path to the input file (if the use attribute is omitted).
  • genAll o 1.5 — generate a group of tests with a single generator.
  • validate o 1.10 — identifier of the <Validator> object.
  • validateParam o 1.10 — command-line argument to pass to <Validator>.
  • hash o 1.10 — input file hash in the format $alg$hex, where 'alg' is one of 'sha' or 'md5', and 'hex' is a sequence of lowcase hexadecimal digits representing hash value.
Test input description.
If the "use" attribute is present, input file is produced by running the given test generator. If the "param" attribute contains "|" character, then generation is performed by a pipeline, starting with test generator, followed by generator modules. For example:
<Test rank="10"><In use="gen" param="100 | shuffle 19234"/></Test>
If neither "src" nor "use" attribute is present, input text is nested inside the tag1.9. Whitespace is preserved exactly.
<Out>
<Test>
, <TestRange>1.1
  • use o — identifier of the <Solution> object.
  • src o — path to the output file (if the use attribute is omitted).
If the "use" attribute is present, output file is produced by running the given jury solution. If neither "src" nor "use" attribute is present, output text is nested inside the tag1.9. Whitespace is preserved exactly.
<Testset>1.5
<Problem>
  • name — name of the test set.
  • tests — test rank specification.
  • points o 1.8 — number of points for the whole testset.
  • hideDetails o 1.8 — hide results of individual tests.
  • comment o 1.8 — comment.
  • depends_on o 1.9rank specification for tests upon which this testset depends.
Contains test set description. While adding the problem to the contest, one or more testsets to use for checking may be specified. By default all the available tests are used. If the number of points for the testset is specified, the points are awarded only if all tests have passed. It is allowed to mix testsets and stand-alone tests, as well as specify overlapping testsets. However, the test must not be included in a several concurrently used testsets with points, dependencies or hidden details.
<Module>1.2
<Problem>
  • name — identifier of the <Module> object.
  • src — path to the source code file.
  • de_code o — development environment code.
  • type — module type (generator, checker, solution, linter).
  • export o 1.4 — globally unique identifier.
  • main o 1.10 — use this module as main file, and submitted code as a module with given name. For modules of type 'solution' only.
Module description. Module files are unpacked and compiled together with every object of the corresponding type. For the modules which do not require compilation, use development environment "None" (de_code="1"). Modules are compiled in the order they are listed in the package.
<Import>1.4
<Problem>
  • guid — globally unique identifier of the imported object. Can contain * character, designating an arbitrary substring.1.5
  • type o — type of the imported object (generator, checker, solution).
  • name o 1.5 — problem-local identifier of the imported object.
Import an object from the existing problem. Object is searched by guid. Is the type attribute is present, the type of referenced object is checked against it. The effect of importing an object is equivalent to adding that object to a package.
<Sample>
<Problem>
  • rank — sample rank specifier (independent of similar attribute of <Test> tag).
Sample test descrption. Attributes of tags <SampleIn> and <SampleOut> nested inside of <Sample> can contain context variable referencing sample rank1.9. For example:
<Sample rank="1-3">
  <SampleIn src="%0n.in"/>
  <SampleOut src="%0n.out"/>
</Sample>
<SampleIn>
<Sample>
  • src o 1.6 — path to the sample input file.
If the src attribute is omitted, sample input text is nested inside the tag. Whitespace is preserved exactly.
<SampleOut>
<Sample>
  • src o 1.6 — path to the sample input file.
If the src attribute is omitted, sample output text is nested inside the tag. Whitespace is preserved exactly.

Test case ranks specification

Specifier is a comma-separated list of elements. Each element may be one of:

Context variables

Have a form of %n, %0n, meaning test number and zero-padded test number correspondingly.

STML (Simple Text Markup Language)

STML is a radically simplified subset of HTML with a few additional tags. The following tags are defined in STML:

Tag name
Parent tag
AttributesComments
<img>
  • picture — identifier of the <Picture> object.
  • width o — image width (in pixels).
  • height o — image height (in pixels).
  • align o — image alignment
    (May have value of left or right).
Embed an image.
<a>1.6
  • attachment — identifier of the <Attachment> object.
Insert a link to the attached file.
<object>1.6
  • attachment — identifier of the <Attachment> object.
Insert a link to the attached file.
<include>1.7
  • src — name of the file to be included; the file must have the same encoding as the XML.
Insert a text from the file.
<code>
  • language1.10 — programming language name for syntax highlighting.
Format text as code.
<i>, <em>   Italics.
<b>   Bold.
<p>   Paragraph
<table>
  • border o — 1 — draw border,
    0 — do not draw border (default).
  • width o — table width.
HTML Table.
<tr>
<table>
  Table row
<td>
<tr>
  Table cell
<th>
<tr>
  Table header

STML conditionals

Any tag inside STML can have additional cats-if attribute. Its value is a condition on problem tags.

Condition is a list of expressions separated by comma. Each expression is one of name, !name, name=value or !name=value, where ! sign denotes logical not, name — tag name, value — tag value.

lang attribute 1.10

By default, problem text is enclosed in a div tag with lang attribute corresponding to the chosen language tag. However, if the text uses several languages simultaneously (e.g. English terms in Russian text), spans of non-default language should have explicit lang attribute.

cats-dict attribute 1.10

Words inside of tag with attribute cats-dict="1" are added to the dictionary of the current language.

Memory units 1.9

Memory size in mlimit, memoryLimit, wlimit or writeLimit attribute value must be an integer optionally followed by a suffix 'B' for bytes, 'K' for kilobytes, 'M' for megabytes, 'G' for gigabytes. If no suffix is given, megabytes are assumed.

o Attributes market with this sign are optional.

1.1 This feature is available since 1.1.

1.2 This feature is available since 1.2.

1.3 This feature is available since 1.3.

1.4 This feature is available since 1.4.

1.5 This feature is available since 1.5.

1.6 This feature is available since 1.6.

1.7 This feature is available since 1.7.

1.8 This feature is available since 1.8.

1.9 This feature is available since 1.9.

1.10 This feature is available since 1.10.

−1.4 This feature is deprecated since version 1.4.

−1.5 This feature is deprecated since version 1.5.

Far Eastern Federal University