前回の環境
今回の目的
atcoder-libraryを追加します。
dockerfile
git, python3-pip, pypy3, nodejs, npm, online-judge-tools, atcoder-cli, ac-libraryを使えるようにします。
imageは、「mcr.microsoft.com/vscode/devcontainers/cpp」を使用します。
dockerfile
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.134.0/containers/cpp/.devcontainer/base.Dockerfile
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
# インタラクティブモードにならないようにする
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends
# gitのインストール
RUN apt-get install -y git
# C++, Python3, PyPy3の3つの環境想定
RUN apt-get -y install python3-pip \
pypy3 \
nodejs \
npm \
&& pip3 install online-judge-tools \
&& npm install -g atcoder-cli \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf ~/.cache/pip \
&& npm cache clean --force
# C++でAtCoder Library(ACL)を使えるようにする
RUN git clone https://github.com/atcoder/ac-library.git /lib/ac-library
ENV CPLUS_INCLUDE_PATH /lib/ac-library
launch.json
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C++: Current File",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/a.out",
"args": [
"<input.txt"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Build Main"
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"args": [],
}
]
}
tasks.json
ショートカットキーに登録する「CheckTestCase」、「SubmitCode」を追加しました。
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Main",
"type": "shell",
"command": "g++",
"args": [
"-std=c++17",
"-g",
"${relativeFile}",
"-o",
"${fileDirname}/a.out"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "CheckTestCase",
"type": "shell",
"command": "cd ${fileDirname} && rm -f ${fileDirname}/${fileBasenameNoExtension} && g++ -std=gnu++17 ${fileBasename} -o a.out && oj test -c \"${fileDirname}/a.out\" -d ${fileDirname}/tests/",
"presentation": {
"reveal": "always",
"focus": true,
"panel": "shared",
}
},
{
"label": "SubmitCode",
"type": "shell",
"command": "cd ${fileDirname} && acc s ${fileBasename}",
"presentation": {
"reveal": "always",
"focus": true,
"panel": "shared",
}
},
]
}
ショートカットキー
vscodeの好きなキーに「CheckTestCase」、「SubmitCode」を追加します。
template
#include を記載してビルドできます。
C++
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }
int main(){
return 0;
}