online-judge-tools / oj

Tools for various online judges. Downloading sample cases, generating additional test cases, testing your code, and submitting it.
MIT License
1.02k stars 88 forks source link

同時開催ABC/ARCで誤ったテストケースをダウンロードしてしまう #889

Open StellarTerror opened 3 years ago

StellarTerror commented 3 years ago

Summary / 概要

同時開催ABC/ARC (ARC058 ~ ARC103) のテストケースをダウンロードすると、誤った問題のテストケースをダウンロードしてしまう。

Steps to reproduce / 再現方法

oj download https://atcoder.jp/contests/arc065/tasks/arc065_b --system --dropbox-token=${DROPBOX_TOKEN}

Expected behavior / 期待される挙動

ARC065の2問目(D問題)のテストケースがダウンロードされる。

Actual behavior / 実際の挙動

ARC065と同時に開催されたABC049のB問題のテストケースがダウンロードされる。

Other notes / その他

koba-e964 commented 2 years ago

https://github.com/online-judge-tools/api-client/blob/v10.10.0/onlinejudge/service/atcoder.py#L823-L829_match_system_cases_contest_folder_match_system_cases_problem_folder を改善すれば直るはずです。 / Improving _match_system_cases_contest_folder and _match_system_cases_problem_folder at https://github.com/online-judge-tools/api-client/blob/v10.10.0/onlinejudge/service/atcoder.py#L823-L829 should fix this issue.

k1832 commented 1 year ago

ARC065はABC049と同日開催されたので、1問目が"C問題"から始まっています。Dropboxにも/ARC065/C/というパスに1問目のテストケースが格納されているのですが、URLから取得した1問目のproblem_idは"arc065_a"となっています。 つまり"arc065_a" == "C"という関連付けをする必要があるのですが、コンテストの問題の情報はhttps://atcoder.jp/contests/arc065/standings/json のようにJSONで取得できるのでこれを使えば良さそうです。

JSONは以下のような形式になっているので json["TaskInfo"]のリストを走査して関連付けを見つけることができます。

{
    "Fixed": true,
    "AdditionalColumns": null,
    "TaskInfo": [
        {
            "Assignment": "C",
            "TaskName": "白昼夢 / Daydream",
            "TaskScreenName": "arc065_a"
        },
        {
            "Assignment": "D",
            "TaskName": "連結 / Connectivity",
            "TaskScreenName": "arc065_b"
        },
        {
            "Assignment": "E",
            "TaskName": "へんなコンパス / Manhattan Compass",
            "TaskScreenName": "arc065_c"
        },
        {
            "Assignment": "F",
            "TaskName": "シャッフル / Shuffling",
            "TaskScreenName": "arc065_d"
        }
    ], .....

AtCoderProblemクラスにassignmentというメンバを追加して以下の中で関連付けを行うか、 https://github.com/online-judge-tools/api-client/blob/v10.10.0/onlinejudge/service/atcoder.py#L972-L996 assignmentはそれ以外で使わないので(@koba-e964 さんご指摘の通り)以下で関連付けをしても良さそうです。 https://github.com/online-judge-tools/api-client/blob/v10.10.0/onlinejudge/service/atcoder.py#L827-L829

k1832 commented 1 year ago

今確認したのですが、典型90のような順位表のないコンテストの場合、../standings/jsonの取得ができませんでした。。。 HTMLからassignmentを取得する方法がいいかも知れません。

もしくはAtCoder Problemsが提供するAPIの一つのhttps://kenkoooo.com/atcoder/resources/problems.json を使う方法もあります。