problem.checkerTests now returns runVerdict and runComment when checker test run results are available.problem.validatorTests now returns runVerdict and runComment when validator test run results are available.problem.renderStatements to render statement and tutorial HTML/PDF files from the current working copy.problem.cautions to return structured problem cautions, package-readiness issues, latest package warnings and cached AI correction tips.problem.updateInfo now validates that timeLimit is divisible by 50.problem.clearScript, problem.previewTests, problem.enableTreatPointsFromCheckerAsPercent and problem.viewStatementResource.Use HTTP POST-requests:
Use problem URL and POST-parameters <login>, <password> and optionals <revision>, <type> to download a zip-file with problem package (you can use type=windows or type=linux). If the problem has the pin code, provide an optional POST-parameter <pin>. Example:
wget –post-data=login=vtapochkin&password=??? https://polygon.codeforces.com/p85dIBF/mmirzayanov/a-plus-b
Use problem URL + /problem.xml and POST-parameters <login>, <password> and optional <revision> to download a problem descriptor (much more faster, use it to check if new revision has been released). If the problem has the pin code, provide an optional POST-parameter <pin>. Example:
wget –post-data=login=vtapochkin&password=??? https://polygon.codeforces.com/p85dIBF/mmirzayanov/a-plus-b/problem.xml
Use ‘c/ContestUID/contest.xml’ and POST-parameters <login>, <password> to download a contest descriptor. If the contest has the pin code, provide an optional POST-parameter <pin>. Example:
wget –post-data=login=vtapochkin&password=??? https://polygon.codeforces.com/c/50431a121273b7e31f4200e7/contest.xml
To access Polygon API you just send a HTTP-request to address https://polygon.codeforces.com/api/{methodName} with method-specific parameters.
Most method calls return a JSON-object (if not specified otherwise) with three possible fields: status, comment and result.
Using Polygon API requires authorization. To authorize, you will need an API key, which can be generated on settings page. Each API key has two parameters: key and secret. To use the key you must add following parameters to your request.
apiKey - must be equal to key.time - current time in UNIX format (e.g., System.currentTimeMillis()/1000). If the difference between server time and time, specified in parameter, will be greater than 5 minutes, request will be denied.apiSig - signature to ensure that you know both key and secret. The first six characters of the apiSig parameter can be arbitrary. We recommend to choose them at random for each request. Let’s denote them as rand. The rest of the parameter is hexadecimal representation of SHA-512 hash-code of the following string: <rand>/<methodName>?param1=value1¶m2=value2…¶mN=valueN#<secret> where (param_1, value_1), (param_2, value_2), …, (param_n, value_n) are all the request parameters (including apiKey, time, but excluding apiSig) with corresponding values, sorted lexicographically first by param_i, then by value_i.Returns a list of problems, available to the user, according to search parameters.
showDeleted - bool, optional - show/hide deleted problems (defaults to false)id - problem id, optionalname - problem name, optionalowner - problem owner login, optionalA list of Problem objects.
Create a new empty problem. Returns a created Problem.
name - name of problem being createdTo access problem-specific API methods, add a problemId parameter to your request. The user must have access to the problem. Methods require at least READ access unless stated otherwise; problem.commitChanges and problem.buildPackage require WRITE access. Translators may use only methods explicitly marked as available to translators. If the problem has the pin code, add the pin parameter to your request.
The problem-specific methods available to translators are problem.info, problem.statements, problem.renderStatements, problem.saveStatement, problem.statementResources, problem.viewStatementResource and problem.saveStatementResource.
Returns a ProblemInfo object.
Update problem info. All parameters are optional.
inputFile - problem’s input file, optional; if specified, must be 1..64 characters, valid text and UTF-8outputFile - problem’s output file, optional; if specified, must be 1..64 characters, valid text and UTF-8interactive - boolean - is problem interactivewellFormed - boolean - is tests well-formedtimeLimit - problem’s time limit in milliseconds, from 250 to 15000, must be divisible by 50memoryLimit - problem’s memory limit in MB, from 4 to 1024If both the effective input and output file names are equal ignoring case, the method returns status “FAILED”.
Updates working copy.
Discards working copy.
Commits problem changes. All parameters are optional.
minorChanges - boolean - if true, no email notification will be sentmessage - problem’s commit messageA CommitResult object. If there are no changes, the top-level status is “OK” and the result contains committed=false, conflictOccurred=false and message="No changes". If commit fails, the top-level status is “FAILED” and comment contains the failure message.
Returns a map from language to a Statement object for that language.
Renders statements and tutorials from the current working copy. For each available statement language, the method returns independent HTML and PDF render results. Tutorials are returned only for languages where the current working copy has non-empty tutorial content.
The method requires READ access and is available to translators. If one HTML or PDF render fails or times out, the method still returns status “OK” and puts the error into that particular RenderResult. Each individual HTML/PDF render is limited to 1 minute.
If the whole request does not finish in 4 minutes, the method returns status “FAILED” with comment “Statement rendering did not finish in 4 minutes. Please repeat the request in 4 minutes.”
includeContent - boolean, optional - if true, successful render results include contentBase64; defaults to falseA RenderStatements object.
Update or create a problem’s statement. All parameters except for lang are optional.
lang (required) - statement’s languageencoding - statement’s encodingname - problem’s name in statement’s languagelegend - statement legend/main statement textinput - problem’s input formatoutput - problem’s output formatscoring - problem’s scoringinteraction - problem’s interaction protocol (only for interactive problems)notes - statement notestutorial - problem’s tutorialReturns a list of statement resources for the problem.
None
A list of File objects.
Returns statement resource file. In case of success, this method does not return JSON, instead it returns the requested file with the corresponding mime-type set.
This method is available to translators.
name - statement resource file nameAdd or edit statement resource file.
This method is available to translators.
checkExisting - boolean, optional - if true, only adding files is allowedname - file namefile - file contentReturns the name of the currently set checker.
Returns the name of the currently set validator.
Returns an array containing the names of the currently set extra validators.
Returns the name of the currently set interactor.
Returns a list of validator tests for the problem.
None
A list of ValidatorTest objects.
Add or edit validator test. In case of editing, all parameters except for testIndex are optional. In case of adding, all parameters except for testIndex, testInput and testVerdict are optional.
checkExisting - boolean, optional - if true, only adding validator’s test is allowedtestVerdict - VALID/INVALID - validator test verdicttestIndex - index of a validator testtestInput - input of a validator testtestGroup - optional - test group (groups should be enabled for the testset)testset - optional - testset nameReturns a list of checker tests for the problem.
None
A list of CheckerTest objects.
Adds or edits checker test. In case of editing, all parameters except for testIndex are optional. In case of adding, all parameters except for testIndex, testInput, testAnswer, testOutput and testVerdict are optional.
checkExisting - boolean, optional - if true, only adding checker test is allowedtestVerdict - OK/WRONG_ANSWER/PRESENTATION_ERROR/CRASHED - checker’s test verdicttestIndex - index of a checker testtestInput - input of a checker testtestOutput - output of a checker testtestAnswer - answer of a checker testReturns the list of resource, source and aux files. Method returns a JSON object with three fields: resourceFiles, sourceFiles and auxFiles, each of them is a list of File objects.
Returns the list of Solution objects.
Returns resource, source or aux file. In case of success, this method does not return JSON, instead it returns plain view of the file with the corresponding mime-type set.
type - resource/aux/source - requested file’s typename - file nameReturns solution file. In case of success, this method does not return JSON, instead in returns plain view of the solution file.
name - solution’s nameReturns script for generating tests. In case of success, this method does not return JSON, instead it returns plain view of the script.
testset - testset for which the script is requestedClears script for generating tests in the specified testset.
testset - testset for which the script should be clearedReturns tests for the given testset
testset - testset for which tests are requestednoInputs - boolean, optional - if true, returns tests without inputA list of Test objects.
Returns cached or currently available test previews for tests in the specified testset. If a preview is missing or stale, the method may start preview generation and return a TestPreview object without input and answer; repeat the request later to get generated data.
testset - testset for which tests should be previewedA list of TestPreview objects.
Returns generated test input. In case of success, this method does not return JSON, instead it returns plain view.
testset - testset of the testtestIndex - index of the testReturns generated test answer. In case of success, this method does not return JSON, instead it returns plain view.
testset - testset of the testtestIndex - index of the testUpdate validator.
validator - name of the validator (one of source files)Update checker.
checker - name of the checker (one of source files)Update interactor.
interactor - name of the interactor (one of source files)Add or edit resource, source or aux file. In case of editing, all parameters except for type and name are optional.
checkExisting - boolean, optional - if true, only adding files is allowedtype - file type (resource/source or aux)name - file namefile - file contentsourceType - optional - source type (in case of a source file)
In case of type=resource there some possible additional parameters:forTypes - optional - semicolon separated list of applicable file types (see ResourceAdvancedProperties)stages - optional - semicolon separated list of values COMPILE or RUN, meaning the phase when the resource is applicable (currently only stages=COMPILE is supported)assets - optional - semicolon separated list of values VALIDATOR, INTERACTOR, CHECKER, SOLUTION, meaning the asset types the resource is applicable (currently only assets=SOLUTION is supported)The parameters forTypes, stages, assets can be present only together (it means, all of them are absent or all of them are used at the same time). They can be used only for type=resource.
To delete ResourceAdvancedProperties of a resource file pass empty “forTypes=”.
Add or edit solution. In case of editing, all parameters except for name are optional.
checkExisting - boolean, optional - if true, only adding solutions is allowedname - solution namefile - solution contentsourceType - optional - source typetag - solution’s tag: MA (Main), OK, RJ, TL, TO (Time Limit or Accepted), TM (Time Limit or Memory Limit), WA, PE, ML, NR (Do not run), RE.Add or remove testset or test group extra tag for solution.
remove - boolean - if true - remove extra tag, if false - add extra tag.name - solution nametestset - optional - testset name for which edit extra tagtestGroup - optional - test group name for which edit extra tag
Exactly one from testset and testGroup should be specifiedtag - optional - when you add extra tag - solution’s extra tag: OK, RJ, TL, TO (Time Limit or Accepted), TM (Time Limit or Memory Limit), WA, PE, ML, NR (Do not run), RE.Edit script.
testset - testset of the scriptsource - script sourceAdd or edit test. In case of editing, all parameters except for testset and testIndex are optional.
checkExisting - boolean, optional - if true, only adding new test is allowedtestset - testset of the testtestIndex - index of the testtestInput - test inputtestGroup - optional - test group (groups should be enabled for the testset)testPoints - optional - test points (points should be enabled for the problem); non-negative double value less than 10^9 with at most 2 digits after a decimal pointtestDescription - optional - test descriptiontestUseInStatements - bool, optional - whether to use test in statementstestInputForStatements - optional - test input for viewing in the statementstestOutputForStatements - optional - test output for viewing in the statementsverifyInputOutputForStatements - bool, optional - whether to verify input and output for statementsSet test group for one or more tests. It expects that for specified testset test groups are enabled.
testset - testset of the test(s)testGroup - test group name to settestIndex - index of the test, you can specify multiple parameters with the same name testIndex to set test group to many tests of the same testset at the same time.testIndices - list of test indices, separated by a comma. It’s alternative for testIndex, you should use only one from these two waysEnable or disable test groups for the specified testset.
testset - testset to enable or disable groupsenable - bool - if it is true test groups become enabled, else test groups become disabledEnable or disable test points for the problem.
enable - bool - if it is true test points become enabled, else test points become disabledEnable or disable treating points returned by checker as percents.
If enable is true while test points are disabled for the problem, the method returns status “FAILED”.
enable - bool - if it is true checker points are treated as percents, else this behavior is disabledReturns test groups for the specified testset.
testset - testset namegroup - optional - test group nameA list of TestGroup objects.
Saves test group. Use if only to save a test group. If you want to create new test group, just add new test with such test group.
testset - testset namegroup - test group namepointsPolicy - optional - COMPLETE_GROUP or EACH_TEST (leaves old value if no specified)feedbackPolicy - optional - NONE, POINTS, ICPC or COMPLETE (leaves old value if no specified)dependencies - optional - string of group names from which group should depends on separated by a commaReturns tags for the problem.
None
A list of strings - tags for the problem.
Saves tags for the problem. Existed tags will be replaced by new tags.
tags - string of tags, separated by a comma. If you specified several same tags will be add only one of them.Returns problem general description.
None
A string - the problem general description.
Saves problem general description.
description - string - the problem general description to save. The description may be empty.Returns problem general tutorial.
None
A string - the problem general tutorial.
Saves problem general tutorial.
tutorial - string - the problem general tutorial to save. The tutorial may be empty.Returns a list of Package objects - list all packages available for the problem.
None
Download a package as a zip-archive.
packageId - package idtype - string, optional - type of the package: “standard”, “linux” or “windows”. Standard packages don’t contain generated tests, but contain windows executables and scripts for windows and linux via wine. Linux packages contain generated tests, but don’t contain compiled binaries. Windows packages contain generated tests and compiled binaries for Windows. If not provided, “standard” is used.Starts to build a new Package.
full - bool - defines whether to build full package, contains “standard”, “linux” and “windows” packages, or only “standard”
Standard packages don’t contain generated tests, but contain windows executables and scripts for windows and linux via wine. Linux packages contain generated tests, but don’t contain compiled binaries. Windows packages contain generated tests and compiled binaries for Windows.verify - bool - if that parameter is true all solutions will be invoked on all tests to be sure that tags are valid. Stress tests will run the checker to verify its credibility.Returns structured warnings and package-readiness issues for the problem. Also returns cached “Correction tips from AI”, if available.
The method inspects the current working copy. The four caution arrays common, statement, structure and issues are always present and may be empty. If both a missing checker/validator caution and the corresponding missing tests caution are detected, the redundant missing tests caution is omitted: NO_CHECKER_TESTS is omitted when NO_CHECKER is present, and NO_VALIDATOR_TESTS is omitted when NO_VALIDATOR is present.
AI tips are read from Polygon cache only; this method does not start new AI requests. If problem metadata cannot be built, the method returns status “FAILED”.
The method requires READ access and is not available to translators.
None
A ProblemCautions object.
To access contest methods, you have to include contestId parameter in your request. If the contest has the pin code, you need to include the parameter pin in your request.
Returns a list of Problem objects - problems of the contest.
Represents a polygon problem.
id - problem idowner - problem owner handlename - problem namedeleted - boolean - is a problem deletedfavourite - boolean - is a problem in user’s favouritesaccessType - READ/WRITE/OWNER - user’s access type for the problemrevision - current problem revisionworkingCopyRevision - current working copy revision (may be absent)latestPackage - latest revision with package available (may be absent)modified - is the problem modified (does the working copy have uncommitted modifications)Represents the problem’s general information.
inputFile - problem’s input fileoutputFile - problem’s output fileinteractive - boolean - is problem interactivewellFormed - boolean - is tests well-formedtimeLimit - problem’s time limit in millisecondsmemoryLimit - problem’s memory limit in MBRepresents result of a problem.commitChanges call.
committed - boolean, whether changes were committedconflictOccurred - boolean, whether a conflict occurred while updating the working copy during commit processingmessage - human-readable commit result messageRepresents a problem’s statement.
encoding - statement’s encodingname - problem’s name in statement’s languagelegend - statement legend/main statement textinput - problem’s input formatoutput - problem’s output formatscoring - problem’s scoringinteraction - problem’s interaction protocol (only for interactive problems)notes - statement notestutorial - problem’s tutorialRepresents rendered statements and tutorials for the current working copy.
revision - working copy revision used for renderingrenderingTimeSeconds - unix time in seconds when rendering result was producedstatements - list of RenderedStatement objects, one for each statement language; always present, may be emptytutorials - list of RenderedStatement objects for languages with non-empty tutorial content; always present, may be emptyRepresents rendered files for one language.
language - statement languagehtml - RenderResult object for HTML renderpdf - RenderResult object for PDF renderRepresents one HTML or PDF render result.
status - OK/FAILEDsha256 - SHA-256 hex digest of the rendered file; present when status is OKsizeBytes - rendered file size in bytes; present when status is OKcontentBase64 - rendered file content encoded as Base64; present only when status is OK and includeContent is truemessage - render error message; present when status is FAILEDRepresents a resource, source or aux file.
name - file namemodificationTimeSeconds - file’s modification time in unix formatlength - file lengthsourceType - (present only for source files) - source file typeresourceAdvancedProperties - (may be absent) Problem resource files can have extra property called resourceAdvancedProperties of type ResourceAdvancedPropertiesRepresents special properties of resource files. Basically, they stand for compile- or run-time resources for specific file types and asset types. The most important application is IOI-style graders. Example: {“forTypes”:”cpp.*”,”main”:false,”stages”:[“COMPILE”],”assets”:[“SOLUTION”]}
forTypes - colon or semicolon separated list of file types this resource if applied, wildcards are supported (example: “cpp.” or “pascal.;java.11”)main - currently reserved to be false,stages - array of possible string values COMPILE or RUN, meaning the phase when the resource is applicable,assets - array of possible string values VALIDATOR, INTERACTOR, CHECKER, SOLUTION, meaning the asset types the resource is applicable.Represents a problem solution.
name - solution namemodificationTimeSeconds - solution’s modification time in unix formatlength - solution lengthsourceType - source file typetag - solution tagRepresents a test for the problem.
index - test indexmanual - boolean - whether test is manual of generatedinput - lossy UTF-8 string view of test input (absent for generated tests)inputBase64 - exact Base64-encoded test input bytes (absent for generated tests and for manual tests without input)description - test description (may be absent)useInStatements - boolean - whether test is included in statementsscriptLine - script line for generating test (absent for manual tests)group - test group (may be absent)points - test points (may be absent)inputForStatement - input for statements (may be absent)outputForStatement - output for statements (may be absent)verifyInputOutputForStatements - boolean - whether to verify input and output for statements (may be absent)Represents preview data for one test.
id - internal preview id (may be absent)session - working copy sessioncreationTime - preview creation time, serialized as a legacy Gson date string (may be absent)updateTime - preview update time, serialized as a legacy Gson date string (may be absent)problemId - problem idtestset - testset nametestIndex - test indexdescription - test description (may be absent)useInStatements - boolean - whether test is included in statementsinput - generated preview input; may be absent while preview generation is pending; may contain an error message if preview generation failedinputSha1 - SHA-1 hash of generated preview input (may be absent)answer - generated preview answer; may be absent while preview generation is pending; may contain an error message if preview generation failedchangeAfterLastGenerate - boolean, whether the test changed after the last preview generationtestOverviewLog - test overview log (may be absent)Represents a test group in testset.
name - test group namepointsPolicy - test group points policy, COMPLETE_GROUP for the complete group points policy, EACH_TEST for the each test points policyfeedbackPolicy - test group feedback policy, COMPLETE for the complete feedback policy, ICPC for the first error feedback policy, POINTS for the only points feedback policy, NONE for no feedback policy.dependencies - list of group names from which this group depends on (may be empty)Represents a package.
id - package’s idrevision - revision of the problem for which the package was createdcreationTimeSeconds - package’s creation time in unix formatstate - PENDING/RUNNING/READY/FAILED package’s statecomment - comment for the packagetype - type of the package: “standard”, “linux” or “windows”. Standard packages don’t contain generated tests, but contain windows executables and scripts for windows and linux via wine. Linux packages contain generated tests, but don’t contain compiled binaries. Windows packages contain generated tests and compiled binaries for Windows.Represents a validator’s test for the problem.
index - validator test indexinput - validator test inputexpectedVerdict - INVALID/VALID - expected verdict for the validator testtestset - validator test set (may be absent)group - validator test group (may be absent)runVerdict - VALID/INVALID/IN_QUEUE/CANT_RUN - validator test run verdict, if available; absent if the test has not been runrunComment - validator test run comment, if available; absent if unavailableRepresents a checker’s test for the problem.
index - checker test indexinput - checker test inputoutput - checker test outputanswer - checker test answerexpectedVerdict - OK/WRONG_ANSWER/CRASHED/PRESENTATION_ERROR - expected verdict for the checker’s testrunVerdict - checker test run verdict, if available; completed runs return raw checker interop verdict name; IN_QUEUE means the run has not finished yet; absent if the test has not been runrunComment - checker test run comment, if available; absent if unavailableRepresents structured cautions for the problem.
common - list of Caution objects with COMMON category; always present, may be emptystatement - list of Caution objects with STATEMENT category; always present, may be emptystructure - list of Caution objects with STRUCTURE category; always present, may be emptyissues - list of Caution objects with ISSUES category; always present, may be emptypackageReadinessIssues - list of PackageReadinessIssue objects found by package validation; always present, may be emptylatestPackageWarnings - list of package verification warning strings from the latest READY package; always present, may be emptyai - AiTips object with cached AI correction tips; always presentRepresents one problem caution.
type - caution type, for example NO_TAGS, NO_CHECKER, TESTSET_SEEMS_TO_BE_INCOMPLETE or OPENED_ISSUESseverity - SOFT/HARDcategory - COMMON/STATEMENT/STRUCTURE/ISSUESmessage - human-readable caution messageparameters - list of string parameters used to format the caution message; may be emptyRepresents a pre-package state issue collected by package validation.
type - package validation exception type, for example HAS_MODIFICATIONS, WORKING_COPY_IS_OUTDATED, CHECKER_IS_NOT_SET, NO_TESTS or INVALID_TEST_SCRIPTreason - optional exception context, for example a source file name or testset name; may be absentmessage - human-readable formatted package validation message; fixed for simple types such as HAS_MODIFICATIONS, CHECKER_IS_NOT_SET and NO_TESTS, and may include reason and/or an internal exception message for types such as INVALID_TEST_SCRIPTproblem.cautions uses fast package validation, so compile-only package checks are not included in packageReadinessIssues.
Represents cached “Correction tips from AI” for the problem.
disabled - boolean, whether AI tips are disabled for the problem; always presentstatements - list of StatementAiTip objects for statement languages with cached AI correction data; always present, may be emptyvalidator - SourceAiTip object with cached validator review comment; may be absent if there is no cached useful comment or if validator review is not applicablechecker - SourceAiTip object with cached checker review comment; may be absent if there is no cached useful comment or if checker review is not applicableIf disabled is true, statements is empty and validator and checker are absent. Internal UI confidence flags for AI tips are not returned.
Represents a cached AI correction tip for one statement language.
language - statement languagesource - normalized statement text used for the cached AI request; may be largesuggestion - suggested corrected statement text; absent when no suggestion is available, including when processing is trueprocessing - boolean, whether the cached AI request is still being processedIf processing is true, call problem.cautions later to check whether the suggestion has appeared.
Represents a cached AI review comment for a source file.
name - source file namecomment - raw cached AI review comment; may be large