- C++/Python environment for AtCoder with docker
- Because it is docker, it is highly portable and can be run without contaminating the host environment
- Docker (and enough PC to run it)
- Visual Studio Code (in host)
- AtCoder Account
Clone this repository to an arbitrary location.
$ git clone https://github.com/kurimochi/atcoder_on_dockerNext, log in to AtCoder in your browser and press F12 to open DevTools. Then, go to Application -> Cookies -> https://atcoder.jp and copy the Value of the cookie named REVEL_SESSION.
The copied values are used for online-judge-tools and atcoder-cli logins. Therefore, copy .devcontainer/src/cookie-template.jar to .devcontainer/secrets/cookie.jar and .devcontainer/src/session-template.json to . devcontainer/src/session-template.json and replace {Insert the copied value} in each with the value you just copied.
$ cp .devcontainer/src/cookie-template.jar .devcontainer/secrets/cookie.jar
$ cp .devcontainer/src/session-template.jar .devcontaier/secrets/session.jsonGo to .devcontainer and create a container.
$ cd .devcontainer
$ docker compose up -d --buildIn my environment, it took about a little over 3 minutes. This image will eventually be over 3 GB, so it requires a good amount of disk space.
If the container has been terminated, start it up again.
$ docker compose up -dInstall the Dev Containers extension in VSCode and attach it to the atcoder container from a remote tab.
In the following, we will explain the procedure for actually solving the problem. First, go to contest/ and download the test data for the problem. For example, the problem abc001 can be downloaded as follows.
$ acc new abc001If you want to answer in Python, add the --template python option.
$ acc new abc001 --template pythonFor more information, please see the atcoder-cli repository and help (-h).
There is a contest directory under contest/ and a directory for each problem under contest/. Edit main.* in the directory of the problem you want to solve using VSCode.
Originally, you would have to type a longer command, but I preconfigured an alias, so no problem. You can run the test with the following commands, respectively.
C++: cpptest
Python3(PyPy): pypytest
Python3(CPython): py3test
If the test shows no problems, the code will be submitted to AtCoder. Note that the alias is also set as follows.
C++: cppsb
Python3(PyPy): pypysb
Python3(CPython): py3sb
Before submission, you will receive a confirmation in the form of a text string, which you can follow and submit. The results can be viewed on the site.
This repository consists of the following And the places marked with * are where you can customize it. If a directory is marked with *, it means that the files under the directory can be customized.
.
│ .gitignore
│ README.md
│
├─.devcontainer/
│ │ devcontainer.json *
│ │ docker-compose.yml *
│ │ Dockerfile *
│ │
│ └─src
│ │ .bashrc *
│ │ cookie-template.jar
│ │ requirements.txt *
│ │ session-template.jar
│ │ template.json
│ │
│ └─templates *
│ ├─cpp
│ │ main.cpp
│ │ template.json
│ │
│ └─python
│ main.py
│ template.json
│
├─.vscode
│ c_cpp_properties.json
│
└─contest
└─...
The following sections describe how to customize each file/directory.
devcontainer.json is the configuration file used by VSCode in this configuration. It is {.customizations.vscode} that can be customized here. You can specify preinstalled extensions in extensions and standard settings in settings.
docker-compose.yml is the container configuration file. You can change the container name in .service.atcoder.container_name.
Dockerfile is a container image design document. What you can customize here is the apt install command on line 5. You can customize the packages to be installed here. For example, if you want to install Ruby in this environment, you can add ruby after apt install -y. You can also add your own commands, although this is not recommended for beginners.
In .bashrc, the alias is set. If you want to add a new language or set an alias for another command, you can add it here.
In requirements.txt, you can customize which libraries to install with pip. For example, if you want to install numpy, you can add numpy to requirements.txt.
In this directory, the template for downloading test data with atcoder-cli is set up. The template can be changed as you wish in main.*.
To add a template, create a directory under templates (the directory name should be the template name) and write a code template for your language. Then copy src/template.json to that directory and replace {insert file name} with the file name of the code you created.
To change the default template, execute the following command Replace {Insert template name} with the name of the template.
$ acc config default-template {Insert template name}