Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

41 Commits

Folders and files

Repository files navigation

icpc-resolver-from-domjudge

中文 | English

A tool that generates the event-feed file for the ICPC resolver via the DOMjudge RESTful API.

One command produces resolver-ready scoreboard data with award information attached.

Awards generated by default:

  • Overall first place (World Champion)
  • Top three official teams
  • Gold medal teams
  • Silver medal teams
  • Bronze medal teams
  • Best women's team award
  • First-to-solve award for official teams
  • Tenacious Award (last accepted submission)
  • First WA award

Star (unofficial) teams still receive gold, silver, or bronze medals, but they do not consume any of the official medal slots.

Alongside the json output, a csv file with the same name is generated. It contains the team information and awards, which makes it convenient to build the award-ceremony slides.

Notes on reading the resolver source code (in Chinese): 滚榜程序Resolver源码阅读

Prerequisite

Recommended: icpc-resolver-2.6.1331

Python dependencies are listed in requirements.txt:

pip install -r requirements.txt

Usage

  1. Set up config.json

config.json

{
  "url": <contest api url>,
  "file": <local event feed, optional>,
  "username": <username whose role is api_reader>,
  "password": <password of the user>,
  "skip_verify": true/false,
  "cache_requests": true/false,
  "download_logos": true/false,
  "json": <output json file name>,
  "gold": <the number of gold medals>,
  "silver": <the number of silver medals>,
  "bronze": <the number of bronze medals>,
  "first_place_citation": <citation of first place award>,
  "gold_show_list": true/false,
  "silver_show_list": true/false,
  "bronze_show_list": true/false,
  "honors_show_list": true/false,
  "no_occupy_award_categories": [<group_id1>, <group_id2>, ...],
  "award_best_girl": [<group_id1>],
  "exclude_teams": [<team_id1>, <team_id2>, ...],
  "manual_medals": {"gold": [<team_id>], "silver": [<team_id>], "bronze": [<team_id>]},
  "special_awards": [
    {"id": <award id>, "rule": "last_ac" | "most_submissions", "citation": <citation>},
    {"id": <award id>, "citation": <citation>, "team_ids": [<team_id1>, ...]}
  ]
}
  • The user used to log in must have the api_reader role.

  • file is a local event feed (NDJSON). When it is not empty the data is rebuilt from that file instead of the API, and no logos are downloaded. /scoreboard is not part of an event feed, so it is recomputed from the submissions using the contest penalty rules.

  • skip_verify controls whether HTTPS certificate verification is skipped. The recommended default is false. Only set it to true when the contest server's certificate is unusable and you trust the network you are on.

  • cache_requests controls whether the raw DOMjudge API responses are cached. When true, the tool first looks for a local copy in api-cache/. Only when no matching file exists does it hit the network, after which the response is stored in that directory.

  • download_logos controls whether affiliation/organization logos are downloaded. When true, the tool requests /organizations/{id}/logo and saves each logo to organizations/<organization_id>/logo.png.

  • first_place_citation is the citation shown in the event feed for the overall first-place award. World Champion is a sensible default.

  • gold_show_list, silver_show_list, bronze_show_list, and honors_show_list control whether the resolver additionally shows the teams in that tier as a list (Gold Winner, Silver Winner, Bronze Winner, Honorable Mention).

  • no_occupy_award_categories lists the group IDs of star teams. Star teams that land in the medal zone still get their photo shown (they are given the Star Team award), but they do not take up any official medal slot.

  • award_best_girl lists the group ID used for the best women's team award. The highest-ranked team in that group receives the award.

  • manual_medals names the medal winners directly. When any of its lists is non-empty the medals are no longer derived from the ranking, the 1st/2nd/3rd Place awards follow the same teams, and everyone else falls into Honorable Mention.

  • special_awards is a list of extra prizes. Each entry has an id and a citation, and is either computed by a rule or hand-picked with team_ids:

    • "rule": "last_ac": the last team to make a first accepted submission on a problem.
    • "rule": "most_submissions": the team(s) with the most judged submissions.
    • "team_ids": [...]: the listed teams receive the award as-is (e.g. a sponsor prize).

    Star teams never receive rule-based special awards. If special_awards is omitted, a single last-AC award is produced with the citation from last_ac_citation (default Tenacious Award).

  • exclude_teams lists the team IDs to drop from the resolution. Those teams, their submissions and their judgements are left out of the generated event-feed entirely.

  • Star teams are not eligible for the first-to-solve award.

