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.
For the detailed documentation, read docs/getting-started.md.
Many online judges (Codeforces, AtCoder, HackerRank, etc.) are supported. For the full list, see the table of online-judge-tools/api-client.
The package is https://pypi.python.org/pypi/online-judge-tools .
pip3 install online-judge-tools
For detailed instructions, read docs/INSTALL.md.
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.
oj download http://agc001.contest.atcoder.jp/tasks/agc001_a [INFO] online-judge-tools 11.2.0 (+ online-judge-api-client 10.8.0) [INFO] load cookie from: /home/user/.local/share/online-judge-tools/cookie.jar [NETWORK] GET: https://atcoder.jp/contests/agc001/tasks/agc001_a [NETWORK] 200 OK [INFO] sample 0 [INFO] input: sample-1 2 1 3 1 2 [SUCCESS] saved to: test/sample-1.in [INFO] output: sample-1 3 [SUCCESS] saved to: test/sample-1.out [INFO] sample 1 [INFO] input: sample-2 5 100 1 2 3 14 15 58 58 58 29 [SUCCESS] saved to: test/sample-2.in [INFO] output: sample-2 135 [SUCCESS] saved to: test/sample-2.out cat <<EOF > main.py !/usr/bin/env python3 n = int(input()) a = list(map(int, input().split())) ans = max(a) print(ans) EOF oj t -c "python3 main.py" [INFO] online-judge-tools 11.2.0 (+ online-judge-api-client 10.8.0) [INFO] 2 cases found [INFO] sample-1 [INFO] time: 0.043601 sec [SUCCESS] AC [INFO] sample-2 [INFO] time: 0.043763 sec [FAILURE] WA input: 5 100 1 2 3 14 15 58 58 58 29 output: 3 expected: 135 [INFO] slowest: 0.043763 sec (for sample-2) [INFO] max memory: 10.064000 MB (for sample-2) [FAILURE] test failed: 1 AC / 2 cases
-c) option if needed. For example, for Python, you can run
$ oj t -c "python3 main.py".
-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.
oj-preparecommand in kmyk/online-judge-template-generator.
$ g++ main.cpp && oj t.
$ oj t && oj s main.cpp. By the way, you need to take care of problems whose sample cases are not so strong.
[y/N]confirmation before submitting code?
oj ssubcommand. 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.
.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, write
alias oj-test-python='oj t -c "python3 main.py"'to
For other questions, use Gitter or other SNSs.
projects collaborating with kmyk/online-judge-tools: