AtCoderテスト自動化スクリプト
tags: 情報
競プロのテストめんどくさいなぁ
以前makeを使った方法を書きましたがこれでもすべてのテストを調べるのは面倒
と思ったので調べたら次のような良いツールが有りました(AtCoder専用ですが)
AtCoderのテストができるツールを$ sudo pip3 install online-judge-tools
でインストールできるますよということが書いてあります
これをこのまま使うのも面倒なので,シェルスクリプトを探したところこの記事に当たりました
ただ,エイリアスの説明がなかったのと,このままだと自分の環境に使えなかったので次のようにエイリアスを設定し,書き換えたという話です
コード
. |--abc | |- 133a.cpp | |--arc | |-001a.cpp | |--agc |-001a.cpp
ABCの際は次のように書いています
#!/bin/bash problemname=$1 contest="abc" oj dl "https://${contest}${problemname:0:3}.contest.atcoder.jp/tasks/${contest}${problemname:0:3}_${problemname:3}" g++ -Wall -std=c++14 ./$1.cpp oj test rm -f a.out rm -rf test
エイリアスは~/.bashsrc
に
alias cptest="./cptest"
と書くだけ
実際に使ってみる
まずはcptest.sh
に権限を与えます
$ chmod 777 ./cptest.sh
実際のテストは次のように行います.非常に簡単です
$ cptest 133a
出力結果です
[x] GET: https://pypi.org/pypi/online-judge-tools/json [x] 200 OK [!] update available: 6.2.1 -> 6.5.0 [*] run: $ pip3 install -U online-judge-tools [*] see: https://github.com/kmyk/online-judge-tools/blob/master/CHANGELOG.md [x] problem recognized: AtCoderProblem.from_url('https://atcoder.jp/contests/abc133/tasks/abc133_a'): https://abc133.contest.atcoder.jp/tasks/abc133_a [x] GET: https://atcoder.jp/contests/abc133/tasks/abc133_a [x] 200 OK [*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 1 [*] skipped due to language: current one is lang-ja, not lang-en: Sample Output 1 [*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 2 [*] skipped due to language: current one is lang-ja, not lang-en: Sample Output 2 [*] skipped due to language: current one is lang-ja, not lang-en: Sample Input 3 [*] skipped due to language: current one is lang-ja, not lang-en: Sample Output 3 [x] save cookie to: /Users/diohabara/Library/Application Support/online-judge-tools/cookie.jar [x] append history to: /Users/diohabara/Library/Caches/online-judge-tools/download-history.jsonl [*] sample 0 [x] input: sample-1 4 2 9 [+] saved to: test/sample-1.in [x] output: sample-1 8 [+] saved to: test/sample-1.out [*] sample 1 [x] input: sample-2 4 2 7 [+] saved to: test/sample-2.in [x] output: sample-2 7 [+] saved to: test/sample-2.out [*] sample 2 [x] input: sample-3 4 2 8 [+] saved to: test/sample-3.in [x] output: sample-3 8 [+] saved to: test/sample-3.out [!] update available: 6.2.1 -> 6.5.0 [*] run: $ pip3 install -U online-judge-tools [*] see: https://github.com/kmyk/online-judge-tools/blob/master/CHANGELOG.md [*] 3 cases found [*] sample-1 [x] time: 0.009526 sec [+] AC [*] sample-2 [x] time: 0.008854 sec [+] AC [*] sample-3 [x] time: 0.008949 sec [+] AC [x] slowest: 0.009526 sec (for sample-1) [+] test success: 3 cases
ちなみに
同じ寮の人間が東大のミスターコンテストに出ているので是非投票してあげてください
"ENTRY 03 赤尾将希"と書いてある人です