example

  "url": "https://www.example.com/api/v4/contests/{cid}",
  "username": "cds",
  "password": "cds",
  "skip_verify": false,
  "cache_requests": false,
  "download_logos": false,
  "json": "event-feed",
  "gold": 16,
  "silver": 32,
  "bronze": 47,
  "first_place_citation": "World Champion",
  "gold_show_list": false,
  "silver_show_list": true,
  "bronze_show_list": true,
  "honors_show_list": true,
  "no_occupy_award_categories": ["18", "20"],
  "award_best_girl": ["11"]
  1. Run main.py
python3 main.py

A different config file can be passed with --config:

python3 main.py --config my-config.json

Place the generated event-feed.json inside a directory laid out in the CDP format, then run the Resolver:

./resolver.sh /path/to/cdp

tip

The CDP directory layout for Resolver 2.5 looks like this:

.
├── contest
│   └── logo.png        // image on the resolver's main page & default photo for teams without one
├── event-feed.json     // the json generated by this Python tool
├── organizations       // Affiliation logos. If any team of an affiliation has a logo, every team of that affiliation uses it
│   ├── 2              // affiliation id
│   │   └── logo.png
└── teams               // team photos
    ├── 3000            // team id
    │   └── photo.png
    ├── 3001
    │   └── photo.png
    ├── 3009
    │   └── photo.png
    └── 3010
        └── photo.png

Changelog

2026.05.18

Adapted to Resolver 2.6.1331.

Added API response caching and affiliation logo downloading.

The Tenacious Award now skips repeated ACs on the same problem.

2025.05.11

Adapted to the PTA version.

2025.04.18

Updated for DOMjudge >= 8.2. The PTA version has not been tested!

For DOMjudge 7.0, see the domjudge7 branch.

A demo folder in CDP format is provided. Run the resolver with:

./resolver.sh ./demo

2023.05.14

Added the PTA_School class for the PTA platform, implementing the CCPC Final award rules. Award names use Chinese plus Emoji, and the font is Noto Sans CJK. Award rules:

  1. Gold, silver, and bronze are awarded by school ranking.
  2. Undergraduate and vocational-college groups are awarded separately.
  3. A team that is not the top team of its school takes the school rank of the next team below it.

pta.json description:

{
  "url": "https://pintia.cn/api/xcpc/problem-sets/<PID>/",
  "file":"",
  "username": <pta email>,
  "password": <pta password>,
  "xml": "events",
  "ben": {
      "group": [1],
      "gold": 10,
      "silver": 20,
      "bronze": 30,
      "first": 3,
      "suffix": ""
  },
  "zhuan": {
      "group": [2],
      "gold": 1,
      "silver": 2,
      "bronze": 3,
      "first": 3,
      "suffix": "(专科)"
  }
}
  • file points to a local eventfeed. If it is non-empty, data is read from that local file; otherwise it is fetched from url.
  • ben holds the award settings for the undergraduate group and zhuan for the vocational-college group. group lists the groups eligible for awards, followed by the gold/silver/bronze counts, the number of top places (first, i.e. champion/runner-up/third), and suffix, which is appended to the award name. (A single medal list would probably be a cleaner design.)

2022.10.06

No need to obtain a Basic Authorization key anymore. Login is now done with a username and password.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages