|
1 | 1 | package problem_package |
2 | 2 |
|
3 | | -#problem_settings: { |
4 | | - name!: string | close({[#language_code]: string}) |
5 | | - problem_format_version?: *"legacy" | "draft" | =~"^[0-9]{4}-[0-9]{2}(-draft)?$" |
6 | | - |
7 | | - author?: #author_information | [...#author_information] |
8 | | - source?: string |
9 | | - source_url?: string // only allow if source exists |
10 | | - license?: *"unknown" | "public domain" | #license_with_rights |
11 | | - rights_owner?: string |
12 | | - if rights_owner != _|_ {license?: #license_with_rights} |
13 | | - |
14 | | - type?: *"pass-fail" | "scoring" |
15 | | - validation?: *"default" | "custom" | close({["multipass" | "interactive" | "scoring"]: _}) |
16 | | - limits?: { |
17 | | - time_multiplier?: { |
18 | | - ac_to_time_limit?: *2.0 | number |
19 | | - time_limit_to_tle?: *1.5 | number |
| 3 | +import "time" |
| 4 | +import "strings" |
| 5 | + |
| 6 | +#ProgrammingLanguage: "ada" | "algol68" | "apl" | "bash" | "c" | "cgmp" | "cobol" | "cpp" | "cppgmp" | "crystal" | "csharp" | "d" | "dart" | "elixir" | "erlang" | "forth" | "fortran" | "fsharp" | "gerbil" | "go" | "haskell" | "java" | "javaalgs4" | "javascript" | "julia" | "kotlin" | "lisp" | "lua" | "modula2" | "nim" | "objectivec" | "ocaml" | "octave" | "odin" | "pascal" | "perl" | "php" | "prolog" | "python2" | "python3" | "python3numpy" | "racket" | "ruby" | "rust" | "scala" | "simula" | "smalltalk" | "snobol" | "swift" | "typescript" | "visualbasic" | "zig" |
| 7 | + |
| 8 | + |
| 9 | +// A problem source is typically a contest or course, such as "NWERC 2023" or { name: "NWERC 2023", url: "2023.nwerc.eu" } |
| 10 | +#Source: string | { |
| 11 | + name!: string |
| 12 | + url?: string |
| 13 | +} |
| 14 | + |
| 15 | +#Person: string |
| 16 | + |
| 17 | +// Persons are one or more people, such as "Ada Lovelace <[email protected]>" or ["Alice", "Bob"] |
| 18 | +#Persons: #Person | [#Person, ...#Person] |
| 19 | + |
| 20 | +#Problem: { |
| 21 | + // Problem package format used by this file, such as "2023-12-draft" |
| 22 | + problem_format_version!: =~"^[0-9]{4}-[0-9]{2}(-draft)?$" | "draft" | "legacy" | "legacy-icpc" |
| 23 | + |
| 24 | + // The judgement type is "pass-fail" (the default) or "scoring" |
| 25 | + judgement_type?: *"pass-fail" | "scoring" |
| 26 | + |
| 27 | + // The submission types are standard, interactive or multi-pass, or submit_answer. |
| 28 | + submission_type?: *"standard" | "submit_answer" | "interactive" | "multi-pass" | "interactive multi-pass" |
| 29 | + |
| 30 | + // The name of this problem, such as "Hello" or { en: "Hello", da: "Hej" } |
| 31 | + name!: string | {[string]: string} |
| 32 | + |
| 33 | + // A unique identifier for this problem, such as "8ee7605a-ab1a-8226-1d71-e346ab1e688d" |
| 34 | + uuid!: string |
| 35 | + |
| 36 | + // A version for this problem, such as "draft" or "1.1" |
| 37 | + version?: string |
| 38 | + |
| 39 | + // The people who created this problem. Can be a single person such as "Ada Lovelace". |
| 40 | + credits?: #Person | { |
| 41 | + // The people who conceptualised this problem. |
| 42 | + authors?: #Persons |
| 43 | + // The people who developed the problem package, such as the statement, validators, and test data. |
| 44 | + contributors?: #Persons |
| 45 | + // The people who tested the problem package, for example, by providing a solution and reviewing the statement. |
| 46 | + testers?: #Persons |
| 47 | + // The people who created the problem package out of an existing problem. |
| 48 | + packagers?: #Persons |
| 49 | + // Extra acknowledgements or special thanks in addition to the previously mentioned. |
| 50 | + acknowledgements?: #Persons |
| 51 | + // The people who translated the statement to other languages, mapped by language code. |
| 52 | + translators?: [string]: #Persons |
| 53 | + } |
| 54 | + |
| 55 | + // The source(s) of this problem, such as "NWERC 2024" |
| 56 | + source?: #Source | [#Source, ...#Source] |
| 57 | + |
| 58 | + // The license of this problem. |
| 59 | + *{license?: *"unknown" | "public domain"} | { |
| 60 | + license!: "cc0" | "cc by" | "cc by-sa" | "educational" | "permission" |
| 61 | + // Who owns the rights to this problem. |
| 62 | + rights_owner?: #Person |
| 63 | + } |
| 64 | + |
| 65 | + // Do not publish this problem until the embargo is lifted. |
| 66 | + embargo_until?: time.Format("2006-01-02") | time.Format("2006-01-02T15:04:05Z") |
| 67 | + |
| 68 | + // Time and size limits for this problem. |
| 69 | + limits: { |
| 70 | + // The time limit for submission, in seconds |
| 71 | + time_limit?: number & >0 |
| 72 | + |
| 73 | + // Safety margins relative to the slowest accepted submission |
| 74 | + time_multipliers?: { |
| 75 | + ac_to_time_limit?: number & >=1 | *2.0 |
| 76 | + time_limit_to_tle?: number & >=1 | *1.5 |
| 77 | + } |
| 78 | + |
| 79 | + // Resolution for determining the time_limit from the slowest accepted solution |
| 80 | + time_resolution?: number & >0 | *1.0 |
| 81 | + |
| 82 | + // Time bounds in seconds |
| 83 | + ["compilation_time" | "compilation_time"]: int & >0 |
| 84 | + |
| 85 | + // Size bounds in MiB |
| 86 | + ["memory" | "output" | "compilation_memory" | "validation_memory" | "validation_output"]: int & >0 |
| 87 | + |
| 88 | + // Code length in kiB |
| 89 | + code?: int & >0 |
| 90 | + |
| 91 | + if submission_type != _|_ { |
| 92 | + if strings.Contains(submission_type, "multi-pass") { |
| 93 | + // For multi-pass problems, how many passes does validation use? |
| 94 | + validation_passes: *2 | int & >=2 |
| 95 | + } |
20 | 96 | } |
21 | | - time_limit?: number & >0 |
22 | | - time_resolution?: *1.0 | number |
23 | | - [#other_limits]: int |
24 | 97 | } |
25 | | - constants?: {[=~"^[a-z0-9]+$"]: number | string} |
26 | | - keywords?: string | [...string] |
27 | | - uuid!: =~"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" |
28 | | - keywords?: string | [...string] |
29 | | - if validation.scoring != _|_ {type: "scoring"} |
30 | | - languages?: *"all" | [...string] |
31 | | -} |
32 | 98 |
|
33 | | -#problem_settings |
| 99 | + // A sequence of keywords describing the problem, such as ["brute force", "real-life"]. |
| 100 | + keywords?: [...string] |
34 | 101 |
|
35 | | -#author_information : string | { |
36 | | - name!: string |
37 | | - email?: string |
| 102 | + // If not "all", restrict the programming languages that this problem may be solved in. |
| 103 | + languages?: *"all" | [#ProgrammingLanguage, ...#ProgrammingLanguage] |
| 104 | + |
| 105 | + // Should submissions have access to creating, editing and deleting files in their working directory? |
| 106 | + allow_file_writing?: *false | true |
| 107 | + |
| 108 | + // Constants for templates in the rest of the package, such as { max_n: 2000, name: "Alice" } |
| 109 | + constants?: [=~"^[a-zA-Z_][a-zA-Z0-9_]*$"]: number | string |
38 | 110 | } |
39 | | -#license_with_rights: "cc0" | "cc by" | "cc by-sa" | "educational" | "permission" |
40 | | -#language_code: =~"^[a-z]{2,4}(-[A-Z][A-Z])?$" |
41 | | -#other_limits: "memory" | "output" | "code" | "compilation_time" | "compilation_memory" | "validation_time" | "validation_memory" | "validation_output" |
|
0 commit comments