online-judge-tools / Oj
Programming Languages
Projects that are alternatives of or similar to Oj
online-judge-tools/oj
oj
is a command to help solving problems on various online judges. This command automates downloading sample cases, generating additional test cases, testing for your code, and submitting it.
Screencast
Features
- Download sample cases
- Download system test cases
- Login
- Submit your code
- Test your code
- Test your code for reactive problems
- Generate input files from generators
- Generate output files from input and reference implementation
For the detailed documentation, read docs/getting-started.md. For Japanese: 日本語バージョンのドキュメントは docs/getting-started.ja.md にあります。
Many online judges (Codeforces, AtCoder, HackerRank, etc.) are supported. For the full list, see the table of online-judge-tools/api-client.
How to install
The package is https://pypi.python.org/pypi/online-judge-tools .
$ pip3 install online-judge-tools
For detailed instructions, read docs/INSTALL.md. For Japanese: 日本語バージョンのドキュメントは docs/INSTALL.ja.md にあります。
How to use
$ oj download [--system] URL
$ oj login URL
$ oj submit [URL] FILE
$ oj test [-c COMMAND] [TEST...]
$ oj test-reactive [-c COMMAND] JUDGE_COMMAND
$ oj generate-input GENERATOR_COMMAND
$ oj generate-output [-c COMMAND] [TEST...]
For details, see $ oj --help
.
Example
$ oj download http://agc001.contest.atcoder.jp/tasks/agc001_a
[+] problem recognized: <onlinejudge.atcoder.AtCoder object at 0x7f2925a5df60>
[x] GET: http://agc001.contest.atcoder.jp/tasks/agc001_a
[+] 200 OK
[*] sample 0
[x] input: 入力例 1
2
1 3 1 2
[+] saved to: test/sample-1.in
[x] output: 出力例 1
3
[+] saved to: test/sample-1.out
[*] sample 1
[x] input: 入力例 2
5
100 1 2 3 14 15 58 58 58 29
[+] saved to: test/sample-2.in
[x] output: 出力例 2
135
[+] saved to: test/sample-2.out
[*] sample 2
[x] input: Sample Input 1
2
1 3 1 2
[+] saved to: test/sample-3.in
[x] output: Sample Output 1
3
[+] saved to: test/sample-3.out
[*] sample 3
[x] input: Sample Input 2
5
100 1 2 3 14 15 58 58 58 29
[+] saved to: test/sample-4.in
[x] output: Sample Output 2
135
[+] saved to: test/sample-4.out
FAQ
- I usually make one directory per one contest (or, site). Can I keep using this style?
- Yes, you can use the
--directory
(-d
) option or$ rm -rf test/
. However, we don't recommend this style, because you should make additional test cases by yourself and run stress tests to maximize your rating.
- Yes, you can use the
- Can I download all sample cases of all problems at once?
- No, but you can use
oj-prepare
command in kmyk/online-judge-template-generator.
- No, but you can use
- Can I automatically compile my source code before testing?
- Yes, use your shell. Run
$ g++ main.cpp && oj t
.
- Yes, use your shell. Run
- Can I automatically submit code after it passes tests?
- Yes, use your shell. Run
$ oj t && oj s main.cpp
. By the way, you need to take care of problems whose sample cases are not so strong.
- Yes, use your shell. Run
- Can I remove the delays and the
[y/N]
confirmation before submitting code?- Yes, put
--wait=0
option and--yes
option tooj s
subcommand. Of course, we don't recommend this. They exist for failsafe. For example, please consider a situation where if you save 3 seconds, you will move up 3 places on the standings. In such a case, if you get a penalty of 5 minutes, then you will move down at least 300 places on the standings.
- Yes, put
- Can I clear my download history to omit the URL of the problem to submit?
- Yes, remove the history file, whose name is
download-history.jsonl
.
- Yes, remove the history file, whose name is
- Is my password stored?
- Your password is not stored into any files. This program stores only your session tokens (but of course, it's still credentials). Please read onlinejudge/_implementation/command/login.py.
- Can I specify problems by their IDs or names, instead of URLs?
- No. It may sound nice, but actually, hard to use and maintain.
- Does the config file exist?
- No. You can use your
.bashrc
(or similar files) instead. It's a config file of your shell. Read man bash and write shell aliases or shell functions. For example, if you want to use Python code for tests by default, writealias oj-test-python='oj t -c "python3 main.py"'
(alias) to.bashrc
and use$ oj-test-python
, or writefunction oj-test-python() { FILE="$1" ; shift ; oj t -c "python3 '$FILE'" "[email protected]" ; }
(function) and useoj-test-python main.py
.
- No. You can use your
For other questions, use Gitter or other SNSs.
Resources
Articles
in Japanese:
- online-judge-toolsを導入しよう! · ますぐれメモ
- online-judge-toolsをVimから呼んで楽をする - Leverage Copy
- VSCodeでAtCoderのサンプルケースをサクッとテストする - Qiita
Related Tools
conflicted:
not conflicted:
- shivawu/topcoder-greed for Topcoder Single Round Match
- FakePsyho/mmstats for Topcoder Marathon Match
- https://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins
projects depending on kmyk/online-judge-tools:
- wrappers:
- Tatamo/atcoder-cli is a thin wrapper optimized for AtCoder
- kjnh10/pcm is a tool which internally uses online-judge-tools
- some people use
oj
via Visual Studio Code
- libraries using this for CI:
-
kmyk/competitive-programming-library is my library for competitive programming, which uses
oj
via kmyk/online-judge-verify-helper - beet-aizu/library also uses kmyk/online-judge-verify-helper
-
blue-jam/ProconLibrary uses
oj
for CI from their own scripts
-
kmyk/competitive-programming-library is my library for competitive programming, which uses
- others:
- kmyk/online-judge-verify-helper automates testing your library for competitive programming and generate documents
- kmyk/online-judge-template-generator analyzes problems and generates templates including auto-generated input/output parts
- fukatani/rujaion is an IDE for competitive-programming with Rust
Maintainers
- current maintainers
- maintainers who are not working now
- @fukatani (AtCoder: ryoryoryo111)
- @kawacchu (AtCoder: kawacchu)
License
MIT License