This template provides several built-in useful features for problem solving with c++, such as
- auto include your own libraries
- AtCoder library included by default
- flexible and IDE-friendly compilation upon cmake
- library management powered by vcpkg
- basic stdin/out automated testing
- c++ compiler
- cmake >= 3.17
- git
-
Download vcpkg with git submodule.
git submodule init git submodule update
-
Bootstrap vcpkg.
# for macOS & linux ./vcpkg/bootstrap-vcpkg.sh --disable-metrics # for windows ./vcpkg/bootstrap-vcpkg.bat --disable-metrics
-
Generate cmake build system and install vcpkg dependencies.
cmake .
-
Create cpp file in
solutions
directory and update cmake# You can start with `solution/example.cpp`. cp solutions/example.cpp solutions/cf553.cpp # keeping file inside nested directory is also ok EXCEPT that file name must be unique. mkdir -p solutions/codeforce cp solutions/example.cpp solutions/codeforce/cf553.cpp cmake .
-
Solve the problem!
-
Compile code with cmake and run.
cmake --build . --target cf553 ./build/cf553
-
Add test input and expected output respectively as
{solution_filename}.in
{solution_filename}.out
besides{solution_filename}.cpp
. For example, if solution file issolutions/cf553.cpp
,solutions/cf553.in
5 2 1 5 3 4 2 6 4 3 2 2 2
solutions/cf553.out
2 5 TT
-
Build and run test. The test is defined as
{solution_filename}_test
by cmake.cmake --build . --target cf553_test ./build/cf553_test
Just write your libraries inside include
directory and use it in your solution.
Codes inside include
directory is included by default.
For example, suppose that you just implemented header-only include/dijkstra.hpp
, by then
// inside solution.cpp
#include <dijkstra.hpp>
...
AtCoder library which is included by default can be used right away.
// inside solution.cpp
#include <atcoder/fenwicktree>
using namespace atcoder;
fenwick_tree<int> fw(2 << 20);
fw.add(1, 10)
Add desired package in dependencies
array in vcpkg.json
. Suppose that you want to add abseil. Then,
-
add
"abseil"
inside"dependencies"
key ofvcpkg.json
-
run
cmake .
-
done!
// inside solution.cpp #include <absl/container/btree_set.h> using namespace absl; btree_set<std::string> set1;