rindag-devs / cplib

A modern C++ library for processing test data in competitive programming.

Home Page:https://cplib.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CPLib

header std license docs

Getting Started

Visit the documentation home page to learn more.

Introduction

CPLib is a library written in C++ for processing test data of competitive programming problems. It helps you write clear and efficient checkers, interactors, validators, and generators.

Here is a basic example of a checker using CPLib:

#include "cplib.hpp"

using namespace cplib;

CPLIB_REGISTER_CHECKER(chk);

void checker_main() {
  auto var_ans = var::i32(-2000, 2000, "ans");

  int ouf_output = chk.ouf.read(var_ans);
  int ans_output = chk.ans.read(var_ans);

  if (ouf_output != ans_output) {
    chk.quit_wa(format("Expected %d, got %d", ans_output, ouf_output));
  }

  chk.quit_ac();
}

The above example demonstrates a core logic of CPLib: "variable input template". Using the "variable input template", you can save and reuse the logic of reading variables with the same restrictions. At the same time, based on the hierarchy of variable input, CPLib generates concise input stack information in case of errors.

License

MPL-2.0

Copyright (c) 2023-present, rindag-devs

About

A modern C++ library for processing test data in competitive programming.

https://cplib.vercel.app

License:Mozilla Public License 2.0


Languages

Language:C++ 89.5%Language:TypeScript 10.5%