onlinejudge.service.atcoder module

the module for AtCoder (https://atcoder.jp/)

note

There are some useful endpoints:

note

There is an unofficial API https://github.com/kenkoooo/AtCoderProblems

note

Some methods not inherited from classes onlinejudge.type may be modified in future, because the specification is not fixed yet.

class onlinejudge.service.atcoder.AtCoderContest(*, contest_id)[source]

Bases: onlinejudge.type.Contest

Variables

contest_idstr

download_data(*, session=None, lang='en')[source]
Return type

AtCoderContestDetailedData

classmethod from_url(url)[source]
Parameters

url (str) – example:

Return type

Optional[AtCoderContest]

get_service()[source]
Return type

AtCoderService

get_url(*, type=None, lang=None)[source]
Return type

str

iterate_submission_data_where(*, me=False, problem_id=None, language_id=None, status=None, user_glob=None, order=None, desc=False, lang=None, pages=None, session=None)[source]
Note

If you use certain combination of options, then the results may not correct when there are new submissions while crawling.

Parameters
  • status (Optional[str]) – must be one of AC, WA, TLE, MLE, RE, CLE, OLE, IE, WJ, WR, or Judging

  • order (Optional[str]) – must be one of created, score, source_length, time_consumption, or memory_consumption

  • me (bool) – use the …/submissions/me page instead of …/submission

  • user_glob (Optional[str]) – is used as the value of f.User query parameter

  • language_id (Optional[NewType()(LanguageId, str)]) – is used as the value of f.Language query parameter

  • lang (Optional[str]) – must be one of ja, en

  • pages (Optional[Iterator[int]]) – is an iterator to list the page numbers to GET

Return type

Iterator[AtCoderSubmissionData]

iterate_submissions(*, session=None)[source]
Note

in implementation, use “ORDER BY created DESC” to list all submissions even when there are new submissions

Return type

Iterator[AtCoderSubmission]

iterate_submissions_where(**kwargs)[source]
Return type

Iterator[AtCoderSubmission]

list_problem_data(*, session=None)[source]
Return type

List[AtCoderProblemData]

list_problems(*, session=None)[source]
Return type

List[AtCoderProblem]

class onlinejudge.service.atcoder.AtCoderContestData(*, contest, duration, lang, name, rated_range, response, session, start_time, timestamp)[source]

Bases: onlinejudge.type.ContestData

Variables
property contest
Return type

AtCoderContest

property html
Return type

bytes

property name
Return type

str

property response
Return type

Response

property session
Return type

Session

property timestamp
Return type

datetime

class onlinejudge.service.atcoder.AtCoderContestDetailedData(*, can_participate, penalty, **kwargs)[source]

Bases: onlinejudge.service.atcoder.AtCoderContestData

Variables
class onlinejudge.service.atcoder.AtCoderProblem(*, contest_id, problem_id)[source]

Bases: onlinejudge.type.Problem

Variables
  • contest_idstr

  • problem_idstr

Note

AtCoder has problems independently from contests. Therefore the notions contest_id, alphabet, and url don’t belong to problems itself.

download_data(*, session=None)[source]
Raises

Exception – if no such problem exists

Return type

AtCoderProblemDetailedData

download_input_format(*, session=None)[source]
Raises

Exception – if no such problem exists

Return type

Optional[str]

download_sample_cases(*, session=None)[source]
Raises
  • requests.exceptions.HTTPError – if no such problem exists

  • SampleParseError – if parsing failed

Return type

List[TestCase]

classmethod from_url(s)[source]
Return type

Optional[AtCoderProblem]

get_available_languages(*, session=None)[source]
Raises

NotLoggedInError

Return type

List[Language]

get_contest()[source]
Return type

AtCoderContest

get_name(*, session=None)[source]
Return type

str

get_service()[source]
Return type

AtCoderService

get_url(*, type=None, lang=None)[source]
Return type

str

iterate_submissions(*, session=None)[source]
Note

in implementation, use “ORDER BY created DESC” to list all submissions even when there are new submissions

Return type

Iterator[AtCoderSubmission]

iterate_submissions_where(**kwargs)[source]
Return type

Iterator[AtCoderSubmission]

submit_code(code, language_id, *, filename=None, session=None)[source]
Raises
Return type

AtCoderSubmission

class onlinejudge.service.atcoder.AtCoderProblemData(*, alphabet, memory_limit_byte, name, problem, response, session, time_limit_msec, timestamp, html=None)[source]

Bases: onlinejudge.type.ProblemData

Note

AtCoderProblemData is obtained the list page (e.g. https://atcoder.jp/contests/agc001/tasks )

Variables
property html
Return type

bytes

property name

for example of Problem:

  • 器物損壊!高橋君

  • AtCoDeerくんと変なじゃんけん / AtCoDeer and Rock-Paper

  • Xor Sum

Return type

str

property problem
Return type

AtCoderProblem

property response
Return type

Optional[Response]

property session
Return type

Optional[Session]

property timestamp
Return type

Optional[datetime]

class onlinejudge.service.atcoder.AtCoderProblemDetailedData(*, available_languages, input_format, sample_cases, score, **kwargs)[source]

Bases: onlinejudge.service.atcoder.AtCoderProblemData

Note

AtCoderProblemDetailedData is obtained the problem page (e.g. https://atcoder.jp/contests/agc001/tasks/agc001_a )

Variables
  • available_languagesOptional [ List [ Language ] ]

  • input_formatOptional [ str ]

  • sample_casesOptional [ List [ TestCase ] ]

  • scoreOptional [ float ]

classmethod from_html(html, *, problem, session=None, response=None, timestamp=None)[source]
Parameters

html (bytes) – must be a HTML of the new (beta) version of AtCoder

New in version 6.2.0.

Return type

AtCoderProblemDetailedData

property sample_cases
Return type

Optional[List[TestCase]]

class onlinejudge.service.atcoder.AtCoderService[source]

Bases: onlinejudge.type.Service

classmethod from_url(url)[source]
Parameters

url (str) – example:

Return type

Optional[AtCoderService]

get_name()[source]

example:

  • AtCoder

  • Codeforces

  • PKU JudgeOnline

Note

If you want something like identifier (e.g. atcoder, codeforces or poj), you can use a domain obtained from get_url().

Return type

str

get_url()[source]
Return type

str

get_url_of_login_page()[source]
Return type

str

get_user_history_url(user_id)[source]
Return type

str

is_logged_in(*, session=None)[source]
Return type

bool

iterate_contest_data(*, lang='ja', session=None)[source]
Parameters

lang (str) – must be ja (default) or en.

Note

lang=ja is required to see some Japanese-local contests.

Note

You can use lang=en to see the English names of contests.

Return type

Iterator[AtCoderContestData]

iterate_contests(*, lang='ja', session=None)[source]
Return type

Iterator[AtCoderContest]

login(*, get_credentials, session=None)[source]
Raises

LoginError

Return type

None

class onlinejudge.service.atcoder.AtCoderSubmission(*, contest_id, submission_id)[source]

Bases: onlinejudge.type.Submission

Variables
  • contest_idstr

  • submission_idstr

download_data(*, session=None)[source]
Note

Exec Time is undefined when the status is RE or TLE

Note

Memory is undefined when the status is RE or TLE

Return type

AtCoderSubmissionDetailedData

download_problem(*, session=None)[source]
Return type

AtCoderProblem

classmethod from_url(s)[source]
Return type

Optional[AtCoderSubmission]

get_problem()[source]
Raises

Exception

Note

There is no way to reconstruct problem_id without networking

Return type

AtCoderProblem

get_service()[source]
Return type

AtCoderService

get_url(*, type=None, lang=None)[source]
Return type

str

class onlinejudge.service.atcoder.AtCoderSubmissionData(*, code_size, exec_time_msec, language_name, memory_byte, problem, problem_id, response, score, session, status, submission, submission_time, timestamp, user_id)[source]

Bases: onlinejudge.type.SubmissionData

Variables
property problem
Return type

AtCoderProblem

property response
Return type

Optional[Response]

property session
Return type

Optional[Session]

property status
Return type

str

property submission
Return type

AtCoderSubmission

property timestamp
Return type

Optional[datetime]

class onlinejudge.service.atcoder.AtCoderSubmissionDetailedData(*, source_code, compile_error, test_sets, test_cases, **kwargs)[source]

Bases: onlinejudge.service.atcoder.AtCoderSubmissionData

property source_code
Return type

bytes

class onlinejudge.service.atcoder.AtCoderSubmissionTestCaseResult(*, case_name, status, exec_time_msec, memory_byte)[source]

Bases: object

Variables
  • case_namestr

  • statusstr

  • exec_time_msecint in millisecond

  • memory_byteint in byte

class onlinejudge.service.atcoder.AtCoderSubmissionTestSet(*, set_name, score, max_score, test_case_names)[source]

Bases: object

Variables